diff --git a/README.html b/README.html index 331e892..8f7637f 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -309,13 +309,14 @@ for the JavaScript code in this tag.

TREXIO source code documentation

- +

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/examples.html b/examples.html index 588b4de..bd4819b 100644 --- a/examples.html +++ b/examples.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Examples @@ -333,24 +333,24 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Accessing sparse quantities

+
+

1 Accessing sparse quantities

-
-

1.1 Fortran

+
+

1.1 Fortran

program print_energy
@@ -413,8 +413,8 @@ One needs to read from the TREXIO file:
 
-
-

1.1.1 Declare Temporary variables

+
+

1.1.1 Declare Temporary variables

integer                       :: i, j, k, l, m
@@ -429,8 +429,8 @@ One needs to read from the TREXIO file:
 
-
-

1.1.2 Obtain the name of the TREXIO file from the command line, and open it for reading

+
+

1.1.2 Obtain the name of the TREXIO file from the command line, and open it for reading

call getarg(1, filename)
@@ -446,8 +446,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
 
-
-

1.1.3 Read the nuclear repulsion energy

+
+

1.1.3 Read the nuclear repulsion energy

rc = trexio_read_nucleus_repulsion(f, E_nn)
@@ -461,8 +461,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
 
-
-

1.1.4 Read the number of molecular orbitals

+
+

1.1.4 Read the number of molecular orbitals

