[UP]


Manual Reference Pages  - unit_check (3)

NAME

unit_check(3f) - [M_verify] if logical expression is false, call command "goodbad NAME bad" and stop program by default (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Examples
Author
License

SYNOPSIS

subroutine unit_check(name,expression,msg,msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9)

    character(len=*),intent(in) :: name
    logical,intent(in) :: expression
    class(*),intent(in),optional :: msg,msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9

DESCRIPTION

unit_check(3f) tests the expression and if it is false, calls the shell command

        goodbad NAME bad

and stops the program.

OPTIONS

NAME the unit test name passed on to the goodbad(1) command
EXPRESSION
  the logical expression to evaluate
MSG,MSG1...MSG9
  optional message to display when performing test, composed of any scalar intrinsics of type INTEGER, REAL, DOUBLEPRECISION, COMPLEX, LOGICAL, or CHARACTER, with a space placed between each value.

EXAMPLES

Sample program:

   program demo_unit_check
   use M_verify, only: unit_check
   use M_verify, only: unit_check_start
   use M_verify, only: unit_check_done
   use M_verify,  only: almost

!!use M_verify, only: unit_check_keep_going ! default is unit_check_keep_going=.false. !!use M_verify, only: debug ! default is .false. !!use M_verify, only: unit_check_command ! default is unit_check_command=’goodbad’

implicit none integer :: i integer :: x integer,allocatable :: arr(:) real,allocatable :: arr1(:) real,allocatable :: arr2(:)

!!unit_check_command=’’ x=10 arr1=[1.0,10.0,100.0] arr2=[1.0001,10.001,100.01] call unit_check_start(’myroutine’)

call unit_check(’myroutine’, x.gt.3 ,’test if big enough’) call unit_check(’myroutine’, x.lt.100 ,’test if small enough’)

do i=1,size(arr1) call unit_check(’myroutine’, almost(arr1(i),arr2(i),3.9,verbose=.true.) ) enddo

arr=[10,20,30] call unit_check(’myroutine’, .not.any(arr.lt.0) ,’test if any negative values in array ARR’) call unit_check(’myroutine’, all(arr.lt.100) ,’test if all values less than 100 in array ARR’)

call unit_check_done(’myroutine’,msg=’checks on "myroutine" all passed’)

end program demo_unit_check

Sample output (varies with what goodbad(1) command is used):

   unit_check:      myroutine        SUCCESS:test if big enough
   unit_check:      myroutine        SUCCESS:test if small enough
   unit_check:      myroutine        SUCCESS:test if any negative values in array ARR
   unit_check:      myroutine        SUCCESS:test if all values less than 100 in array ARR
    *almost* for values 1.00000000 1.00010002 agreement of 3.99997139 digits out of requested 3.90000010
    *almost* for values 10.0000000 10.0010004 agreement of 3.99986792 digits out of requested 3.90000010
    *almost* for values 100.000000 100.010002 agreement of 3.99995065 digits out of requested 3.90000010
   unit_check_good: myroutine        PASSED:checks on "myroutine" all passed

AUTHOR

John S. Urban

LICENSE

Public Domain


unit_check (3) March 11, 2021
Generated by manServer 1.08 from 4fad8ab3-7545-41b6-96d8-541bbdacd128 using man macros.