Newsgroups: comp.lang.fortran
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!news
From: oliveria@srvr1 (ROQUE DONIZETE DE OLIVEIRA)
Subject: Re: How to use -I to specify an alternate include directory in f77
Message-ID: <1991Apr18.214704.20998@engin.umich.edu>
Sender: news@engin.umich.edu (CAEN Netnews)
Organization: The University of Michigan, Ann Arbor
References: <1991Apr18.055611.6793@engin.umich.edu>
Date: Thu, 18 Apr 1991 21:47:04 GMT

From article <1991Apr18.055611.6793@engin.umich.edu>, by oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA):
> 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 ~/nodes.cbl
>       PARAMETER (MaxNode=10000)
> spam% pwd
> //spam/sys/node_data/tmp
> spam% cat ~/nodes.cbl
>       PARAMETER (MaxNode=10000)
> spam% cat j.F
>       INCLUDE 'nodes.cbl'
>       DIMENSION L(Maxnode),F(Maxnode)
> C Do some calculations
>       STOP
>       END
> 
> spam% f77 -c -I/users/oliveria j.F
> j.f:
> (00001)       INCLUDE 'nodes.cbl'
> **** Error #64 on Line 1: cannot open file
> 
> The transcript above is for the apollos but I get a similar error on the decs.
> I tried several combinations of -I options. I also use j.f instead of j.F but
> nothing. 
> The man page on f77 for both decs (decstation 5000)  and apollos mention 
> the -I option although it says the -I option changes the search path for
>  #include files. Isn't this #include refering to the INCLUDE f77 statement ?
> 
> Does anyone know what is wrong ? I'm using the -I option incorrectly ? 
> Or is it just another bug. On the apollos the f77 compiler is  
>                "Fortran 77 compiler 68K Rev 10.8(190)"
> 
> Thanks.
> 
>     Roque Oliveira
>     oliveria@caen.engin.umich.edu
> 

Thanks to all those who replied. There is no portable way of doing this
but not all is lost. I did more testing on all platforms available to me.

In all the examples below I was working in /tmp. The include file 'nodes.cbl'
was in my home directory (not /tmp) and contained only 1 line, shown below:
      PARAMETER (MaxNode=10000)



------------------The transcript below is for the IBM RS/6000--------------
tsetse% pwd
/tmp
tsetse% cat junk.f
      SUBROUTINE FLGVVR ( )
      INCLUDE 'nodes.cbl'
      DIMENSION L(maxnode)
C do some calculations here
      RETURN
      END

tsetse% xlf -c junk.f
  2.6   1512-001: (S) Input file nodes.cbl was not found or is not define
d.  Statement is ignored.
1501-511  Compilation failed for file junk.f.

tsetse% xlf -c -I/afs/engin.umich.edu/user/o/l/oliveria junk.f
** flgvvr   === End of Compilation 1 ===
1501-510  Compilation successful for file junk.f.

------------------The transcript below is for the sun sparcstation---------

sol% cd /tmp
sol% cat junk.F
      SUBROUTINE FLGVVR ( )
#include 'nodes.cbl'
      DIMENSION L(maxnode)
C do some calculations here
      RETURN
      END

sol% f77 -c -I/n/engin/sol/u2/oliveria junk.F
/tmp/cpp.20784.0.f:
        flgvvr:

sol% pwd
/tmp
sol% cat nodes.cbl
cat: nodes.cbl: No such file or directory

------------------The transcript below is for the apollo------------
spam% cat junk.F
      SUBROUTINE FLGVVR ( )
      INCLUDE 'nodes.cbl'
      DIMENSION L(maxnode)
C do some calculations here
      RETURN
      END

spam% f77 -c -I/users/oliveria junk.F
junk.f:
(00002)       INCLUDE 'nodes.cbl'
**** Error #64 on Line 2: cannot open file

Error.  No assembly.
spam% f77 -c -W0,-idir,/users/oliveria junk.F
junk.f:

------------------The transcript below is for the decs (ultrix)------

I couldn't get the -I option to work in any shape or form (INCLUDE, #include,
filename with or without quotes, -cpp option, etc).
---------------------------------------------------------------------

Of the solutions shown above, the IBM RS/6000 was the only one that pleased
me, i.e., I don't have to call the source file filename.F and it follows
the fortran syntax 
                   INCLUDE 'nodes.cbl'

I wish more vendors would adopt a solution like this one.
