I apologize in advance for the rant
But I’ve just found out after hours of debugging that this program:
program t
implicit none
real :: A
! Just a comment \
A = 2.0
print *, A
end
Will return garbage in A if compiled with gfortran -cpp or .F90.
The reason (I’ve now found) is that line A = 2.0 is not parsed by gfortran because of the tiny \ at the end of the previous comment line… so A=2.0 is treated as a continuation of the comment line. LOL! Compiler explorer.
The backslash is quite useful when defining long macros with the pre-processor. If you don’t want C-like pre-processing, name the file with .f90 rather than .F90.
flang-new in the Compiler explorer returns the correct result, so it does appear that they’ve restricted its application to macro definition and other preprocessor-specific lines
Trying to integrate a subset of the C preprocessing has always been fraught with problems. Different compilers implement subtly different subsets. It gets really fun when one has to do multiple pre-processing passes. (ESMF does this for some files where macros are used for generating multiple versions of a code for different data types/kinds. We finally had to add our own utility function to concatenate character strings, because using the // operator was unreliable.)
Unless it is some really simple conditional compilation, I generally use fypp these days.