Determines whether an optional dummy argument is present.
Fortran 95 and later
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