test_empty Subroutine

subroutine test_empty()

use M_anything, only : empty, assignment(=)

Arguments

None

Variables

Type Visibility Attributes Name Initial
integer, public :: answer
character(len=:), public, allocatable :: c(:)
doubleprecision, public, allocatable :: d(:)
integer, public, allocatable :: i(:)
integer, public, allocatable :: ints(:)
real, public, allocatable :: r(:)
character(len=:), public, allocatable :: strs(:)

Source Code

subroutine test_empty 
!!use M_anything, only : empty, assignment(=) 
implicit none 
doubleprecision,allocatable  :: d(:)
integer,allocatable          :: i(:)
real,allocatable             :: r(:)
character(len=:),allocatable :: c(:)
integer, allocatable         :: ints(:) 
character(:), allocatable    :: strs(:) 
integer                      :: answer

   call unit_check_start('empty') !  register an entry for specified name in database with status of zero (0)

   d=empty
   r=empty
   i=empty
   c=empty

   call unit_check('empty', size(d).eq.0, 'checking double')
   call unit_check('empty', size(r).eq.0, 'checking real')
   call unit_check('empty', size(i).eq.0, 'checking integer')
   call unit_check('empty', size(c).eq.0, 'checking character')

   ints = empty 
   answer=0
   call check_ints(answer,ints) 

   ints = [1,2,3] 
   answer=3
   call check_ints(answer,ints) 
   call unit_check('empty',all(ints.eq.[1,2,3]),msg='normal allocation')

   ints = empty 
   answer=0
   call check_ints(answer,ints) 

   strs = empty 
   answer=0
   call check_strs(answer,strs) 

   strs = [ "apple", "orang", "banan" ] 
   answer=3
   call check_strs(answer,strs) 
   call unit_check('empty',all(strs.eq.["apple","orang","banan"]),msg='normal allocation') 

   strs = empty 
   answer=0
   call check_strs(answer,strs) 

   call unit_check_done('empty')

end subroutine test_empty