Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(in) | :: | n | |||
integer(kind=I4P), | intent(in), | optional | :: | nz_pad |
elemental function strz_I8P(n, nz_pad) result(str)
!< Converting integer to string, prefixing with the right number of zeros.
!<
!<```fortran
!< use penf
!< print "(A)", strz(n=1_I8P)
!<```
!=> 0000000000000000001 <<<
!<
!<```fortran
!< use penf
!< print "(A)", strz(n=1_I8P, nz_pad=5)
!<```
!=> 00001 <<<
integer(I8P), intent(in) :: n !< Integer to be converted.
integer(I4P), intent(in), optional :: nz_pad !< Number of zeros padding.
character(DI8P) :: str !< Returned string containing input number plus padding zeros.
write(str,FI8PZP) n ! Casting of n to string.
str=str(2:) ! Leaving out the sign.
if (present(nz_pad)) str=str(DI8P-nz_pad:DI8P-1) ! Leaving out the extra zeros padding
endfunction strz_I8P