Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gfortran preprocessor
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 05, 2010 6:40 pm    Post subject: gfortran preprocessor Reply with quote

I am trying to compile a fortran code that some directive such as

Code:
#ifdef ABC
 do something
#endif


If I compile the code I get the a warning: Illegal preprocessor directive

How can I instruct gfortran to ignore these lines unless ABC=TRUE and explicitly set?
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10211
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Nov 05, 2010 6:46 pm    Post subject: Reply with quote

GNU Fortran Documentation wrote:
Many Fortran compilers including GNU Fortran allow passing the source code through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, FPP) to allow for conditional compilation. In the case of GNU Fortran, this is the GNU C Preprocessor in the traditional mode. On systems with case-preserving file names, the preprocessor is automatically invoked if the filename extension is .F, .FOR, .FTN, .fpp, .FPP, .F90, .F95, .F03 or .F08. To manually invoke the preprocessor on any file, use -cpp, to disable preprocessing on files where the preprocessor is run automatically, use -nocpp.
Are you not using one of the standard extensions listed? If not, just add the -cpp option to your CFLAGS.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 05, 2010 7:00 pm    Post subject: Reply with quote

Yes, but it's a mix of files f90 and F90. The file that causes the error is a f90 file. So, preprocessing should always be switched on but only the parts of the code that are explicitly enabled should be compiled.
The ibm compiler for example does it with -qsuffix=f=f90:cpp=f90 and -WF,-D ABC and the pgi with -Mpreprocess -D ABC. So, I guess there is something similar with gfortran.
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Fri Nov 05, 2010 7:16 pm    Post subject: Reply with quote

What about the -x switch ?
Try -x f90-cpp-input
It's possible it does not work as, in the manual of my version, it is stated that only f77-cpp-input and f95-cpp-input are recognized...
Nevermind... I only use f77... :P
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 05, 2010 8:33 pm    Post subject: Reply with quote

Yeah, just -cpp does the job for now. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum