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