Time stepping

step_time.f90

Quick access

Variables:

start_from_another_scheme, transp_lmloc_to_rloc, transp_rloc_to_lmloc, transp_rloc_to_lmloc_io

Routines:

initialize_step_time(), step_time()

Needed modules

Variables

  • step_time_mod/start_from_another_scheme [private]
  • step_time_mod/transp_lmloc_to_rloc [private]
  • step_time_mod/transp_rloc_to_lmloc [private]
  • step_time_mod/transp_rloc_to_lmloc_io [private]

Subroutines and functions

subroutine  step_time_mod/initialize_step_time()
Called from:

magic

Call to:

initialize_signals()

subroutine  step_time_mod/step_time(time, tscheme, n_time_step, run_time_start)

This subroutine performs the actual time-stepping.

Parameters:
  • time [real ,inout]

  • tscheme [real ]

  • n_time_step [integer ,inout]

  • run_time_start [timer_type ,in]

Called from:

magic

Call to:

check_signals(), logwrite(), l_correct_step(), open_graph_file(), radialloopg(), finish_explicit_assembly_rdist(), get_b_nl_bcs(), finish_explicit_assembly(), scatter_from_rank0_to_lo(), output(), close_graph_file(), dt_courant(), lmloop_rdist(), lmloop(), assemble_stage_rdist(), assemble_stage(), formattime()

courant.f90

Description

This module handles the computation of Courant factors on grid space. It then checks whether the timestep size needs to be modified.

Quick access

Variables:

file_handle

Routines:

courant(), dt_courant(), finalize_courant(), initialize_courant()

Needed modules

Variables

  • courant_mod/file_handle [integer,private]

Subroutines and functions

subroutine  courant_mod/initialize_courant(time, dt, tag)

This subroutine opens the timestep.TAG file which stores the time step changes of MagIC.

Parameters:
  • time [real ,in] :: time

  • dt [real ,in] :: time step

  • tag [character(len=*),in] :: trailing of the fime

Called from:

magic

subroutine  courant_mod/finalize_courant()
Called from:

magic

subroutine  courant_mod/courant(n_r, dtrkc, dthkc, vr, vt, vp, br, bt, bp, courfac, alffac)

courant condition check: calculates Courant advection lengths in radial direction dtrkc and in horizontal direction dthkc on the local radial level n_r

for the effective velocity, the abs. sum of fluid velocity and Alfven velocity is taken

instead of the full Alfven velocity a modified Alfven velocity is employed that takes viscous and Joule damping into account. Different Courant factors are used for the fluid velocity and the such modified Alfven velocity

Parameters:
  • n_r [integer ,in] :: radial level

  • dtrkc [real ,inout] :: Courant step (based on radial advection)

  • dthkc [real ,inout] :: Courant step based on horizontal advection

  • vr (*,*) [real ,in] :: radial velocity

  • vt (*,*) [real ,in] :: longitudinal velocity

  • vp (*,*) [real ,in] :: azimuthal velocity

  • br (*,*) [real ,in] :: radial magnetic field

  • bt (*,*) [real ,in] :: longitudinal magnetic field

  • bp (*,*) [real ,in] :: azimuthal magnetic field

  • courfac [real ,in]

  • alffac [real ,in]

subroutine  courant_mod/dt_courant(l_new_dt, dt, dt_new, dtmax, dtrkc, dthkc, time)

This subroutine checks if the Courant criterion based on combined fluid and Alfven velocity is satisfied. It returns a new value for the time step size.

Parameters:
  • l_new_dt [logical ,out] :: flag indicating that time step is changed (=1) or not (=0)

  • dt [real ,in] :: old time step size

  • dt_new [real ,out] :: new time step size

  • dtmax [real ,in] ::

  • dtrkc (1 - nrstart + nrstop) [real ,in] :: radial Courant time step as function of radial level

  • dthkc (1 - nrstart + nrstop) [real ,in] :: horizontal Courant time step as function of radial level

  • time [real ,in] :: Current time

Called from:

step_time()

Call to:

logwrite()

timing.f90

Description

This module contains functions that are used to measure the time spent.

Quick access

Types:

timer_type

Variables:

finalize, initialize, start_count, stop_count

Routines:

formattime()

Needed modules

  • iso_fortran_env (output_unit())

  • mpimod

  • precision_mod: This module controls the precision used in MagIC

  • parallel_mod: This module contains the blocking information

Types

  • type  timing/timer_type
    Type fields:
    • % n_counts [integer ]

    • % tstart [real ]

    • % ttot [real ]

Variables

  • timing/finalize [private]
  • timing/initialize [private]
  • timing/start_count [private]
  • timing/stop_count [private]

Subroutines and functions

subroutine  timing/formattime(n_out, message, time_in_sec)
Parameters:
  • n_out [integer ,in]

  • message [character(len=*),in]

  • time_in_sec [real ,in]

Called from:

step_time()

Time schemes

time_schemes.f90

Description

This module defines an abstract class type_tscheme which is employed for the time advance of the code.

Quick access

Types:

