Writes the benchmark data to a specified file, including method, speedup, elapsed time, flops, and other details.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(benchmark), | intent(inout) | :: | this |
Benchmark object |
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