assert.h
#ifdef NDEBUG #define assert(expr) #else #define assert(expr) call assertion(expr) #endif
assertion.F90
module assert_m
contains
subroutine assertion(cond)
implicit none
logical, intent(in) :: cond
real, volatile :: r
r = 1.0
if (.not. cond) r = r / 0.0
end subroutine assertion
end module
Beispiel:
#include "assert.h"
use assert_m
subroutine VBEST(H, RH, KZ, DFM, Q, V0, V)
implicit none
real, intent(in) :: H
real, intent(in) :: RH
integer, intent(in) :: KZ
real, intent(in) :: DFM
real, intent(in) :: Q
assert(Q == Q)
assert(H >= 0)
assert(RH >= 0)
assert(KZ >= 1)
assert(DFM > 0)