...
- Introduction
- Files provided
- Running a test example
- Structure of the parameter 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 provided
- Methods provided
- Module triangular_grid_ids_io
- Data types provided
- Methods provided
- EIRENE input wrapper
- Structure of EIRENE input files
- Module eirene_data_io
- Data types provided
- Methods provided
- 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 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.
Files provided
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 The files listed below can be found in the public directory ~g2yyakov/public/eirene/version0.910.!!! To be updated
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 parameter command file for the program save_input.exe |
provide_input.par | A template parameter 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 |
...
- 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
...
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:
...
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:
...
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:
...
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:
...
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'.
...
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 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
...
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 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
...
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)
...
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)
...
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)
...
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_
...
??????????????
Module imas_controls_for_input
????????????
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:
- ???????? Initializes an instance of the
edge_profiles
IDS in the code memory with writing some mandatory fields. - Writes some labels to the IDS.
- Allocates the
grid_ggd
AOS with only one element. - Reads information about the grid from files and establishes grid edges, using the
read_eirene_grid
function (moduletriangular_grid_module
). - Puts the grid information into the IDS, using the
put_triangular_grid_to_ids
subroutine (moduletriangular_grid_ids_io
). - Creates the corresponding IDS in an IMAS database.
- Writes the IDS prepared in the code memory to the IMAS database and closes the database.
The program contained in the file recover_grid.f90
performs the following actions:
...
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)
...