Convert integer to string, prefixing with the right number of zeros.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I1P), | intent(in) | :: | n | Integer to be converted. |
||
| integer(kind=I4P), | intent(in), | optional | :: | nz_pad | Number of zeros padding. |
Returned string containing input number plus padding zeros.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
elemental function strz_I1P(n, nz_pad) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
!< Convert integer to string, prefixing with the right number of zeros.
!---------------------------------------------------------------------------------------------------------------------------------
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
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strz_I1P