set_cfl_time_step_and_check_if_too_large Subroutine

private subroutine set_cfl_time_step_and_check_if_too_large()

Calculates the cfl limit from the module level max_vel value saves it using save_dt_cfl and then sets the reset flag based on checking if the current time step is too large.

Arguments

None

Contents


Source Code

  subroutine set_cfl_time_step_and_check_if_too_large
    use run_parameters, only: reset
    use gs2_time, only: save_dt_cfl, check_time_step_too_large
    implicit none
    real :: dt_cfl, max_vel

    max_vel = get_max_vel(max_vel_components)

    ! Estimate the global cfl limit based on max_vel.
    if (max_vel <= 0.0) then
       ! We should only end up here in unusual cases (likely
       ! tests) as we initialise max_vel > 0 so the only way
       ! we get here is if the estimated NL velocity limit is
       ! exactly 0.
       dt_cfl = dt_cfl_default_large
    else
       dt_cfl = 1./max_vel
    end if

    call save_dt_cfl (dt_cfl)

    ! Now check to see if we've violated the cfl condition.
    call check_time_step_too_large(reset)
  end subroutine set_cfl_time_step_and_check_if_too_large