mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-08-25 06:31:43 +02:00
commit
cdf25b4162
@ -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
|
||||
|
@ -50,11 +50,12 @@ typedef int32_t trexio_exit_code;
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "trexio.h"
|
||||
#include "trexio_s.h"
|
||||
#include "trexio_private.h"
|
||||
#include "trexio_s.h"
|
||||
#include "trexio_text.h"
|
||||
#include "trexio_hdf5.h"
|
||||
/*
|
||||
@ -71,6 +72,7 @@ typedef int32_t trexio_exit_code;
|
||||
#include "trexio.h"
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#+end_src
|
||||
|
||||
* Coding conventions
|
||||
@ -422,11 +424,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
|
||||
@ -459,11 +462,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);
|
||||
@ -510,16 +515,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);
|
||||
|
||||
@ -546,7 +550,6 @@ trexio_open(const char* file_name, const char mode,
|
||||
}
|
||||
|
||||
if (rc != TREXIO_SUCCESS) {
|
||||
free(result->file_name);
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
@ -572,7 +575,6 @@ trexio_open(const char* file_name, const char mode,
|
||||
}
|
||||
|
||||
if (rc != TREXIO_SUCCESS) {
|
||||
free(result->file_name);
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
@ -593,6 +595,34 @@ 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
|
||||
|
||||
#+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_set_one_based
|
||||
end interface
|
||||
#+end_src
|
||||
|
||||
** File closing
|
||||
|
||||
~trexio_close~ closes an existing ~trexio_t~ file.
|
||||
@ -636,7 +666,6 @@ trexio_close (trexio_t* file)
|
||||
}
|
||||
|
||||
if (rc != TREXIO_SUCCESS) {
|
||||
FREE(file->file_name);
|
||||
FREE(file);
|
||||
return rc;
|
||||
}
|
||||
@ -663,8 +692,6 @@ trexio_close (trexio_t* file)
|
||||
|
||||
/* Terminate front end */
|
||||
|
||||
FREE(file->file_name);
|
||||
|
||||
int irc = pthread_mutex_destroy( &(file->thread_lock) );
|
||||
|
||||
free(file);
|
||||
@ -1102,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;
|
||||
|
||||
@ -1110,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; i<rank; ++i){
|
||||
dim_size *= dims[i];
|
||||
}
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$[i] += ($group_dset_dtype_single$) 1;
|
||||
}
|
||||
}
|
||||
|
||||
return TREXIO_SUCCESS;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
@ -1143,30 +1185,56 @@ trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_doub
|
||||
|
||||
/* 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;
|
||||
|
||||
uint32_t rank = $group_dset_rank$;
|
||||
uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$};
|
||||
|
||||
$group_dset_dtype_double$* $group_dset$_p = $group_dset$;
|
||||
|
||||
/* Handle index type */
|
||||
if ($is_index$) {
|
||||
|
||||
uint64_t dim_size = 1;
|
||||
for (uint32_t i=0; i<rank; ++i){
|
||||
dim_size *= dims[i];
|
||||
}
|
||||
|
||||
$group_dset$_p = CALLOC(dim_size, $group_dset_dtype_double$);
|
||||
if ($group_dset$_p == NULL) return TREXIO_ALLOCATION_FAILED;
|
||||
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$_p[i] = $group_dset$_p[i] - ($group_dset_dtype_single$) 1;
|
||||
}
|
||||
}
|
||||
|
||||
assert(file->back_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
|
||||
|
||||
@ -1190,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; i<rank; ++i){
|
||||
for (uint32_t i=0; i<rank; ++i){
|
||||
dim_size *= dims[i];
|
||||
}
|
||||
|
||||
@ -1222,8 +1290,14 @@ trexio_read_$group_dset$_32 (trexio_t* const file, $group_dset_dtype_single$* co
|
||||
return rc;
|
||||
}
|
||||
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$[i] = ($group_dset_dtype_single$) $group_dset$_64[i];
|
||||
if ($is_index$) {
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$[i] = ($group_dset_dtype_single$) $group_dset$_64[i] + ($group_dset_dtype_single$) 1;
|
||||
}
|
||||
} else {
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$[i] = ($group_dset_dtype_single$) $group_dset$_64[i];
|
||||
}
|
||||
}
|
||||
|
||||
FREE($group_dset$_64);
|
||||
@ -1252,7 +1326,7 @@ trexio_write_$group_dset$_32 (trexio_t* const file, const $group_dset_dtype_sing
|
||||
uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$};
|
||||
|
||||
uint64_t dim_size = 1;
|
||||
for (unsigned int i=0; i<rank; ++i){
|
||||
for (uint32_t i=0; i<rank; ++i){
|
||||
dim_size *= dims[i];
|
||||
}
|
||||
|
||||
@ -1260,8 +1334,14 @@ trexio_write_$group_dset$_32 (trexio_t* const file, const $group_dset_dtype_sing
|
||||
if ($group_dset$_64 == NULL) return TREXIO_ALLOCATION_FAILED;
|
||||
|
||||
/* A type conversion from single precision to double reqired since back end only accepts 64-bit data */
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$_64[i] = ($group_dset_dtype_double$) $group_dset$[i];
|
||||
if ($is_index$) {
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$_64[i] = ($group_dset_dtype_double$) $group_dset$[i] - ($group_dset_dtype_double$) 1;
|
||||
}
|
||||
} else {
|
||||
for (uint64_t i=0; i<dim_size; ++i){
|
||||
$group_dset$_64[i] = ($group_dset_dtype_double$) $group_dset$[i];
|
||||
}
|
||||
}
|
||||
|
||||
assert(file->back_end < TREXIO_INVALID_BACK_END);
|
||||
@ -1535,13 +1615,22 @@ contains
|
||||
integer(8) function trexio_open (filename, mode, backend)
|
||||
use, intrinsic :: iso_c_binding
|
||||
implicit none
|
||||
character(len=*) :: filename
|
||||
character, intent(in), value :: mode
|
||||
character(len=*) :: filename
|
||||
character, intent(in), value :: mode
|
||||
integer(trexio_backend), 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
|
||||
rc = trexio_close(trexio_open)
|
||||
trexio_open = 0_8
|
||||
endif
|
||||
end function trexio_open
|
||||
#+end_src
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
104
trex.json
104
trex.json
@ -1,104 +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" , [] ]
|
||||
, "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" ] ]
|
||||
} ,
|
||||
|
||||
"ao": {
|
||||
"cartesian" : [ "int" , [] ]
|
||||
, "num" : [ "int" , [] ]
|
||||
, "shell" : [ "int" , [ "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" ] ]
|
||||
}
|
||||
|
||||
}
|
16
trex.org
16
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
|
||||
@ -198,12 +202,12 @@ written in C.
|
||||
| ~type~ | ~str~ | | Type of basis set: "Gaussian" or "Slater" |
|
||||
| ~num~ | ~int~ | | Total Number of shells |
|
||||
| ~prim_num~ | ~int~ | | Total number of primitives |
|
||||
| ~nucleus_index~ | ~int~ | ~(nucleus.num)~ | Index of the first shell of each nucleus ($A$) |
|
||||
| ~nucleus_index~ | ~index~ | ~(nucleus.num)~ | Index of the first shell of each nucleus ($A$) |
|
||||
| ~nucleus_shell_num~ | ~int~ | ~(nucleus.num)~ | Number of shells for each nucleus |
|
||||
| ~shell_ang_mom~ | ~int~ | ~(basis.num)~ | Angular momentum ~0:S, 1:P, 2:D, ...~ |
|
||||
| ~shell_prim_num~ | ~int~ | ~(basis.num)~ | Number of primitives in the shell ($N_{\text{prim}}$) |
|
||||
| ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) |
|
||||
| ~shell_prim_index~ | ~int~ | ~(basis.num)~ | Index of the first primitive in the complete list |
|
||||
| ~shell_prim_index~ | ~index~ | ~(basis.num)~ | Index of the first primitive in the complete list |
|
||||
| ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}) |
|
||||
| ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) |
|
||||
| ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) |
|
||||
@ -217,12 +221,12 @@ written in C.
|
||||
"type" : [ "str" , [] ]
|
||||
, "num" : [ "int" , [] ]
|
||||
, "prim_num" : [ "int" , [] ]
|
||||
, "nucleus_index" : [ "int" , [ "nucleus.num" ] ]
|
||||
, "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" : [ "int" , [ "basis.num" ] ]
|
||||
, "shell_prim_index" : [ "index" , [ "basis.num" ] ]
|
||||
, "exponent" : [ "float", [ "basis.prim_num" ] ]
|
||||
, "coefficient" : [ "float", [ "basis.prim_num" ] ]
|
||||
, "prim_factor" : [ "float", [ "basis.prim_num" ] ]
|
||||
@ -333,7 +337,7 @@ prim_factor =
|
||||
#+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")
|
||||
@ -344,7 +348,7 @@ prim_factor =
|
||||
"ao": {
|
||||
"cartesian" : [ "int" , [] ]
|
||||
, "num" : [ "int" , [] ]
|
||||
, "shell" : [ "int" , [ "ao.num" ] ]
|
||||
, "shell" : [ "index", [ "ao.num" ] ]
|
||||
, "normalization" : [ "float", [ "ao.num" ] ]
|
||||
} ,
|
||||
#+end_src
|
||||
|
Loading…
Reference in New Issue
Block a user