PRESENT
— Determine whether an optional dummy argument is specified ¶Determines whether an optional dummy argument is present.
Fortran 90 and later
Inquiry function
RESULT = PRESENT(A)
A | May be of any type and may be a pointer, scalar or array value, or a dummy procedure. It shall be the name of an optional dummy argument accessible within the current subroutine or function. |
Returns either TRUE
if the optional argument A is present, or
FALSE
otherwise.
PROGRAM test_present WRITE(*,*) f(), f(42) ! "F T" CONTAINS LOGICAL FUNCTION f(x) INTEGER, INTENT(IN), OPTIONAL :: x f = PRESENT(x) END FUNCTION END PROGRAM