From c63a23ae9a78d6603fe960aa1dadf6a189ece456 Mon Sep 17 00:00:00 2001 From: q-posev <45995097+q-posev@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:20:14 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20TREX-CoE?= =?UTF-8?q?/trexio@dab4310efac9b735a25b6725b67b7e3a577efb3f=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.html | 4 +- examples.html | 82 +++--- index.html | 4 +- templator_front.html | 670 +++++++++++++++++++++++-------------------- templator_hdf5.html | 70 ++--- templator_text.html | 88 +++--- trex.html | 134 ++++----- 7 files changed, 554 insertions(+), 498 deletions(-) diff --git a/README.html b/README.html index 3b10641..f055db0 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 @@ -551,8 +551,8 @@ The maximum string size for the filenames is 4096 characters.
All calls to TREXIO are thread-safe. @@ -560,10 +560,10 @@ TREXIO front end is modular, which simplifies implementation of new back ends.
trexio_read_determinant_coefficient_size |
Get the number of the coefficients | + +
trexio_get_int64_num |
+Get the number of int64 bit fields per determinant | +
trexio_exit_code +trexio_get_int64_num(trexio_t* const file, int32_t* const num) +{ + + if (file == NULL) return TREXIO_INVALID_ARG_1; + if (num == NULL) return TREXIO_INVALID_ARG_2; + + /* Read the number of mos */ + int64_t mo_num = 0L; + trexio_exit_code rc = trexio_read_mo_num_64(file, &mo_num); + if (rc != TREXIO_SUCCESS) return rc; + if (mo_num == 0L) return TREXIO_INVALID_NUM; + + /* Compute how many integer numbers is needed to represent a determinant */ + int32_t int_num = 0; + int_num = (mo_num - 1L)/64 + 1; + + *num = int_num; + + return TREXIO_SUCCESS; +} ++
trexio_exit_code trexio_read_determinant_list (trexio_t* const file, const int64_t offset_file, int64_t* const buffer_size_read, int64_t* const dset) @@ -5722,17 +5752,10 @@ This section concerns API calls related to Slater determinants. if (dset == NULL) return TREXIO_INVALID_ARG_2; if (trexio_has_determinant_list(file) != TREXIO_SUCCESS) return TREXIO_DSET_MISSING; - trexio_exit_code rc; - - /* Read the number of mos */ - int64_t mo_num = 0L; - rc = trexio_read_mo_num_64(file, &mo_num); + /* Get the number of int bit fields per determinant */ + int32_t int_num = 0; + trexio_exit_code rc = trexio_get_int64_num(file, &int_num); if (rc != TREXIO_SUCCESS) return rc; - if (mo_num == 0L) return TREXIO_INVALID_NUM; - - /* Compute how many integer numbers is needed to represent a determinant */ - uint32_t int_num = 0; - int_num = (mo_num - 1)/64 + 1; uint32_t rank = 2; uint64_t det_size = (uint64_t) (*buffer_size_read); @@ -5770,11 +5793,12 @@ This section concerns API calls related to Slater determinants. if (rc == TREXIO_END) *buffer_size_read = eof_read_size; return rc; - } ++
trexio_exit_code trexio_read_determinant_coefficient (trexio_t* const file, const int64_t offset_file, int64_t* const buffer_size_read, double* const dset) { @@ -5820,13 +5844,15 @@ This section concerns API calls related to Slater determinants. if (rc == TREXIO_END) *buffer_size_read = eof_read_size; return rc; - } ++
trexio_exit_code trexio_read_determinant_coefficient_size(trexio_t* const file, int64_t* const size_max) { + if (file == NULL) return TREXIO_INVALID_ARG_1; if (size_max == NULL) return TREXIO_INVALID_ARG_2; if (trexio_has_determinant_coefficient(file) != TREXIO_SUCCESS) return TREXIO_DSET_MISSING; @@ -5853,8 +5879,11 @@ This section concerns API calls related to Slater determinants. return TREXIO_FAILURE; /* Impossible case */ } } ++
trexio_exit_code trexio_read_safe_determinant_list (trexio_t* const file, const int64_t offset_file, int64_t* const buffer_size_read, int64_t* const dset_out, const int64_t dim_out) { return trexio_read_determinant_list(file, offset_file, buffer_size_read, dset_out); @@ -5876,17 +5905,10 @@ This section concerns API calls related to Slater determinants. if (file == NULL) return TREXIO_INVALID_ARG_1; if (dset == NULL) return TREXIO_INVALID_ARG_2; - trexio_exit_code rc; - - /* Read the number of mos */ - int64_t mo_num = 0L; - rc = trexio_read_mo_num_64(file, &mo_num); + /* Get the number of int bit fields per determinant */ + int32_t int_num = 0; + trexio_exit_code rc = trexio_get_int64_num(file, &int_num); if (rc != TREXIO_SUCCESS) return rc; - if (mo_num == 0L) return TREXIO_INVALID_NUM; - - /* Compute how many integer numbers is needed to represent a determinant */ - uint32_t int_num = 0; - int_num = (mo_num - 1)/64 + 1; uint32_t rank = 2; uint64_t dims[2] = {buffer_size, int_num*2UL}; @@ -5939,8 +5961,11 @@ This section concerns API calls related to Slater determinants. return TREXIO_SUCCESS; } ++
trexio_exit_code trexio_write_determinant_coefficient (trexio_t* const file, const int64_t offset_file, const int64_t buffer_size, const double* dset) { @@ -5975,8 +6000,11 @@ This section concerns API calls related to Slater determinants. return TREXIO_FAILURE; } ++
trexio_exit_code trexio_write_safe_determinant_list (trexio_t* const file, const int64_t offset_file, const int64_t buffer_size, const int64_t* dset_in, const int64_t dim_in) { return trexio_write_determinant_list(file, offset_file, buffer_size, dset_in); @@ -6053,8 +6081,8 @@ This section concerns API calls related to Slater determinants.
The Fortran
templates that provide an access to the C
API calls from Fortran.
@@ -6197,13 +6225,22 @@ These templates are based on the use of iso_c_binding
. Pointers hav
integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_determinant_coefficient
end interface
+
+interface
+ integer(trexio_exit_code) function trexio_get_int64_num (trex_file, num) bind(C)
+ use, intrinsic :: iso_c_binding
+ import
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int32_t), intent(out) :: num
+ end function trexio_get_int64_num
+end interface
def write_determinant_list(trexio_file: File, offset_file: int, buffer_size: int, determinants: list) -> None: @@ -6274,6 +6311,7 @@ These templates are based on the use ofiso_c_binding
. Pointers hav if rc != TREXIO_SUCCESS: raise Error(rc) + def write_determinant_coefficient(trexio_file: File, offset_file: int, buffer_size: int, coefficients: list) -> None: """Write the determinant coefficients in the TREXIO file. @@ -6362,8 +6400,7 @@ These templates are based on the use ofiso_c_binding
. Pointers hav # read the number of determinants already in the file det_num = read_determinant_num(trexio_file) # calculate the int_num (number of int bit fields per determinant) - mo_num = read_mo_num(trexio_file) - int_num = 2*int((mo_num-1)/64+1) + int_num = 2 * get_int64_num(trexio_file) # additional modification needed to avoid allocating more memory than needed if EOF will be reached during read overflow = offset_file + buffer_size - det_num @@ -6392,6 +6429,7 @@ These templates are based on the use ofiso_c_binding
. Pointers hav return (dets_reshaped, n_int_read, eof_flag) + def read_determinant_coefficient(trexio_file: File, offset_file: int, buffer_size: int) -> tuple: """Read determinant_coefficient from the TREXIO file. @@ -6477,13 +6515,30 @@ These templates are based on the use ofiso_c_binding
. Pointers hav raise Error(rc) return num + + +def get_int64_num(trexio_file) -> int: + """Compute the number of int64 bit fields corresponding to the TREXIO file. + + Parameter is a ~TREXIO File~ object that has been created by a call to ~open~ function. + + Returns: + ~num~: int + Number of int64 bit fields per determinant. + + Raises: + - Exception from AssertionError if TREXIO return code ~rc~ is different from TREXIO_SUCCESS and prints the error message using trexio_string_of_error. + - Exception from some other error (e.g. RuntimeError). + """ + + rc, num = pytr.trexio_get_int64_num(trexio_file.pytrexio_s) + if rc != TREXIO_SUCCESS: + raise Error(rc) + + return num
-#+endsrc -
-def has_determinant_list(trexio_file) -> bool: """Check that determinant_list exists in the TREXIO file. @@ -6504,6 +6559,7 @@ These templates are based on the use ofiso_c_binding
. Pointers hav return rc == TREXIO_SUCCESS + def has_determinant_coefficient(trexio_file) -> bool: """Check that determinant_coefficient exists in the TREXIO file. @@ -6528,8 +6584,8 @@ These templates are based on the use ofiso_c_binding
. Pointers hav
This section contains general helper functions like trexio_info
.
@@ -6563,8 +6619,8 @@ of the determinant and returns two list of orbitals each corresponding to a diff
trexio_exit_code trexio_info(void); @@ -6759,8 +6815,8 @@ of the determinant and returns two list of orbitals each corresponding to a diff
interface
@@ -6801,8 +6857,8 @@ of the determinant and returns two list of orbitals each corresponding to a diff
def info(): @@ -6878,8 +6934,8 @@ of the determinant and returns two list of orbitals each corresponding to a diff
The function below adapts the original C-based trexio_open
for Fortran.
@@ -7020,7 +7076,7 @@ two code are identical, i.e. if the assert
statement pass.
else
call trexio_string_of_error(trexio_rc, str)
print *, trim(str)
- error stop 1
+ stop 1
endif
end subroutine trexio_assert
@@ -7031,7 +7087,7 @@ two code are identical, i.e. if the assert
statement pass.
#define $GROUP$_GROUP_NAME "$group$" @@ -339,8 +339,8 @@ for the JavaScript code in this tag.
typedef struct trexio_hdf5_s { @@ -353,8 +353,8 @@ for the JavaScript code in this tag.
trexio_exit_code
@@ -459,8 +459,8 @@ for the JavaScript code in this tag.
trexio_exit_code
@@ -564,8 +564,8 @@ for the JavaScript code in this tag.
trexio_exit_code
@@ -699,8 +699,8 @@ for the JavaScript code in this tag.
Sparse data is stored using extensible datasets of HDF5. Extensibility is required @@ -903,8 +903,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
trexio_exit_code
@@ -1102,8 +1102,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
trexio_exit_code
@@ -1230,8 +1230,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
@@ -1271,8 +1271,8 @@ Thus, any corrupted/lost file space will remain in the first file. The use of
Each array is stored in a separate HDF5 dataset due to the fact that determinant I/O has to be decoupled. @@ -1525,8 +1525,8 @@ Size specifies the number of data items (e.g. determinants) to process.
trexio_exit_code
@@ -1789,7 +1789,7 @@ Size specifies the number of data items (e.g. determinants) to process.
typedef struct $group$_s { @@ -366,8 +366,8 @@ The file is written when closed, or when the flush function is called.
typedef struct trexio_text_s { @@ -380,8 +380,8 @@ The file is written when closed, or when the flush function is called.
trexio_exit_code
@@ -524,8 +524,8 @@ The file is written when closed, or when the flush function is called.
trexio_exit_code
@@ -547,8 +547,8 @@ The file is written when closed, or when the flush function is called.
$group$_t* @@ -849,8 +849,8 @@ trexio_text_read_$group$ (trexio_text_t*
trexio_exit_code @@ -914,8 +914,8 @@ trexio_text_read_$group$ (trexio_text_t*
Memory is allocated when reading. The following function frees memory. @@ -962,8 +962,8 @@ Memory is allocated when reading. The following function frees memory.
trexio_exit_code
@@ -1026,8 +1026,8 @@ Memory is allocated when reading. The following function frees memory.
The group_dset
array is assumed allocated with the appropriate size.
@@ -1123,8 +1123,8 @@ The group_dset
array is assumed allocated with the appropriate size
The group_dset
array is assumed allocated with the appropriate size.
@@ -1225,8 +1225,8 @@ The group_dset
array is assumed allocated with the appropriate size
trexio_exit_code
@@ -1300,8 +1300,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
@@ -1575,8 +1575,8 @@ User provides indices and values of the sparse array as two separate variables.
trexio_exit_code
@@ -1604,8 +1604,8 @@ User provides indices and values of the sparse array as two separate variables.
Each array is stored in a separate .txt
file due to the fact that determinant I/O has to be decoupled
@@ -2009,7 +2009,7 @@ Size specifies the number of data items, e.g. determinants.
As we expect our files to be archived in open-data repositories, we @@ -418,7 +418,7 @@ which have participated to the creation of the file, a list of authors of the file, and a textual description.
-