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_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,'(a)') 'end of benchmark' close(nunit) if (this_image() == 1) then 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) end if if (allocated(this%marks_co)) deallocate(this%marks_co) call this%marks%finalize_mark() if (allocated(this%marks)) deallocate(this%marks) if (allocated(this%filename_image)) deallocate(this%filename_image) if (allocated(this%argi)) deallocate(this%argi) if (allocated(this%argr)) deallocate(this%argr) if (this_image() == 1) print'(a)', 'end of benchmark' end subroutine finalize