Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

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,".

 

Thanks.

0 Kudos