<Example Program>
Program present_example Call one('Hello') Call one Contains Subroutine one(x) Character(*), Intent(In), Optional :: x Print *, 'one: x is present =', Present(x) Call two(x) End Subroutine Subroutine two(y) Character(*), Intent(In), Optional :: y If (Present(y)) Then Print *, 'two: y is present with value "', y, '"' Else Print *, 'two: y is not present' End If End Subroutine End Program
Execution Results
one: x is present = T two: y is present with value "Hello" one: x is present = F two: y is not present