The function ctor_R4P converts string to real. This function achieves casting of string to real.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str | |||
real(kind=R4P), | intent(in) | :: | knd |
function ctor_R4P(str,knd) result(n)
!---------------------------------------------------------------------------------------------------------------------------------
!!The function ctor\_R4P converts string to real. This function achieves casting of string to real.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
implicit none
character(*), intent(IN):: str ! String containing input number.
real(R4P), intent(IN):: knd ! Number kind.
real(R4P):: 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,'//FR4P//')') 'Kind parameter ',knd
write(6,'(A)') 'Function used "ctor_R4P"'
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction ctor_R4P