tem_restart_module Module

This module provides the main IO facilities to read and write large amounts of data during the simulation.

Especially, it enables the dumping of the simulation status (e.g. the state vector) to disk and reading the information later on to restart the simulation at a certain point of time. Additionally, information like solver, version, number of elements, etc. are stored in a seperate header file.

The general procedure is as follows:

  • read the configuration from the lua file with tem_load_restart
  • initialize the read/write restart with tem_init_restart
  • read restart
  • write restart

Find more information about usage of restart in the section '[restart_usage]'

The Restart / Harvester Format


The Restart Usage


To use the restart functionality the user has to define the io buffersize

 -- IO buffer size in MB (default = 8)
 io_buffer_size = 1

and the restart settings in the lua configuration file.

 -- Restart settings
 restart = { read  = 'restart/gaussian_lastHeader.lua',
                     -- file to restart from
             write = 'restart/',
                     -- prefix to write the files to
             time_control = { min = 0, max = 10, interval = 10,
                              align_trigger = false,
             }
             -- timing definitions (either iterations or simulation time)
           }

Another option to read restart is from initial conditions. The user then has to define restart data to be read into a variable in this way:

 initial_condition = { file = 'restart/channel_lastHeader.lua',
   depend = {
     variable = { {'pdf', 19} },
     usescheme = 'mini-channel'
   }
 }

If only the write option shall be used the identifier read has to be removed and vice versa.


Uses

Used by

  • module~~tem_restart_module~~UsedByGraph module~tem_restart_module tem_restart_module module~tem_general_module tem_general_module module~tem_general_module->module~tem_restart_module module~hvs_output_module hvs_output_module module~hvs_output_module->module~tem_restart_module program~tem_varsys_stfunvar_test tem_varSys_stfunVar_test program~tem_varsys_stfunvar_test->module~tem_general_module module~tem_utestenv_module tem_utestEnv_module program~tem_varsys_stfunvar_test->module~tem_utestenv_module program~tem_varsys_statevar_test tem_varSys_stateVar_test program~tem_varsys_statevar_test->module~tem_general_module program~tem_varsys_statevar_test->module~tem_utestenv_module program~tem_sparta_test tem_sparta_test program~tem_sparta_test->module~tem_general_module program~tem_sparta_test->module~tem_utestenv_module program~tem_varsys_derivevar_test tem_varSys_deriveVar_test program~tem_varsys_derivevar_test->module~tem_general_module program~tem_varsys_derivevar_test->module~tem_utestenv_module program~tem_variable_evaltype_test tem_variable_evaltype_test program~tem_variable_evaltype_test->module~tem_general_module program~tem_variable_evaltype_test->module~tem_utestenv_module program~tem_varsys_test tem_varSys_test program~tem_varsys_test->module~tem_general_module program~tem_varsys_test->module~tem_utestenv_module program~tem_spacetime_fun_test tem_spacetime_fun_test program~tem_spacetime_fun_test->module~tem_general_module program~tem_spacetime_fun_test->module~tem_utestenv_module program~tem_logical_opertor_test tem_logical_opertor_test program~tem_logical_opertor_test->module~tem_general_module program~tem_logical_opertor_test->module~tem_utestenv_module program~bin_search_test bin_search_test program~bin_search_test->module~tem_general_module program~tem_variable_extract_test tem_variable_extract_test program~tem_variable_extract_test->module~tem_general_module program~tem_variable_extract_test->module~tem_utestenv_module program~tem_variable_combine_test tem_variable_combine_Test program~tem_variable_combine_test->module~tem_general_module program~tem_variable_combine_test->module~tem_utestenv_module program~tem_face_test tem_face_test program~tem_face_test->module~tem_general_module program~tem_face_test->module~tem_utestenv_module program~tem_face_test~2 tem_face_test program~tem_face_test~2->module~tem_general_module program~tem_face_test~2->module~tem_utestenv_module module~tem_utestenv_module->module~tem_general_module module~tem_tracking_module tem_tracking_module module~tem_tracking_module->module~hvs_output_module program~tem_face_test~3 tem_face_test program~tem_face_test~3->module~tem_general_module program~tem_face_test~3->module~tem_utestenv_module program~tem_varsys_opvar_test tem_varSys_opVar_test program~tem_varsys_opvar_test->module~tem_general_module program~tem_varsys_opvar_test->module~tem_utestenv_module program~tem_tracking_test tem_tracking_test program~tem_tracking_test->module~tem_tracking_module

Contents


Derived Types

type, public :: tem_restartControl_type

Control the behavior of the restart, like at which point in time etc.

Components

TypeVisibilityAttributesNameInitial
logical, private :: init_on_missing

Do a normal initialization if the read restart file is not found?

logical, private :: readRestart

is the restart read active?

logical, private :: writeRestart

is the restart write active?

character(len=PathLen), private :: readFileName

read the restart file from following file

character(len=PathLen), private :: writePrefix

