write_benchmark Subroutine

private impure subroutine write_benchmark(this)

Writes the benchmark data to a specified file, including method, speedup, elapsed time, flops, and other details.

Type Bound

benchmark

Arguments

Type IntentOptional Attributes Name
class(benchmark), intent(inout) :: this

Benchmark object


Called by

proc~~write_benchmark~2~~CalledByGraph proc~write_benchmark~2 forbenchmark_coarray::benchmark%write_benchmark proc~stop_benchmark~2 forbenchmark_coarray::benchmark%stop_benchmark proc~stop_benchmark~2->proc~write_benchmark~2

Source Code

   impure subroutine write_benchmark(this)
      !! author: Seyed Ali Ghasemi
      !! Writes the benchmark data to a specified file, including method, speedup, elapsed time, flops, and other details.
      !!
      class(benchmark), intent(inout) :: this   !! Benchmark object
      integer                         :: nunit  !! Unit number for file access
      character(len=53)               :: fmt1   !! Format for write
      character(len=82)               :: fmt2   !! Format for write
      logical                         :: exist  !! Logical variable for file existence
      integer                         :: iostat !! I/O status
      integer                         :: lm

      lm = 20-len_trim(this%marks(this%imark)%method)
      write(fmt1,'(a,g0,a)')&
         '(a,',lm,'x,3x,E20.14,3x,E20.14,3x,g8.0,3x,*(g8.0,3x))'

      inquire(file=this%filename_image, exist=exist, iostat=iostat)
      if (iostat /= 0 .or. .not. exist) then
         error stop 'file '//trim(this%filename_image)//' does not exist or cannot be accessed.'
      end if
      open (newunit = nunit, file = this%filename_image, access = 'append')
      write(nunit,fmt1) &
         this%marks(this%imark)%method,&
         this%marks_co(this%imark)%time%elapsed_time,&
         this%marks_co(this%imark)%flops,&
         this%nloops,&
         this%argi
      close(nunit)

      if (this_image() == 1) then
         write(fmt2,'(a,g0,a)')&
            '(a,',lm,'x,3x,F12.6,3x,E20.14,3x,E20.14,3x,E20.14,3x,E20.14,3x,g8.0,3x,*(g20.0,3x))'

         inquire(file=this%filename, exist=exist, iostat=iostat)
         if (iostat /= 0 .or. .not. exist) then
            error stop 'file '//trim(this%filename)//' does not exist or cannot be accessed.'
         end if
         open (newunit = nunit, file = this%filename, access = 'append')
         write(nunit,fmt2) &
            this%marks(this%imark)%method,&
            this%marks(this%imark)%speedup_max_total,&
            this%marks(this%imark)%elapsed_time_max,&
            this%marks(this%imark)%elapsed_time_min,&
            this%marks(this%imark)%elapsed_time_average,&
            this%marks(this%imark)%flops_total,&
            this%nloops,&
            this%argi
         close(nunit)
      end if

   end subroutine write_benchmark