Modern Fortran submodule vs. preprocessor

Fortran has a long legacy of preprocessing systems, reaching back at least to the 1970s when C was not yet widely known. I would argue that modern Fortran ≥ 2008 has eliminated most preprocessors use cases. It’s usually much cleaner and quicker (build/runtime) to use Fortran submodule to switch functionality such as MKL vs. Atlas vs. Netlib Lapack using CMake, for example.

Numerous Python preprocessors have arisen (and sunk) along with the usual C/C++-based preprocessors. The only thing we use preprocessors for is very simple single-line statements, where adding a submodule would be significantly more cumbersome than a one-liner preprocessor statement.

Historically, very elaborate Fortran preprocessors were developed such that they nearly became a language unto themselves.

  • Ratfor (also ratfiv, ratfor90, etc.)

These extensive preprocessors have been made obsolete by advances from Fortran 77 onward.