use macro to define function name in Fortran

Is it possible to use macro to define function name in the Fortran source code like in C, so that I can easily switch to the version of code I want to use

Say I call to func_1 at multiple locations. Now I have another implementation of func_1, called func_2. I want to test/compare between func_1 and func_2.
In C, I just use func_ at every location I call, and in the begining of the file, I just define
#define func_ func_1

! or
#define func_ func_2


Can we do this in Fortran?

Thanks,
Tuan

Hi Tuan,

Is it possible to use macro to define function name in the Fortran source code like in C, so that I can easily switch to the version of code I want to use

Sure. You can use most C pre-processing statements by using the “-Mpreprocess” flag or have upper case suffix names (i.e. .F or .F90). Pre-processing is on by default when the suffix is upper case.

Alternatively, you can use the “-Mcpp” flag to use the cpp preprocessor instead of the internal Fortran pre-processor.

Hope this helps,
Mat