1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-01-08 20:33:36 +01:00

Using iso_c_binding types in trexio_f.f90

This commit is contained in:
Anthony Scemama 2022-01-19 18:37:09 +01:00
parent 51c43fe1ac
commit 16e9a815d2
4 changed files with 151 additions and 115 deletions

View File

@ -25,9 +25,9 @@ cat prefix_python.py > trexio.py
# append version string and attributes to the Fortran module file # append version string and attributes to the Fortran module file
echo "" >> trexio_f.f90 echo "" >> trexio_f.f90
echo "character(len = 12) :: TREXIO_PACKAGE_VERSION = ${VERSION_VAL}" >> trexio_f.f90 echo "character(len = 12) :: TREXIO_PACKAGE_VERSION = ${VERSION_VAL}" >> trexio_f.f90
echo "integer(4) :: TREXIO_VERSION_MAJOR = ${VERSION_MAJOR_VAL}" >> trexio_f.f90 echo "integer(int32) :: TREXIO_VERSION_MAJOR = ${VERSION_MAJOR_VAL}" >> trexio_f.f90
echo "integer(4) :: TREXIO_VERSION_MINOR = ${VERSION_MINOR_VAL}" >> trexio_f.f90 echo "integer(int32) :: TREXIO_VERSION_MINOR = ${VERSION_MINOR_VAL}" >> trexio_f.f90
echo "integer(4) :: TREXIO_VERSION_PATCH = ${VERSION_PATCH_VAL}" >> trexio_f.f90 echo "integer(int32) :: TREXIO_VERSION_PATCH = ${VERSION_PATCH_VAL}" >> trexio_f.f90
echo "" >> trexio_f.f90 echo "" >> trexio_f.f90
# c front end # c front end

View File

