Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Preprocessor directive

tonio
Beginner
897 Views
Hello,

I use ifort and pgf90, mainly ifort.

I also use preprocessor directives as -D, the problem is that the source code required to use a directive is different between ifort and pgf90.

For instance, ifort needs
!DEC$ IF DEFINED (FOO)
!DEC$ END IF
but pgf90 needs
#ifndef FOO
#endif

Is there a way to have a source code that would compile with both compilers ?

Thx.
0 Kudos
5 Replies
Steven_L_Intel1
Employee
897 Views
ifort supports the cpp-style directives too. You can add -fpp on the line or name the file with .F or .F90 file types.
0 Kudos
tonio
Beginner
897 Views
Many Thx !
It's ok now.

There's only a minor difference, a module which is encapsulated in such a directive won't compile.
I have to put the directive inside the module definition keywords :

does not compile with -fpp style :
#IFDEF FOO
module FOOFOO
...
end module FOOFOO
#ENDIF

this one is ok :
module FOOFOO
#IFDEF FOO
...
#ENDIF
end module FOOFOO
0 Kudos
Steven_L_Intel1
Employee
897 Views
Our compiler does not like it if a source file has no compilable lines.
0 Kudos
tonio
Beginner
897 Views
But it just works ok with !DEC$ style directives !

Thx again.
0 Kudos
Steven_L_Intel1
Employee
897 Views
I know. The !DEC$ directives are processed by the compiler directly, whereas the # directives are run through a preprocessor. I'm just explaining what happens, not trying to rationalize it!
0 Kudos
Reply