gs2_save Module

FIXME : Add documentation


Uses


Contents


Variables

Type Visibility Attributes Name Initial
logical, public :: read_many = .false.

Read and write single or multiple restart files. Effectively ignored if not built with parallel netcdf

logical, public :: save_many = .false.

Read and write single or multiple restart files. Effectively ignored if not built with parallel netcdf

logical, public :: include_explicit_source_in_restart = .true.

Do we want to include the explicit source terms and related timesteps when saving/restoring from the restart file.

integer, public :: proc_to_save_fields

Which processor should save the potentials. If <0 (default) then all processors save their potentials. If >= nproc then will be set to mod(proc_to_save_fields, nproc)

character(len=run_name_size), private :: restart_file

Used to hold the base of the restart file name.

character(len=5), private, parameter, dimension(*) :: g_dim_names = ["theta", "sign ", "glo  "]

Names of dimensions for distribution-sized variables in netCDF files

character(len=5), private, parameter, dimension(*) :: field_dim_names = ["theta", "akx  ", "aky  "]
real, private, allocatable, dimension(:,:,:) :: tmpr
real, private, allocatable, dimension(:,:,:) :: tmpi
real, private, allocatable, dimension(:,:,:) :: ftmpr
real, private, allocatable, dimension(:,:,:) :: ftmpi
real, private, allocatable, dimension(:) :: stmp
real, private, allocatable, dimension(:) :: atmp
logical, private, parameter :: include_parameter_scan = .true.

Do we save the scan parameter or not?

logical, private, parameter :: has_netcdf_parallel = .false.

The NETCDF_PARALLEL directives include code for parallel netcdf using HDF5 to write the output to a single restart file The save_many/read_many flag allows the old style multiple file output Here we set a run time flag to enable us to handle some of the different paths through the code at run time rather than with ifdef mazes


Interfaces

public interface gs2_restore

  • private subroutine gs2_restore_many(g, scale, istatus, has_phi, has_apar, has_bpar, fileopt)

    FIXME : Add documentation

    Arguments

    Type IntentOptional Attributes Name
    complex, intent(out), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
    real, intent(in) :: scale
    integer, intent(out) :: istatus
    logical, intent(in) :: has_phi
    logical, intent(in) :: has_apar
    logical, intent(in) :: has_bpar
    character(len=*), intent(in), optional :: fileopt

Derived Types

type, public ::  EigNetcdfID

A custom type to look after the netcdf ids for the eigenvalue file

Components

Type Visibility Attributes Name Initial
integer, public :: ncid

File handle

integer, public :: nconv_count

Current size of conv dimension


Functions

public function restart_writable(read_only, my_file, error_message)

This function checks to see if we can create a file with name // if not then our restarts are not going to be possible and we return false. Can also be used to check that we can read from the restart file (which assumes it exists).

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: read_only

If present and true, only check that files can be read

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

An optional specific filename to check

character(len=:), intent(out), optional, allocatable :: error_message

Error message returned from open if there was a problem

Return Value logical

private function get_file_proc(is_one_file_per_processor, fileopt) result(file_proc)

Returns the file corresponding to restart file in current setup

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: is_one_file_per_processor
character(len=*), intent(in), optional :: fileopt

Return Value character(len=run_name_size)


Subroutines

public subroutine gs2_save_for_restart(g, t0, vnm, has_phi, has_apar, has_bpar, code_dt, code_dt_prev1, code_dt_prev2, code_dt_max, fileopt, save_glo_info_and_grids, save_velocities, header)

Create and fill the restart files

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g

The distribution function

real, intent(in) :: t0

Current simulation time

real, intent(in), dimension (2) :: vnm

FIXME: Collisionality multiplier?

logical, intent(in) :: has_phi

Do we include electrostatic potential,

logical, intent(in) :: has_apar

Do we include vector potential,

logical, intent(in) :: has_bpar

Do we include parallel magnetic field,

real, intent(in) :: code_dt

The current time step, the two previous time steps and the maximum allowed time step.

real, intent(in) :: code_dt_prev1

The current time step, the two previous time steps and the maximum allowed time step.

real, intent(in) :: code_dt_prev2

The current time step, the two previous time steps and the maximum allowed time step.

