I can use Fortran optional argumenrs with subroutines with intent(in) and intent(inout), but with functions optional arguments work only with intent(in), right? With intent(inout) I get segmentation faults in the following code:
real function foo(x, tol)
real, intent(in) :: x
real, optional, intent(inout) :: tol
if( .not. present(tol) ) tol = 1e-6
!...
end function foo