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