strz_I4P Function

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

Convert integer to string, prefixing with the right number of zeros.

 use penf
 print "(A)", strz(n=1_I4P)
 use penf
 print "(A)", strz(n=1_I4P, nz_pad=5)

Arguments

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

Integer to be converted.

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

Number of zeros padding.

Return Value character

Returned string containing input number plus padding zeros.


Called by

proc~~strz_i4p~~CalledByGraph proc~strz_i4p strz_I4P interface~strz strz interface~strz->proc~strz_i4p program~volatile_doctest~8 volatile_doctest program~volatile_doctest~8->interface~strz program~volatile_doctest~30 volatile_doctest program~volatile_doctest~30->interface~strz program~volatile_doctest~32 volatile_doctest program~volatile_doctest~32->interface~strz program~volatile_doctest~24 volatile_doctest program~volatile_doctest~24->interface~strz program~volatile_doctest~72 volatile_doctest program~volatile_doctest~72->interface~strz program~volatile_doctest~78 volatile_doctest program~volatile_doctest~78->interface~strz program~volatile_doctest~86 volatile_doctest program~volatile_doctest~86->interface~strz program~volatile_doctest~88 volatile_doctest program~volatile_doctest~88->interface~strz

Contents

Source Code


Source Code

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

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