@ -80,10 +80,11 @@ typedef int32_t trexio_exit_code;
module trexio module trexio
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
use, intrinsic :: iso_fortran_env
implicit none implicit none
integer, parameter :: trexio_exit_code = 4 integer, parameter :: trexio_exit_code = int32
integer, parameter :: trexio_backend = 4 integer, parameter :: trexio_backend = int32
character(kind=c_char), parameter :: TREXIO_DELIM = c_new_line character(kind=c_char), parameter :: TREXIO_DELIM = c_new_line
#+end_src #+end_src
@ -490,6 +491,7 @@ trexio_string_of_error_f (const trexio_exit_code error, char result[<<MAX_STRING
interface interface
subroutine trexio_string_of_error (error, string) bind(C, name='trexio_string_of_error_f') subroutine trexio_string_of_error (error, string) bind(C, name='trexio_string_of_error_f')
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
use, intrinsic :: iso_fortran_env
import import
integer (trexio_exit_code), intent(in), value :: error integer (trexio_exit_code), intent(in), value :: error
character, intent(out) :: string(<<MAX_STRING_LENGTH()>>) character, intent(out) :: string(<<MAX_STRING_LENGTH()>>)
@ -597,7 +599,8 @@ bool trexio_has_backend(back_end_t back_end) {
interface interface
logical function trexio_has_backend (back_end) bind(C) logical function trexio_has_backend (back_end) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(4), intent(in), value :: back_end use, intrinsic :: iso_fortran_env
integer(int32), intent(in), value :: back_end
end function trexio_has_backend end function trexio_has_backend
end interface end interface
#+end_src #+end_src
@ -966,8 +969,9 @@ trexio_open(const char* file_name, const char mode,
#+begin_src f90 :tangle prefix_fortran.f90 #+begin_src f90 :tangle prefix_fortran.f90
interface interface
integer(8) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open") integer(int64) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open")
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
use, intrinsic :: iso_fortran_env
import import
character(kind=c_char), dimension(*) :: filename character(kind=c_char), dimension(*) :: filename
character, intent(in), value :: mode character, intent(in), value :: mode
@ -1046,7 +1050,8 @@ trexio_exit_code trexio_set_one_based(trexio_t* file)
interface interface
integer function trexio_set_one_based(trex_file) bind(C) integer function trexio_set_one_based(trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_set_one_based end function trexio_set_one_based
end interface end interface
#+end_src #+end_src
@ -1149,7 +1154,8 @@ trexio_close (trexio_t* file)
interface interface
integer function trexio_close (trex_file) bind(C) integer function trexio_close (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_close end function trexio_close
end interface end interface
#+end_src #+end_src
@ -1271,29 +1277,29 @@ def _inquire(file_name: str) -> bool:
example, in ~#define~ statements). More detailed description of example, in ~#define~ statements). More detailed description of
each variable can be found below: each variable can be found below:
| Template variable | Description | Example | | Template variable | Description | Example |
|--------------------------------+-----------------------------------------------------+-----------------------| |--------------------------------+-----------------------------------------------------+-------------------------------|
| ~$group$~ | Name of the group | ~nucleus~ | | ~$group$~ | Name of the group | ~nucleus~ |
| ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ | | ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ |
| ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ | | ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ |
| ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ | | ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ |
| ~$group_dset_rank$~ | Rank of the dataset | ~2~ | | ~$group_dset_rank$~ | Rank of the dataset | ~2~ |
| ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ | | ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ |
| ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ | | ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ |
| ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ | | ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ |
| ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ | | ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ |
| ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ | | ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ |
| ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ | | ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ |
| ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ | | ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ |
| ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ | | ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ |
| ~$group_dset_dtype_double$~ | Double precision datatype of the dataset [C] | ~double/int64_t~ | | ~$group_dset_dtype_double$~ | real(real64) datatype of the dataset [C] | ~double/int64_t~ |
| ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(8)/integer(4)~ | | ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(real64)/integer(int32)~ |
| ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(4)/integer(4)~ | | ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(real32)/integer(int32)~ |
| ~$group_dset_f_dtype_double$~ | Double precision datatype of the dataset [Fortran] | ~real(8)/integer(8)~ | | ~$group_dset_f_dtype_double$~ | real(real64) datatype of the dataset [Fortran] | ~real(real64)/integer(int64)~ |
| ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ | | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ |
| ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ | | ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ |
| ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ | | ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ |
| ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ | | ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ |
Some of the aforementioned template variables with ~group_dset~ prefix are duplicated with ~group_num~ prefix, Some of the aforementioned template variables with ~group_dset~ prefix are duplicated with ~group_num~ prefix,
@ -1315,7 +1321,7 @@ def _inquire(file_name: str) -> bool:
For each of the aforementioned objects, TREXIO provides *has*, For each of the aforementioned objects, TREXIO provides *has*,
*read* and *write* functionality. TREXIO supports I/O with single *read* and *write* functionality. TREXIO supports I/O with single
or double precision for integer and floating point numbers. or real(real64) for integer and floating point numbers.
*Note:* single integer attributes that contain ~num~ in their name (e.g. ~nucleus_num~) are *Note:* single integer attributes that contain ~num~ in their name (e.g. ~nucleus_num~) are
considered dimensioning variables and cannot be negative or 0. An attempt to write negative or 0 considered dimensioning variables and cannot be negative or 0. An attempt to write negative or 0
@ -1344,7 +1350,7 @@ def _inquire(file_name: str) -> bool:
handle. Second parameter is the variable to be written/read handle. Second parameter is the variable to be written/read
to/from the ~TREXIO~ file (except for ~trexio_has_~ functions). to/from the ~TREXIO~ file (except for ~trexio_has_~ functions).
Suffixes ~_32~ and ~_64~ correspond to API calls dealing with Suffixes ~_32~ and ~_64~ correspond to API calls dealing with
single and double precision, respectively. The basic single and real(real64), respectively. The basic
(non-suffixed) API call on dimensioning variables deals with single (non-suffixed) API call on dimensioning variables deals with single
precision (see Table above). precision (see Table above).
@ -1360,7 +1366,7 @@ trexio_exit_code trexio_read_$group_num$_64(trexio_t* const file, $group_num_dty
trexio_exit_code trexio_write_$group_num$_64(trexio_t* const file, const $group_num_dtype_double$ num); trexio_exit_code trexio_write_$group_num$_64(trexio_t* const file, const $group_num_dtype_double$ num);
#+end_src #+end_src
**** Source code for double precision functions **** Source code for real(real64) functions
#+begin_src c :tangle read_attr_num_64_front.c #+begin_src c :tangle read_attr_num_64_front.c
trexio_exit_code trexio_exit_code
@ -1548,7 +1554,8 @@ trexio_has_$group_num$ (trexio_t* const file)
interface interface
integer function trexio_write_$group_num$_64 (trex_file, num) bind(C) integer function trexio_write_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(in), value :: num $group_num_f_dtype_double$, intent(in), value :: num
end function trexio_write_$group_num$_64 end function trexio_write_$group_num$_64
end interface end interface
@ -1558,7 +1565,8 @@ end interface
interface interface
integer function trexio_read_$group_num$_64 (trex_file, num) bind(C) integer function trexio_read_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(out) :: num $group_num_f_dtype_double$, intent(out) :: num
end function trexio_read_$group_num$_64 end function trexio_read_$group_num$_64
end interface end interface
@ -1568,7 +1576,8 @@ end interface
interface interface
integer function trexio_write_$group_num$_32 (trex_file, num) bind(C) integer function trexio_write_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(in), value :: num $group_num_f_dtype_single$, intent(in), value :: num
end function trexio_write_$group_num$_32 end function trexio_write_$group_num$_32
end interface end interface
@ -1578,7 +1587,8 @@ end interface
interface interface
integer function trexio_read_$group_num$_32 (trex_file, num) bind(C) integer function trexio_read_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(out) :: num $group_num_f_dtype_single$, intent(out) :: num
end function trexio_read_$group_num$_32 end function trexio_read_$group_num$_32
end interface end interface
@ -1588,7 +1598,8 @@ end interface
interface interface
integer function trexio_write_$group_num$ (trex_file, num) bind(C) integer function trexio_write_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(in), value :: num $group_num_f_dtype_default$, intent(in), value :: num
end function trexio_write_$group_num$ end function trexio_write_$group_num$
end interface end interface
@ -1598,7 +1609,8 @@ end interface
interface interface
integer function trexio_read_$group_num$ (trex_file, num) bind(C) integer function trexio_read_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(out) :: num $group_num_f_dtype_default$, intent(out) :: num
end function trexio_read_$group_num$ end function trexio_read_$group_num$
end interface end interface
@ -1608,7 +1620,8 @@ end interface
interface interface
integer function trexio_has_$group_num$ (trex_file) bind(C) integer function trexio_has_$group_num$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_has_$group_num$ end function trexio_has_$group_num$
end interface end interface
#+end_src #+end_src
@ -1706,16 +1719,16 @@ def has_$group_num$(trexio_file) -> bool:
| ~trexio_write_safe_$group_dset$~ | Write a bounded dataset | Double | | ~trexio_write_safe_$group_dset$~ | Write a bounded dataset | Double |
| ~trexio_read_$group_dset$_32~ | Read a dataset in single precision | Single | | ~trexio_read_$group_dset$_32~ | Read a dataset in single precision | Single |
| ~trexio_write_$group_dset$_32~ | Write a dataset in single precision | Single | | ~trexio_write_$group_dset$_32~ | Write a dataset in single precision | Single |
| ~trexio_read_$group_dset$_64~ | Read a dataset in double precision | Double | | ~trexio_read_$group_dset$_64~ | Read a dataset in real(real64) | Double |
| ~trexio_write_$group_dset$_64~ | Write a dataset in double precision | Double | | ~trexio_write_$group_dset$_64~ | Write a dataset in real(real64) | Double |
*** C templates for front end *** C templates for front end
The C templates that correspond to each of the abovementioned functions can be found below. The C templates that correspond to each of the abovementioned functions can be found below.
First parameter is the ~TREXIO~ file handle. Second parameter is the variable to be written/read First parameter is the ~TREXIO~ file handle. Second parameter is the variable to be written/read
to/from the ~TREXIO~ file (except for ~trexio_has_~ functions). to/from the ~TREXIO~ file (except for ~trexio_has_~ functions).
Suffixes ~_32~ and ~_64~ correspond to API calls dealing with single and double precision, respectively. Suffixes ~_32~ and ~_64~ correspond to API calls dealing with single and real(real64), respectively.
The basic (non-suffixed) API call on datasets deals with double precision (see Table above). The basic (non-suffixed) API call on datasets deals with real(real64) (see Table above).
**** Function declarations **** Function declarations
@ -1735,7 +1748,7 @@ trexio_exit_code trexio_read_safe_$group_dset$_64(trexio_t* const file, $group_d
trexio_exit_code trexio_write_safe_$group_dset$_64(trexio_t* const file, const $group_dset_dtype_double$* dset_in, const int64_t dim_in); trexio_exit_code trexio_write_safe_$group_dset$_64(trexio_t* const file, const $group_dset_dtype_double$* dset_in, const int64_t dim_in);
#+end_src #+end_src
**** Source code for double precision functions **** Source code for real(real64) functions
#+begin_src c :tangle read_dset_data_64_front.c #+begin_src c :tangle read_dset_data_64_front.c
trexio_exit_code trexio_exit_code
@ -2211,7 +2224,8 @@ trexio_has_$group_dset$ (trexio_t* const file)
interface interface
integer function trexio_write_$group_dset$_64 (trex_file, dset) bind(C) integer function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$ $group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_64 end function trexio_write_$group_dset$_64
end interface end interface
@ -2221,7 +2235,8 @@ end interface
interface interface
integer function trexio_read_$group_dset$_64 (trex_file, dset) bind(C) integer function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$ $group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_64 end function trexio_read_$group_dset$_64
end interface end interface
@ -2231,7 +2246,8 @@ end interface
interface interface
integer function trexio_write_$group_dset$_32 (trex_file, dset) bind(C) integer function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(in) :: dset$group_dset_f_dims$ $group_dset_f_dtype_single$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_32 end function trexio_write_$group_dset$_32
end interface end interface
@ -2241,7 +2257,8 @@ end interface
interface interface
integer function trexio_read_$group_dset$_32 (trex_file, dset) bind(C) integer function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(out) :: dset$group_dset_f_dims$ $group_dset_f_dtype_single$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_32 end function trexio_read_$group_dset$_32
end interface end interface
@ -2251,7 +2268,8 @@ end interface
interface interface
integer function trexio_write_$group_dset$ (trex_file, dset) bind(C) integer function trexio_write_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(in) :: dset$group_dset_f_dims$ $group_dset_f_dtype_default$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$ end function trexio_write_$group_dset$
end interface end interface
@ -2261,7 +2279,8 @@ end interface
interface interface
integer function trexio_read_$group_dset$ (trex_file, dset) bind(C) integer function trexio_read_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(out) :: dset$group_dset_f_dims$ $group_dset_f_dtype_default$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$ end function trexio_read_$group_dset$
end interface end interface
@ -2271,7 +2290,8 @@ end interface
interface interface
integer function trexio_has_$group_dset$ (trex_file) bind(C) integer function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_has_$group_dset$ end function trexio_has_$group_dset$
end interface end interface
#+end_src #+end_src
@ -2353,7 +2373,7 @@ def read_$group_dset$(trexio_file, dim = None, doReshape = None, dtype = None):
If None, the function will read all necessary array dimensions from the file. If None, the function will read all necessary array dimensions from the file.
dtype (Optional): type dtype (Optional): type
NumPy data type of the output (e.g. np.int32|int16 or np.float32|float16). If specified, the output array will be converted from the default double precision. NumPy data type of the output (e.g. np.int32|int16 or np.float32|float16). If specified, the output array will be converted from the default real(real64).
doReshape (Optional): bool doReshape (Optional): bool
Flag to determine whether the output NumPy array has be reshaped or not. Be default, reshaping is performed Flag to determine whether the output NumPy array has be reshaped or not. Be default, reshaping is performed
@ -2822,11 +2842,12 @@ interface
offset_file, buffer_size, & offset_file, buffer_size, &
index_sparse, value_sparse) bind(C) index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(8), intent(in), value :: offset_file integer(int64), intent(in), value :: trex_file
integer(8), intent(in), value :: buffer_size integer(int64), intent(in), value :: offset_file
integer(4), intent(in) :: index_sparse(*) integer(int64), intent(in), value :: buffer_size
double precision, intent(in) :: value_sparse(*) integer(int32), intent(in) :: index_sparse(*)
real (real64), intent(in) :: value_sparse(*)
end function trexio_write_$group_dset$ end function trexio_write_$group_dset$
end interface end interface
@ -2836,13 +2857,14 @@ interface
index_sparse, index_size, & index_sparse, index_size, &
value_sparse, value_size) bind(C) value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(8), intent(in), value :: offset_file integer(int64), intent(in), value :: trex_file
integer(8), intent(in), value :: buffer_size integer(int64), intent(in), value :: offset_file
integer(4), intent(in) :: index_sparse(*) integer(int64), intent(in), value :: buffer_size
integer(8), intent(in), value :: index_size integer(int32), intent(in) :: index_sparse(*)
double precision, intent(in) :: value_sparse(*) integer(int64), intent(in), value :: index_size
integer(8), intent(in), value :: value_size real (real64), intent(in) :: value_sparse(*)
integer(int64), intent(in), value :: value_size
end function trexio_write_safe_$group_dset$ end function trexio_write_safe_$group_dset$
end interface end interface
#+end_src #+end_src
@ -2853,11 +2875,12 @@ interface
offset_file, buffer_size, & offset_file, buffer_size, &
index_sparse, value_sparse) bind(C) index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(8), intent(in), value :: offset_file integer(int64), intent(in), value :: trex_file
integer(8), intent(inout) :: buffer_size integer(int64), intent(in), value :: offset_file
integer(4), intent(out) :: index_sparse(*) integer(int64), intent(inout) :: buffer_size
double precision, intent(out) :: value_sparse(*) integer(int32), intent(out) :: index_sparse(*)
real (real64), intent(out) :: value_sparse(*)
end function trexio_read_$group_dset$ end function trexio_read_$group_dset$
end interface end interface
@ -2867,13 +2890,14 @@ interface
index_sparse, index_size, & index_sparse, index_size, &
value_sparse, value_size) bind(C) value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(8), intent(in), value :: offset_file integer(int64), intent(in), value :: trex_file
integer(8), intent(inout) :: buffer_size integer(int64), intent(in), value :: offset_file
integer(4), intent(out) :: index_sparse(*) integer(int64), intent(inout) :: buffer_size
integer(8), intent(in), value :: index_size integer(int32), intent(out) :: index_sparse(*)
double precision, intent(out) :: value_sparse(*) integer(int64), intent(in), value :: index_size
integer(8), intent(in), value :: value_size real (real64), intent(out) :: value_sparse(*)
integer(int64), intent(in), value :: value_size
end function trexio_read_safe_$group_dset$ end function trexio_read_safe_$group_dset$
end interface end interface
#+end_src #+end_src
@ -2883,8 +2907,9 @@ interface
integer function trexio_read_$group_dset$_size (trex_file, & integer function trexio_read_$group_dset$_size (trex_file, &
size_max) bind(C) size_max) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(8), intent(out) :: size_max integer(int64), intent(in), value :: trex_file
integer(int64), intent(out) :: size_max
end function trexio_read_$group_dset$_size end function trexio_read_$group_dset$_size
end interface end interface
#+end_src #+end_src
@ -2893,7 +2918,8 @@ end interface
interface interface
integer function trexio_has_$group_dset$ (trex_file) bind(C) integer function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_has_$group_dset$ end function trexio_has_$group_dset$
end interface end interface
#+end_src #+end_src
@ -3391,9 +3417,10 @@ trexio_has_$group_dset$ (trexio_t* const file)
interface interface
integer function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C) integer function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
character, intent(in) :: dset(*) character, intent(in) :: dset(*)
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
end function trexio_write_$group_dset$_low end function trexio_write_$group_dset$_low
end interface end interface
#+end_src #+end_src
@ -3402,9 +3429,10 @@ end interface
interface interface
integer function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C) integer function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
character, intent(out) :: dset(*) character, intent(out) :: dset(*)
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
end function trexio_read_$group_dset$_low end function trexio_read_$group_dset$_low
end interface end interface
#+end_src #+end_src
@ -3413,7 +3441,8 @@ end interface
interface interface
integer function trexio_has_$group_dset$ (trex_file) bind(C) integer function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_has_$group_dset$ end function trexio_has_$group_dset$
end interface end interface
#+end_src #+end_src
@ -3421,12 +3450,12 @@ end interface
#+begin_src f90 :tangle helper_read_dset_str_front_fortran.fh_90 #+begin_src f90 :tangle helper_read_dset_str_front_fortran.fh_90
integer function trexio_read_$group_dset$ (trex_file, dset, max_str_len) integer function trexio_read_$group_dset$ (trex_file, dset, max_str_len)
implicit none implicit none
integer(8), intent(in), value :: trex_file integer(int64), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
character(len=*), intent(inout) :: dset(*) character(len=*), intent(inout) :: dset(*)
character, allocatable :: str_compiled(:) character, allocatable :: str_compiled(:)
integer(8) :: $group_dset_dim$ integer(int64) :: $group_dset_dim$
integer :: rc integer :: rc
rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$) rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$)
@ -3450,12 +3479,12 @@ end interface
#+begin_src f90 :tangle helper_write_dset_str_front_fortran.fh_90 #+begin_src f90 :tangle helper_write_dset_str_front_fortran.fh_90
integer function trexio_write_$group_dset$ (trex_file, dset, max_str_len) integer function trexio_write_$group_dset$ (trex_file, dset, max_str_len)
implicit none implicit none
integer(8), intent(in), value :: trex_file integer(int64), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
character(len=*), intent(in) :: dset(*) character(len=*), intent(in) :: dset(*)
character(len=:), allocatable :: str_compiled character(len=:), allocatable :: str_compiled
integer(8) :: $group_dset_dim$ integer(int64) :: $group_dset_dim$
integer :: rc integer :: rc
rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$) rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$)
@ -3708,9 +3737,10 @@ interface
integer function trexio_write_$group_str$_c (trex_file, str, max_str_len) & integer function trexio_write_$group_str$_c (trex_file, str, max_str_len) &
bind(C, name="trexio_write_$group_str$") bind(C, name="trexio_write_$group_str$")
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
character, intent(in) :: str(*) character, intent(in) :: str(*)
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
end function trexio_write_$group_str$_c end function trexio_write_$group_str$_c
end interface end interface
#+end_src #+end_src
@ -3720,9 +3750,10 @@ interface
integer function trexio_read_$group_str$_c (trex_file, str, max_str_len) & integer function trexio_read_$group_str$_c (trex_file, str, max_str_len) &
bind(C, name="trexio_read_$group_str$") bind(C, name="trexio_read_$group_str$")
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
character, intent(out) :: str(*) character, intent(out) :: str(*)
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
end function trexio_read_$group_str$_c end function trexio_read_$group_str$_c
end interface end interface
#+end_src #+end_src
@ -3731,7 +3762,8 @@ end interface
interface interface
integer function trexio_has_$group_str$ (trex_file) bind(C) integer function trexio_has_$group_str$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer(8), intent(in), value :: trex_file use, intrinsic :: iso_fortran_env
integer(int64), intent(in), value :: trex_file
end function trexio_has_$group_str$ end function trexio_has_$group_str$
end interface end interface
#+end_src #+end_src
@ -3739,8 +3771,8 @@ end interface
#+begin_src f90 :tangle helper_read_attr_str_front_fortran.fh_90 #+begin_src f90 :tangle helper_read_attr_str_front_fortran.fh_90
integer function trexio_read_$group_str$ (trex_file, str, max_str_len) integer function trexio_read_$group_str$ (trex_file, str, max_str_len)
implicit none implicit none
integer(8), intent(in), value :: trex_file integer(int64), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
character, intent(out) :: str(*) character, intent(out) :: str(*)
trexio_read_$group_str$ = trexio_read_$group_str$_c(trex_file, str, max_str_len) trexio_read_$group_str$ = trexio_read_$group_str$_c(trex_file, str, max_str_len)
@ -3751,9 +3783,10 @@ end interface
#+begin_src f90 :tangle helper_write_attr_str_front_fortran.fh_90 #+begin_src f90 :tangle helper_write_attr_str_front_fortran.fh_90
integer function trexio_write_$group_str$ (trex_file, str, max_str_len) integer function trexio_write_$group_str$ (trex_file, str, max_str_len)
use, intrinsic :: iso_c_binding, only : c_null_char use, intrinsic :: iso_c_binding, only : c_null_char
use, intrinsic :: iso_fortran_env
implicit none implicit none
integer(8), intent(in), value :: trex_file integer(int64), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len integer(int32), intent(in), value :: max_str_len
character(len=*), intent(in) :: str character(len=*), intent(in) :: str
character(len=len_trim(str)+1) :: str_c character(len=len_trim(str)+1) :: str_c
@ -3857,8 +3890,9 @@ def has_$group_str$(trexio_file) -> bool:
#+begin_src f90 :tangle helper_fortran.f90 #+begin_src f90 :tangle helper_fortran.f90
contains contains
integer(8) function trexio_open (filename, mode, backend, rc_open) integer(int64) function trexio_open (filename, mode, backend, rc_open)
use, intrinsic :: iso_c_binding, only : c_null_char use, intrinsic :: iso_c_binding, only : c_null_char
use, intrinsic :: iso_fortran_env
implicit none implicit none
character(len=*), intent(in) :: filename character(len=*), intent(in) :: filename
character, intent(in), value :: mode character, intent(in), value :: mode
@ -3904,9 +3938,10 @@ contains
#+begin_src f90 :tangle helper_fortran.f90 #+begin_src f90 :tangle helper_fortran.f90
subroutine trexio_strarray2str(str_array, max_num_str, max_len_str, str_res) subroutine trexio_strarray2str(str_array, max_num_str, max_len_str, str_res)
use, intrinsic :: iso_c_binding, only : c_null_char use, intrinsic :: iso_c_binding, only : c_null_char
use, intrinsic :: iso_fortran_env
implicit none implicit none
integer(8), intent(in), value :: max_num_str ! number of elements in strign array integer(int64), intent(in), value :: max_num_str ! number of elements in strign array
integer, intent(in), value :: max_len_str ! maximum length of a string in an array integer, intent(in), value :: max_len_str ! maximum length of a string in an array
character(len=*), intent(in) :: str_array(*) character(len=*), intent(in) :: str_array(*)
character(len=:), allocatable, intent(out) :: str_res character(len=:), allocatable, intent(out) :: str_res
@ -3927,14 +3962,14 @@ contains
subroutine trexio_str2strarray(str_flat, max_num_str, max_len_str, str_array) subroutine trexio_str2strarray(str_flat, max_num_str, max_len_str, str_array)
implicit none implicit none
integer(8), intent(in), value :: max_num_str ! number of elements in strign array integer(int64), intent(in), value :: max_num_str ! number of elements in strign array
integer, intent(in), value :: max_len_str ! maximum length of a string in an array integer, intent(in), value :: max_len_str ! maximum length of a string in an array
character, intent(in) :: str_flat(*) character, intent(in) :: str_flat(*)
character(len=*), intent(inout) :: str_array(*) character(len=*), intent(inout) :: str_array(*)
character(len=max_len_str) :: tmp_str character(len=max_len_str) :: tmp_str
integer :: i, j, k, ind, offset integer :: i, j, k, ind, offset
integer(8) :: len_flat integer(int64) :: len_flat
len_flat = (max_len_str+1)*max_num_str + 1 len_flat = (max_len_str+1)*max_num_str + 1

