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~~CalledByGraph proc~write_benchmark forbenchmark_default::benchmark%write_benchmark proc~stop_benchmark forbenchmark_default::benchmark%stop_benchmark proc~stop_benchmark->proc~write_benchmark program~demo demo program~demo->proc~stop_benchmark

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=65)               :: fmt    !! Format for write
      logical                         :: exist  !! Logical variable for file existence
      integer                         :: iostat !! I/O status
      integer                         :: lm

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

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

      write(nunit,fmt) &
         this%marks(this%imark)%method,&
         this%marks(this%imark)%speedup,&
         this%marks(this%imark)%elapsed_time,&
         this%marks(this%imark)%flops,&
         this%nloops,&
         this%argi

      close(nunit)
   end subroutine write_benchmark