Option -I (include directory) in f2c and g77 
Author Message
 Option -I (include directory) in f2c and g77

First, thanks to Craig for the g77 release. Wonderful.

Now off to the nitpicking. Most commercial compilers support a -I switch or
its m{*filter*}equivalent, which defines a directory which will be searched for
files included with the fortran "include 'file.name'" directive. Extremely
convenient if you have common include files in a particular directory, so you
don't need to make copies of them for each subproject.

F2c didn't use to have this feature. Because it is so convenient, I had
patched the source code to f2c and added it in; in the meantime, the version
at netlib also has had this feature added. Works just fine now.

G77 does have a -I switch, but it seems to be only used by the C
preprocessor. In principle I could just rename all my source files from
foobar.f to foobar.F, and replace all the "include 'file.name'" with "#include
"file.name"" (in column one), using the C pre-processor to do the inclusion,
but then I loose source compatibility to other platforms.  Wouldn't it be nice
if there were a "-I" option which works for the fortran include statement too?

Two more nits: The lack of INTEGER*2 makes g77 useles for my current problem.
Better documentation (in particular of compiler options such as -fugly etc.)
would be good. But that's life, and I can deal with that.

I also patched f2c to add support for the bit-functions IAND, IOR, IBITS,
ISHIFT, and maybe some others I've forgotten about.  If someone wants them,
and if I get organized enough, I could post my patches sometime.

By the way, did you know that f2c has the following "feature": If you use
include inside a file which was already included itself, it will attempt to
locate the second include file relative to the directory where the first
include file was read from.  Example: First do "include '../sub/foo.inc'.
Inside foo.inc, do "include 'bar.inc'". Then f2c will look for ../sub/bar.inc.
I think f2c must have inherited this behavior from the old f77 compiler. I
checked the compilers on Sun, AIX, and SGI, and some do have this feature,
some don't (I forgot the details), but in all cases a local file will override
(i.e. in the above case, the compiler would first look for bar.inc in the
local directory, and only after a failure look for ../sub/bar.inc). I'm not
sure I like f2c's behavior; it might be convenient for project-common include
files which use other include files, but it makes it harder to override
include files by having local copies of them. My patched version will first
look in the local directory. I'll check what g77 does sometime.

--


M.S. 95, P.O. Box 4349, Stanford, CA 94309                    (415)926-2701
My opinion. This is not SLAC, Stanford U, or the US DoE speaking. Just me.



Fri, 22 Aug 1997 06:51:30 GMT  
 Option -I (include directory) in f2c and g77

   G77 does have a -I switch, but it seems to be only used by the C
   preprocessor. In principle I could just rename all my source files from
   foobar.f to foobar.F, and replace all the "include 'file.name'" with "#include
   "file.name"" (in column one), using the C pre-processor to do the inclusion,
   but then I loose source compatibility to other platforms.  Wouldn't it be nice
   if there were a "-I" option which works for the fortran include statement too?

Yes, I need to document this.  In the meantime, use the above solution,
though g77 needs to support # directives to make using .F files really
useful.  (It has to do with finding errors in your source code, &c.)

If anyone knows how to teach gcc/gcc.c to pass -I flags to the g77
compiler itself (f771), please let me know...I'm sure I can figure out
how to handle them, but right now, the -I options just don't get passed
to any code I wrote, and I don't know how the language-specific stuff
in gcc/gcc.c really works.

   I also patched f2c to add support for the bit-functions IAND, IOR, IBITS,
   ISHIFT, and maybe some others I've forgotten about.  If someone wants them,
   and if I get organized enough, I could post my patches sometime.

g77 already supports these, as you probably know.
--




Sat, 23 Aug 1997 01:41:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Corresponding g77 options for ifort options

2. Problems including libraries with Linux f77/f2c

3. f2c and include files

4. g77/f2c: diff between double and doublereal?

5. G77 breaks f2c on Linux?

6. f2c/g77 and the pointer extention....

7. g77 and f2c

8. Porting problem with g77 or f2c on Linux

9. g77 vs f2c : Experiences ?

10. Advice sought: using g77,f2c for fortran code development

11. f2c, g77, libraries questions

12. g77, Linux, and f2c shared libs

 

 
Powered by phpBB® Forum Software