View File

@ -494,9 +494,9 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
'default_prec' : '64', 'default_prec' : '64',
f'group_{target}_dtype' : 'double', f'group_{target}_dtype' : 'double',
f'group_{target}_h5_dtype' : 'native_double', f'group_{target}_h5_dtype' : 'native_double',
f'group_{target}_f_dtype_default' : 'real(8)', f'group_{target}_f_dtype_default' : 'real(real64)',
f'group_{target}_f_dtype_double' : 'real(8)', f'group_{target}_f_dtype_double' : 'real(real64)',
f'group_{target}_f_dtype_single' : 'real(4)', f'group_{target}_f_dtype_single' : 'real(real32)',
f'group_{target}_dtype_default' : 'double', f'group_{target}_dtype_default' : 'double',
f'group_{target}_dtype_double' : 'double', f'group_{target}_dtype_double' : 'double',
f'group_{target}_dtype_single' : 'float', f'group_{target}_dtype_single' : 'float',
@ -509,9 +509,9 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
'default_prec' : '32', 'default_prec' : '32',
f'group_{target}_dtype' : 'int64_t', f'group_{target}_dtype' : 'int64_t',
f'group_{target}_h5_dtype' : 'native_int64', f'group_{target}_h5_dtype' : 'native_int64',
f'group_{target}_f_dtype_default' : 'integer(4)', f'group_{target}_f_dtype_default' : 'integer(int32)',
f'group_{target}_f_dtype_double' : 'integer(8)', f'group_{target}_f_dtype_double' : 'integer(int64)',
f'group_{target}_f_dtype_single' : 'integer(4)', f'group_{target}_f_dtype_single' : 'integer(int32)',
f'group_{target}_dtype_default' : 'int32_t', f'group_{target}_dtype_default' : 'int32_t',
f'group_{target}_dtype_double' : 'int64_t', f'group_{target}_dtype_double' : 'int64_t',
f'group_{target}_dtype_single' : 'int32_t', f'group_{target}_dtype_single' : 'int32_t',

