Avoiding preprocessing problems
Because Fortran and C differ in their treatment of some sequences of characters, be careful when using /* or */. These might be interpreted as C comment delimiters, possibly causing problems even if they occur inside Fortran comments. Also be careful when using three-character sequences that begin with ?? (which might be interpreted as C trigraphs).
program testcase
character a
character*4 word
a = '?'
word(1:2) = '??'
print *, word(1:2)
end program testcase
If the preprocessor matches your character combination with the corresponding trigraph sequence, your output may not be what you expected.
If your code does not require the use of the XL Fortran compiler option -qnoescape, a possible solution is to replace the character string with an escape sequence word(1:2) = '\?\?'. However, if you are using the -qnoescape compiler option, this solution will not work. In this case, you require a cpp that will ignore the trigraph sequence. XL Fortran uses the cpp that is shipped as part of the compiler. This is the standard cpp. It is ISO C compliant and therefore recognizes trigraph sequences.
xlf95 tst.F -d -v -WF,-qlanglvl=classic
This
invokes cpp tst.F -qlanglvl=classic.