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

compile with #ifdef

diedro
Beginner
1,311 Views

Dear all,

I would like to create a program with #ifdef and #endif compilation options  but I do not know how could i compile even tis simple hello program:

 

PROGRAM HELLO
IMPLICIT NONE

#ifdef PARALLEL
  WRITE(*,*) 'OPTION A'
#endif

 WRITE(*,*) 'OPTION A+B'

END PROGRAM

When I compile, I get this error:

hello.f90(4): warning #5117: Bad # preprocessor line
#ifdef PARALLEL
-^
hello.f90(6): warning #5117: Bad # preprocessor line
#endif

Can someone explain me how to compile and activate or not activate options A and B.

Really Really thanks

0 Kudos
3 Replies
Lorri_M_Intel
Employee
1,311 Views
Unlike C/C++, standard Fortran doesn't have a built-in preprocessor. On your compilation line, add the command line switch "-fpp", as: ifort -fpp myfile.f and then you should get option "A+B". or ifort -fpp -DPARALLEL myfile.f and you should get option A --Lorri
0 Kudos
TimP
Honored Contributor III
1,311 Views

In addition to what Lorri said, changing the file extension to .F90 will set -fpp.

0 Kudos
diedro
Beginner
1,311 Views

Dear all,

thanks a lot for your suggestions, It saves to me a lot of time.

Thanks again

0 Kudos
Reply