assertions_interface Module

Compile with -DNO_ASSERTIONS to turn assertions off

Use case 1


Pass the optional success argument & check for false return value as an indication of assertion failure:

use assertions_interface, only : assert,assertions
if (assertions) call assert( 2 > 1, "always true inequality", success)
if (error_code/=0) call my_error_handler()

Use case 2


Error-terminate if the assertion fails:

use assertions_interface, only : assert,assertions
if (assertions) call assert( 2 > 1, "always true inequality")

Used by

  • module~~assertions_interface~~UsedByGraph module~assertions_interface assertions_interface module~spherical_grid_implementation spherical_grid_implementation module~spherical_grid_implementation->module~assertions_interface module~define_problem_discretization define_problem_discretization module~define_problem_discretization->module~assertions_interface module~emulated_intrinsics_implementation emulated_intrinsics_implementation module~emulated_intrinsics_implementation->module~assertions_interface module~solver_submodule solver_submodule module~solver_submodule->module~assertions_interface module~plate_3d_implementation plate_3d_implementation module~plate_3d_implementation->module~assertions_interface module~assertions_implementation assertions_implementation module~assertions_implementation->module~assertions_interface module~ellipsoidal_field_implementation ellipsoidal_field_implementation module~ellipsoidal_field_implementation->module~assertions_interface module~grid_implementation grid_implementation module~grid_implementation->module~assertions_interface module~cylinder_2d_implementation cylinder_2d_implementation module~cylinder_2d_implementation->module~assertions_interface module~units_implementation units_implementation module~units_implementation->module~assertions_interface module~cartesian_grid_implementation cartesian_grid_implementation module~cartesian_grid_implementation->module~assertions_interface module~cylindrical_grid_implementation cylindrical_grid_implementation module~cylindrical_grid_implementation->module~assertions_interface module~surfaces_implementation surfaces_implementation module~surfaces_implementation->module~assertions_interface module~array_functions_implementation array_functions_implementation module~array_functions_implementation->module~assertions_interface module~structured_grid_implementation structured_grid_implementation module~structured_grid_implementation->module~assertions_interface module~sphere_1d_implementation sphere_1d_implementation module~sphere_1d_implementation->module~assertions_interface module~package_implementation package_implementation module~package_implementation->module~assertions_interface

Contents


Variables

TypeVisibility AttributesNameInitial
logical, public, parameter:: assertions =.false.
integer, public, parameter:: max_errmsg_len =len("warning (183): FASTMEM allocation is requested but the libmemkind library is not linked in, so using the default allocator.")

longest Intel compiler error messagea (see https://intel.ly/35x84yr).


Interfaces

interface

  • public impure elemental module subroutine assert(assertion, description, diagnostic_data, success)

    Report on the truth of an assertion or error-terminate on assertion failure

    Arguments

    Type IntentOptional AttributesName
    logical, intent(in) :: assertion

    Most assertions will be expressions, e.g., call assert( i>0, "positive i")

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

    Brief statement of what is being asserted

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

    Optional assertion result

    logical, intent(out), optional :: success

    Optional assertion result