gs2_init Module

This module is analogous to the init() function in Linux-based operating systems: it initialises gs2 to a certain init_level. At a given init level, certain modules are initialised and certain are not.

The gs2_init module is used by gs2_main to initialise modules. A typical additional use case for this module is when it is desired to override a given parameter (as in the override_* functions in gs2_main). GS2 must be taken down to the appropriate init_level, where all modules which contain any of those parameters are uninitialized. The override is then set and gs2 is brought back up to the highest init_level.

As in Linux, this module cannot be used until a certain basic initialization has happened (think loading the kernel). This basic initialization occurs in gs2_initialize in gs2_main, and set the init_level to gs2_initialized.

This is free software released under the MIT licence. Originally written by: Edmund Highcock (edmundhighcock@users.sourceforge.net) A list of possible intialization levels.

Bring gs2 to the target initialization level.

Reads the gs2_init namelist

Finalize the module



Contents


Variables

Type Visibility Attributes Name Initial
type(init_level_type), private, dimension(:), allocatable :: init_levels

Used to store all the init_level_type instances. Setup during init_gs2_init.

type(init_level_list_type), public, parameter :: init_level_list = init_level_list_type()
logical, private :: initialized = .false.

Interfaces

interface

  • private subroutine change_level_specific_interface(current, going_up)

    Arguments

    Type IntentOptional Attributes Name
    type(init_type), intent(in) :: current
    logical, intent(in) :: going_up

public interface init

  • private subroutine init_pass_type(current, target_level)

    Small wrapper to allow init_level_type to be passed instead of the level integer.

    Arguments

    Type IntentOptional Attributes Name
    type(init_type), intent(inout) :: current
    type(init_level_type), intent(in) :: target_level
  • private subroutine init_pass_int(current, target_level)

    Initialize gs2 to the level of target_level. The init_type current contains info about the current initialization level. At the end of the subroutine, current%level is set to target_level

    Arguments

    Type IntentOptional Attributes Name
    type(init_type), intent(inout) :: current
    integer, intent(in) :: target_level

Derived Types

type, public ::  init_type

A type for storing the current initialization status, as well as all the overrides.

Components

Type Visibility Attributes Name Initial
integer, public :: level = 0

The current init level

logical, public :: diagnostics_initialized = .false.

Whether or not diagnostics have been initialized Not obvious why this belongs here really as we don't deal with diagnostics in this module.

type(miller_geometry_overrides_type), public :: mgeo_ov

An object for overriding all or selected Miller geometry parameters. You must call gs2_main::prepare_miller_geometry_overrides before setting these overrides. See documentation for the overrides::miller_geometry_overrides_type for more information.

type(kt_grids_overrides_type), public :: kt_ov

An object for overriding all or selected profile parameters such as species temperature, density, and gradients as well as the flow gradient and mach number. You must call gs2_main::prepare_profiles_overrides before setting these overrides. See documentation for the overrides::profiles_overrides_type for more information.

type(profiles_overrides_type), public :: prof_ov

An object for overriding all or selected kt_grids parameters such as ny, nx, y0, jtwist etc. You must call gs2_main::prepare_kt_grids_overrides before setting these overrides. See documentation for the overrides::kt_grids_overrides_type for more information.

type(timestep_overrides_type), public :: tstep_ov

An object for overriding parameters connected to the timestep and cfl condition

type(initial_values_overrides_type), public :: initval_ov

An object for overriding the initial values of the fields and distribution function. You must call gs2_main::prepare_initial_values_overrides before setting these overrides. This override is very complicated. See documentation for the overrides::initial_values_overrides_type for more information.

type(optimisations_overrides_type), public :: opt_ov

An object for overriding non physics parameters which may alter run time and efficiency. You must call gs2_main::prepare_optimisations_overrides before setting these overrides.

type, private ::  init_level_type

Define an type to represent an initialisation level. This uses a hack to approximate type extension without the boiler plate of extending an abstract type. Specifically, we offer a type bound change_level procedure which just calls a procedure pointer to implement the actual work to change the level, specific to each instance.

Components

Type Visibility Attributes Name Initial
character(len=40), public :: name = 'init level name not set'
integer, public :: level = -1
integer, public :: debug_message_level = 1

Used to set the verbosity level at which this level reports debug messages.

procedure(change_level_specific_interface), private, pointer, nopass :: change_level_specific => null()
real, public, dimension(2) :: time_init = 0.

