dbcsr_int_to_string Function

private 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)

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: i

the integer to convert

Return Value character(len=6)


Contents

Source Code


Source Code

   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