1! Program to test the PRESENT intrinsic 2program intrinsic_present 3 implicit none 4 integer a 5 integer, pointer :: b 6 integer, dimension(10) :: c 7 integer, pointer, dimension(:) :: d 8 9 if (testvar()) call abort () 10 if (.not. testvar(a)) call abort () 11 if (testptr()) call abort () 12 if (.not. testptr(b)) call abort () 13 if (testarray()) call abort () 14 if (.not. testarray(c)) call abort () 15 if (testparray()) call abort () 16 if (.not. testparray(d)) call abort () 17 18contains 19logical function testvar (p) 20 integer, optional :: p 21 testvar = present(p) 22end function 23 24logical function testptr (p) 25 integer, pointer, optional :: p 26 testptr = present(p) 27end function 28 29logical function testarray (p) 30 integer, dimension (10), optional :: p 31 testarray = present(p) 32end function 33 34logical function testparray (p) 35 integer, pointer, dimension(:), optional :: p 36 testparray = present(p) 37end function 38 39end program 40 41