Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!cs.umn.edu!uc!shamash!hare!ddh From: ddh@hare.cdc.com (Dan Horsfall) Newsgroups: comp.lang.fortran Subject: Re: How to use -I to specify an alternate include directory in f77 Keywords: f77, INCLUDE Message-ID: <32361@shamash.cdc.com> Date: 18 Apr 91 14:26:49 GMT Article-I.D.: shamash.32361 References: <1991Apr18.055611.6793@engin.umich.edu> Sender: usenet@shamash.cdc.com Reply-To: ddh@dash.udev.cdc.com (Dan Horsfall) Organization: Control Data Corp, Arden Hills, MN Lines: 47 In article <1991Apr18.055611.6793@engin.umich.edu>, oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA) writes: > The transcript below demonstrates tht problem I'm having with specifying > an alternate directory to search for INCLUDE files in f77 on the decs running > ultrix 4.1 or apollos running sr10.3 DomainOS. > > spam% cat j.F > INCLUDE 'nodes.cbl' > DIMENSION L(Maxnode),F(Maxnode) > END > > spam% f77 -c -I/users/oliveria j.F > j.f: > (00001) INCLUDE 'nodes.cbl' > **** Error #64 on Line 1: cannot open file > > Does anyone know what is wrong ? I'm using the -I option incorrectly ? In a word, yes. You caught the problem yourself, but I trimmed it to fit posting guidelines on this system. Understand that "f77" is not the compiler itself. It is a driver, which calls lots of separate pieces of the "compiler system" in sequence, depending on file suffices and command-line options. 1) The -I parameter on f77 line, particularly when used with ".F" files, tells the *preprocessor* (usually _cpp_, where to look for #include files. This form of include is _not_ a FORTRAN statement, which you can tell because it does not start in column 7, contains a non-FORTRAN character, etc. 2) The " INCLUDE 'nodes.cbl' " statement _is_ a FORTRAN statement. The preprocessor doesn't see it, because it's looking for #include in column 1. This INCLUDE is processed by the compiler itself (fcom, in many cases). In general, the compiler looks ONLY in the same directory as the file it is compiling. The incompatibility of these two statements is causing your problem. Unfortunately, there is no completely-portable solution to this issue, as each vendor has implemented this extension to the language in his own fashion (and you can bet your ass that NO vendor is going to invalidate all the "millions and millions" of lines of existing code on their platform by changing their compiler, solely to be compatible with one of their competitors!) For C-based systems, the #include statement will be more-portable since many systems will have cpp.