type_tscheme

Variables:

print_info, unknown_interface

Needed modules

  • iso_fortran_env (output_unit())

  • time_array: This module defines two types that are defined to store the implicit/explicit terms at the different sub-stage/step.

  • logic (l_save_out()): Module containing the logicals that control the run

  • output_data (log_file()): This module contains the parameters for output control

  • precision_mod: This module controls the precision used in MagIC

Types

  • type  time_schemes/type_tscheme
    Type fields:
    • % alffac [real ]

    • % courfac [real ]

    • % dt (*) [real ,allocatable]

    • % family [character(len=10)]

    • % intfac [real ]

    • % istage [integer ]

    • % l_assembly [logical ]

    • % l_exp_calc (*) [logical ,allocatable]

    • % l_imp_calc_rhs (*) [logical ,allocatable]

    • % nexp [integer ]

    • % nimp [integer ]

    • % nold [integer ]

    • % nstages [integer ]

    • % time_scheme [character(len=8)]

    • % wimp_lin (*) [real ,allocatable]

Variables

  • time_schemes/print_info [private]
  • time_schemes/unknown_interface [private]

multistep_schemes.f90

Description

This module defines the type_multistep which inherits from the abstract type_tscheme. It actually implements all the routine required to time-advance an IMEX multistep scheme such as CN/AB2, SBDF(2,3,4), CNLF, …

Quick access

Types:

type_multistep

Variables:

assemble_imex, assemble_imex_scalar, bridge_with_cnab2, get_time_stage, rotate_imex, rotate_imex_scalar, set_dt_array, set_imex_rhs, set_imex_rhs_ghost, set_imex_rhs_scalar, set_weights, start_with_ab1

Needed modules

Types

  • type  multistep_schemes/type_multistep
    Type fields:
    • % wexp (*) [real ,allocatable]

    • % wimp (*) [real ,allocatable]

Variables

  • multistep_schemes/assemble_imex [private]
  • multistep_schemes/assemble_imex_scalar [private]
  • multistep_schemes/bridge_with_cnab2 [private]
  • multistep_schemes/finalize [private]
  • multistep_schemes/get_time_stage [private]
  • multistep_schemes/initialize [private]
  • multistep_schemes/rotate_imex [private]
  • multistep_schemes/rotate_imex_scalar [private]
  • multistep_schemes/set_dt_array [private]
  • multistep_schemes/set_imex_rhs [private]
  • multistep_schemes/set_imex_rhs_ghost [private]
  • multistep_schemes/set_imex_rhs_scalar [private]
  • multistep_schemes/set_weights [private]
  • multistep_schemes/start_with_ab1 [private]

dirk_schemes.f90

Description

This module defines the type_dirk which inherits from the abstract type_tscheme. It actually implements all the routine required to time-advance an diagonally implicit Runge-Kutta scheme. It makes use of Butcher tables to construct the right-hand-sides.

Quick access

Types:

type_dirk

Needed modules

Types

  • type  dirk_schemes/type_dirk
    Type fields:
    • % butcher_ass_exp (*) [real ,allocatable]

    • % butcher_ass_imp (*) [real ,allocatable]

    • % butcher_c (*) [real ,allocatable]

    • % butcher_exp (*,*) [real ,allocatable]

    • % butcher_imp (*,*) [real ,allocatable]

Variables

  • dirk_schemes/assemble_imex [private]
  • dirk_schemes/assemble_imex_scalar [private]
  • dirk_schemes/bridge_with_cnab2 [private]
  • dirk_schemes/finalize [private]
  • dirk_schemes/get_time_stage [private]
  • dirk_schemes/initialize [private]
  • dirk_schemes/rotate_imex [private]
  • dirk_schemes/rotate_imex_scalar [private]
  • dirk_schemes/set_dt_array [private]
  • dirk_schemes/set_imex_rhs [private]
  • dirk_schemes/set_imex_rhs_ghost [private]
  • dirk_schemes/set_imex_rhs_scalar [private]
  • dirk_schemes/set_weights [private]
  • dirk_schemes/start_with_ab1 [private]

time_array.f90

Description

This module defines two types that are defined to store the implicit/explicit terms at the different sub-stage/step.

Quick access

Types:

type_tarray, type_tscalar

Variables:

finalize_scalar, initialize_scalar

Needed modules

Types

  • type  time_array/type_tarray
    Type fields:
    • % expl (*,*,*) [complex ,pointer]

    • % impl (*,*,*) [complex ,allocatable]

    • % l_exp [logical ]

    • % llm [integer ]

    • % nrstart [integer ]

    • % nrstop [integer ]

    • % old (*,*,*) [complex ,allocatable]

    • % ulm [integer ]

  • type  time_array/type_tscalar
    Type fields:
    • % expl (*) [real ,allocatable]

    • % impl (*) [real ,allocatable]

    • % old (*) [real ,allocatable]

Variables

  • time_array/finalize [private]
  • time_array/finalize_scalar [private]
  • time_array/initialize [private]
  • time_array/initialize_scalar [private]