fix_nvhpc_octal_format Function

pure function fix_nvhpc_octal_format(fmt) result(fixed)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fmt

Return Value character(len=:), allocatable


Variables

Type Visibility Attributes Name Initial
integer, private :: dot_pos
integer, private :: pos
character(len=10), private :: precision_str

Source Code

   pure function fix_nvhpc_octal_format(fmt) result(fixed)
      character(len=*), intent(in) :: fmt
      character(len=:), allocatable :: fixed
      integer :: pos, dot_pos
      character(len=10) :: precision_str

      ! Check if format contains "O0."
      pos = index(fmt, 'O0.')
      if (pos > 0) then
         ! Extract precision after the dot
         dot_pos = pos + 2  ! Position of '.'
         precision_str = fmt(dot_pos + 1:)
         ! Replace O0.w with Ow.w (where w is the precision)
         fixed = fmt(1:pos - 1)//'O'//trim(precision_str)//'.'//trim(precision_str)
      else
         fixed = fmt
      end if
   end function fix_nvhpc_octal_format