Convert a string into a real(RK)
.
fmt=*
, rather than
fmt=real_fmt
, since it doesn't work for some unusual cases
(e.g., when str='1E-5'
).Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(kind=CK,len=*), | intent(in) | :: | str | |||
real(kind=RK), | intent(out) | :: | rval | |||
logical(kind=LK), | intent(out) | :: | status_ok | true if there were no errors |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
subroutine string_to_real(str,rval,status_ok)
implicit none
character(kind=CK,len=*),intent(in) :: str
real(RK),intent(out) :: rval
logical(LK),intent(out) :: status_ok !! true if there were no errors
integer(IK) :: ierr !! read iostat error code
read(str,fmt=*,iostat=ierr) rval
status_ok = (ierr==0)
if (.not. status_ok) rval = 0.0_RK
end subroutine string_to_real