Fortran Wiki
Access to the Fortran revision

Proposal: There should be a way to adapt code to the standards revision used by the compiler, and request a specific revision.

Rationale:

  • For code that uses certain language features, it would be nice to include a statement indicating the minimum acceptable revision. Many languages have some statement in the form of “require version XXX”.
  • It should be possible to adapt code to more than one revision. In general, this requires conditional compilation. For example, a a given math function can be available for some Fortran revisions, but otherwise supplied as a user-defined function.
  • It is against the normal programming language conventions to make new file suffixes with every revision. Using “.f90”, “.f95”, “.f03”, “.f08”, etc., is increasingly cumbersome. What will Fortran2066 files be called?

One possibility is to expose language revisions in the form of intrinsic modules. For example:

use, intrinsic :: ISO_FORTRAN_2008

This would also allow new functions to easily be renamed to avoid conflicts with existing code.


Another possibility is to follow the design of the new COMPILER_VERSION intrinsic:

FORTRAN_VERSION() – return the Fortran revision, as an integer, or maybe a string? Or, maybe multiple forms like DATE_AND_TIME?


For conditional compilation, there should be standard tokens that define the language revision, similar to the ISO-C declaration __STDC_VERSION__. Currently, preprocessing is not a standardized feature in Fortran compilers. coco is the official Fortran preprocessor, but it is far more common to use fpp. The coco standards could be updated to define standard preprocessor tokens, and compilers supporting fpp or any other preprocessor could define the same token=value pairs by convention.