Assertions in Fortran

assert, fortran, preprocessor

Solution

To my knowledge, there is no such statement or function/subroutine in Standard Fortran. But - as you have said - you can use your own subroutines/function and/or OOP in Fortran to realize this goal. See Arjen Markus' excellent paper on this topic.

Problem

Does Fortran have a standard function/keyword equivalent for C `assert`? I could not find `assert` mentioned in Fortran2003 standard I have. I have found few ways how to use pre-processor, but in this answer it is suggested to write own assertions. Is it possible to create such user function/subroutine without using pre-processor? I expect that these assertions are disabled for release builds.

Original source