write the restart file into a file with the following prefix

type(tem_timeControl_type), private :: timeControl

control about when to do the restart

type, public :: tem_restartHeader_type

Define quantities like the prefix, the mesh and the timestamp

Components

TypeVisibilityAttributesNameInitial
character(len=LabelLen), private :: solverTag ='unknown'

a unique tag for the solver including version

character(len=LabelLen), private :: solverKind

solver creating the input data (Ateles, Musubi)

character(len=LabelLen), private :: simName =''

the simulation name

character(len=pathLen), private :: solverConfigFile =''

the solver config file name

character(len=PathLen), private :: binName

name of the binary files (this variable is set for every timestamp differently, used for read and write)

character(len=PathLen), private :: binPrefix

prefix for the binary files (includes directory and file prefix)

character(len=PathLen), private :: headerPrefix

prefix for the header files (includes directory and file prefix)

character(len=16), private :: timestamp

the current time generated from tem_time_module

integer, private :: nElems

mesh directory Number of elements as read from the restart header

type(tem_varSys_type), private :: varSys

variable system dumped in restart header

type, public :: tem_restart_type

The restart type defining everything related to the disk input/output

Components

TypeVisibilityAttributesNameInitial
type(tem_comm_env_type), private :: comm

communicator for the processes participating in this restart (might be only a subset of the global communicator)

integer, private :: nChunkElems

