Using the include Statement

Hi,

I have a suite of programs that were written for the unix environment that I am trying to compile in a windows environment (pgi workstation 11.7 (64)) with no sucess. We have narrowed down that the problem seems to be with the INCLUDE statement in that it is not reading the file properly. It was suggested to me that someone here may be able to help me. To simplify things I have deleted most of the code and just included the problem pieces.

My source code (Csumnvpi.F) is as follows

SUBROUTINE SUMM
INCLUDE ‘INPARAN.F’
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
INTEGER MCATEG
PARAMETER (MAXG=MCATEG)
print *,MAXG
print *,MCATEG
end

The INPARAN.F file is

PARAMETER(MCATEG=735)
END

I have been compling it with the following command

pgf77 Csumnvpi.F

When I change PARAMETER (MAXG=MCATEG) to be PARAMETER (MAXG=100) it compiles and my print statement for MAXG is 100. However, it is not reading in MCATEG variable (the print statement for this is 0).

I am not a programmer so hopefully I have included all the information needed.
Can anyone help?

Thanks

Kirsty

Hi Kristy,

The “INCLUDE” statement basically copies the entire contents of the file into this spot. Hence, you should be getting a syntax error since your INPARAN.F contains an “END” statement.

PGI$ pgf77 test.f -o test1.exe
PGFTN-S-0087-Non-constant expression where constant expression required (test.f:4)
  0 inform,   0 warnings,   1 severes, 0 fatal for MAIN
PGFTN/x86-64 Windows 11.9-0: compilation completed with severe errors

Though, when I remove the ‘END’, the code compiles and runs as expected:

PGI$ cat test.f
        INCLUDE 'INPARAN.F'
        IMPLICIT DOUBLE PRECISION (A-H,O-Z)
        INTEGER MCATEG
        PARAMETER (MAXG=MCATEG)
        print *,MAXG
        print *,MCATEG
        end
PGI$ cat INPARAN.F
        PARAMETER(MCATEG=735)
PGI$ pgf77 test.f -o test1.exe
PGFTN-W-0119-Redundant specification for mcateg (test.f: 3)
  0 inform,   1 warnings,   0 severes, 0 fatal for MAIN
PGFTN/x86-64 Windows 11.9-0: compilation completed with warnings
PGI$ test1.exe
          735
          735
PGI$

This seems to suggest that INPARAN.F isn’t getting included or is blank. On Windows, file names are not case sensitive so ‘INPARAN.F’ and ‘inparan.f’ are the same. If you are doing any pre-processing, then you could be overwriting the file.

Can you try the above example and see if it works for you?

  • Mat

Hi Mat,

Many thanks for your help. I tried what you said it worked.

Cheers

Kirsty