Error with #insert fortran code in HYCOM

I am having trouble compiling a F90 code with a #insert directive, as follows.

In the main code (mod_incupd.F90):

"...
      logical, parameter :: lpipe_incupd=.false.  !extra checking
!
      character utxt*12,vtxt*12
      integer   i,j,k
      real      q,utotij,vtotij
!
# include "stmt_fns.h"

…"

In the inserted code (stmt_fns.h):

"...
!-----------------------------------------------------------------------------
      integer, parameter :: &
#if defined (EOS_SIG0)
# if defined (EOS_7T)
        sigver=1  !7-term sigma-0
# elif defined (EOS_9T)
        sigver=3  !9-term sigma-0
# elif defined (EOS_12T)
        sigver=7  !12-term sigma-0
# elif defined (EOS_17T)
        sigver=5  !17-term sigma-0
# endif
#elif defined (EOS_SIG2)
# if defined (EOS_7T)
        sigver=2  !7-term sigma-2
# elif defined (EOS_9T)
        sigver=4  !9-term sigma-2
# elif defined (EOS_12T)
        sigver=8  !12-term sigma-2
# elif defined (EOS_17T)
        sigver=6  !17-term sigma-2
# endif
#endif

      real    sig,dsigdt,dsigds,tofsig,sofsig, &
              sigloc,dsiglocdt,dsiglocds,tofsigloc

…"

The compilation error is:
“…
mpif90 -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DTIMER -fno-strict-aliasing -L/usr/local/nvidia/hpc_sdk/Linux_x86_64/24.11/compilers/lib -c mod_incupd.F90
NVFORTRAN-S-0034-Syntax error at or near identifier sig (./stmt_fns.h: 2)
…”

The funny is that, if I just cut & past the lines of codes from the *.h file into the *.F90, it works.

How are the “EOS” macros getting defined?

I doesn’t look like you have them on the command line so the post-processed code will look like:

      integer, parameter :: &
      real    sig,dsigdt,dsigds,tofsig,sofsig, &
              sigloc,dsiglocdt,dsiglocds,tofsigloc

Which is causing the syntax error.

Note you can have the compiler just pre-process the file by adding the “-P” flag, with the post-process source outputted to “mod_incupd.f90”. I find it easier to find these issues by looking at the post-processed source.

-Mat

Dear Mat
Thank you very much. Yes, I made a mistake in my script to run the Makefile. For some reason, the correct line for the CPP macros was commented out. Now, the compilation completed without any error with the flags:

mpif90 -DREAL8 -DENDIAN_IO -DTIMER -DRELO -DEOS_SIG2 -DEOS_17T -I/usr/local/nvidia/hpc_sdk/Linux_x86_64/24.11/comm_libs/12.6/openmpi4/openmpi-4.1.5/include