strz_I1P Function

private elemental function strz_I1P(n, nz_pad) result(str)

Arguments

TypeIntentOptionalAttributesName
integer(kind=I1P), intent(in) :: n
integer(kind=I4P), intent(in), optional :: nz_pad

Return Value character


Called by

proc~~strz_i1p~2~~CalledByGraph proc~strz_i1p~2 strz_I1P interface~strz~2 strz interface~strz~2->proc~strz_i1p~2

Contents

Source Code


Source Code

   elemental function strz_I1P(n, nz_pad) result(str)
   !< Convert integer to string, prefixing with the right number of zeros.
   !<
   !<```fortran
   !< use penf
   !< print "(A)", strz(n=1_I1P)
   !<```
   !=> 001 <<<
   !<
   !<```fortran
   !< use penf
   !< print "(A)", strz(n=1_I1P, nz_pad=3)
   !<```
   !=> 001 <<<
   integer(I1P), intent(in)           :: n      !< Integer to be converted.
   integer(I4P), intent(in), optional :: nz_pad !< Number of zeros padding.
   character(DI1P)                    :: str    !< Returned string containing input number plus padding zeros.

   write(str,FI1PZP) n                              ! Casting of n to string.
   str=str(2:)                                      ! Leaving out the sign.
   if (present(nz_pad)) str=str(DI1P-nz_pad:DI1P-1) ! Leaving out the extra zeros padding
   endfunction strz_I1P