From 77f285854873b3679faa39bb29f8bba374a5a279 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 4 Jun 2021 14:43:27 +0200 Subject: [PATCH 1/6] Add index in files --- configure.ac | 2 +- src/templates_front/templator_front.org | 48 +++++++++++++++++-------- trex.json | 6 ++-- trex.org | 19 +++++----- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index ae24f4b..f2ad108 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,7 @@ AC_PROG_LN_S ## --------- # Checks for basic header files. -AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdlib.h string.h unistd.h]) +AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdbool.h stdlib.h string.h unistd.h]) ### HDF5 diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 971ac89..374dcbb 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -49,11 +49,12 @@ typedef int32_t trexio_exit_code; #include #include #include +#include #include #include "trexio.h" -#include "trexio_s.h" #include "trexio_private.h" +#include "trexio_s.h" #include "trexio_text.h" #include "trexio_hdf5.h" /* @@ -70,6 +71,7 @@ typedef int32_t trexio_exit_code; #include "trexio.h" #include #include +#include #+end_src * Coding conventions @@ -421,11 +423,12 @@ typedef struct trexio_s trexio_t; #+begin_src c :tangle prefix_s_front.h struct trexio_s { - char* file_name; + char file_name[TREXIO_MAX_FILENAME_LENGTH]; pthread_mutex_t thread_lock; back_end_t back_end; char mode; - char padding[7]; /* Ensures the proper alignment of back ends */ + bool one_based; + char padding[6]; /* Ensures the proper alignment of back ends */ }; #+end_src ** Polymorphism of the file handle @@ -458,11 +461,13 @@ struct trexio_back_end_s { output: ~trexio_t~ file handle - Note: the ~file_name~ in TEXT back end actually corresponds to the name of the folder where ~.txt~ - data files are stored. The actual name of each ~.txt~ file corresponds to the group name provided in - ~trex.config~ (e.g. ~nucleus.txt~ for nuclei-related data). - These names are populated by the generator.py (i.e. they are hard-coded), which is why the user - should tend to avoid renaming the ~.txt~ data files. + Note: the ~file_name~ in TEXT back end actually corresponds to the + name of the directory where ~.txt~ data files are stored. The + actual name of each ~.txt~ file corresponds to the group name + provided in ~trex.config~ (e.g. ~nucleus.txt~ for nuclei-related + data). These names are populated by the generator.py (i.e. they + are hard-coded), which is why the user should tend to avoid + renaming the ~.txt~ data files. #+begin_src c :tangle prefix_front.h :exports none trexio_t* trexio_open(const char* file_name, const char mode, const back_end_t back_end); @@ -509,16 +514,15 @@ trexio_open(const char* file_name, const char mode, /* Data for the parent type */ - result->file_name = CALLOC(TREXIO_MAX_FILENAME_LENGTH, char); strncpy(result->file_name, file_name, TREXIO_MAX_FILENAME_LENGTH); if (result->file_name[TREXIO_MAX_FILENAME_LENGTH-1] != '\0') { - free(result->file_name); free(result); return NULL; } result->back_end = back_end; result->mode = mode; + result->one_based = false; // Need to be flipped in Fortran interface int irc = pthread_mutex_init ( &(result->thread_lock), NULL); assert (irc == 0); @@ -545,7 +549,6 @@ trexio_open(const char* file_name, const char mode, } if (rc != TREXIO_SUCCESS) { - free(result->file_name); free(result); return NULL; } @@ -571,7 +574,6 @@ trexio_open(const char* file_name, const char mode, } if (rc != TREXIO_SUCCESS) { - free(result->file_name); free(result); return NULL; } @@ -591,6 +593,25 @@ interface end interface #+end_src + Because arrays are zero-based in Fortran, we need to set a flag to + know if we need to shift by 1 arrays of indices. + + #+begin_src c :tangle prefix_front.h :exports none +trexio_exit_code trexio_set_one_based(trexio_t* file); + #+end_src + + #+begin_src c :tangle prefix_front.c +trexio_exit_code trexio_set_one_based(trexio_t* file) +{ + if (file == NULL) + return TREXIO_FILE_ERROR; + + file->one_based = true; + + return TREXIO_SUCCESS; +} + #+end_src + ** File closing ~trexio_close~ closes an existing ~trexio_t~ file. @@ -634,7 +655,6 @@ trexio_close (trexio_t* file) } if (rc != TREXIO_SUCCESS) { - FREE(file->file_name); FREE(file); return rc; } @@ -661,8 +681,6 @@ trexio_close (trexio_t* file) /* Terminate front end */ - FREE(file->file_name); - int irc = pthread_mutex_destroy( &(file->thread_lock) ); free(file); diff --git a/trex.json b/trex.json index 8c3c8e4..9870240 100644 --- a/trex.json +++ b/trex.json @@ -39,11 +39,11 @@ "basis": { "type" : [ "str" , [] ] , "shell_num" : [ "int" , [] ] - , "shell_center" : [ "int" , [ "basis.shell_num" ] ] + , "shell_center" : [ "index", [ "basis.shell_num" ] ] , "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ] , "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ] , "shell_factor" : [ "float", [ "basis.shell_num" ] ] - , "prim_index" : [ "int" , [ "basis.shell_num" ] ] + , "prim_index" : [ "index", [ "basis.shell_num" ] ] , "prim_num" : [ "int" , [] ] , "exponent" : [ "float", [ "basis.prim_num" ] ] , "coefficient" : [ "float", [ "basis.prim_num" ] ] @@ -53,7 +53,7 @@ "ao": { "cartesian" : [ "int" , [] ] , "num" : [ "int" , [] ] - , "shell" : [ "int" , [ "ao.num" ] ] + , "shell" : [ "index", [ "ao.num" ] ] , "normalization" : [ "float", [ "ao.num" ] ] } , diff --git a/trex.org b/trex.org index cdc7365..57b336d 100644 --- a/trex.org +++ b/trex.org @@ -7,6 +7,10 @@ column-major order (as in Fortran), and the ordering of the dimensions is reversed in the produces JSON configuration file as the library is written in C. +In Fortran, the arrays are 1-based and in most other languages the +arrays are 0-base. Hence, we introduce the ~index~ type which is an +1-based ~int~ in the Fortran interface and 0-based otherwise. + #+begin_src python :tangle trex.json { #+end_src @@ -195,11 +199,11 @@ written in C. #+NAME: basis | ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" | | ~shell_num~ | ~int~ | | Total Number of shells | - | ~shell_center~ | ~int~ | ~(basis.shell_num)~ | Nucleus on which the shell is centered ($A$) | + | ~shell_center~ | ~index~ | ~(basis.shell_num)~ | Nucleus on which the shell is centered ($A$) | | ~shell_ang_mom~ | ~int~ | ~(basis.shell_num)~ | Angular momentum ~0:S, 1:P, 2:D, ...~ | | ~shell_prim_num~ | ~int~ | ~(basis.shell_num)~ | Number of primitives in the shell ($N_{\text{prim}}$) | | ~shell_factor~ | ~float~ | ~(basis.shell_num)~ | Normalization factor of the shell ($\mathcal{N}_s$) | - | ~prim_index~ | ~int~ | ~(basis.shell_num)~ | Index of the first primitive in the complete list | + | ~prim_index~ | ~index~ | ~(basis.shell_num)~ | Index of the first primitive in the complete list | | ~prim_num~ | ~int~ | | Total number of primitives | | ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}) | | ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) | @@ -213,11 +217,11 @@ written in C. "basis": { "type" : [ "str" , [] ] , "shell_num" : [ "int" , [] ] - , "shell_center" : [ "int" , [ "basis.shell_num" ] ] + , "shell_center" : [ "index", [ "basis.shell_num" ] ] , "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ] , "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ] , "shell_factor" : [ "float", [ "basis.shell_num" ] ] - , "prim_index" : [ "int" , [ "basis.shell_num" ] ] + , "prim_index" : [ "index", [ "basis.shell_num" ] ] , "prim_num" : [ "int" , [] ] , "exponent" : [ "float", [ "basis.prim_num" ] ] , "coefficient" : [ "float", [ "basis.prim_num" ] ] @@ -250,8 +254,7 @@ written in C. \chi_i (\mathbf{r}) = \mathcal{N}_i\, P_{\eta(i)}(\mathbf{r})\, R_{\theta(i)} (\mathbf{r}) \] - where $i$ is the atomic orbital index, - $P$ encodes for either the + where $i$ is the atomic orbital index, $P$ encodes for either the polynomials or the spherical harmonics, $\theta(i)$ returns the shell on which the AO is expanded, and $\eta(i)$ denotes which angular function is chosen. @@ -273,7 +276,7 @@ written in C. #+NAME: ao | ~cartesian~ | ~int~ | | ~1~: true, ~0~: false | | ~num~ | ~int~ | | Total number of atomic orbitals | - | ~shell~ | ~int~ | ~(ao.num)~ | basis set shell for each AO | + | ~shell~ | ~index~ | ~(ao.num)~ | basis set shell for each AO | | ~normalization~ | ~float~ | ~(ao.num)~ | Normalization factors | #+CALL: json(data=ao, title="ao") @@ -284,7 +287,7 @@ written in C. "ao": { "cartesian" : [ "int" , [] ] , "num" : [ "int" , [] ] - , "shell" : [ "int" , [ "ao.num" ] ] + , "shell" : [ "index", [ "ao.num" ] ] , "normalization" : [ "float", [ "ao.num" ] ] } , #+end_src From 4549276e866a30f24bf99beff3b70c6bd66144de Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 4 Jun 2021 15:00:13 +0200 Subject: [PATCH 2/6] Add trexio_set_one_based in fortran interface --- src/templates_front/templator_front.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 374dcbb..4e013ff 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -612,6 +612,15 @@ trexio_exit_code trexio_set_one_based(trexio_t* file) } #+end_src + #+begin_src f90 :tangle prefix_fortran.f90 +interface + integer function trexio_set_one_based(trex_file) bind(C) + use, intrinsic :: iso_c_binding + integer(8), intent(in), value :: trex_file + end function trexio_open_c +end interface + #+end_src + ** File closing ~trexio_close~ closes an existing ~trexio_t~ file. @@ -1554,10 +1563,20 @@ contains character(len=*) :: filename character, intent(in), value :: mode integer, intent(in), value :: backend + character(len=len_trim(filename)+1) :: filename_c + integer :: rc filename_c = trim(filename) // c_null_char trexio_open = trexio_open_c(filename_c, mode, backend) + if (trexio_open == 0_8) then + return + endif + rc = trexio_set_one_based(trexio_open) + if (rc /= TREXIO_SUCCESS) then + call trexio_close(trexio_open) + trexio_open = 0_8 + endif end function trexio_open #+end_src From 1bfc8d0c6c801c85cedf80375be3c7666affd26e Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 4 Jun 2021 17:02:14 +0200 Subject: [PATCH 3/6] fix typos --- src/templates_front/templator_front.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 4e013ff..f0e9741 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -617,7 +617,7 @@ interface integer function trexio_set_one_based(trex_file) bind(C) use, intrinsic :: iso_c_binding integer(8), intent(in), value :: trex_file - end function trexio_open_c + end function trexio_set_one_based end interface #+end_src @@ -1574,7 +1574,7 @@ contains endif rc = trexio_set_one_based(trexio_open) if (rc /= TREXIO_SUCCESS) then - call trexio_close(trexio_open) + rc = trexio_close(trexio_open) trexio_open = 0_8 endif end function trexio_open From 15a238636084e5532e4ab8d6a953da3186694fb9 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jun 2021 23:44:56 +0200 Subject: [PATCH 4/6] update json --- trex.json | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/trex.json b/trex.json index 8c3c8e4..4924b85 100644 --- a/trex.json +++ b/trex.json @@ -37,17 +37,18 @@ } , "basis": { - "type" : [ "str" , [] ] - , "shell_num" : [ "int" , [] ] - , "shell_center" : [ "int" , [ "basis.shell_num" ] ] - , "shell_ang_mom" : [ "int" , [ "basis.shell_num" ] ] - , "shell_prim_num" : [ "int" , [ "basis.shell_num" ] ] - , "shell_factor" : [ "float", [ "basis.shell_num" ] ] - , "prim_index" : [ "int" , [ "basis.shell_num" ] ] - , "prim_num" : [ "int" , [] ] - , "exponent" : [ "float", [ "basis.prim_num" ] ] - , "coefficient" : [ "float", [ "basis.prim_num" ] ] - , "prim_factor" : [ "float", [ "basis.prim_num" ] ] + "type" : [ "str" , [] ] + , "num" : [ "int" , [] ] + , "prim_num" : [ "int" , [] ] + , "nucleus_index" : [ "int" , [ "nucleus.num" ] ] + , "nucleus_shell_num" : [ "int" , [ "nucleus.num" ] ] + , "shell_ang_mom" : [ "int" , [ "basis.num" ] ] + , "shell_prim_num" : [ "int" , [ "basis.num" ] ] + , "shell_factor" : [ "float", [ "basis.num" ] ] + , "shell_prim_index" : [ "int" , [ "basis.num" ] ] + , "exponent" : [ "float", [ "basis.prim_num" ] ] + , "coefficient" : [ "float", [ "basis.prim_num" ] ] + , "prim_factor" : [ "float", [ "basis.prim_num" ] ] } , "ao": { From bec752361c21bd22726b3c6a2c84f9191063e6c0 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 10 Jun 2021 01:49:43 +0200 Subject: [PATCH 5/6] Index OK --- src/templates_front/templator_front.org | 83 ++++++++++++++++++++----- tests/test_f.f90 | 47 ++++++++++---- tools/generator_tools.py | 9 ++- 3 files changed, 110 insertions(+), 29 deletions(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index cdd63ba..9b8ac23 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -1129,6 +1129,7 @@ trexio_read_$group_dset$_64 (trexio_t* const file, $group_dset_dtype_double$* co /* Error handling for this call is added by the generator */ rc = trexio_read_$group_dset_dim$_64(file, &($group_dset_dim$)); + if (rc != TREXIO_SUCCESS) return rc; if ($group_dset_dim$ == 0L) return TREXIO_INVALID_NUM; @@ -1137,22 +1138,36 @@ trexio_read_$group_dset$_64 (trexio_t* const file, $group_dset_dtype_double$* co assert(file->back_end < TREXIO_INVALID_BACK_END); + rc = TREXIO_FAILURE; switch (file->back_end) { - + case TREXIO_TEXT: - return trexio_text_read_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_text_read_$group_dset$(file, $group_dset$, rank, dims); break; case TREXIO_HDF5: - return trexio_hdf5_read_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_hdf5_read_$group_dset$(file, $group_dset$, rank, dims); break; /* case TREXIO_JSON: - return trexio_json_read_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_json_read_$group_dset$(file, $group_dset$, rank, dims); break; ,*/ } - return TREXIO_FAILURE; + if (rc != TREXIO_SUCCESS) return rc; + + /* Handle index type */ + if ($is_index$) { + uint64_t dim_size = 1; + for (uint32_t i=0; iback_end < TREXIO_INVALID_BACK_END); + rc = TREXIO_FAILURE; switch (file->back_end) { case TREXIO_TEXT: - return trexio_text_write_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_text_write_$group_dset$(file, $group_dset$_p, rank, dims); break; case TREXIO_HDF5: - return trexio_hdf5_write_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_hdf5_write_$group_dset$(file, $group_dset$_p, rank, dims); break; /* case TREXIO_JSON: - return trexio_json_write_$group_dset$(file, $group_dset$, rank, dims); + rc = trexio_json_write_$group_dset$(file, $group_dset$_p, rank, dims); break; ,*/ } - return TREXIO_FAILURE; + + /* Handle index type */ + if ($is_index$) { + FREE($group_dset$_p); + } + + return rc; } #+end_src @@ -1217,7 +1258,7 @@ trexio_read_$group_dset$_32 (trexio_t* const file, $group_dset_dtype_single$* co uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$}; uint64_t dim_size = 1; - for (unsigned int i=0; iback_end < TREXIO_INVALID_BACK_END); diff --git a/tests/test_f.f90 b/tests/test_f.f90 index 9ceef27..dcf1526 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -35,6 +35,7 @@ subroutine test_write(file_name, back_end) character*(128) :: str + integer :: basis_nucleus_index(12) double precision :: charge(12) double precision :: coord(3,12) @@ -55,6 +56,8 @@ subroutine test_write(file_name, back_end) 0.00000000d0, 2.47304151d0 , 0.00000000d0 /), & shape(coord) ) + basis_nucleus_index = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /) + ! ================= START OF TEST ===================== ! trex_file = trexio_open(file_name, 'w', back_end) @@ -63,7 +66,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_HAS_NOT) then write(*,*) 'SUCCESS HAS NOT 1' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -72,7 +75,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_HAS_NOT) then write(*,*) 'SUCCESS HAS NOT 2' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -82,7 +85,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS WRITE NUM' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -91,7 +94,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS WRITE CHARGE' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -100,7 +103,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS WRITE COORD' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -109,7 +112,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS HAS 1' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -118,7 +121,16 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS HAS 2' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) + print *, trim(str) + call exit(1) + endif + + rc = trexio_write_basis_nucleus_index(trex_file, basis_nucleus_index) + if (rc == TREXIO_SUCCESS) then + write(*,*) 'SUCCESS WRITE INDEX' + else + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -127,7 +139,7 @@ subroutine test_write(file_name, back_end) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS CLOSE' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -172,6 +184,7 @@ subroutine test_read(file_name, back_end) integer :: rc = 1 integer :: num, num_read + integer :: basis_nucleus_index(12) double precision :: charge(12) double precision :: coord(3,12) @@ -188,7 +201,7 @@ subroutine test_read(file_name, back_end) if (rc == TREXIO_SUCCESS .and. num_read == num) then write(*,*) 'SUCCESS READ NUM' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif @@ -199,7 +212,7 @@ subroutine test_read(file_name, back_end) if (rc == TREXIO_SUCCESS .and. (dabs(charge(11) - 1.d0) < 1.0D-8) ) then write(*,*) 'SUCCESS READ CHARGE' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(-1) endif @@ -209,16 +222,26 @@ subroutine test_read(file_name, back_end) if (rc == TREXIO_SUCCESS .and. (dabs(coord(2,1) - 1.39250319d0) < 1.0D-8) ) then write(*,*) 'SUCCESS READ COORD' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(-1) endif + rc = trexio_read_basis_nucleus_index(trex_file, basis_nucleus_index) + if (rc == TREXIO_SUCCESS .and. (basis_nucleus_index(12) == 12) ) then + write(*,*) 'SUCCESS READ INDEX' + else + call trexio_string_of_error(rc,str) + print *, trim(str) + call exit(-1) + endif + + rc = trexio_close(trex_file) if (rc == TREXIO_SUCCESS) then write(*,*) 'SUCCESS CLOSE' else - call trexio_string_of_error(TREXIO_READONLY,str) + call trexio_string_of_error(rc,str) print *, trim(str) call exit(1) endif diff --git a/tools/generator_tools.py b/tools/generator_tools.py index 03adfd9..d9a496e 100644 --- a/tools/generator_tools.py +++ b/tools/generator_tools.py @@ -100,7 +100,7 @@ def recursive_populate_file(fname: str, paths: dict, detailed_source: dict) -> N fname_new = join('populated',f'pop_{fname}') templ_path = get_template_path(fname, paths) - triggers = ['group_dset_dtype', 'group_dset_h5_dtype', 'default_prec', + triggers = ['group_dset_dtype', 'group_dset_h5_dtype', 'default_prec', 'is_index', 'group_dset_f_dtype_default', 'group_dset_f_dtype_double', 'group_dset_f_dtype_single', 'group_dset_dtype_default', 'group_dset_dtype_double', 'group_dset_dtype_single', 'group_dset_rank', 'group_dset_dim_list', 'group_dset_f_dims', @@ -472,7 +472,7 @@ def split_dset_dict_detailed (datasets: dict) -> tuple: default_prec = '64' group_dset_std_dtype_out = '24.16e' group_dset_std_dtype_in = 'lf' - elif v[0] == 'int': + elif v[0] in ['int', 'index']: datatype = 'int64_t' group_dset_h5_dtype = 'native_int64' group_dset_f_dtype_default= 'integer(4)' @@ -490,6 +490,11 @@ def split_dset_dict_detailed (datasets: dict) -> tuple: # add the dset name for templates tmp_dict['group_dset'] = k + # add flag to detect index types + if 'index' == v[0]: + tmp_dict['is_index'] = 'file->one_based' + else: + tmp_dict['is_index'] = 'false' # add the datatypes for templates tmp_dict['dtype'] = datatype tmp_dict['group_dset_dtype'] = datatype From 65fe15b3e73d07edbbc25e04d301764bbd09ba78 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 10 Jun 2021 01:51:28 +0200 Subject: [PATCH 6/6] removed trex.json --- trex.json | 105 ------------------------------------------------------ 1 file changed, 105 deletions(-) delete mode 100644 trex.json diff --git a/trex.json b/trex.json deleted file mode 100644 index 3588937..0000000 --- a/trex.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - -"metadata": { - "code_num" : [ "int", [] ] - , "code" : [ "str", [ "metadata.code_num" ] ] - , "author_num" : [ "int", [] ] - , "author" : [ "str", [ "metadata.author_num" ] ] - , "description" : [ "str", [] ] -} , - -"electron": { - "up_num" : [ "int", [] ] - , "dn_num" : [ "int", [] ] -} , - -"nucleus": { - "num" : [ "int" , [] ] - , "charge" : [ "float", [ "nucleus.num" ] ] - , "coord" : [ "float", [ "nucleus.num", "3" ] ] - , "label" : [ "str" , [ "nucleus.num" ] ] - , "point_group" : [ "str" , [] ] -} , - -"ecp": { - "lmax_plus_1" : [ "int" , [ "nucleus.num" ] ] - , "z_core" : [ "float", [ "nucleus.num" ] ] - , "local_n" : [ "int" , [ "nucleus.num" ] ] - , "local_num_n_max" : [ "int" , [] ] - , "local_exponent" : [ "float", [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "local_coef" : [ "float", [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "local_power" : [ "int" , [ "nucleus.num", "ecp.local_num_n_max" ] ] - , "non_local_n" : [ "int" , [ "nucleus.num" ] ] - , "non_local_num_n_max" : [ "int" , [] ] - , "non_local_exponent" : [ "float", [ "nucleus.num", "ecp.non_local_num_n_max" ] ] - , "non_local_coef" : [ "float", [ "nucleus.num", "ecp.non_local_num_n_max" ] ] - , "non_local_power" : [ "int" , [ "nucleus.num", "ecp.non_local_num_n_max" ] ] -} , - -"basis": { - "type" : [ "str" , [] ] - , "num" : [ "int" , [] ] - , "prim_num" : [ "int" , [] ] - , "nucleus_index" : [ "index" , [ "nucleus.num" ] ] - , "nucleus_shell_num" : [ "int" , [ "nucleus.num" ] ] - , "shell_ang_mom" : [ "int" , [ "basis.num" ] ] - , "shell_prim_num" : [ "int" , [ "basis.num" ] ] - , "shell_factor" : [ "float", [ "basis.num" ] ] - , "shell_prim_index" : [ "index" , [ "basis.num" ] ] - , "exponent" : [ "float", [ "basis.prim_num" ] ] - , "coefficient" : [ "float", [ "basis.prim_num" ] ] - , "prim_factor" : [ "float", [ "basis.prim_num" ] ] -} , - -"ao": { - "cartesian" : [ "int" , [] ] - , "num" : [ "int" , [] ] - , "shell" : [ "index", [ "ao.num" ] ] - , "normalization" : [ "float", [ "ao.num" ] ] -} , - -"ao_1e_int": { - "overlap" : [ "float", [ "ao.num", "ao.num" ] ] - , "kinetic" : [ "float", [ "ao.num", "ao.num" ] ] - , "potential_n_e" : [ "float", [ "ao.num", "ao.num" ] ] - , "ecp_local" : [ "float", [ "ao.num", "ao.num" ] ] - , "ecp_non_local" : [ "float", [ "ao.num", "ao.num" ] ] - , "core_hamiltonian" : [ "float", [ "ao.num", "ao.num" ] ] -} , - -"ao_2e_int": { - "eri" : [ "float sparse", [ "ao.num", "ao.num", "ao.num", "ao.num" ] ] - , "eri_lr" : [ "float sparse", [ "ao.num", "ao.num", "ao.num", "ao.num" ] ] -} , - -"mo": { - "type" : [ "str" , [] ] - , "num" : [ "int" , [] ] - , "coefficient" : [ "float", [ "mo.num", "ao.num" ] ] - , "class" : [ "str" , [ "mo.num" ] ] - , "symmetry" : [ "str" , [ "mo.num" ] ] - , "occupation" : [ "float", [ "mo.num" ] ] -} , - -"mo_1e_int": { - "overlap" : [ "float", [ "mo.num", "mo.num" ] ] - , "kinetic" : [ "float", [ "mo.num", "mo.num" ] ] - , "potential_n_e" : [ "float", [ "mo.num", "mo.num" ] ] - , "ecp_local" : [ "float", [ "mo.num", "mo.num" ] ] - , "ecp_non_local" : [ "float", [ "mo.num", "mo.num" ] ] - , "core_hamiltonian" : [ "float", [ "mo.num", "mo.num" ] ] -} , - -"mo_2e_int": { - "eri" : [ "float sparse", [ "mo.num", "mo.num", "mo.num", "mo.num" ] ] - , "eri_lr" : [ "float sparse", [ "mo.num", "mo.num", "mo.num", "mo.num" ] ] -} , - -"rdm": { - "one_e" : [ "float" , [ "mo.num", "mo.num" ] ] - , "one_e_up" : [ "float" , [ "mo.num", "mo.num" ] ] - , "one_e_dn" : [ "float" , [ "mo.num", "mo.num" ] ] - , "two_e" : [ "float sparse", [ "mo.num", "mo.num", "mo.num", "mo.num" ] ] -} - -}