str_I1P Function

private elemental function str_I1P(n, no_sign) result(str)

Arguments

TypeIntentOptionalAttributesName
integer(kind=I1P), intent(in) :: n
logical, intent(in), optional :: no_sign

Return Value character


Called by

proc~~str_i1p~5~~CalledByGraph proc~str_i1p~5 str_I1P proc~str_a_i1p~5 str_a_I1P proc~str_a_i1p~5->proc~str_i1p~5 interface~str~5 str interface~str~5->proc~str_i1p~5 interface~str~5->proc~str_a_i1p~5 proc~bctoi_i8p~5 bctoi_I8P proc~bctoi_i8p~5->interface~str~5 proc~bctoi_i4p~5 bctoi_I4P proc~bctoi_i4p~5->interface~str~5 proc~bctoi_i2p~5 bctoi_I2P proc~bctoi_i2p~5->interface~str~5 proc~bctoi_i1p~5 bctoi_I1P proc~bctoi_i1p~5->interface~str~5 interface~bcton~5 bcton interface~bcton~5->proc~bctoi_i8p~5 interface~bcton~5->proc~bctoi_i4p~5 interface~bcton~5->proc~bctoi_i2p~5 interface~bcton~5->proc~bctoi_i1p~5

Contents

Source Code


Source Code

   elemental function str_I1P(n, no_sign) result(str)
   !< Convert integer to string.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1_I1P)
   !<```
   !=> -1 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", str(n=-1_I1P, no_sign=.true.)
   !<```
   !=> 1 <<<
   integer(I1P), intent(in)           :: n       !< Integer to be converted.
   logical,      intent(in), optional :: no_sign !< Flag for leaving out the sign.
   character(DI1P)                    :: str     !< Returned string containing input number plus padding zeros.

   write(str, FI1P) n                ! Casting of n to string.
   str = adjustl(trim(str))          ! Removing white spaces.
   if (n>=0_I1P) str='+'//trim(str)  ! Prefixing plus if n>0.
   if (present(no_sign)) str=str(2:) ! Leaving out the sign.
   endfunction str_I1P