Clicky

Fortran Wiki
F2008 Smart Macros

Preprocessing is an important feature, still not supported by Fortran 2008

Tools

See Preprocessors for links to coco, fpp and others.

Rant

Preprocessing can be very important for dealing with code compilation options. That is why Fortran compilers support CPP preprocessing. Unfortunately, CPP is not a good choice, so most compilers support a Fortran-aware variant of CPP often referred to ads fpp, but it is non-standard and not always equivalent among compilers.

I was happy to hear that Fortran2008 was going to support “Intelligent Macros”. ☺ However, it was dropped from the final F2008 draft. ☹ Here is a discussion

It seems that they tried to make macros too intelligent, then decided it was an unnecessary complication. So, once again, the Fortran Standards committees have failed to get a clue, and we are stuck with hoping for a common fpp convention outside of the standards.

There is an official specification for coco, a conditional-compilation preprocessor. This seems to be a good alternative to support conditional features while avoiding functional macros. However, coco was not designed well, and never caught on.

Actually, it seems than Dan Nagle is using coco. He is the author of the coco implementation referenced above, which has a latest revision date of 2007. Dan Nagle is also one of the opponents to F2008 macros. Maybe the Standards committees still want us to use coco?