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

Preprocessor directive for fpp variable and macro definitions


I am trying to use the Fortran preprocessor directives to print the unit numbers (this is sometimes a constant and sometimes a variable) used in all the write statements in my code. This requires me to redefine the write keyword as well as its first argument. My code compiles successfully with the following:

#define write write(*,*) 'WRITE STATEMENT: '//__FILE__, __LINE__; write

I would however like to add the unit number to this and was thinking of using

#define write(a,b) write(*,*) 'WRITE STATEMENT: '//__FILE__, __LINE__,a ; write(a,b)

but I run in to problems when compiler runs into lines that originally had "write(*"

Is there any way to avoid "write(*" but still catch "write(n,".



0 Kudos
0 Replies