converts an int to a string (should be a variable length string, but that does not work with all the compilers)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | i |
the integer to convert |
FUNCTION dbcsr_int_to_string(i) RESULT(res)
!! converts an int to a string
!! (should be a variable length string, but that does not work with
!! all the compilers)
INTEGER, INTENT(in) :: i
!! the integer to convert
CHARACTER(len=6) :: res
CHARACTER(len=6) :: t_res
INTEGER :: iostat
REAL(KIND=dp) :: tmp_r
iostat = 0
IF (i > 999999 .OR. i < -99999) THEN
tmp_r = i
WRITE (t_res, fmt='(es6.1)', iostat=iostat) tmp_r
ELSE
WRITE (t_res, fmt='(i6)', iostat=iostat) i
END IF
res = t_res
IF (iostat /= 0) THEN
PRINT *, "dbcsr_int_to_string ioerror", iostat
CALL print_stack(dbcsr_logger_get_default_unit_nr())
END IF
END FUNCTION dbcsr_int_to_string