Type-Bound Procedures

procedure , public , :: generate_debug_message => init_level_generate_debug_message Subroutine
procedure , public , :: report_time => init_level_report_time Subroutine
procedure , public , :: change_level => init_level_change_level Function

type, private ::  init_level_list_type

A type for labelling the different init levels available in gs2.

Components

Type Visibility Attributes Name Initial
integer, public :: basic = 1
integer, public :: gs2_layouts = 2
integer, public :: normalisations = 3
integer, public :: theta_grid_params = 4
integer, public :: fields_parameters = 5
integer, public :: gs2_save = 6
integer, public :: init_g = 7
integer, public :: override_optimisations = 8
integer, public :: override_miller_geometry = 9
integer, public :: theta_grid = 10
integer, public :: kt_grids_parameters = 11
integer, public :: override_kt_grids = 12
integer, public :: kt_grids = 13
integer, public :: run_parameters = 14
integer, public :: species = 15
integer, public :: gs2_time = 16
integer, public :: override_profiles = 17
integer, public :: le_grids = 18
integer, public :: hyper = 19
integer, public :: antenna = 20
integer, public :: dist_fn_parameters = 21
integer, public :: dist_fn_layouts = 22
integer, public :: fields_level_1 = 23
integer, public :: nonlinear_terms = 24
integer, public :: split_nonlinear_terms = 25
integer, public :: dist_fn_arrays = 26
integer, public :: dist_fn_level_1 = 27
integer, public :: dist_fn_level_2 = 28
integer, public :: override_timestep = 29
integer, public :: collisions = 30
integer, public :: dist_fn_level_3 = 31
integer, public :: fields_level_2 = 32
integer, public :: override_initial_values = 33
integer, public :: set_initial_values = 34
integer, public :: full = 35

Functions

private function init_level_change_level(self, current, going_up) result(new_level)

General wrapper to the init_level instance's specific change level method.

Arguments

Type IntentOptional Attributes Name
class(init_level_type), intent(inout) :: self
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

Return Value integer


Subroutines

private subroutine init_level_generate_debug_message(self, going_up)

Produce the debug message associated with this level

Arguments

Type IntentOptional Attributes Name
class(init_level_type), intent(in) :: self
logical, intent(in) :: going_up

private subroutine init_level_report_time(self, unit)

Report the time spent in init for this level

Arguments

Type IntentOptional Attributes Name
class(init_level_type), intent(in) :: self
integer, intent(in), optional :: unit

public subroutine write_init_times()

Write the init times to .init_times

Arguments

None

public subroutine report_init_times(unit)

Report the time spent in each initialisation level

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: unit

public subroutine reset_init_times()

Reset the time spent in each initialisation level

Arguments

None

private subroutine init_pass_type(current, target_level)

Small wrapper to allow init_level_type to be passed instead of the level integer.

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(inout) :: current
type(init_level_type), intent(in) :: target_level

private subroutine init_pass_int(current, target_level)

Initialize gs2 to the level of target_level. The init_type current contains info about the current initialization level. At the end of the subroutine, current%level is set to target_level

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(inout) :: current
integer, intent(in) :: target_level

private subroutine basic_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine gs2_layouts_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine normalisations_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine theta_grid_params_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine fields_parameters_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine gs2_save_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine init_g_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_optimisations_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_miller_geometry_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine theta_grid_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine kt_grids_parameters_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_kt_grids_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine kt_grids_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine run_parameters_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine species_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine gs2_time_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_profiles_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine le_grids_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine hyper_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine antenna_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_parameters_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_layouts_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine fields_level_1_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine nonlinear_terms_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine split_nonlinear_terms_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_arrays_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_level_1_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_level_2_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_timestep_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine collisions_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine dist_fn_level_3_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine fields_level_2_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine override_initial_values_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine set_initial_values_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

private subroutine full_subroutine(current, going_up)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current
logical, intent(in) :: going_up

public subroutine init_gs2_init()

Initialise this module. As we pass in the initialisation state object (current), we could/should consider making this set the level to basic, e.g. current%level = init_level_list%basic

Arguments

None

public subroutine finish_gs2_init()

Finish this module

Arguments

None

private subroutine set_initial_field_and_dist_fn_values(current)

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(in) :: current