F.1.2 Finalize_Timer Procedure

The main documentation of the Finalize_Timer Procedure contains additional explanation of this code listing.

  subroutine Finalize_Timer (Timer, status)

    ! Input/Output variable.

    ! Timer to be finalized.
    type(Timer_type), intent(inout) :: Timer  

    ! Output variables.

    type(Status_type), intent(out), optional :: status   ! Exit status.

    ! Internal variables.

    type(Status_type), dimension(6) :: deallocate_status ! Deallocation Status.
    type(Status_type) :: consolidated_status             ! Consolidated Status.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Verify requirements.

    VERIFY(Valid_State(Timer),7) ! Timer is valid.

    ! Unset initialization flag.

    call Finalize (Timer%Initialized)

    ! Set deallocation status.

    call Initialize (deallocate_status)
    call Initialize (consolidated_status)

    ! Finalize internals.

    call Finalize (Timer%CPU_Time%Start, deallocate_status(1))
    call Finalize (Timer%CPU_Time%Statistics, deallocate_status(2))
    call Finalize (Timer%Wall_Clock_Time%Start, deallocate_status(3))
    call Finalize (Timer%Wall_Clock_Time%Statistics, deallocate_status(4))
    call Finalize (Timer%Running, deallocate_status(5))
    call Finalize (Timer%Name, deallocate_status(6))

    ! Process status variables.

    consolidated_status = deallocate_status
    if (PRESENT(status)) then
      WARN_IF(Error(consolidated_status), 5)
      status = consolidated_status
    else
      VERIFY(Normal(consolidated_status), 5)
    end if
    call Finalize (consolidated_status)
    call Finalize (deallocate_status)

    ! Verify guarantees.

    VERIFY(.not.Valid_State(Timer),7)  ! Timer is not valid.

    return
  end subroutine Finalize_Timer



Michael L. Hall