Convert a string to a real(wp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str | |||
real(kind=wp), | intent(out) | :: | val | |||
logical, | intent(out) | :: | status_ok |
pure elemental subroutine to_real_wp(str,val,status_ok) implicit none character(len=*),intent(in) :: str real(wp),intent(out) :: val logical,intent(out) :: status_ok integer :: istat !! read `iostat` error code read(str,fmt=*,iostat=istat) val if (istat==0) then status_ok = .true. else status_ok = .false. val = zero end if end subroutine to_real_wp