[comp.lang.fortran] Thanks for the answers on include expansions

anita@utastro.UUCP (Anita Cochran) (12/22/87)

About a week ago I asked how to expand includes in fortran codes
so that you could get listings with  the stuff in the include file
instead of the include statement itself.  My thanks to the following
people for sending me responses:
    Peter Yee, Jai Srinivasan, Fred Clare, Robert Novak, Paul Layman,
     Tony Willis and Charles Sandel
As several people pointed out, it can be done with the C preprocessor
/lib/cpp but only some people mentioned you could not use the fortran
form of the include but must use the C form.
Thus, the fortran form is
      include 'file.com'
while the C form is
#      include "file.com"
/lib/cpp handles the latter exactly as I wanted but f77 barfs on it while
/lib/cpp doesn't expand the former but f77 likes it.  Thus, I have
renamed all of my .f files to .F files and can run them through /lib/cpp
or the f77 compiler will do it for me.

Also, since /lib/cpp isn't intended to be used directly by the
user there is no man page (at least on any system I have access to)
so I will pass on an important thing I learned. If you have many .F
files and want to compile, you could say
   f77 -F file1.F file2.F ... filen.F
but /lib/cpp will only accept 2 files and it writes the processed file1
onto file2, thus destroying your processed file.  Sigh.  I had a backup.

Several people also sent shell scripts for doing the expands.  I haven't
had a chance to try  them.  One person suggested a utility called PP in
the UNIX version of AIPS.  I haven't tried that either. 

Anyway, thanks for all of the help.
-- 
 Anita Cochran  uucp:  {noao, ut-sally, ut-ngp}!utastro!anita
                arpa:  anita@astro.as.utexas.edu  
                snail: Astronomy Dept., The Univ. of Texas, Austin, TX, 78712
                at&t:  (512) 471-1471