View File

@ -384,7 +384,7 @@ exponent =
coefficient = coefficient =
[ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0, [ 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0,
0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0 ] 0.006068, 0.045308, 0.202822, 0.503903, 0.383421, 1.0, 1.0, 1.0, 1.0, 1.0 ]
`
prim_factor = prim_factor =
[ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.9610924849766440e-01 [ 1.0006253235944540e+01, 2.4169531573445120e+00, 7.9610924849766440e-01
3.0734305383061117e-01, 1.2929684417481876e-01, 3.0734305383061117e-01, 3.0734305383061117e-01, 1.2929684417481876e-01, 3.0734305383061117e-01,
@ -401,8 +401,9 @@ prim_factor =
construction of all the angular functions of each shell. We construction of all the angular functions of each shell. We
consider two cases for the angular functions: the real-valued consider two cases for the angular functions: the real-valued
spherical harmonics, and the polynomials in Cartesian coordinates. spherical harmonics, and the polynomials in Cartesian coordinates.
In the case of spherical harmonics, the AOs are ordered as In the case of real spherical harmonics, the AOs are ordered as
$0, +1, -1, +2, -2, \dots, +m, -m$ and in the case of polynomials we $0, +1, -1, +2, -2, \dots, +m, -m$ (see [[https://en.wikipedia.org/wiki/Table_of_spherical_harmonics#Real_spherical_harmonics][Wikipedia]]).
In the case of polynomials we
impose the canonical (or alphabetical) ordering), i.e impose the canonical (or alphabetical) ordering), i.e
\begin{eqnarray} \begin{eqnarray}