I am having a problem with using optional arguments. I have two routines num_to_str
and qry
that take a format fm
as an optional argument. When I call qry ("lc")
, even though
fm
is not present, the routine num_to_str
thinks fm
is present.
Call qry ("lc")
Subroutine qry (lb, fm)
Character (Len=*), Intent (In), Optional :: lb, fm
Real :: n
Character (Len=65) :: s
n = 90.0
Call num_to_str (n, s, fm)
End Subroutine
Subroutine num_to_str (nb, s, fm)
Real, Intent (In) :: nb
Character (Len=*), Intent (In) :: s
Character (Len=*), Intent (In), Optional :: fm
fmt = "*"
if (Present (fm)) fmt = Trim (fm)
End Subroutine