rc = trexio_read_mo_num(f, n)
@@ -476,8 +476,8 @@ f = trexio_open (filename, 'r', TREXIO_HDF5
 
-
-

1.1.5 Allocate memory

+
+

1.1.5 Allocate memory

allocate( D(n,n), h0(n,n) )
@@ -489,8 +489,8 @@ W(:,:,:,:) = 0.d0
 
-
-

1.1.6 Read one-electron quantities

+
+

1.1.6 Read one-electron quantities

rc = trexio_has_mo_1e_int_core_hamiltonian(f)
@@ -522,8 +522,8 @@ rc = trexio_read_rdm_1e(f, D)
 
-
-

1.1.7 Read two-electron quantities

+
+

1.1.7 Read two-electron quantities

Reading is done with OpenMP. Each thread reads its own buffer, and @@ -539,8 +539,8 @@ to be protected in the critical section when modified.

-
-
1.1.7.1 Electron repulsion integrals
+
+
1.1.7.1 Electron repulsion integrals
rc = trexio_has_mo_2e_int_eri(f)
@@ -589,8 +589,8 @@ icount = BUFSIZE
 
-
-
1.1.7.2 Reduced density matrix
+
+
1.1.7.2 Reduced density matrix
rc = trexio_has_rdm_2e(f)
@@ -634,8 +634,8 @@ icount = bufsize
 
-
-

1.1.8 Compute the energy

+
+

1.1.8 Compute the energy

As \((n,m)\) 2D arrays are stored in memory as \((\n times m)\) 1D @@ -669,8 +669,8 @@ E = E + E_nn

-
-

1.1.9 Terminate

+
+

1.1.9 Terminate

  deallocate( D, h0, G, W )
@@ -685,7 +685,7 @@ E = E + E_nn
 

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/index.html b/index.html index 331e892..8f7637f 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -309,13 +309,14 @@ for the JavaScript code in this tag.

TREXIO source code documentation

- +

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/templator_front.html b/templator_front.html index 929fef7..7a60bc5 100644 --- a/templator_front.html +++ b/templator_front.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Front end API @@ -333,137 +333,137 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 Coding conventions

+
+

1 Coding conventions

  • integer types will be defined using types given in stdint.h
  • @@ -478,8 +478,8 @@ for the JavaScript code in this tag.
-
-

1.1 Memory allocation

+
+

1.1 Memory allocation

Memory allocation of structures can be facilitated by using the @@ -514,8 +514,8 @@ The maximum string size for the filenames is 4096 characters.

-
-

2 Front end

+
+

2 Front end

All calls to TREXIO are thread-safe. @@ -523,10 +523,10 @@ TREXIO front end is modular, which simplifies implementation of new back ends.

-
-

2.1 Error handling

+
+

2.1 Error handling

- +
@@ -767,8 +767,8 @@ and the corresponding message are not propagated to the source code. -
-

2.1.1 Decoding errors

+
+

2.1.1 Decoding errors

The trexio_string_of_error converts an exit code into a string. The @@ -794,8 +794,8 @@ and the corresponding message are not propagated to the source code.

-
-
2.1.1.1 C source code
+
+
2.1.1.1 C source code
const char*
@@ -906,8 +906,8 @@ and the corresponding message are not propagated to the source code.
 
-
-
2.1.1.2 Fortran interface
+
+
2.1.1.2 Fortran interface
interface
@@ -923,8 +923,8 @@ and the corresponding message are not propagated to the source code.
 
-
-
2.1.1.3 Python interface
+
+
2.1.1.3 Python interface
class Error(Exception):
@@ -963,8 +963,8 @@ and the corresponding message are not propagated to the source code.
 
-
-

2.2 Back ends

+
+

2.2 Back ends

TREXIO has several back ends: @@ -988,8 +988,8 @@ lines that correspond to the TREXIO_JSON back end (not implemented

-
-

2.2.1 C

+
+

2.2.1 C

typedef int32_t back_end_t;
@@ -1032,8 +1032,8 @@ This is useful due to the fact that HDF5 back end can be disabled at configure s
 
-
-

2.2.2 Fortran

+
+

2.2.2 Fortran

  integer(trexio_backend), parameter :: TREXIO_HDF5 = 0
@@ -1059,8 +1059,8 @@ The function below is a Fortran interface for the aforementioned C-compatible 
 
-
-

2.2.3 Python

+
+

2.2.3 Python

# define TREXIO back ends
@@ -1074,8 +1074,8 @@ The function below is a Fortran interface for the aforementioned C-compatible 
 
-
-

2.3 Read/write behavior

+
+

2.3 Read/write behavior

Every time a reading function is called, the data is read from the @@ -1103,8 +1103,8 @@ concurrent programs, the behavior is not specified.

-
-

2.4 TREXIO file type

+
+

2.4 TREXIO file type

trexio_s is the the main type for TREXIO files, visible to the users @@ -1138,8 +1138,8 @@ TREXIO files will have as a first argument the TREXIO file handle.

-
-

2.4.1 TREXIOFile Python class

+
+

2.4.1 TREXIOFile Python class

class File:
@@ -1212,8 +1212,8 @@ TREXIO files will have as a first argument the TREXIO file handle.
 
-
-

2.5 Polymorphism of the file handle

+
+

2.5 Polymorphism of the file handle

Polymorphism of the trexio_t type is handled by ensuring that the @@ -1232,8 +1232,8 @@ corresponding types for all back ends can be safely casted to

-
-

2.6 File opening

+
+

2.6 File opening

trexio_open creates a new TREXIO file or opens existing one. @@ -1272,8 +1272,8 @@ renaming the .txt data files.

-
-

2.6.1 C

+
+

2.6.1 C

trexio_t*
@@ -1346,10 +1346,10 @@ renaming the .txt data files.
   result->one_based   = false;  // Need to be flipped in Fortran interface
   int irc = pthread_mutex_init ( &(result->thread_lock), NULL);
   if (irc != 0) {
+    if (rc_open != NULL) *rc_open = TREXIO_FAILURE;
     free(result);
     return NULL;
   }
-  assert (irc == 0);
 
   trexio_exit_code rc;
 
@@ -1459,8 +1459,8 @@ renaming the .txt data files.
 
-
-

2.6.2 Fortran

+
+

2.6.2 Fortran

interface
@@ -1478,8 +1478,8 @@ renaming the .txt data files.
 
-
-

2.6.3 Python

+
+

2.6.3 Python

def open(file_name: str, mode: str, back_end: int):
@@ -1527,8 +1527,8 @@ renaming the .txt data files.
 
-
-

2.6.4 Zero-based versus one-based arrays of indices

+
+

2.6.4 Zero-based versus one-based arrays of indices

Because arrays are zero-based in Fortran, we need to set a flag to @@ -1561,8 +1561,8 @@ know if we need to shift by 1 arrays of indices.

-
-

2.7 File closing

+
+

2.7 File closing

trexio_close closes an existing trexio_t file. @@ -1579,8 +1579,8 @@ output:

-
-

2.7.1 C

+
+

2.7.1 C

trexio_exit_code
@@ -1659,8 +1659,8 @@ output:
 
-
-

2.7.2 Fortran

+
+

2.7.2 Fortran

interface
@@ -1674,8 +1674,8 @@ output:
 
-
-

2.7.3 Python

+
+

2.7.3 Python

def close(trexio_file):
@@ -1697,12 +1697,12 @@ output:
 
-
-

3 Templates for front end

+
+

3 Templates for front end

-
-

3.1 Description

+
+

3.1 Description

Consider the following block of trex.json: @@ -1923,12 +1923,12 @@ value will result in TREXIO_INVALID_ARG_2 exit code.

-
-

3.2 Templates for front end has/read/write a single numerical attribute

+
+

3.2 Templates for front end has/read/write a single numerical attribute

-
-

3.2.1 Introduction

+
+

3.2.1 Introduction

This section concerns API calls related to numerical attributes, @@ -1999,8 +1999,8 @@ namely single value of int/float types.

-
-

3.2.2 C templates for front end

+
+

3.2.2 C templates for front end

The C templates that correspond to each of the abovementioned @@ -2014,12 +2014,12 @@ precision (see Table above).

-
-
3.2.2.1 Function declarations
+
+
3.2.2.1 Function declarations
-
-
3.2.2.2 Source code for double precision functions
+
+
3.2.2.2 Source code for double precision functions
trexio_exit_code
@@ -2088,8 +2088,8 @@ precision (see Table above).
 
-
-
3.2.2.3 Source code for single precision functions
+
+
3.2.2.3 Source code for single precision functions
trexio_exit_code
@@ -2165,8 +2165,8 @@ precision (see Table above).
 
-
-
3.2.2.4 Source code for default functions
+
+
3.2.2.4 Source code for default functions
trexio_exit_code
@@ -2223,8 +2223,8 @@ precision (see Table above).
 
-
-

3.2.3 Fortran templates for front end

+
+

3.2.3 Fortran templates for front end

The Fortran templates that provide an access to the C API calls from Fortran. @@ -2309,8 +2309,8 @@ These templates are based on the use of iso_c_binding. Pointers hav

-
-

3.2.4 Python templates for front end

+
+

3.2.4 Python templates for front end

def write_$group_num$(trexio_file, num_w: $group_num_py_dtype$) -> None:
@@ -2395,12 +2395,12 @@ These templates are based on the use of iso_c_binding. Pointers hav
 
-
-

3.3 Templates for front end has/read/write a dataset of numerical data

+
+

3.3 Templates for front end has/read/write a dataset of numerical data

-
-

3.3.1 Introduction

+
+

3.3.1 Introduction

This section concerns API calls related to datasets. @@ -2482,8 +2482,8 @@ This section concerns API calls related to datasets.

-
-

3.3.2 C templates for front end

+
+

3.3.2 C templates for front end

The C templates that correspond to each of the abovementioned functions can be found below. @@ -2494,12 +2494,12 @@ The basic (non-suffixed) API call on datasets deals with double precision (see T

-
-
3.3.2.1 Function declarations
+
+
3.3.2.1 Function declarations
-
-
3.3.2.2 Source code for double precision functions
+
+
3.3.2.2 Source code for double precision functions
trexio_exit_code
@@ -2595,7 +2595,7 @@ The basic (non-suffixed) API call on datasets deals with double precision (see T
     if ($group_dset$_p == NULL) return TREXIO_ALLOCATION_FAILED;
 
     for (uint64_t i=0; i<dim_size; ++i){
-      $group_dset$_p[i] -= ($group_dset_dtype_double$) 1;
+       $group_dset$_p[i] = $group_dset$[i] - ($group_dset_dtype_double$) 1;
     }
   }
 
@@ -2634,8 +2634,8 @@ The basic (non-suffixed) API call on datasets deals with double precision (see T
 
-
-
3.3.2.3 Source code for single precision functions
+
+
3.3.2.3 Source code for single precision functions
trexio_exit_code
@@ -2784,11 +2784,11 @@ The basic (non-suffixed) API call on datasets deals with double precision (see T
 
-
-
3.3.2.4 Source code for memory-safe functions
+
+
3.3.2.4 Source code for memory-safe functions
-
trexio_exit_code rc;
+
trexio_exit_code rc;
 int64_t $group_dset_dim$ = 0;
 
 /* Error handling for this call is added by the generator */
@@ -2944,8 +2944,8 @@ rc = trexio_read_$group_dset_dim$_64(file, &($group_dset_dim$));
 
-
-
3.3.2.5 Source code for default functions
+
+
3.3.2.5 Source code for default functions
trexio_exit_code
@@ -3023,8 +3023,8 @@ rc = trexio_read_$group_dset_dim$_64(file, &($group_dset_dim$));
 
-
-

3.3.3 Fortran templates for front end

+
+

3.3.3 Fortran templates for front end

The Fortran templates that provide an access to the C API calls from Fortran. @@ -3109,8 +3109,8 @@ These templates are based on the use of iso_c_binding. Pointers hav

-
-

3.3.4 Python templates for front end

+
+

3.3.4 Python templates for front end

def write_$group_dset$(trexio_file, dset_w) -> None:
@@ -3305,12 +3305,12 @@ These templates are based on the use of iso_c_binding. Pointers hav
 
-
-

3.4 Templates for front end has/read/write a dataset of sparse data

+
+

3.4 Templates for front end has/read/write a dataset of sparse data

-
-

3.4.1 Introduction

+
+

3.4.1 Introduction

Sparse data structures are used typically for large tensors such as @@ -3471,16 +3471,16 @@ This section concerns API calls related to sparse data structures.

-
-

3.4.2 C templates for front end

+
+

3.4.2 C templates for front end

-
-
3.4.2.1 Function declarations
+
+
3.4.2.1 Function declarations
-
-
3.4.2.2 Source code for default functions
+
+
3.4.2.2 Source code for default functions
trexio_exit_code trexio_read_safe_$group_dset$(trexio_t* const file,
@@ -3668,6 +3668,7 @@ This section concerns API calls related to sparse data structures.
     break;
 #else
     rc = TREXIO_BACK_END_MISSING;
+    break;
 #endif
 /*
   case TREXIO_JSON:
@@ -3724,8 +3725,8 @@ This section concerns API calls related to sparse data structures.
 
-
-

3.4.3 Fortran templates for front end

+
+

3.4.3 Fortran templates for front end

The Fortran templates that provide an access to the C API calls from Fortran. @@ -3820,8 +3821,8 @@ These templates are based on the use of iso_c_binding. Pointers hav

-
-

3.4.4 Python templates for front end

+
+

3.4.4 Python templates for front end

def write_$group_dset$(trexio_file: File, offset_file: int, buffer_size: int, indices: list, values: list) -> None:
@@ -4042,12 +4043,12 @@ These templates are based on the use of iso_c_binding. Pointers hav
 
-
-

3.5 Templates for front end has/read/write a dataset of strings

+
+

3.5 Templates for front end has/read/write a dataset of strings

-
-

3.5.1 Introduction

+
+

3.5.1 Introduction

This section concerns API calls related to datasets of strings. @@ -4087,8 +4088,8 @@ This section concerns API calls related to datasets of strings.

-
-

3.5.2 C templates for front end

+
+

3.5.2 C templates for front end

First parameter is the TREXIO file handle. Second parameter is the variable to be written/read @@ -4096,12 +4097,12 @@ to/from the TREXIO file (except for trexio_has_ functi

-
-
3.5.2.1 Function declarations
+
+
3.5.2.1 Function declarations
-
-
3.5.2.2 Source code for default functions
+
+
3.5.2.2 Source code for default functions
trexio_exit_code
@@ -4199,7 +4200,7 @@ to/from the TREXIO file (except for trexio_has_ functi
 
 
trexio_exit_code
-trexio_write_$group_dset$_low (trexio_t* const file, const char* dset_in, const int32_t max_str_len)
+trexio_write_$group_dset$_low (trexio_t* const file, char* dset_in, const int32_t max_str_len)
 {
 
   if (file  == NULL) return TREXIO_INVALID_ARG_1;
@@ -4232,7 +4233,7 @@ to/from the TREXIO file (except for trexio_has_ functi
   for(uint64_t i=0; i<dims[0]; i++) {
 
     char* pch;
-    pch = i == 0 ? strtok( (char*) dset_in, TREXIO_DELIM) : strtok(NULL, TREXIO_DELIM) ;
+    pch = i == 0 ? strtok(dset_in, TREXIO_DELIM) : strtok(NULL, TREXIO_DELIM) ;
 
     if (pch == NULL) {
       FREE(dset_str[0]);
@@ -4355,8 +4356,8 @@ to/from the TREXIO file (except for trexio_has_ functi
 
-
-

3.5.3 Fortran templates for front end

+
+

3.5.3 Fortran templates for front end

The Fortran templates that provide an access to the C API calls from Fortran. @@ -4452,8 +4453,8 @@ These templates are based on the use of iso_c_binding. Pointers hav

-
-

3.5.4 Python templates for front end

+
+

3.5.4 Python templates for front end

def write_$group_dset$(trexio_file, dset_w: list) -> None:
@@ -4569,12 +4570,12 @@ These templates are based on the use of iso_c_binding. Pointers hav
 
-
-

3.6 Templates for front end has/read/write a single string attribute

+
+

3.6 Templates for front end has/read/write a single string attribute

-
-

3.6.1 Introduction

+
+

3.6.1 Introduction

This section concerns API calls related to string attributes. @@ -4614,16 +4615,16 @@ This section concerns API calls related to string attributes.

-
-

3.6.2 C templates for front end

+
+

3.6.2 C templates for front end

-
-
3.6.2.1 Function declarations
+
+
3.6.2.1 Function declarations
-
-
3.6.2.2 Source code for default functions
+
+
3.6.2.2 Source code for default functions
trexio_exit_code
@@ -4735,8 +4736,8 @@ This section concerns API calls related to string attributes.
 
-
-

3.6.3 Fortran templates for front end

+
+

3.6.3 Fortran templates for front end

The Fortran templates that provide an access to the C API calls from Fortran. @@ -4813,8 +4814,8 @@ These templates are based on the use of iso_c_binding. Pointers hav

-
-

3.6.4 Python templates for front end

+
+

3.6.4 Python templates for front end

def write_$group_str$(trexio_file, str_w: str) -> None:
@@ -4904,8 +4905,8 @@ These templates are based on the use of iso_c_binding. Pointers hav
 
-
-

4 Fortran helper/wrapper functions

+
+

4 Fortran helper/wrapper functions

The function below adapts the original C-based trexio_open for Fortran. @@ -5040,7 +5041,7 @@ two code are identical, i.e. if the assert statement pass.

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/templator_hdf5.html b/templator_hdf5.html index 76a5165..c87001d 100644 --- a/templator_hdf5.html +++ b/templator_hdf5.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + HDF5 back end @@ -311,29 +311,29 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 HDF5 back end

+
+

1 HDF5 back end

-
-

1.1 Template for HDF5 definitions

+
+

1.1 Template for HDF5 definitions

#define $GROUP$_GROUP_NAME          "$group$"
@@ -345,8 +345,8 @@ for the JavaScript code in this tag.
 
-
-

1.2 Template for HDF5 structures

+
+

1.2 Template for HDF5 structures

typedef struct trexio_hdf5_s {
@@ -360,8 +360,8 @@ for the JavaScript code in this tag.
 
-
-

1.3 Template for HDF5 init/deinit

+
+

1.3 Template for HDF5 init/deinit

trexio_exit_code
@@ -441,8 +441,8 @@ for the JavaScript code in this tag.
 
-
-

1.4 Template for HDF5 has/read/write the numerical attribute

+
+

1.4 Template for HDF5 has/read/write the numerical attribute

trexio_exit_code
@@ -536,8 +536,8 @@ for the JavaScript code in this tag.
 
-
-

1.5 Template for HDF5 has/read/write the dataset of numerical data

+
+

1.5 Template for HDF5 has/read/write the dataset of numerical data

trexio_exit_code
@@ -561,7 +561,6 @@ for the JavaScript code in this tag.
   hid_t dspace_id = H5Dget_space(dset_id);
   // get the rank and dimensions of the dataset
   int rrank = H5Sget_simple_extent_dims(dspace_id, ddims, NULL);
-
   // check that dimensions are consistent
   if (rrank != (int) rank) {
     FREE(ddims);
@@ -660,8 +659,8 @@ for the JavaScript code in this tag.
 
-
-

1.6 Template for HDF5 has/read/write the dataset of sparse data

+
+

1.6 Template for HDF5 has/read/write the dataset of sparse data

Sparse data is stored using extensible datasets of HDF5. Extensibility is required @@ -683,13 +682,13 @@ due to the fact that the sparse data will be written in chunks of user-defined s trexio_hdf5_t* f = (trexio_hdf5_t*) file; hid_t index_dtype; - void* index_p; + void* index_p = NULL; uint64_t size_ranked = (uint64_t) size * $group_dset_rank$; /* Determine the optimal type for storing indices depending on the size_max (usually mo_num or ao_num) */ if (size_max < UINT8_MAX) { uint8_t* index = CALLOC(size_ranked, uint8_t); if (index == NULL) return TREXIO_ALLOCATION_FAILED; - for (int64_t i=0; i<size_ranked; ++i){ + for (uint64_t i=0; i<size_ranked; ++i){ index[i] = (uint8_t) index_sparse[i]; } index_p = index; @@ -697,7 +696,7 @@ due to the fact that the sparse data will be written in chunks of user-defined s } else if (size_max < UINT16_MAX) { uint16_t* index = CALLOC(size_ranked, uint16_t); if (index == NULL) return TREXIO_ALLOCATION_FAILED; - for (int64_t i=0; i<size_ranked; ++i){ + for (uint64_t i=0; i<size_ranked; ++i){ index[i] = (uint16_t) index_sparse[i]; } index_p = index; @@ -714,8 +713,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s const hsize_t chunk_v_dims[1] = {size}; /* Indices and values are stored as 2 independent datasets in the HDF5 file */ - char dset_index_name[256] = "\0"; - char dset_value_name[256] = "\0"; + char dset_index_name[256]; + char dset_value_name[256]; /* Build the names of the datasets */ strncpy(dset_index_name, $GROUP_DSET$_NAME "_indices", 256); strncpy(dset_value_name, $GROUP_DSET$_NAME "_values", 256); @@ -773,8 +772,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s const trexio_hdf5_t* f = (const trexio_hdf5_t*) file; /* Indices and values are stored as 2 independent datasets in the HDF5 file */ - char dset_index_name[256] = "\0"; - char dset_value_name[256] = "\0"; + char dset_index_name[256]; + char dset_value_name[256]; /* Build the names of the datasets */ strncpy(dset_index_name, $GROUP_DSET$_NAME "_indices", 256); strncpy(dset_value_name, $GROUP_DSET$_NAME "_values", 256); @@ -824,7 +823,7 @@ due to the fact that the sparse data will be written in chunks of user-defined s hsize_t ddims[1] = {0}; // get the rank and dimensions of the dataset - int rrank = H5Sget_simple_extent_dims(fspace_id, ddims, NULL); + H5Sget_simple_extent_dims(fspace_id, ddims, NULL); H5Dclose(dset_id); H5Sclose(fspace_id); @@ -862,8 +861,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s

-
-

1.7 Template for HDF5 has/read/write the dataset of strings

+
+

1.7 Template for HDF5 has/read/write the dataset of strings

trexio_exit_code
@@ -897,7 +896,6 @@ due to the fact that the sparse data will be written in chunks of user-defined s
 
   // get the rank of the dataset in a file
   int rrank = H5Sget_simple_extent_dims(dspace, ddims, NULL);
-
   if (rrank != (int) rank) {
     FREE(ddims);
     H5Dclose(dset_id);
@@ -1068,8 +1066,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
 
-
-

1.8 Template for HDF5 has/read/write the string attribute

+
+

1.8 Template for HDF5 has/read/write the string attribute

trexio_exit_code
@@ -1090,7 +1088,6 @@ due to the fact that the sparse data will be written in chunks of user-defined s
   const hid_t ftype_id = H5Aget_type(str_id);
   if (ftype_id <= 0) return TREXIO_INVALID_ID;
   uint64_t sdim = H5Tget_size(ftype_id);
-  if (sdim <= 0) return TREXIO_FAILURE;
   sdim++;                         /* Make room for null terminator */
 
   const hid_t mem_id = H5Tcopy(H5T_C_S1);
@@ -1192,8 +1189,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
 
-
-

1.9 Helper functions

+
+

1.9 Helper functions

trexio_exit_code
@@ -1272,6 +1269,12 @@ due to the fact that the sparse data will be written in chunks of user-defined s
 
   // get the rank and dimensions of the dataset
   int rrank = H5Sget_simple_extent_dims(fspace, ddims, NULL);
+  if (rrank != h5_rank) {
+    H5Sclose(fspace);
+    H5Dclose(dset_id);
+    return TREXIO_FAILURE;
+  }
+
   ddims[0] += chunk_dims[0];
 
   // extend the dset size
@@ -1348,6 +1351,12 @@ due to the fact that the sparse data will be written in chunks of user-defined s
    */
   hsize_t ddims[1] = {0};
   int rrank = H5Sget_simple_extent_dims(fspace_id, ddims, NULL);
+  if (rrank != h5_rank) {
+    H5Sclose(fspace_id);
+    H5Dclose(dset_id);
+    return TREXIO_FAILURE;
+  }
+
   hsize_t max_offset = offset_file[0] + size_read[0];
 
   int is_EOF = 0;
@@ -1361,8 +1370,8 @@ due to the fact that the sparse data will be written in chunks of user-defined s
   }
 
   // special case when reading int indices
-  int64_t size_ranked = (int64_t) size_read[0];
-  void* index_p;
+  uint64_t size_ranked = (uint64_t) size_read[0];
+  void* index_p = NULL;
   // read the datatype from the dataset and compare with the pre-defined values
   hid_t dtype = H5Dget_type(dset_id);
   if (is_index == 1) {
@@ -1418,13 +1427,13 @@ due to the fact that the sparse data will be written in chunks of user-defined s
   if (is_index == 1) {
     if (H5Tequal(dtype, H5T_NATIVE_UINT8) > 0) {
       uint8_t* index = (uint8_t*) index_p;
-      for (int64_t i=0; i<size_ranked; ++i){
+      for (uint64_t i=0; i<size_ranked; ++i){
         ((int32_t*)data_sparse)[i] = (int32_t) index[i];
       }
       FREE(index_p);
     } else if (H5Tequal(dtype, H5T_NATIVE_UINT16) > 0) {
       uint16_t* index = (uint16_t*) index_p;
-      for (int64_t i=0; i<size_ranked; ++i){
+      for (uint64_t i=0; i<size_ranked; ++i){
         ((int32_t*)data_sparse)[i] = (int32_t) index[i];
       }
       FREE(index_p);
@@ -1443,7 +1452,7 @@ due to the fact that the sparse data will be written in chunks of user-defined s
 

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/templator_text.html b/templator_text.html index ad9852c..f8d8325 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,28 +311,28 @@ for the JavaScript code in this tag.

Table of Contents

-
-

1 TEXT back end

+
+

1 TEXT back end

The "file" produced by the text back end is a directory with one @@ -353,8 +353,8 @@ The file is written when closed, or when the flush function is called.

-
-

1.1 Template for group-related structures in text back end

+
+

1.1 Template for group-related structures in text back end

typedef struct $group$_s {
@@ -373,8 +373,8 @@ The file is written when closed, or when the flush function is called.
 
-
-

1.2 Template for general structure in text back end

+
+

1.2 Template for general structure in text back end

typedef struct trexio_text_s {
@@ -387,8 +387,8 @@ The file is written when closed, or when the flush function is called.
 
-
-

1.3 Initialize function (constant part)

+
+

1.3 Initialize function (constant part)

trexio_exit_code
@@ -519,8 +519,8 @@ The file is written when closed, or when the flush function is called.
 
-
-

1.4 Deinitialize function (templated part)

+
+

1.4 Deinitialize function (templated part)

trexio_exit_code
@@ -542,8 +542,8 @@ The file is written when closed, or when the flush function is called.
 
-
-

1.5 Template for text read struct

+
+

1.5 Template for text read struct

$group$_t*
@@ -593,7 +593,7 @@ trexio_text_read_$group$ (trexio_text_t* Read the dimensioning variables */
-    int rc;
+    int rc = 0;
     // START REPEAT GROUP_DSET_ALL
     rc = fscanf(f, "%1023s", buffer);
     if ((rc != 1) || (strcmp(buffer, "rank_$group_dset$") != 0)) {
@@ -640,9 +640,9 @@ trexio_text_read_$group$ (trexio_text_t* END REPEAT GROUP_DSET_ALL
 
-    unsigned int local_isSet;
     // START REPEAT GROUP_NUM
     /* Read data */
+    unsigned int $group_num$_isSet;
     rc = fscanf(f, "%1023s", buffer);
     assert(!((rc != 1) || (strcmp(buffer, "$group_num$_isSet") != 0)));
     if ((rc != 1) || (strcmp(buffer, "$group_num$_isSet") != 0)) {
@@ -652,9 +652,9 @@ trexio_text_read_$group$ (trexio_text_t* return NULL;
     }
 
-    /* additional parameter local_isSet is needed to suppress warning when fscanf into bool variable using %u or %d */
-    rc = fscanf(f, "%u", &(local_isSet));
-    $group$->$group_num$_isSet = (bool) local_isSet;
+    /* additional parameter $group_num$_isSet is needed to suppress warning when fscanf into bool variable using %u or %d */
+    rc = fscanf(f, "%u", &($group_num$_isSet));
+    $group$->$group_num$_isSet = (bool) $group_num$_isSet;
     assert(!(rc != 1));
     if (rc != 1) {
       FREE(buffer);
@@ -835,8 +835,8 @@ trexio_text_read_$group$ (trexio_text_t* 
 
-
-

1.6 Template for text flush struct

+
+

1.6 Template for text flush struct

trexio_exit_code
@@ -901,8 +901,8 @@ trexio_text_read_$group$ (trexio_text_t* 
 
-
-

1.7 Template for text free memory

+
+

1.7 Template for text free memory

Memory is allocated when reading. The following function frees memory. @@ -947,8 +947,8 @@ Memory is allocated when reading. The following function frees memory.

-
-

1.8 Template for has/read/write the numerical attribute

+
+

1.8 Template for has/read/write the numerical attribute

trexio_exit_code
@@ -1011,8 +1011,8 @@ Memory is allocated when reading. The following function frees memory.
 
-
-

1.9 Template for has/read/write the dataset of numerical data

+
+

1.9 Template for has/read/write the dataset of numerical data

The group_dset array is assumed allocated with the appropriate size. @@ -1108,8 +1108,8 @@ The group_dset array is assumed allocated with the appropriate size

-
-

1.10 Template for has/read/write the dataset of strings

+
+

1.10 Template for has/read/write the dataset of strings

The group_dset array is assumed allocated with the appropriate size. @@ -1210,8 +1210,8 @@ The group_dset array is assumed allocated with the appropriate size

-
-

1.11 Template for has/read/write the string attribute

+
+

1.11 Template for has/read/write the string attribute

trexio_exit_code
@@ -1285,8 +1285,8 @@ The group_dset array is assumed allocated with the appropriate size
 
-
-

1.12 Template for has/read/write the dataset of sparse data

+
+

1.12 Template for has/read/write the dataset of sparse data

Each sparse array is stored in a separate .txt file due to the fact that sparse I/O has to be decoupled @@ -1333,7 +1333,7 @@ User provides indices and values of the sparse array as two separate variables. CURRENTLY NO OFFSET IS USED WHEN WRITING ! */ int64_t line_length = 0L; - char format_str[256] = "\0"; + char format_str[256]; /* Determine the optimal type for storing indices depending on the size_max (usually mo_num or ao_num) */ if (size_max < UINT8_MAX) { @@ -1357,7 +1357,7 @@ User provides indices and values of the sparse array as two separate variables. /* Write the data in the file and check the return code of fprintf to verify that > 0 bytes have been written */ int rc; - for (uint64_t i=0UL; i<size; ++i) { + for (uint64_t i=0UL; i < (uint64_t) size; ++i) { rc = fprintf(f, format_str, $group_dset_sparse_indices_printf$, *(value_sparse + i)); @@ -1445,9 +1445,9 @@ User provides indices and values of the sparse array as two separate variables. int rc; char buffer[1024]; uint64_t count = 0UL; - for (uint64_t i=0UL; i<size; ++i) { + for (uint64_t i=0UL; i < (uint64_t) size; ++i) { - memset(buffer,0,sizeof(buffer)); + memset(buffer, 0, sizeof(buffer)); if(fgets(buffer, 1023, f) == NULL){ @@ -1563,7 +1563,7 @@ User provides indices and values of the sparse array as two separate variables.

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate

diff --git a/trex.html b/trex.html index 5798cd4..5e9f731 100644 --- a/trex.html +++ b/trex.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + TREX Configuration file @@ -333,33 +333,33 @@ for the JavaScript code in this tag.

Table of Contents

@@ -409,8 +409,8 @@ fetched using multiple function calls to perform I/O on buffers.

-
-

1 Metadata (metadata group)

+
+

1 Metadata (metadata group)

As we expect our files to be archived in open-data repositories, we @@ -420,7 +420,7 @@ which have participated to the creation of the file, a list of authors of the file, and a textual description.

-
+
@@ -487,15 +487,15 @@ authors of the file, and a textual description. -
-

2 Electron (electron group)

+
+

2 Electron (electron group)

We consider wave functions expressed in the spin-free formalism, where the number of ↑ and ↓ electrons is fixed.

-
+
@@ -534,15 +534,15 @@ the number of ↑ and ↓ electrons is fixed. -
-

3 Nucleus (nucleus group)

+
+

3 Nucleus (nucleus group)

The nuclei are considered as fixed point charges. Coordinates are given in Cartesian \((x,y,z)\) format.

-
+
@@ -609,8 +609,8 @@ given in Cartesian \((x,y,z)\) format. -
-

4 Effective core potentials (ecp group)

+
+

4 Effective core potentials (ecp group)

An effective core potential (ECP) \(V_A^{\text{ECP}}\) replacing the @@ -643,7 +643,7 @@ The functions \(V_{A\ell}\) are parameterized as: See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006 for more info.

-
+
@@ -741,8 +741,8 @@ The latter causes issues when written before ang_mom in the TREXIO

-
-

4.1 Example

+
+

4.1 Example

For example, consider H2 molecule with the following @@ -805,8 +805,8 @@ power = [

-
-

5 Basis set (basis group)

+
+

5 Basis set (basis group)

We consider here basis functions centered on nuclei. Hence, we enable @@ -859,7 +859,7 @@ If the the basis function is not considered normalized, \(\mathcal{N}_s=1\). All the basis set parameters are stored in one-dimensional arrays:

-
+
@@ -953,8 +953,8 @@ All the basis set parameters are stored in one-dimensional arrays:
-
-

5.1 Example

+
+

5.1 Example

For example, consider H2 with the following basis set (in GAMESS @@ -1032,8 +1032,8 @@ prim_factor =

-
-

6 Atomic orbitals (ao group)

+
+

6 Atomic orbitals (ao group)

Going from the atomic basis set to AOs implies a systematic @@ -1081,13 +1081,13 @@ shell, as in the GAMESS convention where

In such a case, one should set the normalization of the shell (in -the Basis set section) to \(\mathcal{N}_{z^2}\), which is the +the Basis set section) to \(\mathcal{N}_{z^2}\), which is the normalization factor of the atomic orbitals in spherical coordinates. The normalization factor of the \(xy\) function which should be introduced here should be \(\frac{\mathcal{N}_{xy}}{\mathcal{N}_{z^2}}\).

- +
@@ -1139,8 +1139,8 @@ introduced here should be \(\frac{\mathcal{N}_{xy}}{\mathcal{N}_{z^2}}\).
-
-

6.1 One-electron integrals (ao_1e_int group)

+
+

6.1 One-electron integrals (ao_1e_int group)

  • \[ \hat{V}_{\text{ne}} = \sum_{A=1}^{N_\text{nucl}} @@ -1158,7 +1158,7 @@ The one-electron integrals for a one-electron operator \(\hat{O}\) are over atomic orbitals.

    - +
    @@ -1225,8 +1225,8 @@ over atomic orbitals. -
    -

    6.2 Two-electron integrals (ao_2e_int group)

    +
    +

    6.2 Two-electron integrals (ao_2e_int group)

    The two-electron integrals for a two-electron operator \(\hat{O}\) are @@ -1247,7 +1247,7 @@ notation. \mathbf{r}_j \vert)}{\vert \mathbf{r}_i - \mathbf{r}_j \vert} \] : electron-electron long range potential -

    +
    @@ -1287,10 +1287,10 @@ notation. -
    -

    7 Molecular orbitals (mo group)

    +
    +

    7 Molecular orbitals (mo group)

    -
    +
    @@ -1356,8 +1356,8 @@ notation.
-
-

7.1 One-electron integrals (mo_1e_int group)

+
+

7.1 One-electron integrals (mo_1e_int group)

The operators as the same as those defined in the @@ -1365,7 +1365,7 @@ The operators as the same as those defined in the the basis of molecular orbitals.

- +
@@ -1432,8 +1432,8 @@ the basis of molecular orbitals. -
-

7.2 Two-electron integrals (mo_2e_int group)

+
+

7.2 Two-electron integrals (mo_2e_int group)

The operators as the same as those defined in the @@ -1441,7 +1441,7 @@ The operators as the same as those defined in the the basis of molecular orbitals.

-
+
@@ -1481,13 +1481,13 @@ the basis of molecular orbitals. -
-

8 TODO Slater determinants

+
+

8 TODO Slater determinants

-
-

9 Reduced density matrices (rdm group)

+
+

9 Reduced density matrices (rdm group)

-
+
@@ -1563,7 +1563,7 @@ the basis of molecular orbitals.

Author: TREX-CoE

-

Created: 2022-01-07 Fri 07:58

+

Created: 2022-01-07 Fri 10:04

Validate