timer_obj Derived Type

type, public :: timer_obj

Time management utility


Inherits

type~~timer_obj~~InheritsGraph type~timer_obj timer_obj type~hashtbl_obj hashtbl_obj type~timer_obj->type~hashtbl_obj tbl type~parallel_obj parallel_obj type~timer_obj->type~parallel_obj parallel type~parser_obj parser_obj type~timer_obj->type~parser_obj parser type~sllist_obj sllist_obj type~hashtbl_obj->type~sllist_obj vec MPI_Datatype MPI_Datatype type~parallel_obj->MPI_Datatype REAL_SP, REAL_DP, REAL_WP, COMPLEX_SP, COMPLEX_DP, COMPLEX_WP, INTEGER, INT8, LOGICAL type~communicators communicators type~parallel_obj->type~communicators comm type~patch patch type~parallel_obj->type~patch rank type~entry_obj entry_obj type~parser_obj->type~entry_obj entries MPI_Comm MPI_Comm type~communicators->MPI_Comm w, g type~sllist_obj->type~sllist_obj child

Inherited by

type~~timer_obj~~InheritedByGraph type~timer_obj timer_obj type~collision_obj collision_obj type~collision_obj->type~timer_obj timer type~marker_set marker_set type~collision_obj->type~marker_set IB type~particle_set particle_set type~collision_obj->type~particle_set PP type~respart_set ResPart_set type~collision_obj->type~respart_set RP type~marker_set->type~timer_obj timer type~particle_set->type~timer_obj timer type~respart_set->type~timer_obj timer type~respart_set->type~marker_set ib type~solver_obj solver_obj type~solver_obj->type~timer_obj timer type~cdifs_obj cdifs_obj type~cdifs_obj->type~collision_obj collisions type~cdifs_obj->type~marker_set IB type~cdifs_obj->type~respart_set RP type~cdifs_obj->type~solver_obj type~grans_obj grans_obj type~grans_obj->type~collision_obj collisions type~grans_obj->type~marker_set IB type~grans_obj->type~particle_set PP type~grans_obj->type~respart_set RP type~grans_obj->type~solver_obj type~solid_obj solid_obj type~solid_obj->type~marker_set type~solid_set solid_set type~solid_set->type~solid_obj p

Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: dt

Timestep

logical, public :: finish = .false.

Instructs simulation to end

real(kind=wp), public :: freq_output = huge(1.0_wp)
real(kind=wp), public :: freq_write = huge(1.0_wp)

Frequency of restart writes

integer, public :: iter = 0

Current iteration

integer, public :: iter_max = huge(1)

Maximum iterations

real(kind=wp), public :: itertime

Wall clock time at beginning of iteration (in seconds)

real(kind=wp), public :: lasttime

Wall clock time at last update (in seconds)

type(parallel_obj), public, pointer :: parallel

Parallel object

type(parser_obj), public, pointer :: parser

Parser object

real(kind=wp), public :: starttime

Wall clock time at initialization (in seconds)

real(kind=wp), public :: time = 0.0_wp

Time at the n-th timestep

real(kind=wp), public :: time_max = huge(1.0_wp)

Maximum simulation time

real(kind=wp), public :: time_wall = huge(1.0_wp)

Wall time (in hours)

real(kind=wp), public, allocatable :: timing(:)

Timing array

type(hashtbl_obj), private :: tbl

Hash table for timing info


Type-Bound Procedures

procedure, public :: AddTiming => timer_obj_AddTiming

  • private pure subroutine timer_obj_AddTiming(this, name)

    Adds timing info.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

    character(len=*), intent(in) :: name

    Name of timing data

procedure, public :: Done => timer_obj_Done

  • private impure function timer_obj_Done(this) result(res)

    Determines whether simulation is over.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

    Return Value logical

    Result

procedure, public :: EndRun => timer_obj_EndRun

  • private pure subroutine timer_obj_EndRun(this)

    Changes run status to finished.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

