error with INCLUDE statement

I want to use a separate file where I define the macro to help compiling my source files.
The file is name “macro.h” (I tried with macro.f90) but the same error


!/* macro.f90 --- This file contains macro definition
! */

#ifndef INCLUDED_MACRO_H

#define INCLUDED_MACRO_H 1

#define FIXED_BOUNDARY 0
#define EULER_BOUNDARY 1

  ! use 1 all the time
#define  _USE_LINEAR_FORM 1
  
  ! TUAN: only fixed-boundary is implemented
#define  _BOUNDARY_CONDITION  FIXED_BOUNDARY


  ! 0 = no CUDA/OpenGL
  ! 1 = use 
#define _USE_DISPLAY_ 0
  

#endif
  !/* INCLUDED_MACRO_H */

In the Fortran code, I use the INCLUDE statement

MODULE mycode
  INCLUDE "macro.h"

CONTAINS
  subroutine myfunc()

  end subroutine

END MODULE

And when I try to compile the code, I get the following error

PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 4)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 6)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 8)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 9)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 12)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 15)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 20)
PGF90-S-0021-Label field of continuation line is not blank (./macro.f90: 23)

If I copy the whole file content and paste directly to the fortran source file, then there is no problem. I’m using Fortran 10.9, Ubuntu 64x.

NOTE: I already use -Mpreprocess in the compiler options.

Tuan

Hi Tuan,

Try using the C preprocessor (-Mcpp) instead of the Fortran preprocessor (-Mpreprocess) for these C macros.

For example:

% pgf90 -c macro.f90 -Mpreprocess
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 4)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 6)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 8)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 9)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 12)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 15)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 20)
PGF90-S-0021-Label field of continuation line is not blank (./macro.h: 23)
  0 inform,   0 warnings,   8 severes, 0 fatal for mycode
% pgf90 -c macro.f90 -Mcpp 
%

Hope this helps and Go Ducks!
Mat

Hi Mat,
I tried and it seems the only thing the compiler does is to generate a file with .f extension, ie. a file macro.f, and no other compilation process is done. Could you please check?

Tuan

Hi Tuan,

Ugh, I guess I had my mind on the BCS Championship game. Sorry.

Change “INCLUDE” to “include” to use the C style preprocessing.

% cat macro.f90

MODULE mycode
include “macro.h”

CONTAINS
subroutine myfunc()
end subroutine

END MODULE
% pgf90 macro.f90 -Mpreprocess -c
%

  • Mat

Great, it works now.

Thanks a lot Mat.

Tuan