actual number of elements in the current chunk (= chunkSize or

type(tem_file_layout_type), private :: read_file

Description of the data layout to use when reading a file.

type(tem_file_layout_type), private :: write_file

Description of the data layout to use when writing a file.

type(tem_restartControl_type), private :: controller

Control the behavior of the restart, like at which point in time etc.

type(tem_restartHeader_type), private :: header

Define quantities like the prefix, the mesh and the timestamp

integer, private :: binaryUnit

unit integer to write binary data to

type(tem_varMap_type), private :: varMap

name and position of variables in global variable system

Read more…
integer, private :: nScalars
integer, private :: solSpec_unit =-1

scratch file unit contains solver specific info in dump in restart header This file should contain the information in form of a Lua script.

type(tem_time_type), private :: lastWritten

The time when the last restart file was written.

type, private :: tem_file_layout_type

Components

TypeVisibilityAttributesNameInitial
integer, private :: nDofs =1

Number of degrees of freedom for each of the scalars entries in the varibale system in the file.

integer, private :: nChunks

Number of local chunks required to fit complete data in. Set in routine: tem_restart_getTotalChunks

integer, private :: maxnChunks

Globally maximal number of chunks required. Set in routine: tem_restart_getTotalChunks

integer, private :: chunkSize

Number of elements that fit into the buffer. Set in routine: tem_restart_getTotalChunks

integer, private :: ftype

Handle for the MPI type to describe the view for IO in binary IO

integer, private :: vectype

Handle for the MPI type describing the vector of data in each element

integer(kind=MPI_OFFSET_KIND), private :: displacement

start of view for MPI_SET_VIEW


Subroutines

public subroutine tem_load_restart(me, conf, tree, timing, globProc, parent_table, key)

Read all necessary information for the restart from the lua config file.

Read more…

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: me

restart type to be filled

type(flu_state) :: conf

lua configuration file

type(treelmesh_type), intent(inout) :: tree

mesh, provided in treelm format

type(tem_time_type), intent(inout) :: timing

the timing for re-setting the times

type(tem_comm_env_type), intent(in) :: globProc

Global process communicator env

integer, intent(in), optional :: parent_table

optional parent handle

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

optional key for table

public subroutine tem_init_restart(me, solver, varMap, tree, subTree, nDofs_write, chunkSize, solSpec_unit)

Initialize the global restart data type and prepare for the restart output

Read more…

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: me

The restart object to initialize.

type(tem_solveHead_type), intent(in), optional :: solver

Details about the solver.

type(tem_varMap_type), intent(in) :: varMap

Description of each variable system. This is ignored, if the data is provided by reading a restart. Contains position of variables to dump in restart file in global variable system for a scheme

type(treelmesh_type), intent(in) :: tree

Mesh, provided in treelm format

type(tem_subTree_type), intent(in), optional :: subTree

optional subTree of the given tree

integer, intent(in), optional :: nDofs_write

number of degrees of freedom for each variable of the equation system

integer, intent(in), optional :: chunkSize

use predefined chunkSize

integer, intent(in), optional :: solSpec_unit

Solver specific unit for restart header

public subroutine tem_init_restart_alloc(me, comm, rank, comm_size, solver, nDofs_write)

Author
Kartik Jain

This subroutine initializes the restart in case of reading initial conditions from restart file. The dependent scheme id is passed as input.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: me
integer, intent(in) :: comm
integer, intent(in) :: rank
integer, intent(in) :: comm_size
type(tem_solveHead_type), intent(in), optional :: solver
integer, intent(in), optional :: nDofs_write

public subroutine tem_init_restart_create_types(me, elemOff, locElems)

This subroutine creates MPI types for reading the restart.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: me
integer(kind=long_k), intent(in) :: elemOff
integer, intent(in) :: locElems

public subroutine tem_restart_dump_data(restart, varsys, tree, time, subtree)

This subroutine evaluated get_element and dump each chunk

Read more…

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: restart

The restart object describing how and what to output.

type(tem_varSys_type), intent(in) :: varsys

Description of the available variable system to get the given varnames from.

type(treelmesh_type), intent(in) :: tree

Mesh to write the data on.

type(tem_time_type), intent(in) :: time

Point in time to use for this data.

Can be important for space-time function evaluations.

type(tem_subTree_type), intent(in), optional :: subtree

Optional restriction of the elements to output.

public subroutine tem_restart_writeData(restart, chunk)

This subroutine dumps the given chunk to a given position in the restart file.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: restart

The restart object describing how and what to output.

real(kind=rk), intent(in) :: chunk(:)

The data to output. It is organized as a serialized array of all scalar entries of all variable systems. Where first all the data for the nElems of the first variable system is provided. Within each variable system the data is organized elementwise.

public subroutine tem_restart_readData(restart, chunk)

Read data from a restart file.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: restart

Restart description to read the data from

real(kind=rk), intent(out) :: chunk(:)

Chunk of memory to put the read data into

public subroutine tem_restart_readData_single(restart, chunk, offset)

subroutine which reads data from restart file corresponding to the input variable system

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: restart

Restart object to read the data from

real(kind=rk), intent(out) :: chunk(:)

Memory to chunk to put the data into

integer, intent(in) :: offset

Offset of the chunk of data to get in the global data

public subroutine tem_restart_openRead(me)

open the restart dump file and write out the 'normal' restart header.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart information

public subroutine tem_restart_openRead_single(me)

Open the restart dump file and set file view for the input variable system

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart information

public subroutine tem_restart_closeRead(me)

This subroutine closes the restart dump file and writes the last header.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart information

public subroutine tem_restart_closeRead_single(me)

Close the restart dump file corresponding to a particular variable system

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart infotmation

public subroutine tem_restart_openWrite(me, tree, timing, varSys, subTree, label, suffix)

open the restart dump file and write out the 'normal' restart header as well as the mesh.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart infotmation

type(treelmesh_type) :: tree

mesh, provided in treelm format

type(tem_time_type), intent(in) :: timing

current simulation time information

type(tem_varSys_type), intent(in) :: varSys

the used var systeme

type(tem_subTree_type), intent(inout), optional :: subTree

optional subTree of the given tree

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

additional label for the filename (needed for tracking in harvester format)

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

optional suffix (if present NO timestamp will be added!!!!)

public subroutine tem_restart_writeHeader(me, tree, varSys, subTree, timing, lastHeader, suffix)

This subroutine closes the restart dump file and writes the last header.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart header info

type(treelmesh_type) :: tree

mesh, provided in treelm format

type(tem_varSys_type), intent(in) :: varSys

global variable system defined in solver

type(tem_subTree_type), intent(in), optional :: subTree

optional subTree of the given tree

type(tem_time_type), intent(in) :: timing
logical, optional :: lastHeader

is this header a last header

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

optional suffix (if present NO timestamp will be added!!!!)

public subroutine tem_restart_closeWrite(me, tree, timing, varSys, subTree)

Complete a number of empty writes (due to higher amount of mpi_file_writes from other processes to finalize the write process), close the restart dump file and write the last header.

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart information

type(treelmesh_type) :: tree

mesh, provided in treelm format

type(tem_time_type), intent(in) :: timing

The timing object holding the simulation time

type(tem_varSys_type), intent(in) :: varSys

global variable system defined in solver

type(tem_subTree_type), optional :: subTree

optional subTree of given tree

public subroutine tem_restart_getTotalChunks(restart, nElems, comm, chunkSize)

calculate the maximum number of elements which fit into the output buffer = chunk

Read more…

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: restart

the restart type

integer, intent(in) :: nElems

mesh, provided in treelm format optional subTree

integer, intent(in) :: comm

mesh, provided in treelm format optional subTree

integer, intent(in), optional :: chunkSize

optional predefined chunksize

public subroutine tem_restart_finalize(me)

Finalizing a restart object

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type), intent(inout) :: me

the restart type to close

private subroutine tem_restart_readHeader(me, timing, globProc, tree)

read the restart header lua file and hand the information to the required data types, re-set the time ...

Arguments

TypeIntentOptionalAttributesName
type(tem_restart_type) :: me

the restart header info

type(tem_time_type), intent(inout) :: timing

the timing for re-setting the times

type(tem_comm_env_type), intent(in) :: globProc

Global communicator

type(treelmesh_type), intent(inout) :: tree

mesh, provided in treelm format