What will be the best solution to affect default value to an optional argument?
subroutine dummy(logical_arg) logical,intent(in),optional :: logical_arg logical_value=.false. if( present(logical_arg)) logical_value=logical_arg .... if( logical_value) then ... endif .. end subroutine
or create a function get_arg_logical (and procedure get_arg_value for all kinds of arguments)
logical function get_arg_logical(default_value,logical_arg) logical,intent(in),optional :: logical_arg logical,intent(in) :: default_value get_arg_logical=default_value if( present(logical_arg)) get_arg_logical=logical_arg end function
and use get_arg_value(.false.,logical_arg) and so on where needed
subroutine dummy(logical_arg) logical,intent(in),optional :: logical_arg .... if( get_arg_value(.false.,logical_arg) ) then ... endif .. end subroutine
Thanks for your suggestions