Turing: Preprocessor

Fortran preprocessor

The -WF option of the Fortran compilation system allows you to pass options to the preprocessor component cpp.

The source file should, therefore, be suffixed by one of the following:  .F, .F95, .F90, .F03 or .F08.

The option -qsuffix=cpp=suffix allows you to specify any of the other suffixes.


$ mpixlf90_r -WF,-DDIM=5,-DDOUBLE source_cpp.F90
$ mpixlf90_r -qsuffix=cpp=f90 -WF,-DDIM=5,-DDOUBLE source_cpp.f90
$ cat source_cpp.F90
#define VAL 1.
#ifdef DOUBLE
#  define MYKIND 8
#  define MYKIND 4
program trucc
  implicit none
  real(kind=MYKIND),dimension(DIM) :: tab
  print *, kind(tab)
  print *, tab
end program trucc

C/C++ preprocessor

The options most frequently directed to the  cpp processor are the following:

Options Descriptions
-E Preprocessor output on the standard output (stdout)
-P Preprocessor output in a file suffixed by  .i
-Dmacro[=[value]] Allows giving a value to a macro (idem #define macro=value)


$ mpixlc_r -E main.c
$ mpixlcxx_r -P main.C
$ mpixlc_r -DDIM=1024 main.c
$ cat main.c
int main(int argc,char **argv) {
  double t[DIM];
  int i;

  for (i=0; i<DIM; i++)
     t[i] = 0;



The options -E/-P the C compilation system allow you to execute only the preprocessor component cpp.