Finalizes the benchmark object by deallocating memory and performs necessary cleanup.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(benchmark), | intent(inout) | :: | this |
Benchmark object to be finalized |
elemental impure subroutine finalize(this) !! author: Seyed Ali Ghasemi !! Finalizes the benchmark object by deallocating memory and performs necessary cleanup. !! class(benchmark), intent(inout) :: this !! Benchmark object to be finalized integer :: nunit !! Unit number for file access logical :: exist !! Logical variable for file existence integer :: iostat !! I/O status 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,'(a)') 'end of benchmark' close(nunit) call this%marks(:)%finalize_mark() if (allocated(this%filename)) deallocate(this%filename) if (allocated(this%argi)) deallocate(this%argi) if (allocated(this%argr)) deallocate(this%argr) print'(a)', 'end of benchmark' end subroutine finalize