...
The tool can be currently from the command line. Soon, it will be integrated to the Jorek fortran program in order to be called for Jorek in different use-cases.
1. COMPILING THE SOURCES:
Code Block |
---|
$ cd jorek/util/nmlist2h5 |
...
Requirements: |
...
HDF5 version >= 1.12 |
...
To use the provided Makefile, be sure that: |
...
- The HDF5_HOME environment variable is defined in order to find the HDF5 header files |
...
- The HDF5 lib directory is referenced by the LD_LIBRARY_PATH variable, for linking |
...
- BOOST library is available in your system |
...
Compiling: |
...
$ make -f Makefile_namelist |
...
Example: |
...
[nmlist2h5]$ make -f Makefile_namelist |
...
gcc -c -o namelist2h5.o namelist2h5.c |
...
gcc -c -o h5_2_namelist.o h5_2_namelist.c |
...
gcc -c -o h5_utils.o h5_utils.c |
...
gcc -c -o namelist_api.o namelist_api.c |
...
g++ -pthread -Wl,--no-undefined -o namelist_api namelist2h5.o h5_2_namelist.o h5_utils.o namelist_api.o -L/Applications/libraries/hdf5/1.12.0/gcc/6.4.0/lib -lhdf5 |
1. API
Namelist to HDF5 Converter API:
//---------------------------------------------------------------------
int new_simulation(const char* h5_namelist_folder, const char* nml_file_name);
int restart(const char* h5_namelist_folder, const char* nml_file_name, const char* jorek_restart_file_name, const char* time_index);
int write_restart_file (const char* h5_namelist_folder, const char* jorek_restart_file);
int extract_from_h5_namelist (const char* h5_namelist_folder, const char* nml_file, const char* time_index);
int extract_from_jorek_restart_file (const char* h5_namelist_folder, const char* jorek_restart_file_name, const char* nml_file_name, const char* time_index);
//---------------------------------------------------------------------
NEW SIMULATION:
int new_simulation(const char* h5_namelist_folder, const char* nml_file_name);
/** Creates a new HDF5 namelist file from an existing JOREK parameters file in CSV format. Parameters are written in the '00000' HDF5 group which will be created.
* Inputs:
* h5_namelist_folder (string) : directory path in which the new HDF5 namelist file will be created
* nml_file_name (string) : name of the JOREK namelist file in CSV format, the file must be supplied in the 'h5_namelist_folder', an error will occur otherwise.
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
RESTART:
int restart(const char* h5_namelist_folder, const char* nml_file_name, const char* jorek_restart_file_name, const char* time_index);
/** If the HDF5 namelist file already exists in the folder specified by 'h5_namelist_folder', 'restart' will update this file from the specified JOREK restart file 'jorek_restart_file_name':
* - all HDF5 groups YYYYY >= time_index=XXXXX are removed from the HDF5 namelist file
* - the parameters from the file 'nml_file_name' (in CSV format) are added to the HDF5 namelist file in the HDF5 group XXXXX
* If the HDF5 namelist does not exist in the folder specified by 'h5_namelist_folder', 'restart' will create a new HDF5 namelist file in the folder 'h5_namelist_folder':
* - all parameters of the JOREK restart file specified by 'jorek_restart_file_name' are added to the HDF5 namelist file
* - the parameters located in the file 'nml_file_name' (in CSV format) are added to the HDF5 namelist file in the HDF5 group time_index=XXXXX
* Inputs:
* h5_namelist_folder (string) : directory path in which the HDF5 file is located. If the file does not exist, it will be created in this directory.
* nml_file_name (string) : name of the JOREK parameters file in CSV format, the file must be supplied in the 'h5_namelist_folder', an error will occur otherwise.
* jorek_restart_file_name (string) : name of the JOREK restart file in HDF5 format, the file must be supplied in the 'h5_namelist_folder' if the HDF5 namelist file does not exist, an error will occur otherwise.
* time_index (string) : name of the HDF5 group of the HDF5 namelist file where the namelist parameters from the file 'nml_file_name' will be added
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
WRITE RESTART FILE:
/** Creates a new HDF5 JOREK restart file. All parameters from the existing HDF5 namelist file are written in the 'namelist' HDF5 group.
* If the HDF5 namelist file does not exist in the specified 'h5_namelist_folder' directory, an error will occur.
* Inputs:
* h5_namelist_folder (string) : directory path in which the new HDF5 JOREK restart file will be created
* jorek_restart_file_name (string) : name of the JOREK restart file in HDF5 format
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
EXTRACT FROM H5 NAMELIST:
/** Creates a new namelist parameters file in CSV format. All parameters from the supplied HDF5 namelist file are extracted from the HDF5 group 'time_index' and copied to the CSV namelist parameters file.
* Inputs:
* h5_namelist_folder (string) : directory path in which the CSV namelist file will be created. This directory should contain the supplied HDF5 namelist file, an error will occur otherwise.
* nml_file_name (string) : name of the CSV namelist file to be created
* time_index (string) : time index with format 'XXXXX'
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
EXTRACT FROM JOREK RESTART FILE:
/** Creates a new namelist parameters file in CSV format. All parameters from the existing JOREK HDF5 restart file are extracted from the HDF5 group 'namelist/time_index' and copied to the CSV namelist file.
* Inputs:
* h5_namelist_folder (string) : directory path in which the CSV namelist file will be created. This directory should contain the supplied HDF5 namelist file, an error will occur otherwise.
* jorek_restart_file_name (string) : name of the JOREK restart file
* nml_file_name (string) : name of the CSV namelist file to be created
* time_index (string) : time index with format 'XXXXX'
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
//---------------------------------------------------------------------
int new_simulation(const char* h5_namelist_folder, const char* nml_file_name);
int restart(const char* h5_namelist_folder, const char* nml_file_name, const char* jorek_restart_file_name, const char* time_index);
int write_restart_file (const char* h5_namelist_folder, const char* jorek_restart_file);
int extract_from_h5_namelist (const char* h5_namelist_folder, const char* nml_file, const char* time_index);
int extract_from_jorek_restart_file (const char* h5_namelist_folder, const char* jorek_restart_file_name, const char* nml_file_name, const char* time_index);
//---------------------------------------------------------------------
NEW SIMULATION:
int new_simulation(const char* h5_namelist_folder, const char* nml_file_name);
/** Creates a new HDF5 namelist file from an existing JOREK parameters file in CSV format. Parameters are written in the '00000' HDF5 group which will be created.
* Inputs:
* h5_namelist_folder (string) : directory path in which the new HDF5 namelist file will be created
* nml_file_name (string) : name of the JOREK namelist file in CSV format, the file must be supplied in the 'h5_namelist_folder', an error will occur otherwise.
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
RESTART:
int restart(const char* h5_namelist_folder, const char* nml_file_name, const char* jorek_restart_file_name, const char* time_index);
/** If the HDF5 namelist file already exists in the folder specified by 'h5_namelist_folder', 'restart' will update this file from the specified JOREK restart file 'jorek_restart_file_name':
* - all HDF5 groups YYYYY >= time_index=XXXXX are removed from the HDF5 namelist file
* - the parameters from the file 'nml_file_name' (in CSV format) are added to the HDF5 namelist file in the HDF5 group XXXXX
* If the HDF5 namelist does not exist in the folder specified by 'h5_namelist_folder', 'restart' will create a new HDF5 namelist file in the folder 'h5_namelist_folder':
* - all parameters of the JOREK restart file specified by 'jorek_restart_file_name' are added to the HDF5 namelist file
* - the parameters located in the file 'nml_file_name' (in CSV format) are added to the HDF5 namelist file in the HDF5 group time_index=XXXXX
* Inputs:
* h5_namelist_folder (string) : directory path in which the HDF5 file is located. If the file does not exist, it will be created in this directory.
* nml_file_name (string) : name of the JOREK parameters file in CSV format, the file must be supplied in the 'h5_namelist_folder', an error will occur otherwise.
* jorek_restart_file_name (string) : name of the JOREK restart file in HDF5 format, the file must be supplied in the 'h5_namelist_folder' if the HDF5 namelist file does not exist, an error will occur otherwise.
* time_index (string) : name of the HDF5 group of the HDF5 namelist file where the namelist parameters from the file 'nml_file_name' will be added
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
WRITE RESTART FILE:
/** Creates a new HDF5 JOREK restart file. All parameters from the existing HDF5 namelist file are written in the 'namelist' HDF5 group.
* If the HDF5 namelist file does not exist in the specified 'h5_namelist_folder' directory, an error will occur.
* Inputs:
* h5_namelist_folder (string) : directory path in which the new HDF5 JOREK restart file will be created
* jorek_restart_file_name (string) : name of the JOREK restart file in HDF5 format
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
EXTRACT FROM H5 NAMELIST:
/** Creates a new namelist parameters file in CSV format. All parameters from the supplied HDF5 namelist file are extracted from the HDF5 group 'time_index' and copied to the CSV namelist parameters file.
* Inputs:
* h5_namelist_folder (string) : directory path in which the CSV namelist file will be created. This directory should contain the supplied HDF5 namelist file, an error will occur otherwise.
* nml_file_name (string) : name of the CSV namelist file to be created
* time_index (string) : time index with format 'XXXXX'
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
EXTRACT FROM JOREK RESTART FILE:
/** Creates a new namelist parameters file in CSV format. All parameters from the existing JOREK HDF5 restart file are extracted from the HDF5 group 'namelist/time_index' and copied to the CSV namelist file.
* Inputs:
* h5_namelist_folder (string) : directory path in which the CSV namelist file will be created. This directory should contain the supplied HDF5 namelist file, an error will occur otherwise.
* jorek_restart_file_name (string) : name of the JOREK restart file
* nml_file_name (string) : name of the CSV namelist file to be created
* time_index (string) : time index with format 'XXXXX'
* Returns:
* 0 if the operation is successfull or a code status < 0 otherwise.
**/
...