Content
- Introduction
- Files provided
- Running a test example
- Structure of the command files
- Storing the EIRENE triangular grids in IMAS
- Structure of EIRENE files keeping the grid
- Presentation of EIRENE grid in GGD
- Module triangular_grid_modile
- Data types
- Methods
- Module triangular_grid_ids_io
- Data types
- Methods
- EIRENE input wrapper
- Structure of EIRENE input files
- Module eirene_data_io
- Data types
- Methods
- Module imas_data_io
- Constants
- Methods
- Module edge_profiles_io
- Data types
- Methods
- Module equilibrium_io
- Data types
- Methods
- Module global_objects
- Constants
- Methods
- Module imas_controls_for_input
- Data types
- Methods
- Main program files save_input_main.f90 and provide_input_main.f90
- Known issues
- Things to be done
Introduction
The Fortran routines described herein are intended to become a part of interface between the code EIRENE and the IMAS data structure. In its current form, they write EIRENE input data (grid information and a restricted set of physical quantities defined on this grid) to IMAS and, vice versa, get these data back from IMAS in the native format. Thus, they are a wrapper providing (partly) an interface between IMAS and EIRENE.
In the future, the functions responsible for communication with IMAS could be incorporated to the code directly, but this will depend on the plans of the EIRENE team.
The structure of this document is as follows. Section 2 lists the files provided. Section 3 describes how to run a test example. Section 4 presents the parameter files controlling the wrapper programs. Section 5 describes the organization of the grid storage. In Section 6, the wrapper for the EIRENE input is described. Finally, the things to be done are outlined in Section 7.
This document can be found at EIRENE IMASification - Scientific Worfklows - PCSS Confluence (psnc.pl), https://docs.psnc.pl/display/WFMS/EIRENE+IMASification.
The repository folder of the current version is ~g2yyakov/public/eirene/version0.10.
Files provided
FILES | CONTENT |
---|---|
triangular_grid_module.f90 | Module that supports reading, writing and processing triangular grids |
triangular_grid_ids_io.f90 | Module supporting the storage of triangular grids in IMAS |
imas_data_io.f90 | Module supporting the storage of physical quantities (tallies) in IMAS |
eirene_data_io.f90 | Module supporting reading / writing of EIRENE data files |
edge_profiles_io.f90 | Module that supports placing the data to the 'edge_profiles' IDS |
equilibrium_io.f90 | Module that supports placing the data to the 'equilibrium' IDS |
imas_controls_for_input.f90 | Module that works with the parameter files (the files controlling the work of the programs) |
global_parameters.f90 | Module that holds constants and some service routines |
save_input_main.f90 | Main file of the program save_input.exe |
provide_input_main.f90 | Main file of the program provide_input.exe |
Makefile | Used to compile the programs |
save_input.par | A template command file for the program save_input.exe |
provide_input.par | A template command file for the program provide_input.exe |
soledge3x.npco_char | Triangular grid example received from the EIRENE team |
soledge3x.elemente | Another file of this example |
soledge3x.neighbor | Another file of this example |
Te.dat, nT.dat, TT.dat, nD.dat, TD.dat | Sample files supposed to contain the temperature and density of electrons, D ions and T ions |
Btotal.dat, bx.dat, by.dat, bz.dat | Sample files supposed to contain the strength and components of the magnetic field |
README.txt | Brief description of how to compile and run |
EIRENE_wrapper_ user_guide.pdf | PDF version of this document |
Running a test example
You can use the prepared data files (the files soledge3x.npco_char, soledge3x.elemente, soledge3x.neighbor, and the files with the suffix '.dat'). Admittedly, the dat-files have no physical sense and were created with the only aim to check the correctness of input/output operations.
- Copy the files to your directory.
- If you wish to test the programs with your own files, copy them to the same directory. Do not forget to put the correct names to the command file save_input.par.
- Load the IMAS library by typing:
module load imasenv/3.37.0
- Create the IMAS database entry:
imasdb eirene
- Now you can compile the examples. Type
make clean
make save_input
- Run the program:
./save_input.exe
The program puts the grid stored in the files soledge3x.* and the content of the dat-files into the IMAS databaseeirene
. - Type
make provide_input
- Run the program:
./provide_input.exe
- Compare the new files
eirene.*
with the original filessoledge3x.*
and the original data files with the new files (their names end with the suffix '_input.dat').
Structure of the command files
The program save_input.exe takes parameters that control the work of the program from the file save_input.par. A template of this file is given below.
Code Block |
---|
! Parameters that control saving the EIRENE input to IMAS.
! Use '!' when inserting comment lines.
! You can add comments at the end of each line unless this line holds a text that may contain blanks (e.g., a description field).
! Do not change the order of the parameters.
! |
! Parameters that control saving the EIRENE input to IMAS.
! Use '!' when inserting comment lines.
! You can add comments at the end of each line unless this line holds a text that may contain blanks (e.g., a description field).
! Do not change the order of the parameters.
!
eirene <= IMAS database
10003 <= shot
1 <= run
'IDS created to test EIRENE input storage' <= IDS comment
'Yurii Yakovenko' <= input provider
'once upon a time' <= creation date
!!! grid data
"SN" <= grid name
4 <= grid index in dictionary (single null)
"EIRENE grid for single null configuration" <= grid description
"primary_standard" <= poloidal space name
"primary poloidal triangular grid" <= poloidal space description
soledge3x.npco_char <= grid node file
soledge3x.elemente <= grid triangle file
soledge3x.neighbors <= grid neighbor file
!!! Physical quantities
bx.dat <= bx file
by.dat <= by file
bz.dat <= bz file
Btotal.dat <= Btotal file
vx.dat <= vx file
vy.dat <= vy file
vz.dat <= vz file
Te.dat <= Te file
!!! Ion physical quantities
2 <= Number of ion species
! Ion species 1
D 2 1 1 <= label, mass, Z_ion, Z_element
TD.dat <= temperature file
nD.dat <= density file
! Ion species 2
T 3 1 1 <= label, mass, Z_ion, Z_element
TT.dat <= temperature file
nT.dat <= density file
A template of the file provide_input.par that controls the program provide_input.exe is as follows:
! Parameters that control saving the EIRENE input to IMAS.
! Use '!' when inserting comment lines.
! You can add comments at the end of each line.
! Do not change the order of parameters.
!
eirene <= IMAS database
10003 <= shot
1 <= run
input.dat <= generic suffix of created files
!!! Names of created files: grid
eirene.nodes <= grid node file
eirene.triangles <= grid triangle file
eirene.neighbors <= grid neighbor file
!!! Names of created files: physical quantities
bx_input.dat <= bx file
by_input.dat <= by file
bz_input.dat <= bz file
BF_input.dat <= total B file
vx_input.dat <= vx file
vy_input.dat <= vy file
vz_input.dat <= vz file
Storing the EIRENE triangular grids in IMAS
The Fortran routines described herein take files containing the description of a triangular grid in native EIRENE format and store this grid in an IMAS IDS; on the other hand, they extract a stored grid description from IMAS and provide it in EIRENE format. At present, these routines have been tested only with the IDS's edge_profiles
and equilibrium.
The grid is stored in the IMAS subsystem called GGD (General Grid Description). This subsystem consists of two data sub-trees available in most IMAS IDS: grid_ggd
and ggd
. The former contains the description of the grid itself; the latter, all quantities given with reference to this grid (for, value of electron temperature at all grid nodes, values of energy flux at all nodes at the divertor surface etc.). A more detailed description will be given in section 5.
The files provided are intended to support storing triangular 2D grids in the grid_ggd
structure. In the future (if required), they can be upgraded to support work with 3D grids consisting of a triangular 2D grid in the poloidal plane and a grid in the toroidal direction.
Structure of EIRENE files keeping the grid
There are three files describing the triangular grid used in EIRENE.
The file defining the grid nodes and their coordinates (soledge3x.npco_char
in the provided example) starts with the number of nodes in the line 1. The rest of lines contain 3 number each:
node index, R (or X) coordinate (cm), Z (or Y) coordinate (cm).
The file defining the triangles in terms of its vertices (soledge3x.elemente
in the provided example) has the following structure. The line 1 contains the number of triangles. Each following line contains 4 integers:
triangle index, index of vertex 1 (in the grid node list), index of vertex 2, index of vertex 3.
The file describing the boundaries and neighbours of the triangles in terms of its vertices (soledge3x.neighbor
in the provided example) has the following structure. The line 1 contains the number of triangles. Each following line contains 12 integers:
triangle index, N1, S1, M1, N2, S2, M2, N3, S3, M3, ixtri
, iytri
.
Here Ni is the index of the neighbouring triangle on side i, Si is the index of this side in the triangle Ni, Mi is the ‘material property’ of the side i, ixtri
and iytri
are not used now (they are zeros in this example). Note that side 1 connects vertices 1 and 2; side 2, vertices 2 and 3; side 3, vertices 3 and 1. The material property (MP) is an index referring to a surface model defined in the main EIRENE file. In particular, MP is 0 for transparent (i.e., internal) grid edges. The MP of boundary edges can have different positive values. In the provides example, there are boundary edges with MP = 1, 2, 3.
Presentation of EIRENE grid in GGD
We begin with brief overview of general principles of presentation of grids in the grid_ggd
structure.
We will follow the terminology of the GGD manual. The IMAS data dictionary is a hierarchical tree-like structure consisting of substructures. The following terms will be used:
- A node is any element of the tree.
- A simple node is a regular single node.
- An array of structures node (AOS) is a 1D array of structures under the same node label.
- A leaf is and endpoint of the tree. It holds data in specified format.
- The parent of a node is the element one level above this node.
- A child of a node is an element one level below this node.
- A sibling of a node is a node having the same parent.
First of all, grid_ggd
is AOS whose elements correspond to different time slices of the IDS. If the grid does not depend on time, this array can contain only one element.
Each element of grid_ggd
has (inter alia) two children AOS’s: spaces and grid subsets.
The spaces are used to contain the description of geometric objects constituting the grid, including their location in space. Let us consider a rectangular grid in 2D space as an example. To describe it, we can introduce one 2D space, provide the coordinates of all nodes and then describe the other grid elements (edges and cells) in terms of the nodes they consist of. However, it may be easier to choose another way. We can organize two 1D spaces, put the nodes along each coordinate and (if required) describe edges connecting these nodes.
It seems that for EIRENE in 3D geometry, it will be worthwhile to introduce 2 spaces: a 2D space in the poloidal plane and a 1D space in the toroidal direction. At present, only the poloidal 2D space is implemented.
The main child of each element of the space
AOS is the objects_per_dimension
AOS, each element of this AOS having only one child – the object
AOS.
The element objects_per_dimension(1)
contains information about the 0D objects of the space – the grid nodes. In each element of the object
AOS, only one child – the geometry(:)
real array containing the spatial coordinates of the node – is actually filled.
The 2nd and 3rd elements of objects_per_dimension
hold information about 1D and 2D objects, respectively. For each 1D object (edge), we store the indices of the 2 nodes that the edge connects. They are stored in the nodes(:)
child of each object. For a 2D object (triangle), we fill its children nodes(:) (with 3 elements) and boundary. In the AOS boundary
, we fill the index
child leaf (the index of the bounding edge) and one element of the neighbours
child AOS (the index of the neighbouring triangle).
Each grid subset is an arbitrary set of grid elements of the same dimensionality. For examples, all grid nodes, all grid edges, all grid cells, all boundary grid edges, all cells situated in SOL can be examples of subsets. Each subset provided in the grid_ggd
branch can be used in the ggd
branch of the IDS in order to save a distribution of some physical quantity on this subset. For example, if we have organized the subset of all boundary edges in 2D, we can save in ggd
the flux of particles through these edges as a 1D array. By giving a reference to this grid subset, we establish relation between the flux values and the edges.
To describe a subset, we can refer to objects from several spaces. Let us consider again the example of a 2D rectangular grid represented via two 1D grid spaces. The subset of all grid nodes can be organized as follows. The grid_subset
AOS has a child element, holding information about all subset elements. In our case, the elements are the grid nodes. Each node can be described as a combination of one node of the x-grid and one node of the y-grid. So, each element in the element
AOS has the only child – the object
AOS. Each element of the object
AOS has three leaves: space
(the index of the space from which it is taken), dimension
(its dimensionality index), and index
(its index in the list of objects of this dimensionality). In our case, the elements are grid nodes. Each node (element) can be described as a combination of one node of the x-grid (0-dimensional object of the x-space) and one node of the y-grid (0-dimensional object of the x-space).
The subsets can be distinguished by their identifiers. The identifier
node has three leaves:
name
contains the name given to the subset.index
contains the integer identifier given to the subset (the list of standard integer identifiers can be found in the GGD manual).description
contains a verbose description.
For the triangular EIRENE grid, the following subsets are created (this list can be extended if required or shortened if some subsets are not needed):
- Subset of all nodes in the poloidal plane (the subset name is
'pol1'
, the integer identifier is 1). - Subset of all edges in the poloidal plane (the subset name is
'pol2'
, the integer identifier is 2). - Subset of all 2D cells (triangles) in the poloidal plane (the subset name is
'pol3'
). - Several subsets of edges with a certain MP in the poloidal plane (the subset names are
'MPnnnn'
, where nnnn is the material property value). - Special subset with no objects for storing averages in
ggd_fast
(the subset name is 'average'). - Subset of all nodes in 3D space.
- Subset of all 3D cells (trigonal prisms).
At present, only items 1-4 of this lists are implemented.
Module triangular_grid_module
The module contains a data type for storing the information about all elements of a triangular grid and a library of methods (subroutines and functions). The methods solve the following tasks:
- Reading and writing files in the EIRENE format
- Checking the grid description for sanity
- Building the missing parts of the information from available parts
The last item is important because the information set in the EIRENE files and the information set in GGD are different. In particular, the EIRENE files do not contain information about edges.
The module depends on the IMAS module ids_types
(uses the constant IDS_real
– the kind of real variables in IMAS).
Data types
The following data types are provided:
type triangular_grid
type(coordinates_2d), allocatable, dimension(:) :: vertex
type(triangle_structure), allocatable, dimension(:) :: triangle
type(edge_structure), allocatable, dimension(:) :: edge
end type triangular_grid
The type triangular_grid
is intended for storing the description of a triangular grid, its components keeping information about the grid vertices, the grid cells (triangles), and the grid edges, respectively.
type coordinates_2d
real(IDS_real) :: x, y
end type coordinates_2d
The type coordinates_2d
is intended for storing the grid point coordinates in the poloidal plane.
type triangle_structure
integer :: vertex(3)
integer :: neighbor(3) = (/0,0,0/)
integer :: neighbors_side(3) = (/0,0,0/)
integer :: side(3)
integer :: material_property(3)=(/0,0,0/)
integer :: ixtri=0, iytri=0
end type triangle_structure
The type triangle_structure
is intended for storing information about a grid triangle, including the information about neighbouring triangles available in the EIRENE files. The integer child array vertex holds indices of the triangle vertices in triangular_grid%vertex
. The child arrays side
and material_property
hold indices of the sides in triangular_grid%edges
and their MPs, respectively (side 1 connects vertices 1 and 2; side 2, vertices 2 and 3; side 3, vertices 3 and 1). The child arrays neighbor
and neighbors_side
hold indices of the corresponding neighbouring triangles Ni in triangular_grid%triangle
and the indices of the separating edge in Ni. The child leaves ixtri
and iytri
will be used later (maybe).
type edge_structure
integer :: vertex(2)
integer :: material_property=0
integer :: adjacent(2)=(/0,0/)
end type edge_structure
The type edge_structure
is intended for information about an edge. The integer child array vertex
holds indices of the edge vertices in triangular_grid%vertex
. The leaf material_property
holds the MP of the edge. The child array adjacent
holds the indices of the neighbouring triangles in triangular_grid%triangle
.
Methods
The module member routines are as follows:
function read_eirene_grid
Read information about a triangular grid from EIRENE-format files and generate a list of grid edges;subroutine write_eirene_grid
Write information about a triangular grid into EIRENE-format files;subroutine provide_grid_object_lists
Provide lists of objects (nodes, edges and cells); nodes are characterized by their coordinates; edges and cells, by indices of nodes they consist of;subroutine arrange_neighbors
Build information about neighboring cells necessary the EIRENE file format;subroutine build_edges
Fill the edge(:) child of the grid structure using the triangle child content;function give_edges_with_mat_property
Return the list of indices of edges with a given MP;- function all_material_properties
Provide list of all MP values available in the grid; subroutine deallocate_grid
Deallocate the structure child arrays.
Service routines:
subroutine read_vertices
Read the coordinates of grid vertices from an EIRENE-format file.subroutine read_triangles
Read indices of the vertices that form each grid triangle from an EIRENE-format file.subroutine read_neighbors
Read information on the neighbours of each grid triangle from an EIRENE-format file, putting it to the substructure grid % triangle.subroutine write_vertices
Write the coordinates of grid vertices into an EIRENE-format file.subroutine write_triangles
Write information on the vertices that form each grid triangle into an EIRENE-format file.subroutine write_neighbors
Write information on the neighbors of each grid triangle into an EIRENE-format file.subroutine find_neighboring_triangles
Given the index of a vertex grid % vertex, the subroutine finds the indices of all triangles containing this vertex.integer function find_side
Given two vertex indices and a triangle structure, the function returns the index of the edge consisting of these vertices in the triangle (0 when the edge does not belong to the triangle).subroutine write_edges
Write grid edges to a file.subroutine check_edges
Sanity check: The subroutine checks if all edges that have both adjacent triangles have material_property/=0 and vice versa.subroutine check_vertices
Sanity check: The subroutine checks if every grid vertex belongs to a triangle.subroutine grid_statistics
Print grid statistics.integer function neighboring_triangle_index
The function returns the index of a triangle neighoring with a reference triangle. The neighbor index must be larger than the reference triangle index. When there is no such a triangle, the function returns 0.integer function edge_index
Return the index of an edge consisting of two given vertices (0 when there is no such edge).
Detailed interface of the methods:
function read_eirene_grid (coord_file, triangles_file, neighbors_file, do_tests, io_unit) result (grid)
Read information about a triangular grid from EIRENE-format files and generate a list of grid edges (using the method build_edges
).
Argument / result | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | result | Grid structure holding the content of the files |
coord_file | character(len=*) | in | Name of the file holding grid node coordinates |
triangles_file | character(len=*) | in | Name of the file holding indices of triangle vertices |
neighbors_file | character(len=*) | in | Name of the file holding information about neighbours of triangles |
do_tests | logical | in | Turns on/off sanity checks |
io_unit | integer, optional | in | Number of the i/o unit used (equals to 69 by default) |
subroutine write_eirene_grid (grid, coord_file, triangles_file, neighbors_file, do_tests, io_unit)
Write information about a triangular grid into EIRENE-format files;
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | in | Grid structure |
coord_file | character(len=*) | in | Name of the file to hold grid node coordinates |
triangles_file | character(len=*) | in | Name of the file to hold indices of triangle vertices |
neighbors_file | character(len=*) | in | Name of the file to hold information about neighbours of triangles |
do_tests | logical | in | Turns on/off sanity checks |
io_unit | integer, optional | in | Number of the i/o unit used (equals to 69 by default) |
subroutine provide_grid_object_lists (grid, coordinates, edge_connect, cell_connect)
Given a grid stucture, the subroutine provides three arrays:
coordinates
, real 2D array containing the coordinates for all grid nodes;edge_connect
, integer 2D array containing indices of vertices for all edges;cell_connect
, integer 2D array containing indices of vertices for all cells (triangles).
This subroutine is no longer used in the module triangular_grid_ids_io.f90
.
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | in | Grid structure |
coordinates | real(IDS_real), dimension(:,:) | out | Array containing the coordinates of all vertices |
edge_connect | integer, dimension(:,:) | out | Array containing indices of vertices for all edges |
cell_connect | integer, dimension(:,:) | out | Array containing indices of vertices for all triangles |
subroutine arrange_neighbors (grid)
Process a grid structure taken from IMAS, filling up the missing components of grid%triangle
(information about neighbouring edges and triangles).
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | inout | Grid structure to be completed |
subroutine build_edges (grid)
Process a grid structure, building the missing substructure grid % edge
. The order of the edges in the substructure is as follows: side 1 of triange 1, side 2 of triange 1, side 3 of triange 1, side 1 of triangle 2 (if not accounted for earlier), side 2 of triangle 2 (if not accounted for earlier), and so on.
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | inout | Grid structure to be completed |
function give_edges_with_mat_property (grid, mat_property)
Return a list of edges with a given value of MP.
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | in | Grid structure |
mat_property | integer | in | MP value |
result | integer, allocatable, dimension(:) | result | List of indices of the edges in the substructure grid % edge |
subroutine deallocate_grid (grid)
Deallocate all grid components.
Argument | Type | Intent | Description |
---|---|---|---|
grid | type(triangular_grid) | in | Grid structure |
For the description of the service routines (some of them are no longer used), see comments in the module file.
Module triangular_grid_ids_io
The module contains routines that support writing a grid having the type(triangular_grid)
form to IMAS IDS's and, vice versa, reading a grid from IMAS and putting it into the type(triangular_grid)
form. It depends on the module triangular_grid_module
and the IMAS modules ids_schemas
and ids_routines
.
At present, it is assumed that both input and output of EIRENE represent a steady state. Therefore, only one time slice is organized for both GGD data structure and the GGD grid.
At present, only one grid space is arranged: a two-dimensional poloidal grid space holding a triangular grid. However, the routines of this modules are organized in a way that should facilitate adding additional spaces (most probably, a 1D toroidal space) if required. When the poloidal grid is recovered from an IDS, it is taken from the space having the identifier index equal to 1 (see the function get_grid_objects).
Data types
type grid_control_panel
type(ids_identifier_dynamic_aos3) :: grid_identifier
character(len=ids_string_length) :: poloidal_space_name, poloidal_space_description
character(len=ids_string_length) :: node_file, triangle_file, neighbor_file
integer :: grid_index = 1 ! Use grid_ggd in time slice 1
integer :: ggd_index = 1 ! Use ggd in time slice 1
! The following fields are not used when getting the grid from IDS
integer :: grid_dictionary_index
!! Allocation of IMAS grid space for EIRENE triangular grid
integer :: nSpaces = 1 ! Total number of GGD spaces;
! may change if toroidal coordinate is added
integer :: eirene_space_index = 1 ! May change if toroidal coordinate is added
integer :: Ngrid_slices = 1 ! Number of grid_ggd slices to be allocated
integer :: Nggd_slices = 1 ! Number of ggd slices to be allocated
end type grid_control_panel
The structure type grid_control_panel is intended for holding the control parameters taken from a command file. These parameters determine how the EIRENE triangular grid is saved in / recovered from an IMAS IDS.
Methods
The module contains the following routines:
get_grid_controls_for_input_saving
Get from the command file the parameters that control saving the EIRENE grid to an IMAS database that is to hold an EIRENE input.- get_grid_controls_for_input_fetching
Get from the command file the parameters that control extracting the EIRENE grid from an IMAS database holding an EIRENE input.
get_triangular_grid_from_ids
Read a triangular grid from an IDS (not 'equilibrium'), put it into atype(triangular_grid)
-structure, and build the missing parts of the structure.- get_triangular_grid_from_equilibrium
Read a triangular grid from the 'equilibrium' IDS, put it into atype(triangular_grid)
-structure, and build the missing parts of the structure. - get_grid_objects
Get objects from the space holding a triangular grid and put them into a type(triangular_grid)-structure. - arrange_material_properties
Get information about the material properties of grid edges from IDS and add it to the type(triangular_grid)-structure holding the grid description. put_eirene_grid_to_ids
Save a triangular grid given as atype(triangular_grid)
-structure into a grid_ggd AoS element (not applicable to the 'equilibrium' IDS).- put_eirene_grid_to_equilibrium
Save a triangular grid given as atype(triangular_grid)
-structure into a grid_ggd AoS element (intended for the 'equilibrium' IDS). - arrange_grid_space
Create the 'space' AoS of grid_ggd. arrange_triangular_grid_space
Put a triangular grid given as atype(triangular_grid)
-structure to a desiredgrid_ggd
space.- arrange_subsets
Create the 'subset' AoS. arrange_standard_2d_subset
Arrange a "standard" subset in the poloidal 2d space (subset of all nodes, all edges, or all triangular cells).arrange_mat_property_subset
Arrange a subset of edges with a certain value of MP.- arrange_subset_for_averages
Arrange a special single-element subset for storing averages.
Detailed description of the methods:
function get_grid_controls_for_input_saving (io_unit) result (grid_controls)
Prepare the control parameters for saving an EIRENE grid to an IMAS database that is to hold an EIRENE input. The control parameters are taken from a command file.
Argument | Type | Intent | Description |
---|---|---|---|
grid_controls | type(grid_control_panel) | result | Structure holding the control parameters |
io_unit | integer | in | I/O unit attached to the command file |
function get_grid_controls_for_input_fetching (io_unit) result (grid_controls)
Prepare the control parameters for extracting an EIRENE grid from an IMAS database holding an EIRENE input. The control parameters are taken from a command file.
Argument | Type | Intent | Description |
---|---|---|---|
grid_controls | type(grid_control_panel) | result | Structure holding the control parameters |
io_unit | integer | in | I/O unit attached to the command file |
function get_triangular_grid_from_ids (grid_ggd) result (eirene_grid)
Read data about a triangular grid from a given space of GGD grid, put it into a type(triangular_grid)
-structure and call the subroutines arrange_material_properties
(from this module) and arrange_neighbors
(from triangular_grid_module
) to build the missing parts of the structure. This function is not applicable to the grid stored in the 'equilibrium' IDS (because the type of the structure used for storing the GGD grid in this IDS is peculiar). To extract the grid from the 'equilibrium' IDS, use the function get_triangular_grid_from_equilibrium.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | result | The retrieved grid |
grid_ggd | type(ids_generic_grid_aos3_root), pointer | pointer | Pointer to the grid_ggd AOS element containing the grid |
function get_triangular_grid_from_equilibrium (grid_ggd) result (eirene_grid)
Read data about a triangular grid from a given space of GGD grid, put it into a type(triangular_grid)
-structure and call the subroutines arrange_material_properties
(from this module) and arrange_neighbors
(from triangular_grid_module
) to build the missing parts of the structure. This function is applicable only to the grid stored in the 'equilibrium' IDS (because the type of the structure used for storing the GGD grid in this IDS is peculiar). To extract the grid from another IDS, use the function get_triangular_grid_from_ids.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | result | The retrieved grid |
grid_ggd | type(ids_generic_grid_dynamic), pointer | pointer | Pointer to the grid_ggd AOS element containing the grid |
function get_grid_objects (space) result (eirene_grid)
The function returns a type(triangular_grid)-structure, which is partly filled with information read from the GGD grid space having the identifier index equal to 1 (i.e., being the 'primary grid space'). The function takes as a parameter the AoS of all grid spaces.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | result | Partly filled grid structure |
grid_ggd | type(ids_generic_grid_dynamic_space), dimension(:) | in | Space where the triangular grid is stored |
subroutine arrange_material_properties (eirene_grid, subsets)
Get information about the MPs of grid edges from IDS and add it to the type(triangular_grid)-structure holding the grid description. This information is stored in GGD in the form of subsets uniting the edges with certain values of the MP.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | inout | Partly filled grid structure |
subsets | type(ids_generic_grid_dynamic_grid_subset), dimension(:) | in | Space where the triangular grid is stored |
subroutine put_eirene_grid_to_ids (eirene_grid, grid_ggd, nSpaces, eirene_space_index, grid_identifier, eirene_space_name, eirene_space_description)
Place a grid into a given grid_ggd
structure by allocating the space AOS with a given number of grid spaces, putting a triangular grid given as a type(triangular_grid)
-structure into a desired element of the space
AOS, and organizing the necessary grid subsets. This subroution cannot be used for putting a grid into the 'equilibrium' IDS (because the type of the structure used for storing the GGD grid in this IDS is peculiar). To put the grid into the 'equilibrium' IDS, use the function put_eirene_grid_to_equilibrium.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | in | The grid to be saved |
grid_ggd | type(ids_generic_grid_aos3_root) | pointer | Pointer to the grid_ggd AOS element to hold the grid |
nSpaces | integer | in | The dimension of |
eirene_space_index | integer | in | Index of the triangular grid space in |
grid_identifier | type(ids_identifier_dynamic_aos3) | in | Grid identifier to be put to IDS |
eirene_space_name | character(len=*) | in | Name assigned to the triangular grid space |
eirene_space_description | character(len=*) | in | Verbose description of the triangular grid space |
subroutine put_eirene_grid_to_equilibrium (eirene_grid, grid_ggd, nSpaces, eirene_space_index, grid_identifier, eirene_space_name, eirene_space_description)
Place a grid into a given grid_ggd
structure by allocating the space AOS with a given number of grid spaces, putting a triangular grid given as a type(triangular_grid)
-structure into a desired element of the space
AOS, and organizing the necessary grid subsets. This subroution can be used only for putting a grid into the 'equilibrium' IDS (because the type of the structure used for storing the GGD grid in this IDS is peculiar). To put the grid into another IDS, use the function put_eirene_grid_to_ids.
Argument | Type | Intent | Description |
---|---|---|---|
eirene_grid | type(triangular_grid) | in | The grid to be saved |
grid_ggd | type(ids_generic_grid_dynamic) | pointer | Pointer to the grid_ggd AOS element to hold the grid |
nSpaces | integer | in | The dimension of |
eirene_space_index | integer | in | Index of the triangular grid space in |
grid_identifier | type(ids_identifier_dynamic_aos3) | in | Grid identifier to be put to IDS |
eirene_space_name | character(len=*) | in | Name assigned to the triangular grid space |
eirene_space_description | character(len=*) | in | Verbose description of the triangular grid space |
function arrange_grid_spaces (grid, nSpaces, eirene_space_index, eirene_space_name, eirene_space_description) result (spaces)
Place a grid into a given grid_ggd
structure by allocating the space AOS with a given number of grid spaces, putting a triangular grid given as a type(triangular_grid)
-structure into a desired element of the space
AOS, and organizing the necessary grid subsets. This subroution can be used only for putting a grid into the 'equilibrium' IDS (because the type of the structure used for storing the GGD grid in this IDS is peculiar). To put the grid into another IDS, use the function put_eirene_grid_to_ids.
Argument | Type | Intent | Description |
---|---|---|---|
spaces | type(ids_generic_grid_dynamic_space), dimension(:), pointer | result | Pointer to the allocated and filled 'space' AoS |
grid | type(triangular_grid) | in | The grid to be saved |
nSpaces | integer | in | The dimension of |
eirene_space_index | integer | in | Index of the triangular grid space in |
eirene_space_name | character(len=*) | in | Name assigned to the triangular grid space |
eirene_space_description | character(len=*) | in | Verbose description of the triangular grid space |
function arrange_triangular_grid_space (grid, space_name, space_description) result (space)
Create a GGD space and put the objects (nodes, edges, and cells) of an EIRENE triangular grid there. The information about grid objects is taken from a type(triangular_grid)
-structure.
Argument | Type | Intent | Description |
---|---|---|---|
space | type(ids_generic_grid_dynamic_space), pointer | result | IDS space structure holding the grid |
grid | type(triangular_grid) | in | The grid to be saved |
space_name | character(len=*) | in | Name assigned to the triangular grid space |
space_description | character(len=*) | in | Verbose description of the triangular grid space |
function arrange_subsets (eirene_space, eirene_space_index, grid) result (subsets)
Create a GGD space and put the objects (nodes, edges, and cells) of an EIRENE triangular grid there. The information about grid objects is taken from a type(triangular_grid)
-structure.
Argument | Type | Intent | Description |
---|---|---|---|
subsets | type(ids_generic_grid_dynamic_grid_subset), pointer, dimension(:) | result | IDS space structure holding the grid |
eirene_space | type(ids_generic_grid_dynamic_space) | in | the GGD grid space to which the subsets are attached |
eirene_space_index | integer | in | the index of this space in the 'space' AoS |
grid | type(triangular_grid) | in | The grid to be saved |
subroutine arrange_standard_2d_subset(subset, space, space_index, dimensionality, subset_id)
Arrange a "standard" subset in the poloidal space – a subset of all nodes, edges, or triangular cells (depending on the dimensionality, 1, 2, or 3, respectively). The subset gets the name 'poln', where n is the dimensionality.
Argument | Type | Intent | Description |
---|---|---|---|
subset | type(ids_generic_grid_dynamic_grid_subset) | pointer | Pointer to the |
space | type(ids_generic_grid_dynamic_space) | in | The |
space_index | integer | in | Index of the triangular grid space in the |
dimensionality | integer | in | Dimensionality of subset objects (1 for nodes, 2 for edges etc.) |
subset_id | integer | in | Integer identifier of the subset |
subroutine arrange_mat_property_subset (subset, space, space_index, grid, mat_property, subset_id)
Arrange a subset for edges with a certain value of MP. The subset gets the name 'MPnnnn', where nnnn is the MP value.
Argument | Type | Intent | Description |
---|---|---|---|
subset | type(ids_generic_grid_dynamic_grid_subset) | pointer | Pointer to the |
space | type(ids_generic_grid_dynamic_space) | in | The |
space_index | integer | in | Index of the triangular grid space in the |
grid | type(triangular_grid) | in | The grid being saved |
mat_property | integer | in | MP value |
subset_id | integer | in | Integer identifier of the subset |
subroutine arrange_subset_for_averages (subset, subset_id)
Arrange a special subset for storing 2d averages. The subset gets the name 'average'.
Argument | Type | Intent | Description |
---|---|---|---|
subset | type(ids_generic_grid_dynamic_grid_subset) | pointer | Pointer to the |
subset_id | integer | in | Integer identifier of the subset |
EIRENE input wrappers
Two wrapper programs are provided. The first program, save_input.exe, accepts the EIRENE input (files with a grid description and files with spatial distributions of physical quantities) prepared by some programs and saves their content in a desired IMAS database. The second program, provide_input.exe, recreate these input files, so that they can be used by EIRENE. Both programs are controlled by certain text files ('command files') described in Section 4.
Only a part of input quantities is now processed. According to information received from the EIRENE team, the storage of the following tallies (physical quantities) is of first priority: electron temperature; temperature, density, and velocity components (in cylindrical coordinates) of several sorts of ions; total magnetic field; components of the magnetic field unit vector in cylindrical coordinates.
The storage of the magnetic field, temperatures, and densities is already implemented in the wrappers. However, there is a restriction: the wrappers are able to deal with single-atom ions only.
The storage of velocities will become possible after IMAS 3.38 is implemented.
Structure of EIRENE input files
In addition to the files containing the grid, the EIRENE input includes file holding spatial distributions of physical quantities (magnetic field components, temperatures and densities of plasma species etc.). The values of the quantities are given at the cells (triangles) constituting the grid. The easiest way to describe the format of the input files is to present a sample code reading it:
READ (IFILE,'(A72)') Text_header1
READ (IFILE,'(A72)') Text_header2
READ (IFILE,'(A72)') Text_header3
READ (IFILE,'(A24)') Text_header4
READ (IFILE,'(A24)') Text_header5
READ (IFILE,'(A72)') Text_header6
READ (IFILE,'(A72)') Text_header7
READ (IFILE,*) NR,NP,NT,NB,NTT
DO IRAD=1,NTT,5
READ (IFILE,*) (PROF(IR),IR=IRAD,IRAD+4)
END DO
Here NR=NTRI+1, NTRI is the number of grid triangles, NP=1, NT=1, NB=1, NTT = total number of cells including the additional cells outside of the triangle grid, see below. The additional array element with the index NR usually contains the average over all cells. Further extra elements with indices NR+1, ..., NTT correspond to extra cells outside the implemented triangular mesh (i.e., cells in pump ducts). These elements are not processed now.
The text headers are comments describing the file content, system units etc. It is agreed with the EIRENE team that (a) when reading a data file, the wrapper will consider all lines starting with '*' or '!' as a header line and will not store in IMAS the header texts; (b) when writing a fata file, the wrapper will generate new reasonable headers anew. The headers are not implemented yet.
Module eirene_data_io
This module provides tools for dealing with files containing EIRENE input data (see the file format in Section 6.1).
Data types
type eirene_data
real(ids_real), allocatable :: main_part(:)
real(ids_real) :: average
real(ids_real), allocatable :: extra_data(:) ! To be implemented yet
logical :: extra_data_present ! Shows if extra_data is filled
end type eirene_data
This structure item 'main_part' is intended for storage of array elements 1, ..., NTRI, which correspond to grid triangles (see Section 6.1). The item 'average' is to contain average (element NTRI+1). The item 'extra_data' is intended for storing the extra elements NTRI+2, ..., NTT if they are available, with the item 'extra_data_present' showing if the extra elements are present.
Methods
The module contains the following routines:
- deallocate_data_set
Dallocate the components of a type(eirene_data) variable. - read_quantity_from_file
Read an EIRENE input file holding a distribution of a physical quantity. - write_quantity_to_file
Write an EIRENE input file holding a distribution of a physical quantity.
subroutine deallocate_data_set (quantity)
Deallocate all components of the structure.
Argument | Type | Intent | Description |
---|---|---|---|
quantity | type(eirene_data) | inout | Structure to be deallocated |
subroutine read_quantity_from_file (file_name, quantity, report, io_unit)
Read a physical quantity from a file with the format of EIRENE input tallies.
Argument | Type | Intent | Description |
---|---|---|---|
file_name | character(len=*) | in | file name |
quantity | type(eirene_data) | out | structure to be filled with data from the file |
report | logical, optional (=false) | in | turns on info about each step |
io_unit | integer, optional (=69) | in | I/O unit to be used |
subroutine write_quantity_to_file (file_name, quantity, report, io_unit)
Write a physical quantity to a file with the format of EIRENE input tallies.
Argument | Type | Intent | Description |
---|---|---|---|
file_name | character(len=*) | in | file name |
quantity | type(eirene_data) | in | structure holding data to be saved |
report | logical, optional (=false) | in | turns on info about each step |
io_unit | integer, optional (=69) | in | I/O unit to be used |
Module imas_data_io
The module contains methods used for writing an EIRENE tally (given as a type(eirene_data)-structure) to IMAS IDS and, vice versa, reading it from IDS. The 'main_part' component is associated with the grid subset of all triangles (the subset identifier name 'pol3'); the 'average' component, with the subset having the name 'average'.
It is a difficult choice to decide whether the methods should look for the subsets in the 'subset' AoS by their identifier names or by their dictionary indices (the idea to assign fixed places in the AoS to the subsets seems very bad because it can result in numerous bugs and confusions if it happens that the AoS requires changes). Now the subsets are found by their names. The main reason for this choice is that we have many subsets that have no standard dictionary indices (subsets of edges with given MPs, subset for averages). It is possible to introducing custom indices for them, but it seems a way to great confusion.
Storage of 'extra_data' is yet to be done (after adding the corresponding extra part to the grid).
Constants
! Name of the subset to which the values at all triangles are attached
character(len=ids_string_length), parameter :: main_subset_label = 'pol3'
! Name of the subset to which the average value is attached
character(len=ids_string_length), parameter :: average_subset_label = 'average'
The constants are the identifier names by which the subsets are found by the methods of this module when writing an EIRENE tally (given as a type(eirene_data)-structure) to IMAS IDS and, vice versa, reading it from IDS. The 'main_part' component is associated with the grid subset of all triangles (named 'pol3'); the 'average' component, with the subset having the name 'average'.
Methods
- put_quantity_to_ids
Put a type(eirene_data)-structure to IDS. - get_quantity_from_ids
Get a type(eirene_data)-structure from an IDS (not suitable for the 'equilibrium' IDS). - get_quantity_from_equilibrium
Get a type(eirene_data)-structure from the 'equilibrium' IDS. - put_quantity_for_single_subset
Write a quantity given as array to a given IDS slot, attaching it to a grid subset with a given name. - get_quantity_for_single_subset
Get from a given IDS slot a quantity given as an array attached to the grid subset with a given name (not suitable for the 'equilibrium' IDS). - get_quantity_for_single_subset_in_equilibrium
Get from a given IDS slot a quantity given as an array attached to the grid subset with a given name; suitable only for 'equilibrium'.
subroutine put_quantity_to_ids (quantity, grid_subset, grid_index, quantity_aos, code_to_imas_unit_ratio)
Put a quantity to a given IDS slot (sub-AoS of the ggd AoS intended for the storage of a single physical quantity). The AoS is allocated with the size of 2 in order to save values attached to two grid subsets: the subset of all triangles and the subset organized to store the averages. These subsets are found by their identifier names, which are given by the module constants main_subset_label and average_subset_label, respectively.
Argument | Type | Intent | Description |
---|---|---|---|
quantity | type(eirene_data) | in | structure holding the quantity to be saved |
grid_subset | type(ids_generic_grid_dynamic_grid_subset), dimension(:) | in | AoS, grid subsets |
grid_index | integer | in | index of the grid used in the grid_ggd AOS (must be put to IDS) |
quantity_aos | type(ids_generic_grid_scalar), dimension(:) | pointer | AoS (IDS slot) where the quantity should be written |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
function get_quantity_from_ids (grid_ggd_aos, quantity_aos, code_to_imas_unit_ratio) result (quantity)
Get a quantity from a given IDS slot (sub-AoS of the ggd AoS intended for the storage of a single physical quantity). The subroutine scans the slot, investigating the identifier names of the grid subsets to which the slot array elements are attached (the 'grid_index' and the 'subset_index' components of the element are used to reach this subset). The subroutine obtains the value arrays attached to two grid subsets: the subset of all triangles and the subset organized to store the averages. These subsets are found by their identifier names, which are given by the module constants main_subset_label and average_subset_label, respectively. The obtained arrays are put into the components 'main_data' and 'average' of the function result. Not suitable for the 'equilibrium' IDS (use get_quantity_from_equilibrium for this IDS).
Argument | Type | Intent | Description |
---|---|---|---|
quantity | type(eirene_data) | result | structure holding the obtained quantity |
grid_ggd_aos | type(ids_generic_grid_aos3_root), intent(in), dimension(:) | in | grid_ggd (AoS holding the description of GGD grids) |
quantity_aos | type(ids_generic_grid_scalar), dimension(:) | in | AoS (IDS slot) whence the quantity should be taken |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
function get_quantity_from_equilibrium (grid_ggd_aos, quantity_aos, code_to_imas_unit_ratio) result (quantity)
Get a quantity from a given IDS slot (sub-AoS of the ggd AoS intended for the storage of a single physical quantity) of the 'equilibrium' IDS. The subroutine scans the slot, investigating the identifier names of the grid subsets to which the slot array elements are attached (the 'grid_index' and the 'subset_index' components of the element are used to reach this subset). The subroutine obtains the value arrays attached to two grid subsets: the subset of all triangles and the subset organized to store the averages. These subsets are found by their identifier names, which are given by the module constants main_subset_label and average_subset_label, respectively. The obtained arrays are put into the components 'main_data' and 'average' of the function result. Use get_quantity_from_ids for IDS other than 'equilibrium'.
Argument | Type | Intent | Description |
---|---|---|---|
quantity | type(eirene_data) | result | structure holding the obtained quantity |
grid_ggd_aos | type(ids_generic_grid_aos3_root), intent(in), dimension(:) | in | grid_ggd (AoS holding the description of GGD grids) |
quantity_aos | type(ids_generic_grid_scalar), dimension(:) | in | AoS (IDS slot) whence the quantity should be taken |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
subroutine put_quantity_for_single_subset (quantity, ids_slot, code_to_imas_unit_ratio, grid_subset, grid_index, subset_label)
Write a quantity given as array to a given IDS slot, attaching it to a grid subset with a given name. The array size must coincide with the size of the grid subset.
Argument | Type | Intent | Description |
---|---|---|---|
quantity | type(eirene_data) | result | structure holding the obtained quantity |
ids_slot | type(ids_generic_grid_scalar) | out | AoS (IDS slot) whence the quantity should be taken |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
grid_subset | type(ids_generic_grid_dynamic_grid_subset), dimension(:) | in | array of grid subsets |
grid_index | integer | in | index of the grid used in the grid_ggd AOS (must be put to IDS) |
subset_label | character(len=*) | in | identifier name of the grid subset |
subroutine get_quantity_for_single_subset (ids_slot, subset_label, code_to_imas_unit_ratio, grid_ggd_aos, quantity, grid_index, subset_index)
Get from a given IDS slot a quantity given as an array attached to the grid subset with a given name (not suitable for the 'equilibrium' IDS).
Argument | Type | Intent | Description |
---|---|---|---|
ids_slot | type(ids_generic_grid_scalar) | in | AoS (IDS slot) whence the quantity should be taken |
subset_label | character(len=*) | in | identifier name of the required grid subset |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
grid_ggd_aos | type(ids_generic_grid_aos3_root), dimension(:) | in | grid_ggd AOS |
quantity | real(ids_real), dimension(:), allocatable | out | values of the quantity at a grid subset |
grid_index | integer | out | index of the used grid in grid_ggd AOS |
subset_index | integer | out | index of the grid subset in the 'subset' AoS. |
subroutine get_quantity_for_single_subset_in_equilibrium (ids_slot, subset_label, code_to_imas_unit_ratio, grid_ggd_aos, quantity, grid_index, subset_index)
Get from a given IDS slot a quantity given as an array attached to the grid subset with a given name (suitable onlyfor the 'equilibrium' IDS).
Argument | Type | Intent | Description |
---|---|---|---|
ids_slot | type(ids_generic_grid_scalar) | in | AoS (IDS slot) whence the quantity should be taken |
subset_label | character(len=*) | in | identifier name of the required grid subset |
code_to_imas_unit_ratio | real(ids_real) | in | ratio of the quantity unit in the code to that in IMAS |
grid_ggd_aos | type(ids_generic_grid_dynamic), dimension(:) | in | grid_ggd AOS |
quantity | real(ids_real), dimension(:), allocatable | out | values of the quantity at a grid subset |
grid_index | integer | out | index of the used grid in grid_ggd AOS |
subset_index | integer | out | index of the grid subset in the 'subset' AoS. |
Module edge_profiles_io
The module provides tools for information exchange with the 'edge_profiles' IDS.
Data types
type ion_file_set
character(len=32) :: n, T !, vx, vy, vz ! To be added
end type ion_file_set
This structure holds the collection of names of data files that store characteristics for one ion sort.
type ion_data_set
type(eirene_data) :: n, T !, vx, vy, vz ! To be added
end type ion_data_set
This structure holds the collection of data for one ion sort.
type ion_parameters
character(len=ids_string_length) :: label
real(ids_real) :: mass, Z_ion, Z_element
type(ion_file_set) :: files
type(ion_data_set) :: data
end type ion_parameters
This structure holds all parameters characterizing an ion sort.
Methods
- deallocate_edge_profiles_data
Deallocate all components of a type(edge_profiles_data_set)-stucture. - initiate_ion_list_for_input_saving
Read that part of the command file controls the input wrapper which concerns ions. - initiate_edge_profiles_data_for_input_saving
Read the part of the command file that controls saving the EIRENE data to the edge_profiles IDS. - collect_data_for_edge_profiles_input
Read the EIRENE input data intended for the edge_profiles IDS from files. - save_input_to_edge_profiles
Put EIRENE input to the edge_profiles IDS. - organize_ion_storage
Primary organization of the structure array for storing the ion data. - put_ions_to_edge_profiles
Put quantities associated with ions to the edge_profiles IDS. - fetch_input_from_edge_profiles
Get data from the edge_profiles IDS - get_quantities_from_edge_profiles
Get all physical quantities from the edge_profiles IDS - get_ions_from_edge_profiles
Get quantities associated with ions from the edge_profiles IDS - write_input_data_from_edge_profiles_ids
Write the data extracted from the edge_profiles IDS to files in the format of EIRENE input tallies
subroutine deallocate_edge_profiles_data (all_data)
Deallocate all components of the structure.
Argument | Type | Intent | Description |
---|---|---|---|
all_data | type(edge_profiles_data_set) | inout | structure to be deallocated |
function initiate_ion_list_for_input_saving (io_unit) result (ion_list)
Read that part of the command file of the input wrapper which concerns ions.
Argument | Type | Intent | Description |
---|---|---|---|
ion_list | type(ion_parameters), allocatable, dimension(:) | result | array that holds parameters of all ions |
io_unit | integer | in | index of the I/O unit attached to the command file |
function initiate_edge_profiles_data_for_input_saving (io_unit) result (edge_profiles_data)
Read the part of the command file that controls saving the EIRENE data to the edge_profiles IDS.
Argument | Type | Intent | Description |
---|---|---|---|
edge_profiles_data | type(edge_profiles_data_set) | result | structure holding parameters obtained from the command file |
io_unit | integer | in | index of the I/O unit attached to the command file |
subroutine collect_data_for_edge_profiles_input (edge_profiles_data)
Read the EIRENE input data intended for the edge_profiles IDS from files. At the entry, the 'edge_profiles_data' structure is filled only partly (from the command file). The subroutine fills the remaining part, reading the information from data files.
Uses the subroutine read_quantity_from_file (module eirene_data_io).
Argument | Type | Intent | Description |
---|---|---|---|
edge_profiles_data | type(edge_profiles_data_set) | inout | structure that contains the names of the input files and accepts the data read from the files |
subroutine save_input_to_edge_profiles (idx, imas_controls, grid_controls, edge_profiles_data, eirene_grid)
Put EIRENE input to the edge_profiles IDS. The input consists of (1) a triangular grid; (2) a set of quantities (characteristics of several plasma species) defined on this grid; (3) properties of these species. The first item is provided in 'eirene_grid'; the last two, in 'edge_profiles_data'.
Uses the subroutines: put_quantity_to_ids (module imas_data_io), put_eirene_grid_to_ids (module triangular_grid_ids_io), put_ions_to_edge_profiles (this module).
Argument | Type | Intent | Description |
---|---|---|---|
idx | integer | in | index of the I/O unit attached to the IMAS database |
imas_controls | type(imas_control_panel) | in | parameters of the IMAS database and basic information to be put to IDS |
grid_controls | type(grid_control_panel) | in | parameters controlling the grid saving |
edge_profiles_data | type(edge_profiles_data_set) | in | structure holding the distributions of physical quantities |
eirene_grid | type(triangular_grid) | in | structure holding the EIRENE triangular grid |
subroutine organize_ion_storage (ion_list, ggd)
Primary organization of the structure array for storing the ion data (allocation of AoS and putting basic ion properties there).
Restrictions to be overcome: only single atoms (no molecules); one charge state per ion sort.
Argument | Type | Intent | Description |
---|---|---|---|
ion_list | type(ion_parameters), allocatable, dimension(:) | in | array that holds parameters of all ions |
ggd | type(ids_edge_profiles_time_slice) | inout | ggd AoS element to be filled |
subroutine put_ions_to_edge_profiles (ion_list, ggd, grid_subset, grid_index)
Put quantities associated with ions to the edge_profiles IDS.
Restrictions to be overcome: only single atoms (no molecules); one charge state per ion sort.
Argument | Type | Intent | Description |
---|---|---|---|
ion_list | type(ion_parameters), dimension(:) | in | array that holds parameters of all ions |
ggd | type(ids_edge_profiles_time_slice) | inout | ggd AoS element to be filled |
grid_subset | type(ids_generic_grid_dynamic_grid_subset), dimension(:) | in | array of grid subsets |
grid_index | integer | in | index of the grid_ggd AOS element holding the grid |
subroutine fetch_input_from_edge_profiles (idx, grid_controls, fetch_grid, edge_profiles_data, eirene_grid)
Get all physical quantities from the edge_profiles IDS, putting them to a type(edge_profiles_data_set) structure. If required, get the triangular grid.
Uses the subroutines: get_triangular_grid_from_ids (module triangular_grid_ids_io), get_quantities_from_edge_profiles (this module).
Argument | Type | Intent | Description |
---|---|---|---|
idx | integer | in | index of the I/O unit attached to the IMAS database |
grid_controls | type(grid_control_panel) | in | parameters controlling the grid saving/recovering |
fetch_grid | logical | in | switches on reading the grid |
edge_profiles_data | type(edge_profiles_data_set) | out | the structure holding the data found in the edge_profiles IDS (except for the grid) |
eirene_grid | type(triangular_grid) | inout | structure containing the grid; if fetch_input=.true., it is filled with data read from the IDS; otherwise, it remains unchanged. |
function get_quantities_from_edge_profiles (ggd, grid_ggd_aos) result (edge_profiles_data)
Get all physical quantities from the edge_profiles IDS, putting them to a type(edge_profiles_data_set) structure.
Argument | Type | Intent | Description |
---|---|---|---|
edge_profiles_data | type(edge_profiles_data_set) | result | the structure holding the obtained data |
ggd | type(ids_edge_profiles_time_slice) | in | ggd AoS element where the quantities are written |
grid_ggd_aos | type(ids_generic_grid_aos3_root), dimension(:) | in | AoS containing the GGD grids |
function get_ions_from_edge_profiles (grid_ggd_aos, ggd_ions) result (ion_list)
Get quantities associated with ions from the edge_profiles IDS.
Restrictions: only single-atom ions (no molecules); one charge state per ion sort.
Argument | Type | Intent | Description |
---|---|---|---|
ion_list | type(ion_parameters), allocatable, dimension(:) | result | the structure holding the obtained data |
grid_ggd_aos | type(ids_generic_grid_aos3_root), dimension(:) | in | AoS containing the GGD grids |
ggd_ions | type(ids_edge_profiles_time_slice_ion), dimension(:) | in | sub-AoS of the ggd AOS where ion data are stored |
subroutine write_input_data_from_edge_profiles_ids (edge_profiles_data, file_suffix)
Write the data extracted from the edge_profiles IDS to files in the format of EIRENE input tallies.
The names of the generated files look like <ion_label>_<quantity_label>_<file_suffix>. For example, if the file suffix is "input.dat", and the ion label is "D+", the ion temperature will be written to the file "D+_n_input.dat".
Argument | Type | Intent | Description |
---|---|---|---|
edge_profiles_data | type(edge_profiles_data_set) | in | the structure holding the obtained data |
file_suffix | character(len=*) | in | the suffix added to the names of the created files |
Module equilibrium_io
The module provides tools for information exchange with the 'edge_profiles' IDS.
Data types
type equilibrium_data_set
type(eirene_data) :: bx, by, bz, Btotal ! Components used by EIRENE
type(eirene_data) :: BR, Bvert, Btor ! Components stored in IMAS
end type equilibrium_data_set
This type is a collection of magnetic field components.
type equilibrium_file_set
character(len=32) :: bx, by, bz, Btotal
end type equilibrium_file_set
This type holds names of the files holding the magnetic field components.
Methods
- deallocate_equilibrium_data
Deallocate all components of the structure. - initiate_equilibrium_data_for_input
Read the part of the command file that controls saving the EIRENE data to the equilibrium IDS. - collect_data_for_equilibrium_input
Read the EIRENE input data intended for the equilibrium IDS from files, - transform_equilibrium_for_ids
Transform the magnetic field data to the form suitable for the equilibrium IDS. - save_input_to_equilibrium
Put EIRENE input to the equilibrium IDS. - fetch_input_from_equilibrium
Get all physical quantities from the equilibrium IDS. - get_quantities_from_equilibrium
Get all physical quantities from the equilibrium IDS. - transform_equilibrium_for_eirene
- write_input_data_from_equilibrium_ids
subroutine deallocate_equilibrium_data (all_data)
Deallocate all components of the structure.
Argument | Type | Intent | Description |
---|---|---|---|
all_data | type(equilibrium_set) | inout | structure to be deallocated |
function initiate_equilibrium_data_for_input (io_unit) result (equilibrium_files)
Read the part of the command file that controls saving the EIRENE data to the equilibrium IDS.
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_files | type(equilibrium_file_set) | result | structure holding the file names obtained from the command file |
io_unit | integer | in | index of the I/O unit attached to the command file |
function collect_data_for_equilibrium_input (equilibrium_files) result (equilibrium_data)
Read the EIRENE input data intended for the equilibrium IDS from files.
Uses the subroutine read_quantity_from_file (module eirene_data_io).
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_data | type(equilibrium_data_set) | result | structure that accepts the data read from the files |
equilibrium_files | type(equilibrium_file_set) | in | structure that holds the file names |
subroutine transform_equilibrium_for_ids (equilibrium_data)
Transform the magnetic field data to the form suitable for the equilibrium IDS. On entry, only a part of the 'equilibrium_data' structure is filled. The subroutine fills the rest.
The input files contain b_x, b_y, b_z (b is the mag. field unit vector), and B_total. The equilibrium IDS accepts B_R, B_Z, B_phi. Here x=R, y=Z (vertical), z=phi (toroidal).
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_data | type(equilibrium_data_set) | inout | structure that holds all magnetic field data |
subroutine save_input_to_equilibrium (idx, imas_controls, grid_controls, equilibrium_data, eirene_grid)
Put EIRENE input to the equilibrium IDS. The input consists of (1) a triangular grid; (2) a set of quantities (characteristics of several plasma species) defined on this grid. The first item is provided in 'eirene_grid'; the second one, in 'equilibrium_data'.
Uses the subroutines: put_quantity_to_ids (module imas_data_io), put_eirene_grid_to_equilibrium (module triangular_grid_ids_io), transform_equilibrium_for_ids (this module).
Argument | Type | Intent | Description |
---|---|---|---|
idx | integer | in | index of the I/O unit attached to the IMAS database |
imas_controls | type(imas_control_panel) | in | parameters of the IMAS database and basic information to be put to IDS |
grid_controls | type(grid_control_panel) | in | parameters controlling the grid saving |
equilibrium_data | type(equilibrium_data_set) | inout | structure holding the distributions of physical quantities |
eirene_grid | type(triangular_grid) | in | structure keeping the EIRENE triangular grid |
subroutine fetch_input_from_equilibrium (idx, grid_controls, fetch_grid, equilibrium_data, eirene_grid)
Get all physical quantities from the equilibrium IDS, putting them to a type(equilibrium_data_set) structure. If required, get the triangular grid.
Uses the subroutines: get_triangular_grid_from_equilibrium (module triangular_grid_ids_io), get_quantities_from_equilibrium (this module), transform_equilibrium_for_eirene (this module).
Argument | Type | Intent | Description |
---|---|---|---|
idx | integer | in | index of the I/O unit attached to the IMAS database |
grid_controls | type(grid_control_panel) | in | parameters controlling the grid saving/recovering |
fetch_grid | logical | in | switches on reading the grid |
equilibrium_data | type(equilibrium_data_set) | out | the structure holding the data found in the equilibrium IDS (except for the grid) |
eirene_grid | type(triangular_grid) | inout | structure containing the grid; if fetch_input=.true., it is filled with data read from the IDS; otherwise, it remains unchanged. |
function get_quantities_from_equilibrium (ggd, grid_ggd_aos) result (equilibrium_data)
Get all physical quantities from the equilibrium IDS, putting them to a type(equilibrium_data_set) structure.
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_data | type(equilibrium_data_set) | result | the structure holding the obtained data |
ggd | type(ids_equilibrium_ggd) | in | ggd AoS element where the quantities are written |
grid_ggd_aos | type(ids_generic_grid_dynamic), dimension(:) | in | AoS containing the GGD grids |
subroutine transform_equilibrium_for_eirene (equilibrium_data)
Transform the magnetic field data obtained from the equilibrium IDS into form suitable for EIRENE. On entry, only a part of the 'equilibrium_data' structure is filled. The subroutine fills the rest.
The input files must contain b_x, b_y, b_z (b is the mag. field unit vector), and B_total. The equilibrium IDS accepts B_R, B_Z, B_phi. Here x=R, y=Z (vertical), z=phi (toroidal).
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_data | type(equilibrium_data_set) | inout | structure that holds all magnetic field data |
subroutine write_input_data_from_equilibrium_ids (equilibrium_data, equilibrium_files)
Write the data extracted from the edge_profiles IDS to files in the format of EIRENE input tallies.
The names of the generated files are taken from the 'equilibrium_files' structure.
Argument | Type | Intent | Description |
---|---|---|---|
equilibrium_data | type(equilibrium_data_set) | in | the structure holding the obtained data |
equilibrium_files | type(equilibrium_file_set) | in | the structure containing the file names |
Module global_objects
The module contains global constants and service routines used in other modules.
Constants
real(IDS_real), parameter :: density_unit_ratio = 1.e6_IDS_real, &
& velocity_unit_ratio = 1.e-2_IDS_real, &
& temperature_unit_ratio = 1._IDS_real, &
& Bfield_unit_ratio = 1._IDS_real
real(IDS_real), parameter :: length_unit_ratio = 1.e-2_IDS_real
Each of these constants is the ratio of an EIRENE unit to the corresponding IMAS unit (for example, 1 cm / 1 m = 10^(-2) for length).
Methods
- read_next_line
Return the next file record not starting with '!'. - get_imas_version
Get the versions of IMAS and IMAS Access Layer from the system environment.
function read_next_line (io_unit, label) result (line)
Return the next file record not starting with '!' (the function is used for reading only meaningful records, skipping the comment lines).
Argument | Type | Intent | Description |
---|---|---|---|
line | character(len=ids_string_length) | result | the next meaningful file record |
io_unit | integer | in | I/O unit attached to the file being read |
label | character(len=*) | in | text characterizing the expected record content (used in error messages) |
function get_imas_version () result (version)
Get the versions of IMAS and IMAS Access Layer from the system environment. The function result is a structure with the type 'ids_version_dd_al' (the type used in IMAS for holding this information).
An example of the environment variable used by the function is as follows:
IMAS_PREFIX=/gw/swimas/core/IMAS/3.37.0/AL/4.11.0/intel/2020
Argument | Type | Intent | Description |
---|---|---|---|
version | type(ids_version_dd_al) | result | structure holding the version information |
Module imas_controls_for_input
The module contains the tools that permit to control the wrappers via the content of the command file.
Data types
type imas_control_panel
character(len=16) :: database !! Name of the database/machine
!! Note: the database must exist
!! before running the wrapper
integer :: shot, run
character(len=4) :: imas_major_version = '3'
character(len=16) :: username !! current login username;
!! to be provided with
!! getlog() Fortran routine.
type(ids_ids_properties) :: ids_properties
type(ids_code) :: code !! Code properties
character(len=16) :: generic_suffix !! The last part of the file name if the
!! is generated automatically
end type imas_control_panel
This type is designed to hold the control parameters taken from the command file.
Methods
- get_imas_controls_for_input_saving
- get_imas_controls_for_input_fetching
function get_imas_controls_for_input_saving (io_unit) result (imas_controls)
Prepare control parameters for saving the EIRENE input to IMAS. Most control parameters are taken from a command file.
Argument | Type | Intent | Description |
---|---|---|---|
imas_controls | type(imas_control_panel) | result | Structure hilding the control parameters |
io_unit | integer | in | I/O unit attached to the command file |
function get_imas_controls_for_input_fetching (io_unit) result (imas_controls)
repare control parameters for getting the EIRENE input from IMAS. Most control parameters are taken from a command file.
Argument | Type | Intent | Description |
---|---|---|---|
imas_controls | type(imas_control_panel) | result | Structure hilding the control parameters |
io_unit | integer | in | I/O unit attached to the command file |
Main files save_input_main.f90
and provide_input_main
.f90
The wrapper program contained in the file save_input_main
.f90
performs the following actions:
- Reads the command file 'save_input.par', putting its content to the structures 'imas_controls', 'grid_controls', 'equilibrium_files', and 'edge_profiles_data'.
- Reads information about the grid from files and establishes grid edges, using the
read_eirene_grid
function (moduletriangular_grid_module
). - Inputs distributions of input tallies from data files, invoking the functions 'collect_data_for_edge_profiles_input' and 'collect_data_for_equilibrium_input'.
- Creates an IMAS database entry, invoking the IMAS library subroutine 'imas_create_env'.
- Puts the information (the grid and the tallies) into 2 IMAS IDS's, using the subroutines 'save_input_to_edge_profiles' and 'save_input_to_equilibrium'.
- Closes the database, invoking the IMAS library subroutine 'imas_close'.
- Deallocates the structures holding the data.
The program contained in the file provide_input_main
.f90
performs the following actions:
- Reads the command file 'provide_input.par', putting its content to the structures 'imas_controls', 'grid_controls', and 'equilibrium_files'.
- Opens the IMAS database, invoking the IMAS library subroutine
imas_open_env
. - Inputs the data (the grid and the tallies) from 2 IMAS IDS's, using the subroutines 'fetch_input_from_edge_profiles' and 'fetch_input_from_equilibrium'.
- Writes these data to EIRENE-format files, invoking the subroutines 'write_eirene_grid', 'write_input_data_from_edge_profiles_ids', and 'write_input_data_from_equilibrium_ids'.
- Closes the database, invoking the IMAS library subroutine 'imas_close'.
- Deallocates the structures holding the data.
Known issues
The statements that are to deallocate the IDS's in the program memory when they are not needed anymore are now commented out (they are in the modules 'edge_profiles_io' and 'equilibrium_io'). The reason is that the IMAS library subroutine 'ids_deallocate' hangs the program 'save_input.exe' if it is called for both IDS's ('edge_profiles' and 'equilibrium'). This issue is yet to be resolved.
Things to be done
- Code parameters
- Headers of data files
- Generalize to multi-atom ions
- Resolve the issue with non-deallocated structures
- Implement ion velocities (after IMAS 3.38 appears)
- Extend the list of input quantities
- IMASification of the EIRENE output
- Try to adjust the processing of exceptions to GSL practices (if worthwhile)
The scientific work is published for the realization of the international project co-financed by Polish Ministry of Science and Higher Education in 2019 from financial resources of the program entitled "PMW"; Agreement No. 5040/H2020/Euratom/2019/2
This work has been carried out within the framework of the EUROfusion Consortium and has received funding from the Euratom research and training programme 2014–2020 under grant agreement No 633053. The views and opinions expressed herein do not necessarily reflect those of the European Commission or ITER