Fortran Wiki
Predefined preprocessor macros

Fortran compilers that support fpp or cpp generally define preprocessor macros that can be used to adapt code based on compiler-dependent features.

For some compilers, you can determine the predefined macros by using the preprocess-only flag -E and the cpp flag -dM. For example: gfortran -cpp -E -dM empty.f

Below are examples for some compilers that support fpp or cpp. Eventually, this could be exanded to show values for different host architectures and compilation options. For example, a compiler may define _OPENMP when compiled to support OpenMP.

Unfortunately, there is no common convention for the information supplied, and they do not define the Fortran language revision.

Gnu Fortran (gfortran)

Uses a built-in cpp in traditional mode with the flag -cpp. The following macros are predefined:

#define __STDC_HOSTED__ 0
#define __GNUC__ 4
#define __GNUC_MINOR__ 6
#define __GNUC_PATCHLEVEL__ 0
#define __GFORTRAN__ 1
#define _LANGUAGE_FORTRAN 1
#define __VERSION__ "4.6.0 20100407 (experimental) [trunk revision 158083]"
#define __FINITE_MATH_ONLY__ 0  /* Set to 1 with option -ffinite-math-only */
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_LONG_DOUBLE__ 12
#define __SIZEOF_SIZE_T__ 4

Intel Fortran (ifort)

Invokes fpp externally when given the option -fpp or -cpp. The following macros are predefined:

#define __INTEL_COMPILER 1100
#define __INTEL_COMPILER_BUILD_DATE 20081105
#define _MT 1
#define __ELF__ 1
#define __PTRDIFF_TYPE__ long
#define __SIZE_TYPE__ unsigned long
#define __WCHAR_TYPE__ int
#define __WINT_TYPE__ unsigned int
#define __INTMAX_TYPE__ long int
#define __UINTMAX_TYPE__ long unsigned int
#define __LONG_MAX__ 9223372036854775807L
#define __unix__ 1
#define __unix 1
#define __linux__ 1
#define __linux 1
#define __gnu_linux__ 1
#define unix 1
#define linux 1
#define __x86_64 1
#define __x86_64__ 1

Sun Fortran (sunf95)

Invokes fpp externally when given the option -fpp. It can also invoke an external cpp. The following macros are predefined:

#define __SUNPRO_F90 0x830
#define __SUNPRO_F95 0x830
#define unix 1
#define __unix 1
#define __unix__ 1
#define __linux 1
#define __linux__ 1
#define linux 1
#define __gnu__linux__ 1
#define i386 1
#define __i386 1