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:
Find more information about usage of restart in the section '[restart_usage]'
The Restart / Harvester Format
Add an extensive description of the restart format here
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.
Control the behavior of the restart, like at which point in time etc.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
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 |
Define quantities like the prefix, the mesh and the timestamp
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
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 |
The restart type defining everything related to the disk input/output
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
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 |
|||
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 | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
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 |
Read all necessary information for the restart from the lua config file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Initialize the global restart data type and prepare for the restart output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
This subroutine initializes the restart in case of reading initial conditions from restart file. The dependent scheme id is passed as input.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
This subroutine creates MPI types for reading the restart.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type), | intent(inout) | :: | me | |||
integer(kind=long_k), | intent(in) | :: | elemOff | |||
integer, | intent(in) | :: | locElems |
This subroutine evaluated get_element and dump each chunk
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
This subroutine dumps the given chunk to a given position in the restart file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Read data from a restart file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
subroutine which reads data from restart file corresponding to the input variable system
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
open the restart dump file and write out the 'normal' restart header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type) | :: | me | the restart information |
Open the restart dump file and set file view for the input variable system
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type) | :: | me | the restart information |
This subroutine closes the restart dump file and writes the last header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type) | :: | me | the restart information |
Close the restart dump file corresponding to a particular variable system
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type) | :: | me | the restart infotmation |
open the restart dump file and write out the 'normal' restart header as well as the mesh.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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!!!!) |
This subroutine closes the restart dump file and writes the last header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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!!!!) |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
calculate the maximum number of elements which fit into the output buffer = chunk
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
Finalizing a restart object
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_restart_type), | intent(inout) | :: | me | the restart type to close |
read the restart header lua file and hand the information to the required data types, re-set the time ...
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |