The function ctor_R8P converts string to real. This function achieves casting of string to real.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str | |||
real(kind=R8P), | intent(in) | :: | knd |
function ctor_R8P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
!!The function ctor\_R8P converts string to real. This function achieves casting of string to real.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: str ! String containing input number.
real(R8P), intent(IN):: knd ! Number kind.
real(R8P):: n ! Number returned.
integer(I4P):: E_IO ! Input/Output debug flag.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
read(str,*,iostat=E_IO) n ! Casting of str to n.
if (E_IO/=0) then
write(6,'(A)') 'Conversion of string "'//str//'" to real failed'
write(6,'(A,'//FR8P//')') 'Kind parameter ',knd
write(6,'(A)') 'Function used "ctor_R8P"'
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctor_R8P