real, intent(in) :: code_dt_max

The current time step, the two previous time steps and the maximum allowed time step.

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

Optional extra filename infix

logical, intent(in), optional :: save_glo_info_and_grids

Control if layout and diagnostic information is saved

logical, intent(in), optional :: save_velocities

Control if information is saved

type(standard_header_type), intent(in), optional :: header

Header for files with build and run information

public subroutine gs2_save_slice(g_in, it, ik, il, ie, is, time, nout, fileopt, header)

Save g slices

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:, :, g_lo%llim_proc:) :: g_in

The distribution function

integer, intent(in) :: it

The indices of the slice to save

integer, intent(in) :: ik

The indices of the slice to save

integer, intent(in) :: il

The indices of the slice to save

integer, intent(in) :: ie

The indices of the slice to save

integer, intent(in) :: is

The indices of the slice to save

real, intent(in) :: time

The current time

integer, intent(in), optional :: nout

The current time output index

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

Optional extra filename infix

type(standard_header_type), intent(in), optional :: header

Header for files with build and run information

private subroutine gs2_restore_many(g, scale, istatus, has_phi, has_apar, has_bpar, fileopt)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g
real, intent(in) :: scale
integer, intent(out) :: istatus
logical, intent(in) :: has_phi
logical, intent(in) :: has_apar
logical, intent(in) :: has_bpar
character(len=*), intent(in), optional :: fileopt

public subroutine gs2_save_response(resp, fname, code_dt, condition, header)

This routine writes a passed square complex array to a file with passed name

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(:,:) :: resp
character(len=*), intent(in) :: fname
real, intent(in) :: code_dt
real, intent(in), optional :: condition
type(standard_header_type), intent(in), optional :: header

Header for files with build and run information

public subroutine gs2_restore_response(resp, fname, code_dt, condition)

This routine reads a square complex array from a file with passed name

Arguments

Type IntentOptional Attributes Name
complex, intent(out), dimension(:,:) :: resp
character(len=*), intent(in) :: fname
real, intent(out) :: code_dt
real, intent(out), optional :: condition

public subroutine init_eigenfunc_file(fname, IDs)

Initialises a file for saving output of eigensolver to netcdf

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fname
type(EigNetcdfID), intent(inout) :: IDs

public subroutine add_eigenpair_to_file(eval, has_phi, has_apar, has_bpar, IDs, my_conv)

Add an eigenpairs data to file

Arguments

Type IntentOptional Attributes Name
complex, intent(in) :: eval
logical, intent(in) :: has_phi
logical, intent(in) :: has_apar
logical, intent(in) :: has_bpar
type(EigNetcdfID), intent(inout) :: IDs
real, intent(in), optional :: my_conv

public subroutine finish_eigenfunc_file(IDs)

Close the eigenfunction file

Arguments

Type IntentOptional Attributes Name
type(EigNetcdfID), intent(inout) :: IDs

public subroutine init_gs2_save()

FIXME : Add documentation

Arguments

None

public subroutine set_restart_file(file)

Sets the base of the restart file to be used when writing/reading files.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: file

public subroutine finish_gs2_save()

FIXME : Add documentation

Arguments

None

private subroutine deallocate_arrays()

Deallocate all module level arrays

Arguments

None

public subroutine restore_current_scan_parameter_value(current_scan_parameter_value)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(out) :: current_scan_parameter_value

public subroutine init_dt(delt0, delt1, delt2, delt_max, istatus, not_set_value)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(inout) :: delt0
real, intent(inout) :: delt1
real, intent(inout) :: delt2
real, intent(inout) :: delt_max
integer, intent(out) :: istatus
real, intent(in), optional :: not_set_value

public subroutine init_vnm(vnm, istatus)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(inout), dimension(2) :: vnm
integer, intent(out) :: istatus

public subroutine init_ant_amp(a_ant, b_ant, nk_stir, istatus)

FIXME : Add documentation

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension(:) :: a_ant
complex, intent(inout), dimension(:) :: b_ant
integer, intent(in) :: nk_stir
integer, intent(out) :: istatus

public subroutine read_t0_from_restart_file(tstart, istatus)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
real, intent(inout) :: tstart
integer, intent(out) :: istatus