F.1.7 Get_Wall_Clock_Time Procedure

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

  function Get_Wall_Clock_Time () result(Wall_Clock_Time)

    ! Use association information.

    use Caesar_Numbers_Module, only: milli 

    ! Output variable.

    ! Wall Clock time counter in seconds.
    type(real) :: Wall_Clock_Time 

    ! Internal variables.

    ! Date and Time array for intrinsic F95 call.
    type(integer), dimension(8) :: Date_Time 
    type(integer):: Day              ! Julian Day for this date.
    type(integer) :: Seconds         ! Julian Seconds for this time.

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

    ! Verify requirements - none.

    ! Intrinsic F95 call to get date and time info.

    call DATE_AND_TIME (VALUES=Date_Time)

    ! Calculate Julian day for this date.

    Day = Julian_Day(Date_Time(1), Date_Time(2), Date_Time(3))

    ! Convert into a number of seconds.

    Seconds = ((Day*24 + &         ! Days.
              Date_Time(5))*60 + & ! Hours.
              Date_Time(6))*60 + & ! Minutes.
              Date_Time(7)         ! Seconds.

    ! Add in milliseconds to get the final Wall Clock time.

    Wall_Clock_Time = changetype(real,Seconds) + &
                      milli*Date_Time(8)   ! Milliseconds.
  
    ! Verify guarantees - none.

  return
  end function Get_Wall_Clock_Time



Michael L. Hall