24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

!$omp end do<br />

!$omp end parallel<br />

end<br />

See Conditional Compilation in the Language Elements section of the <strong>XL</strong> <strong>Fortran</strong><br />

<strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> Language Reference <strong>for</strong> more in<strong>for</strong>mation on conditional<br />

compilation.<br />

To customize cpp preprocessing, the configuration file accepts the attributes cpp,<br />

cppsuffix, and cppoptions.<br />

The letter F denotes the C preprocessor with the -t and -W options.<br />

Related In<strong>for</strong>mation: See “-d Option” on page 106, “-t Option” on page 270, “-W<br />

Option” on page 275, and “Customizing the Configuration<br />

File” on page 15.<br />

cpp Directives <strong>for</strong> <strong>XL</strong> <strong>Fortran</strong> Programs<br />

Macro expansion can have unexpected consequences that are difficult to debug,<br />

such as modifying a FORMAT statement or making a line longer than 72<br />

characters in fixed source <strong>for</strong>m. There<strong>for</strong>e, we recommend using cpp primarily <strong>for</strong><br />

conditional compilation of <strong>Fortran</strong> programs. The cpp directives that are most<br />

often used <strong>for</strong> conditional compilation are #if, #ifdef, #ifndef, #elif, #else, and<br />

#endif.<br />

Passing Options to the C Preprocessor<br />

Because the compiler does not recognize cpp options other than -I directly on the<br />

command line, you must pass them through the -W option. For example, if a<br />

program contains #ifdef directives that test the existence of a symbol named<br />

<strong>AIX</strong>V4, you can define that symbol to cpp by compiling with a command like:<br />

xlf95 conditional.F -WF,-D<strong>AIX</strong>V4<br />

Avoiding Preprocessing Problems<br />

Because <strong>Fortran</strong> and C differ in their treatment of some sequences of characters, be<br />

careful when using /* or */. These might be interpreted as C comment delimiters,<br />

possibly causing problems even if they occur inside <strong>Fortran</strong> comments. Also be<br />

careful when using three-character sequences that begin with ?? (which might be<br />

interpreted as C trigraphs).<br />

Consider the following example:<br />

program testcase<br />

character a<br />

character*4 word<br />

a = ’?’<br />

word(1:2) = ’??’<br />

print *, word(1:2)<br />

end program testcase<br />

If the preprocessor matches your character combination with the corresponding<br />

trigraph sequence, your output may not be what you expected.<br />

If your code does not require the use of the <strong>XL</strong> <strong>Fortran</strong> compiler option<br />

-qnoescape, a possible solution is to replace the character string with an escape<br />

sequence word(1:2) = ’\?\?’. However, if you are using the -qnoescape compiler<br />

option, this solution will not work. In this case, you require a cpp that will ignore<br />

Editing, Compiling, Linking, and Running <strong>XL</strong> <strong>Fortran</strong> Programs 41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!