reset_equations Subroutine

public subroutine reset_equations(state)

Effectively resets the state of the diagnostics and time index back to the start of the simulation. Primarily useful to allow one to reuse existing files etc. without having to start a new process. Mostly used in trinity workflows.

Arguments

Type IntentOptional Attributes Name
type(gs2_program_state_type), intent(inout) :: state

Contents

Source Code


Source Code

  subroutine reset_equations (state)
    use gs2_diagnostics, only: gd_reset => reset_init
#ifdef NEW_DIAG
    use gs2_diagnostics_new, only: reset_averages_and_counters
#endif
    use nonlinear_terms, only: nonlin
    use run_parameters, only: trinity_linear_fluxes, use_old_diagnostics
    use gs2_time, only: code_dt, save_dt
    use mp, only: scope, subprocs, allprocs
    use unit_tests, only: debug_message
    implicit none
    type(gs2_program_state_type), intent(inout) :: state

    if (.not. state%included) return
    if (state%nensembles > 1) call scope (subprocs)

    call debug_message(state%verb, 'gs2_main::reset_equations starting')

    call save_dt (code_dt)
    ! This call to gs2_diagnostics::reset_init sets some time averages
    ! and counters to zero... used mainly for trinity convergence checks.
    if (use_old_diagnostics) then
      call gd_reset
#ifdef NEW_DIAG
    else 
      call reset_averages_and_counters
#endif
    end if

    if (trinity_linear_fluxes .and. .not. nonlin) call reset_linear_magnitude

    state%istep_end = 0

    call debug_message(state%verb, 'gs2_main::reset_equations finished')

    if (state%nensembles > 1) call scope (allprocs)
  end subroutine reset_equations