Yes, you have to do some preprocessing. The most common is the C preprocessor, included with GNU Fortran.
#if (condition) use modA #else use modB #endif
The preprocessor does not understand your Fortran code, this is just the text for it. It has its own set of directives and its own set of variables. In the state, only preprocessor variables can be used, not Fortran variables.
Another common directive is #ifdef , which is a variant of #if defined . See the manual for more https://gcc.gnu.org/onlinedocs/cpp/Traditional-Mode.html (gfortran starts the preprocessor in traditional mode).
To enable the preprocessor, use the -cpp flag or on Unix, you can use capital F in the file suffix.
source share