W3cubDocs

/GNU Fortran 5

9.209 PRESENT — Determine whether an optional dummy argument is specified

Description:
Determines whether an optional dummy argument is present.
Standard:
Fortran 95 and later
Class:
Inquiry function
Syntax:
RESULT = PRESENT(A)
Arguments:
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.
Return value:
Returns either TRUE if the optional argument A is present, or FALSE otherwise.
Example:
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

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gfortran/PRESENT.html