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.

Example

$ 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
#else
#  define MYKIND 4
#endif
program trucc
  implicit none
  real(kind=MYKIND),dimension(DIM) :: tab
  tab(:)=VAL
  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)

Example

$ 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;

  printf(''t[%d]=%fn'',DIM-1,t[DIM-1]);
}

Comments:

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