Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre-processing !DEC$ directives in gfortran

I've got a large Fortran codebase that originally targeted Intel's compiler. I'm now gearing up to compile with gfortran. Unfortunately, the code is littered with Intel-style pre-processing directives like:

!DEC$ IF DEFINED (MYDIRECTIVE)
   REAL, DIMENSION(:,:,:), ALLOCATABLE :: my_real_var
!DEC$ ENDIF

From what I can tell via googling and the gfortran docs, there is no internal gfortran support for anything besides C-style pre-processing, like:

#if defined MYDIRECTIVE
   REAL, DIMENSION(:,:,:), ALLOCATABLE :: my_real_var
#endif

Has anyone else encountered this problem and come up with an elegant solution? Obviously, I could write a shell script which calls an external pre-processor before passing code to gfortran for compile, but this just doesn't seem like a terrific solution to me.

Any thoughts? Thanks SO gurus!

like image 311
Mike Avatar asked Nov 05 '22 16:11

Mike


1 Answers

Intel ifort understands the C-style preprocessor directives, so it might be easiest to convert your files to that style. Then you would have a single code base that would work with both compilers. There would be some work regression testing the converted code with ifort.

like image 79
M. S. B. Avatar answered Dec 02 '22 11:12

M. S. B.