private function string_to_double(str)
Arguments
Type |
Intent | Optional |
Attributes | | Name | |
character(kind=CK,len=*), |
intent(in) |
|
| :: |
str | |
Return Value real(kind=RK)
Description
Convert a string into a double.
Variables
Type | Visibility |
Attributes | | Name | | Initial | |
integer(kind=IK), |
public |
| :: |
ierr | | | |
Source Code
function string_to_double(str) result(rval)
implicit none
real(RK) :: rval
character(kind=CK,len=*),intent(in) :: str
integer(IK) :: ierr
if (.not. exception_thrown) then
read(str,fmt=real_fmt,iostat=ierr) rval !string to double
if (ierr/=0) then !if there was an error
rval = 0.0_RK
call throw_exception('Error in string_to_double:'//&
' string cannot be converted to a double: '//trim(str))
end if
end if
end function string_to_double