tem_time_load Subroutine

public subroutine tem_time_load(me, conf, key, parent, clock_start)

Reading a time description from a Lua script given by conf.

The time description has to be provided in the table given by thandle. The time can be given in terms of: - iter: number of iterations - sim: simulated time - clock: running time used to compute the simulation Thus, the configuration looks like: \verbatim time = { iter = 123, sim = 1.23, clock = 12.3 } \end verbatim Omitted time defintions are set to the maximal representable number, indicating something like never. If the time is not provided as a table, it is interpreted as a setting of the sim time, the other entries are set to never.

The optional argument clock_start is useful to overwrite the current time by the settings in a loaded restart header. With clock_start the old reference wtime from tem_time_reset can be maintained, while iterations and simulation time can be inherited from the configuration.

\todo HK: maybe provide the possibility to add up run times from loaded data instead of resetting it.

Arguments

Type IntentOptional Attributes Name
type(tem_time_type), intent(out) :: me

Time to be read from the Lua script

type(flu_State), intent(inout) :: conf

Handle to the Lua script.

character(len=*), intent(in), optional :: key

Name of the table containing the time definition. Default: 'time'.

integer, intent(in), optional :: parent

Handle to the parent table.

real(kind=rk), intent(in), optional :: clock_start

Reference MPI_Wtime mark to use for computation of wallclock

This is basically only useful to update the time object for a read in restart without distorting the clock measurement.


Calls

proc~~tem_time_load~~CallsGraph proc~tem_time_load tem_time_load proc~aot_table_open aot_table_open proc~tem_time_load->proc~aot_table_open proc~aot_table_close aot_table_close proc~tem_time_load->proc~aot_table_close mpi_wtime mpi_wtime proc~tem_time_load->mpi_wtime proc~aot_get_val~2 aot_get_val proc~tem_time_load->proc~aot_get_val~2

Called by

proc~~tem_time_load~~CalledByGraph proc~tem_time_load tem_time_load proc~tem_timecontrol_load tem_timeControl_load proc~tem_timecontrol_load->proc~tem_time_load proc~tem_restart_readheader tem_restart_readHeader proc~tem_restart_readheader->proc~tem_time_load proc~tem_load_adapt tem_load_adapt proc~tem_load_adapt->proc~tem_timecontrol_load proc~tem_load_output tem_load_output proc~tem_load_output->proc~tem_timecontrol_load proc~tem_load_trackingconfig tem_load_trackingConfig proc~tem_load_trackingconfig->proc~tem_timecontrol_load proc~tem_load_surfdata tem_load_surfData proc~tem_load_surfdata->proc~tem_timecontrol_load proc~tem_balance_load tem_balance_load proc~tem_balance_load->proc~tem_timecontrol_load proc~tem_simcontrol_load tem_simControl_load proc~tem_simcontrol_load->proc~tem_timecontrol_load proc~tem_load_convergenceheader tem_load_convergenceHeader proc~tem_load_convergenceheader->proc~tem_timecontrol_load proc~tem_load_restart tem_load_restart proc~tem_load_restart->proc~tem_timecontrol_load proc~tem_load_restart->proc~tem_restart_readheader proc~tem_load_tracking tem_load_tracking proc~tem_load_tracking->proc~tem_load_trackingconfig proc~tem_convergence_load tem_convergence_load proc~tem_convergence_load->proc~tem_load_convergenceheader proc~tem_load_general tem_load_general proc~tem_load_general->proc~tem_balance_load proc~tem_load_general->proc~tem_simcontrol_load proc~tem_abortcriteria_load tem_abortCriteria_load proc~tem_abortcriteria_load->proc~tem_convergence_load

Contents

Source Code


Source Code

  subroutine tem_time_load(me, conf, key, parent, clock_start)
    ! -------------------------------------------------------------------- !
    !> Time to be read from the Lua script
    type(tem_time_type), intent(out) :: me

    !> Handle to the Lua script.
    type(flu_state), intent(inout) :: conf

    !> Name of the table containing the time definition. Default: 'time'.
    character(len=*), intent(in), optional :: key

    !> Handle to the parent table.
    integer, intent(in), optional :: parent

    !> Reference MPI_Wtime mark to use for computation of wallclock
    !!
    !! This is basically only useful to update the time object for a read in
    !! restart without distorting the clock measurement.
    real(kind=rk), intent(in), optional :: clock_start
    ! -------------------------------------------------------------------- !
    integer :: iErr
    character(len=labelLen) :: loc_key
    integer :: thandle
    ! -------------------------------------------------------------------- !

    if ( present(key) ) then
      loc_key = trim(key)
    else
      loc_key = 'time'
    end if

    call aot_table_open(L       = conf,    &
      &                 parent  = parent,  &
      &                 thandle = thandle, &
      &                 key     = loc_key  )

    if (thandle /= 0) then
      ! The time is given as a table load its components accordingly.
      call aot_get_val(L       = conf,         &
        &              thandle = thandle,      &
        &              val     = me%sim,       &
        &              key     = 'sim',        &
        &              default = huge(me%sim), &
        &              ErrCode = iErr          )

      call aot_get_val(L       = conf,          &
        &              thandle = thandle,       &
        &              val     = me%iter,       &
        &              key     = 'iter',        &
        &              default = huge(me%iter), &
        &              ErrCode = iErr           )

      call aot_get_val(L       = conf,           &
        &              thandle = thandle,        &
        &              val     = me%clock,       &
        &              key     = 'clock',        &
        &              default = huge(me%clock), &
        &              ErrCode = iErr            )
    else
      ! The time is not given as a table, try to interpret it as a setting for
      ! the simtime.
      call aot_get_val(L       = conf,         &
        &              thandle = parent,       &
        &              key     = loc_key,      &
        &              val     = me%sim,       &
        &              default = huge(me%sim), &
        &              ErrCode = iErr          )
      me%iter  = huge(me%iter)
      me%clock = huge(me%clock)
    end if

    call aot_table_close(conf, thandle)

    !>\todo HK: maybe provide the possibility to add up run times from loaded
    !!          data instead of resetting it.
    if (present(clock_start)) then
      me%clock_start = clock_start
    else
      me%clock_start = MPI_Wtime()
    end if

  end subroutine tem_time_load