diff --git a/README.html b/README.html index e979e39..171f712 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- +program print_energy @@ -411,8 +411,8 @@ One needs to read from the TREXIO file:
integer :: i, j, k, l, m @@ -427,8 +427,8 @@ One needs to read from the TREXIO file:
call getarg(1, filename) @@ -444,8 +444,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
rc = trexio_read_nucleus_repulsion(f, E_nn)
@@ -459,8 +459,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
rc = trexio_read_mo_num(f, n)
@@ -474,8 +474,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
allocate( D(n,n), h0(n,n) )
@@ -487,8 +487,8 @@ W(:,:,:,:) = 0.d0
rc = trexio_has_mo_1e_int_core_hamiltonian(f) @@ -520,8 +520,8 @@ rc = trexio_read_rdm_1e(f, D)
Reading is done with OpenMP. Each thread reads its own buffer, and @@ -537,8 +537,8 @@ to be protected in the critical section when modified.
rc = trexio_has_mo_2e_int_eri(f) @@ -587,8 +587,8 @@ icount = BUFSIZE
rc = trexio_has_rdm_2e(f) @@ -632,8 +632,8 @@ icount = bufsize
When the orbitals are real, we can use @@ -679,8 +679,8 @@ E = E + E_nn
deallocate( D, h0, G, W )
@@ -695,7 +695,7 @@ E = E + E_nn
stdint.h
Memory allocation of structures can be facilitated by using the @@ -537,8 +537,8 @@ The maximum string size for the filenames is 4096 characters.
All calls to TREXIO are thread-safe. @@ -546,10 +546,10 @@ TREXIO front end is modular, which simplifies implementation of new back ends.
32 | 'Unsafe operation in safe mode' | + +|
TREXIO_INVALID_ELECTRON_NUM |
+33 | +'Inconsistent value of electron num' | +
The trexio_string_of_error
converts an exit code into a string. The
@@ -823,8 +829,8 @@ and the corresponding message are not propagated to the source code.
const char* @@ -924,6 +930,9 @@ and the corresponding message are not propagated to the source code. case TREXIO_SAFE_MODE: return "Unsafe operation in safe mode"; break; + case TREXIO_INVALID_ELECTRON_NUM: + return "Inconsistent value of electron num"; + break; } return "Unknown error"; } @@ -938,8 +947,8 @@ and the corresponding message are not propagated to the source code.
interface
@@ -955,8 +964,8 @@ and the corresponding message are not propagated to the source code.
class Error(Exception): @@ -995,8 +1004,8 @@ and the corresponding message are not propagated to the source code.
TREXIO has several back ends:
@@ -1025,8 +1034,8 @@ lines that correspond to the TREXIO_JSON
back end (not implemented
typedef int32_t back_end_t; @@ -1075,8 +1084,8 @@ This is useful due to the fact that HDF5 back end can be disabled at configure s
integer(trexio_back_end_t), parameter :: TREXIO_HDF5 = 0
@@ -1117,8 +1126,8 @@ consistency, in version 2.2 it was renamed trexio_has_back_end
.
# define TREXIO back ends
@@ -1133,8 +1142,8 @@ consistency, in version 2.2 it was renamed trexio_has_back_end
.
Every time a reading function is called, the data is read from the @@ -1163,8 +1172,8 @@ concurrent programs, the behavior is not specified.
trexio_s
is the the main type for TREXIO files, visible to the users
@@ -1198,8 +1207,8 @@ TREXIO files will have as a first argument the TREXIO file handle.
class File: @@ -1288,8 +1297,8 @@ TREXIO files will have as a first argument the TREXIO file handle.
Polymorphism of the trexio_t
type is handled by ensuring that the
@@ -1308,8 +1317,8 @@ corresponding types for all back ends can be safely casted to
trexio_open
creates a new TREXIO file or opens the existing one.
@@ -1365,8 +1374,8 @@ renaming the .txt
data files.
trexio_t*
@@ -1634,8 +1643,8 @@ renaming the .txt
data files.
interface
@@ -1653,8 +1662,8 @@ renaming the .txt
data files.
def _open(file_name: str, mode: str, back_end: int):
@@ -1702,8 +1711,8 @@ renaming the .txt
data files.
Because arrays are zero-based in Fortran, we need to set a flag to @@ -1736,8 +1745,8 @@ know if we need to shift by 1 arrays of indices.
trexio_close
closes an existing trexio_t
file.
@@ -1754,8 +1763,8 @@ output:
trexio_exit_code @@ -1768,7 +1777,7 @@ output: assert(file->back_end < TREXIO_INVALID_BACK_END); - /* Things to be done before the closing the file in the back-end */ + /* Things to be done before closing the file in the back-end */ rc = trexio_pre_close(file); if (rc != TREXIO_SUCCESS) { return rc; @@ -1842,8 +1851,8 @@ output:
interface
@@ -1858,8 +1867,8 @@ output:
def _close(trexio_file): @@ -1880,8 +1889,8 @@ output:
trexio_inquire
check whether TREXIO file exists.
@@ -1918,8 +1927,8 @@ You can see examples of both functionalities in test_f.f90
(search
trexio_exit_code
@@ -1949,8 +1958,8 @@ You can see examples of both functionalities in test_f.f90
(search
The function below is a C binding.
@@ -1970,8 +1979,8 @@ The front end Fortran function for trexio_inquire
can be found in t
def _inquire(file_name: str) -> bool:
@@ -1990,8 +1999,8 @@ The front end Fortran function for trexio_inquire
can be found in t
trexio_exit_code @@ -2008,55 +2017,60 @@ The front end Fortran function fortrexio_inquire
can be found in t bool has_dn = (trexio_has_electron_dn_num(file) == TREXIO_SUCCESS); bool has_updn = (trexio_has_electron_num(file) == TREXIO_SUCCESS); - if (has_updn && has_up && has_dn) { - rc = trexio_read_electron_up_num(file, &nup); - if (rc != TREXIO_SUCCESS) return rc; + if (file->mode != 'r') { + if (has_updn && has_up && has_dn) { + rc = trexio_read_electron_up_num(file, &nup); + if (rc != TREXIO_SUCCESS) return rc; - rc = trexio_read_electron_dn_num(file, &ndn); - if (rc != TREXIO_SUCCESS) return rc; + rc = trexio_read_electron_dn_num(file, &ndn); + if (rc != TREXIO_SUCCESS) return rc; - rc = trexio_read_electron_num(file, &nelec); - if (rc != TREXIO_SUCCESS) return rc; + rc = trexio_read_electron_num(file, &nelec); + if (rc != TREXIO_SUCCESS) return rc; + + if (nelec != nup + ndn) { + if (file->mode == 'u') { + nelec = nup + ndn; + rc = trexio_write_electron_num(file, nelec); + if (rc != TREXIO_SUCCESS) return rc; + } else { + return TREXIO_INVALID_ELECTRON_NUM; + } + } + } else if (has_up && has_dn) { + rc = trexio_read_electron_up_num(file, &nup); + if (rc != TREXIO_SUCCESS) return rc; + + rc = trexio_read_electron_dn_num(file, &ndn); + if (rc != TREXIO_SUCCESS) return rc; - if (nelec != nup + ndn) { nelec = nup + ndn; rc = trexio_write_electron_num(file, nelec); if (rc != TREXIO_SUCCESS) return rc; + } else if (has_up) { + rc = trexio_read_electron_up_num(file, &nup); + if (rc != TREXIO_SUCCESS) return rc; + + ndn = 0; + rc = trexio_write_electron_dn_num(file, ndn); + if (rc != TREXIO_SUCCESS) return rc; + + nelec = nup; + rc = trexio_write_electron_num(file, nelec); + if (rc != TREXIO_SUCCESS) return rc; + } else if (has_dn) { + rc = trexio_read_electron_dn_num(file, &ndn); + if (rc != TREXIO_SUCCESS) return rc; + + nup = 0; + rc = trexio_write_electron_up_num(file, nup); + if (rc != TREXIO_SUCCESS) return rc; + + nelec = ndn; + rc = trexio_write_electron_num(file, nelec); + if (rc != TREXIO_SUCCESS) return rc; } - } else if (has_up && has_dn) { - rc = trexio_read_electron_up_num(file, &nup); - if (rc != TREXIO_SUCCESS) return rc; - - rc = trexio_read_electron_dn_num(file, &ndn); - if (rc != TREXIO_SUCCESS) return rc; - - nelec = nup + ndn; - rc = trexio_write_electron_num(file, nelec); - if (rc != TREXIO_SUCCESS) return rc; - } else if (has_up) { - rc = trexio_read_electron_up_num(file, &nup); - if (rc != TREXIO_SUCCESS) return rc; - - ndn = 0; - rc = trexio_write_electron_dn_num(file, ndn); - if (rc != TREXIO_SUCCESS) return rc; - - nelec = nup; - rc = trexio_write_electron_num(file, nelec); - if (rc != TREXIO_SUCCESS) return rc; - } else if (has_dn) { - rc = trexio_read_electron_dn_num(file, &ndn); - if (rc != TREXIO_SUCCESS) return rc; - - nup = 0; - rc = trexio_write_electron_up_num(file, nup); - if (rc != TREXIO_SUCCESS) return rc; - - nelec = ndn; - rc = trexio_write_electron_num(file, nelec); - if (rc != TREXIO_SUCCESS) return rc; } - } return TREXIO_SUCCESS; @@ -2067,12 +2081,12 @@ The front end Fortran function fortrexio_inquire
can be found in t
Consider the following block of trex.json
:
@@ -2293,12 +2307,12 @@ value will result in TREXIO_INVALID_ARG_2
exit code.
This section concerns API calls related to numerical attributes, @@ -2369,8 +2383,8 @@ namely single value of int/float types.
The C
templates that correspond to each of the abovementioned
@@ -2384,12 +2398,12 @@ precision (see Table above).
trexio_exit_code
@@ -2453,8 +2467,8 @@ precision (see Table above).
trexio_exit_code
@@ -2530,8 +2544,8 @@ precision (see Table above).
trexio_exit_code
@@ -2586,8 +2600,8 @@ precision (see Table above).
The Fortran
templates that provide an access to the C
API calls from Fortran.
@@ -2679,8 +2693,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def write_$group_num$(trexio_file, num_w: $group_num_py_dtype$) -> None:
@@ -2765,12 +2779,12 @@ These templates are based on the use of iso_c_binding
. Pointers hav
This section concerns API calls related to datasets. @@ -2852,8 +2866,8 @@ This section concerns API calls related to datasets.
The C templates that correspond to each of the abovementioned functions can be found below. @@ -2864,12 +2878,12 @@ The basic (non-suffixed) API call on datasets deals with real(cdouble
trexio_exit_code
@@ -3032,8 +3046,8 @@ The basic (non-suffixed) API call on datasets deals with real(cdouble
trexio_exit_code
@@ -3184,11 +3198,11 @@ The basic (non-suffixed) API call on datasets deals with real(cdouble
trexio_exit_code rc; +trexio_exit_code rc; int64_t $group_dset_dim$ = 0; /* Error handling for this call is added by the generator */ @@ -3344,8 +3358,8 @@ rc = trexio_read_$group_dset_dim$_64(file, &($group_dset_dim$));
trexio_exit_code
@@ -3420,8 +3434,8 @@ rc = trexio_read_$group_dset_dim$_64(file, &($group_dset_dim$));
The Fortran
templates that provide an access to the C
API calls from Fortran
.
@@ -3513,8 +3527,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def write_$group_dset$(trexio_file, dset_w) -> None:
@@ -3709,12 +3723,12 @@ These templates are based on the use of iso_c_binding
. Pointers hav
Sparse data structures are used typically for large tensors such as @@ -3875,16 +3889,16 @@ This section concerns API calls related to sparse data structures.
trexio_exit_code trexio_read_safe_$group_dset$(trexio_t* const file, @@ -4160,8 +4174,8 @@ This section concerns API calls related to sparse data structures.
The Fortran
templates that provide an access to the C
API calls from Fortran
.
@@ -4262,8 +4276,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def write_$group_dset$(trexio_file: File, offset_file: int, buffer_size: int, indices: list, values: list) -> None:
@@ -4484,12 +4498,12 @@ These templates are based on the use of iso_c_binding
. Pointers hav
This section concerns API calls related to datasets of strings. @@ -4529,8 +4543,8 @@ This section concerns API calls related to datasets of strings.
First parameter is the TREXIO
file handle. Second parameter is the variable to be written/read
@@ -4538,12 +4552,12 @@ to/from the TREXIO
file (except for trexio_has_
functi
trexio_exit_code @@ -4793,8 +4807,8 @@ to/from theTREXIO
file (except fortrexio_has_
functi
The Fortran
templates that provide an access to the C
API calls from Fortran
.
@@ -4893,8 +4907,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def write_$group_dset$(trexio_file, dset_w: list) -> None:
@@ -5010,12 +5024,12 @@ These templates are based on the use of iso_c_binding
. Pointers hav
This section concerns API calls related to string attributes. @@ -5055,16 +5069,16 @@ This section concerns API calls related to string attributes.
trexio_exit_code
@@ -5168,8 +5182,8 @@ This section concerns API calls related to string attributes.
The Fortran
templates that provide an access to the C
API calls from Fortran.
@@ -5249,8 +5263,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def write_$group_str$(trexio_file, str_w: str) -> None:
@@ -5339,12 +5353,12 @@ These templates are based on the use of iso_c_binding
. Pointers hav
This section concerns API calls related to string attributes. @@ -5374,8 +5388,8 @@ This section concerns API calls related to string attributes.
trexio_exit_code
@@ -5410,8 +5424,8 @@ This section concerns API calls related to string attributes.
The Fortran
templates that provide an access to the C
API calls from Fortran.
@@ -5431,8 +5445,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
def delete_$group$(trexio_file) -> None:
@@ -5457,8 +5471,8 @@ These templates are based on the use of iso_c_binding
. Pointers hav
This section contains general helper functions like trexio_info
.
@@ -5485,8 +5499,8 @@ then value of the metadata_unsafe
attribute can be changed using th
trexio_exit_code
@@ -5531,8 +5545,8 @@ then value of the metadata_unsafe
attribute can be changed using th
interface
@@ -5545,8 +5559,8 @@ then value of the metadata_unsafe
attribute can be changed using th
def info():
@@ -5562,8 +5576,8 @@ then value of the metadata_unsafe
attribute can be changed using th
The function below adapts the original C-based trexio_open
for Fortran.
@@ -5715,7 +5729,7 @@ two code are identical, i.e. if the assert
statement pass.
#define $GROUP$_GROUP_NAME "$group$" @@ -338,8 +338,8 @@ for the JavaScript code in this tag.
typedef struct trexio_hdf5_s { @@ -352,8 +352,8 @@ for the JavaScript code in this tag.
trexio_exit_code @@ -417,18 +417,20 @@ for the JavaScript code in this tag. /* Create or open groups in the hdf5 file assuming that they exist if file exists */ switch (file->mode) { case 'r': - f->$group$_group = H5Gopen(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT); + if (H5Lexists(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT) > 0) f->$group$_group = H5Gopen(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT); + if (H5Lexists(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT) == 0) f->$group$_group = (hid_t) 0; break; case 'u': case 'w': if (f_exists == 1) { - f->$group$_group = H5Gopen(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT); + if (H5Lexists(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT) > 0) f->$group$_group = H5Gopen(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT); + if (H5Lexists(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT) == 0) f->$group$_group = H5Gcreate(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } else { f->$group$_group = H5Gcreate(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); } break; } - if (f->$group$_group <= 0L) return TREXIO_INVALID_ID; + if (f->$group$_group < (hid_t) 0) return TREXIO_INVALID_ID; return TREXIO_SUCCESS; } @@ -442,7 +444,7 @@ for the JavaScript code in this tag. trexio_hdf5_t* f = (trexio_hdf5_t*) file; - H5Gclose(f->$group$_group); + if (f->$group$_group != (hid_t) 0) H5Gclose(f->$group$_group); f->$group$_group = 0; H5Fclose(f->file_id); @@ -456,8 +458,8 @@ for the JavaScript code in this tag.
trexio_exit_code
@@ -560,8 +562,8 @@ for the JavaScript code in this tag.
trexio_exit_code
@@ -694,8 +696,8 @@ for the JavaScript code in this tag.
Sparse data is stored using extensible datasets of HDF5. Extensibility is required @@ -896,8 +898,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
trexio_exit_code
@@ -1094,8 +1096,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
trexio_exit_code
@@ -1221,8 +1223,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
Note: in early versions of the HDF5 library (v < 1.10) unlinking an object was not working as expected
@@ -1262,8 +1264,8 @@ Thus, any corrupted/lost file space will remain in the first file. The use of
trexio_exit_code @@ -1524,7 +1526,7 @@ Thus, any corrupted/lost file space will remain in the first file. The use ofdiff --git a/templator_text.html b/templator_text.html index 5b2a567..7d6a93e 100644 --- a/templator_text.html +++ b/templator_text.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + - TEXT back end @@ -311,29 +311,29 @@ for the JavaScript code in this tag.Table of Contents
-
- 1. TEXT back end +
- 1. TEXT back end
-
- 1.1. Template for group-related structures in text back end
-- 1.2. Template for general structure in text back end
-- 1.3. Initialize function (constant part)
-- 1.4. Deinitialize function (templated part)
-- 1.5. Template for text read a group
-- 1.6. Template for text flush a group
-- 1.7. Template for text free memory
-- 1.8. Template for has/read/write a numerical attribute
-- 1.9. Template for has/read/write a dataset of numerical data
-- 1.10. Template for has/read/write a dataset of strings
-- 1.11. Template for has/read/write a string attribute
-- 1.12. Template for has/read/write the dataset of sparse data
-- 1.13. Template for text delete a group (UNSAFE mode)
+- 1.1. Template for group-related structures in text back end
+- 1.2. Template for general structure in text back end
+- 1.3. Initialize function (constant part)
+- 1.4. Deinitialize function (templated part)
+- 1.5. Template for text read a group
+- 1.6. Template for text flush a group
+- 1.7. Template for text free memory
+- 1.8. Template for has/read/write a numerical attribute
+- 1.9. Template for has/read/write a dataset of numerical data
+- 1.10. Template for has/read/write a dataset of strings
+- 1.11. Template for has/read/write a string attribute
+- 1.12. Template for has/read/write the dataset of sparse data
+- 1.13. Template for text delete a group (UNSAFE mode)
The "file" produced by the text back end is a directory with one @@ -354,8 +354,8 @@ The file is written when closed, or when the flush function is called.
typedef struct $group$_s { @@ -374,8 +374,8 @@ The file is written when closed, or when the flush function is called.
typedef struct trexio_text_s { @@ -388,8 +388,8 @@ The file is written when closed, or when the flush function is called.
trexio_exit_code
@@ -532,8 +532,8 @@ The file is written when closed, or when the flush function is called.
trexio_exit_code
@@ -555,8 +555,8 @@ The file is written when closed, or when the flush function is called.
$group$_t* @@ -857,8 +857,8 @@ trexio_text_read_$group$ (trexio_text_t*
trexio_exit_code @@ -922,8 +922,8 @@ trexio_text_read_$group$ (trexio_text_t*
Memory is allocated when reading. The following function frees memory. @@ -970,8 +970,8 @@ Memory is allocated when reading. The following function frees memory.
trexio_exit_code
@@ -1034,8 +1034,8 @@ Memory is allocated when reading. The following function frees memory.
The group_dset
array is assumed allocated with the appropriate size.
@@ -1131,8 +1131,8 @@ The group_dset
array is assumed allocated with the appropriate size
The group_dset
array is assumed allocated with the appropriate size.
@@ -1233,8 +1233,8 @@ The group_dset
array is assumed allocated with the appropriate size
trexio_exit_code
@@ -1308,8 +1308,8 @@ The group_dset
array is assumed allocated with the appropriate size
Each sparse array is stored in a separate .txt
file due to the fact that sparse I/O has to be decoupled
@@ -1583,8 +1583,8 @@ User provides indices and values of the sparse array as two separate variables.
trexio_exit_code
@@ -1615,7 +1615,7 @@ User provides indices and values of the sparse array as two separate variables.
As we expect our files to be archived in open-data repositories, we @@ -417,7 +417,7 @@ which have participated to the creation of the file, a list of authors of the file, and a textual description.
-