ctoi_I1P Function

private function ctoi_I1P(str, knd, pref, error) result(n)

Arguments

TypeIntentOptionalAttributesName
character, intent(in) :: str
integer(kind=I1P), intent(in) :: knd
character, intent(in), optional :: pref
integer(kind=I4P), intent(out), optional :: error

Return Value integer(kind=I1P)


Called by

proc~~ctoi_i1p~~CalledByGraph proc~ctoi_i1p ctoi_I1P interface~cton cton interface~cton->proc~ctoi_i1p program~volatile_doctest~44 volatile_doctest program~volatile_doctest~44->interface~cton program~volatile_doctest~266 volatile_doctest program~volatile_doctest~266->interface~cton program~volatile_doctest~620 volatile_doctest program~volatile_doctest~620->interface~cton program~volatile_doctest~60 volatile_doctest program~volatile_doctest~60->interface~cton program~volatile_doctest~648 volatile_doctest program~volatile_doctest~648->interface~cton program~volatile_doctest~1006 volatile_doctest program~volatile_doctest~1006->interface~cton program~volatile_doctest~1046 volatile_doctest program~volatile_doctest~1046->interface~cton program~volatile_doctest~431 volatile_doctest program~volatile_doctest~431->interface~cton program~volatile_doctest~471 volatile_doctest program~volatile_doctest~471->interface~cton program~volatile_doctest~829 volatile_doctest program~volatile_doctest~829->interface~cton program~volatile_doctest~869 volatile_doctest program~volatile_doctest~869->interface~cton program~volatile_doctest~1017 volatile_doctest program~volatile_doctest~1017->interface~cton program~volatile_doctest~1033 volatile_doctest program~volatile_doctest~1033->interface~cton program~volatile_doctest~50 volatile_doctest program~volatile_doctest~50->interface~cton program~volatile_doctest~34 volatile_doctest program~volatile_doctest~34->interface~cton program~volatile_doctest~442 volatile_doctest program~volatile_doctest~442->interface~cton program~volatile_doctest~458 volatile_doctest program~volatile_doctest~458->interface~cton program~volatile_doctest~856 volatile_doctest program~volatile_doctest~856->interface~cton program~volatile_doctest~840 volatile_doctest program~volatile_doctest~840->interface~cton program~volatile_doctest~45 volatile_doctest program~volatile_doctest~45->interface~cton program~volatile_doctest~73 volatile_doctest program~volatile_doctest~73->interface~cton program~volatile_doctest~1007 volatile_doctest program~volatile_doctest~1007->interface~cton program~volatile_doctest~1023 volatile_doctest program~volatile_doctest~1023->interface~cton program~volatile_doctest~1183 volatile_doctest program~volatile_doctest~1183->interface~cton program~volatile_doctest~254 volatile_doctest program~volatile_doctest~254->interface~cton program~volatile_doctest~294 volatile_doctest program~volatile_doctest~294->interface~cton program~volatile_doctest~432 volatile_doctest program~volatile_doctest~432->interface~cton program~volatile_doctest~448 volatile_doctest program~volatile_doctest~448->interface~cton program~volatile_doctest~608 volatile_doctest program~volatile_doctest~608->interface~cton program~volatile_doctest~830 volatile_doctest program~volatile_doctest~830->interface~cton program~volatile_doctest~846 volatile_doctest program~volatile_doctest~846->interface~cton program~volatile_doctest~1018 volatile_doctest program~volatile_doctest~1018->interface~cton program~volatile_doctest~1194 volatile_doctest program~volatile_doctest~1194->interface~cton program~volatile_doctest~1210 volatile_doctest program~volatile_doctest~1210->interface~cton program~volatile_doctest~265 volatile_doctest program~volatile_doctest~265->interface~cton program~volatile_doctest~281 volatile_doctest program~volatile_doctest~281->interface~cton program~volatile_doctest~443 volatile_doctest program~volatile_doctest~443->interface~cton program~volatile_doctest~619 volatile_doctest program~volatile_doctest~619->interface~cton program~volatile_doctest~635 volatile_doctest program~volatile_doctest~635->interface~cton program~volatile_doctest~841 volatile_doctest program~volatile_doctest~841->interface~cton program~volatile_doctest~1184 volatile_doctest program~volatile_doctest~1184->interface~cton program~volatile_doctest~1200 volatile_doctest program~volatile_doctest~1200->interface~cton program~volatile_doctest~33 volatile_doctest program~volatile_doctest~33->interface~cton program~volatile_doctest~255 volatile_doctest program~volatile_doctest~255->interface~cton program~volatile_doctest~271 volatile_doctest program~volatile_doctest~271->interface~cton program~volatile_doctest~609 volatile_doctest program~volatile_doctest~609->interface~cton program~volatile_doctest~625 volatile_doctest program~volatile_doctest~625->interface~cton program~volatile_doctest~1195 volatile_doctest program~volatile_doctest~1195->interface~cton program~volatile_doctest~1223 volatile_doctest program~volatile_doctest~1223->interface~cton

Contents

Source Code


Source Code

   function ctoi_I1P(str, knd, pref, error) result(n)
   !< Convert string to integer.
   !<
   !<```fortran
   !< use penf
   !< print FI1P, cton(str='-1', knd=1_I1P)
   !<```
   !=> -1 <<<
   character(*),           intent(in)  :: str   !< String containing input number.
   integer(I1P),           intent(in)  :: knd   !< Number kind.
   character(*), optional, intent(in)  :: pref  !< Prefixing string.
   integer(I4P), optional, intent(out) :: error !< Error trapping flag: 0 no errors, >0 error occurs.
   integer(I1P)                        :: n     !< Number returned.
   integer(I4P)                        :: err   !< Error trapping flag: 0 no errors, >0 error occurs.
   character(len=:), allocatable       :: prefd !< Prefixing string.

   read(str, *, iostat=err) n ! Casting of str to n.
   if (err/=0) then
     prefd = '' ; if (present(pref)) prefd = pref
     write(stderr, '(A,I1,A)') prefd//' Error: conversion of string "'//str//'" to integer failed! integer(', kind(knd), ')'
   endif
   if (present(error)) error = err
   endfunction ctoi_I1P