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()) STOP 1 10 if (.not. testvar(a)) STOP 2 11 if (testptr()) STOP 3 12 if (.not. testptr(b)) STOP 4 13 if (testarray()) STOP 5 14 if (.not. testarray(c)) STOP 6 15 if (testparray()) STOP 7 16 if (.not. testparray(d)) STOP 8 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