program main implicit none real :: tol call my_sub() ! Tol is not specified and some default value will be used tol=0.000005 call my_sub(tol) ! Tol is explicitly specified contains subroutine my_sub(tol) implicit none real, intent(in), optional :: tol real :: default_tol default_tol=0.000000001 if (present(tol)) then default_tol=tol print*, "Tolerance IS specified by the user and equals", default_tol else print*, "Tolerance NOT specified, using a default value of", default_tol end if end subroutine my_sub end program main