23-24 September 2021
Europe/Zurich timezone

Some adventures with compile time evaluation

23 Sep 2021, 14:30
ZOOM (Virtual)



Communication Communications Presentations


Mohd Furquan (IIT Kanpur)


Compile-time evaluation offers significant advantages during optimization and debugging. It promotes transparency and brings a code closer to functional paradigm. Unfortunately, Fortran does not support compile time evaluation of user defined functions. Nevertheless, it includes two features which salvage such undertakings: a vast library of intrinsic functions and default constructors. The intrinsic functions can be composited to an arbitrary degree and made to act upon default constructors. This allows one to accomplish surprisingly complex computations at compile time. Chief example to be discussed in this presentation is evaluation of arbitrary degree Lagrange polynomials and their derivatives using an ingenious combination of SUM, PRODUCT, SPREAD and RESHAPE functions. Admittedly, the implementation will be admonished as a crazy contrivance once Fortran starts supporting compile-time evaluation of user defined functions. However, it is interesting in its own right to explore the limits and possibility of the approach within the framework of the current standard.

Primary author

Mohd Furquan (IIT Kanpur)

Presentation Materials