F.1.5 Get Value Timer Functions

The main documentation of the Get Value Timer Functions contains additional explanation of this code listing.

  define([ACCESS_ROUTINE],[
    pushdef([VALUE], [$1])
    ifelse(
      VALUE, [Count],
        [pushdef([TYPE], [integer])],
      VALUE, [Totally_Positive],
        [pushdef([TYPE], [logical])],
      [pushdef([TYPE], [real])])
    pushdef([Get_VALUE_Timer], expand(Get_VALUE_Timer))
    pushdef([Timer_VALUE], expand(Timer_VALUE))

    function Get_VALUE_Timer (Timer, Clock, Global, Split) result(Timer_VALUE)

      ! Input variables.

      type(character,*), optional, intent(in) :: Clock  ! Clock toggle.
      type(logical), optional, intent(in) :: Global     ! Global/Local toggle.
      type(logical), optional, intent(in) :: Split      ! Split/Overall toggle.

      ! Input/Output variables.

      type(Timer_type), intent(inout) :: Timer      ! Timer object.

      ! Output variables.

      type(TYPE) :: Timer_VALUE                     ! Timer value to be output.

      ! Internal variables.

      type(character,10) :: A_Clock                 ! Actual clock value.
      type(logical) :: A_Global                     ! Actual global flag.
      type(logical) :: A_Split                      ! Actual split flag.
      type(Statistics_type) :: PE_Stats             ! Overall PE Statistics.
      type(real) :: Total_Time_PE                   ! Total time on this PE.

      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      ! Verify requirements.

      VERIFY(Valid_State(Timer),5)                          ! Timer is valid.
      if (PRESENT(Clock)) then
        VERIFY(Clock == 'CPU' .or. Clock == 'Wall_Clock',5) ! Clock is valid.
      end if

      ! Set clock value.
      
      if (PRESENT(Clock)) then
        A_Clock = Clock
      else
        A_Clock = 'CPU'
      end if

      ! Set global flag.
      
      if (PRESENT(Global)) then
        A_Global = Global
      else
        A_Global = .false.
      end if

      ! Set split flag.
      
      if (PRESENT(Split)) then
        A_Split = Split
      else
        A_Split = .false.
      end if

      ! Set overall PE values if not reporting split values.

      if (.not.A_Split) then
        call Initialize (PE_Stats, "PE Statistics")
        if (A_Clock == 'CPU') then
          Total_Time_PE = Total(Timer%CPU_Time%Statistics)
        else if (A_Clock == 'Wall_Clock') then
          Total_Time_PE = Total(Timer%Wall_Clock_Time%Statistics)
        end if
        call Add_Value (PE_Stats, Total_Time_PE)
      end if

      ! Get VALUE from the statistics object.

      if (A_Split) then
        if (A_Clock == 'CPU') then
          Timer_VALUE = VALUE[](Timer%CPU_Time%Statistics, A_Global)
        else if (A_Clock == 'Wall_Clock') then
          Timer_VALUE = VALUE[](Timer%Wall_Clock_Time%Statistics, A_Global)
        end if
      else
        Timer_VALUE = VALUE[](PE_Stats, A_Global)
      end if

      ! Finalize PE Stats.

      if (.not.A_Split) then
        call Finalize (PE_Stats)
      end if

      ! Verify guarantees - none.
  
      return
    end function Get_VALUE_Timer

    popdef([VALUE])
    popdef([Get_VALUE_Timer])
    popdef([Timer_VALUE])
  ])

  fortext([Value],[Arithmetic_Mean Count Geometric_Mean Harmonic_Mean 
                   Maximum Minimum Standard_Deviation Sum Totally_Positive],[
    ACCESS_ROUTINE(Value)
  ])

  function Get_Name_Timer (Timer) result(Name)
  
    ! Input/Output variables.

    type(Timer_type), intent(in) :: Timer ! Timer object.
  
    ! Output variables.
  
    type(character,80) :: Name              ! Timer value to be output.
  
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
    ! Verify requirements.
  
    VERIFY(Valid_State(Timer),5)            ! Timer is valid.
  
    ! Set value.
  
    Name = Timer%Name
  
    ! Verify guarantees - none.
  
    return
  end function Get_Name_Timer



Michael L. Hall