integer to string with optional zero padding
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | i | |||
| integer, | intent(in), | optional | :: | ipad |
number of digits to pad with zeros |
function int_to_string(i,ipad) result(str) implicit none integer,intent(in) :: i character(len=:),allocatable :: str integer,intent(in),optional :: ipad !! number of digits to pad with zeros character(len=100) :: istr integer :: istat write(istr,'(I100)',iostat=istat) i if (istat==0) then str = trim(adjustl(istr)) if (present(ipad)) then if (len(str)<ipad) then str = repeat('0',ipad-len(str))//str end if end if else str ='****' end if end function int_to_string