assert_subroutine_m Module

use assertions_m, only : assert call assert( 2 > 1, "2 > 1")

Assertion enforcement is controlled via the 0 preprocessor macro, which can be defined to non-zero or zero at compilation time to respectively enable or disable runtime assertion enforcement.

When the 0 preprocessor macro is not defined to any value, the default is that assertions are disabled and will not check the condition.

Disabling assertion enforcement may eliminate any associated runtime overhead by enabling optimizing compilers to ignore the assertion procedure body during a dead-code-removal phase of optimization.

To enable assertion enforcement (e.g., for a debug build), define the preprocessor 0 to non-zero. This file's capitalized .F90 extension causes most Fortran compilers to preprocess this file so that building as follows enables assertion enforcement:

fpm build --flag "-DASSERTIONS"


Used by

  • module~~assert_subroutine_m~~UsedByGraph module~assert_subroutine_m assert_subroutine_m module~assert_m assert_m module~assert_m->module~assert_subroutine_m module~assert_subroutine_s assert_subroutine_s module~assert_subroutine_s->module~assert_subroutine_m module~intrinsic_array_s intrinsic_array_s module~intrinsic_array_s->module~assert_m

Contents


Variables

TypeVisibilityAttributesNameInitial
logical, private, parameter:: enforce_assertions =.false.

Interfaces

interface

  • public pure module module subroutine assert(assertion, description, diagnostic_data)

    If assertion is .false., error-terminate with a character stop code that contains diagnostic_data if present

    Arguments

    TypeIntentOptionalAttributesName
    logical, intent(in) :: assertion

    Most assertions will be expressions such as i>0

    character(len=*), intent(in) :: description

    A brief statement of what is being asserted such as "i>0" or "positive i"

    class(*), intent(in), optional :: diagnostic_data

    Data to include in an error ouptput: may be of an intrinsic type or a type that extends characterizable_t