procedure, public :: Finalize => timer_obj_Final

  • private pure subroutine timer_obj_Final(this)

    Finalizes and frees memomry.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

procedure, public :: GetTiming => timer_obj_GetTiming

  • private pure function timer_obj_GetTiming(this, name) result(res)

    Returns timing information for data given by name.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(in) :: this

    Timer

    character(len=*), intent(in) :: name

    Name of timing data

    Return Value real(kind=wp)

    Timing

procedure, public :: Initialize => timer_obj_Init

  • private impure subroutine timer_obj_Init(this, parallel, parser)

    Initializes the timer.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

    type(parallel_obj), intent(in), target :: parallel

    Parallel structure to link with

    type(parser_obj), intent(in), target :: parser

    Input file parsing tool

procedure, public :: StepForward => timer_obj_StepForward

  • private impure subroutine timer_obj_StepForward(this)

    Moves timer from n to n+1

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

procedure, public :: TimeToWriteOutputData => timer_obj_TimeToWriteOutputData

  • private pure function timer_obj_TimeToWriteOutputData(this) result(res)

    Determine whether it is time to write visualization files.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(in) :: this

    Timer

    Return Value logical

    Result

procedure, public :: TimeToWriteRestartData => timer_obj_TimeToWriteRestartData

  • private pure function timer_obj_TimeToWriteRestartData(this) result(res)

    Determine whether it is time to write restart files.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(in) :: this

    Timer

    Return Value logical

    Result

procedure, public :: UpdateTiming => timer_obj_UpdateTiming

  • private impure subroutine timer_obj_UpdateTiming(this, name)

    Updates timing info with elapsed time since beginning of current iteration.

    Arguments

    Type IntentOptional Attributes Name
    class(timer_obj), intent(inout) :: this

    Timer

    character(len=*), intent(in) :: name

    Name of timing data

Source Code

  type :: timer_obj
    !> Time management utility
    type(parallel_obj),pointer :: parallel                                     !! Parallel object
    type(parser_obj),  pointer :: parser                                       !! Parser object
    real(wp)                   :: starttime                                    !! Wall clock time at initialization (in seconds)
    real(wp)                   :: itertime                                     !! Wall clock time at beginning of iteration (in seconds)
    real(wp)                   :: lasttime                                     !! Wall clock time at last update (in seconds)
    real(wp)                   :: dt                                           !! Timestep
    real(wp)                   :: time         = 0.0_wp                        !! Time at the n-th timestep
    real(wp)                   :: time_max     = huge(1.0_wp)                  !! Maximum simulation time
    real(wp)                   :: time_wall    = huge(1.0_wp)                  !! Wall time (in hours)
    real(wp)                   :: freq_write   = huge(1.0_wp)                  !! Frequency of restart writes
    real(wp)                   :: freq_output  = huge(1.0_wp)
    integer                    :: iter         = 0                             !! Current iteration
    integer                    :: iter_max     = huge(1)                       !! Maximum iterations
    logical                    :: finish       = .false.                       !! Instructs simulation to end
    real(wp),      allocatable :: timing(:)                                    !! Timing array
    type(hashtbl_obj), private :: tbl                                          !! Hash table for timing info
    contains
      procedure :: Initialize              => timer_obj_Init
      procedure :: Finalize                => timer_obj_Final
      procedure :: StepForward             => timer_obj_StepForward
      procedure :: Done                    => timer_obj_Done
      procedure :: EndRun                  => timer_obj_EndRun
      procedure :: TimeToWriteRestartData  => timer_obj_TimeToWriteRestartData
      procedure :: TimeToWriteOutputData   => timer_obj_TimeToWriteOutputData
      procedure :: AddTiming               => timer_obj_AddTiming
      procedure :: UpdateTiming            => timer_obj_UpdateTiming
      procedure :: GetTiming               => timer_obj_GetTiming
  end type timer_obj