From 4ed3e0c6d02a0f16304f602531d22fd72ccb5b13 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 4 Jul 2022 11:22:31 +0200 Subject: [PATCH 01/13] Implement trexio_has_group templates --- src/templates_front/templator_front.org | 94 +++++++++++++++++++- src/templates_hdf5/templator_hdf5.org | 32 +++++++ src/templates_text/templator_text.org | 110 ++++++++++++++++++++++++ tools/generator.py | 2 +- 4 files changed, 236 insertions(+), 2 deletions(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 5a0e423..0947a0a 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -1755,6 +1755,98 @@ trexio_pre_close (trexio_t* file) considered dimensioning variables and cannot be negative or 0. An attempt to write negative or 0 value will result in ~TREXIO_INVALID_ARG_2~ exit code. +** Templates for front end has_group functions +*** Introduction + + This section concerns API calls related to TREXIO groups + + | Function name | Description | + |----------------------+-----------------------------------| + | ~trexio_has_$group$~ | Check if a group exists in a file | + +*** C templates for front end + + The ~C~ templates that correspond to each of the abovementioned + functions can be found below. First parameter is the ~TREXIO~ file + handle. + +**** Function declarations + + #+begin_src c :tangle hrw_group_front.h :exports none +trexio_exit_code trexio_has_$group$(trexio_t* const file); + #+end_src + +**** Source code + + #+begin_src c :tangle has_group_front.c +trexio_exit_code +trexio_has_$group$ (trexio_t* const file) +{ + + if (file == NULL) return TREXIO_INVALID_ARG_1; + + assert(file->back_end < TREXIO_INVALID_BACK_END); + + switch (file->back_end) { + + case TREXIO_TEXT: + return trexio_text_has_$group$(file); + + case TREXIO_HDF5: +#ifdef HAVE_HDF5 + return trexio_hdf5_has_$group$(file); +#else + return TREXIO_BACK_END_MISSING; +#endif +/* + case TREXIO_JSON: + return trexio_json_has_$group$(file); + break; +,*/ + } + + return TREXIO_FAILURE; +} + #+end_src + +*** Fortran templates for front end + + The ~Fortran~ templates that provide an access to the ~C~ API calls from Fortran. + These templates are based on the use of ~iso_c_binding~. Pointers have to be passed by value. + + #+begin_src f90 :tangle has_group_front_fortran.f90 +interface + integer(trexio_exit_code) function trexio_has_$group$ (trex_file) bind(C) + use, intrinsic :: iso_c_binding + import + integer(c_int64_t), intent(in), value :: trex_file + end function trexio_has_$group$ +end interface + #+end_src + +*** Python templates for front end + + #+begin_src python :tangle has_group_front.py +def has_$group$(trexio_file) -> bool: + """Check that $group$ group exists in the TREXIO file. + + Parameter is a ~TREXIO File~ object that has been created by a call to ~open~ function. + + Returns: + True if the variable exists, False otherwise + + Raises: + - trexio.Error if TREXIO return code ~rc~ is TREXIO_FAILURE and prints the error message using string_of_error. + - Exception from some other error (e.g. RuntimeError). + """ + + rc = pytr.trexio_has_$group$(trexio_file.pytrexio_s) + if rc == TREXIO_FAILURE: + raise Error(rc) + + return rc == TREXIO_SUCCESS + #+end_src + ** Templates for front end has/read/write a single numerical attribute *** Introduction @@ -3924,7 +4016,7 @@ def read_$group_dset$(trexio_file, dim = None) -> list: """ $group_dset_dim$ = read_$group_dset_dim$(trexio_file) - + dims_list = [$group_dset_dim_list$] dim_real = 1 for i in range($group_dset_rank$): diff --git a/src/templates_hdf5/templator_hdf5.org b/src/templates_hdf5/templator_hdf5.org index bdfaf61..535f077 100644 --- a/src/templates_hdf5/templator_hdf5.org +++ b/src/templates_hdf5/templator_hdf5.org @@ -179,6 +179,38 @@ trexio_hdf5_deinit (trexio_t* const file) } #+end_src +* Template for HDF5 has a group + + #+begin_src c :tangle hrw_group_hdf5.h :exports none +trexio_exit_code trexio_hdf5_has_$group$ (trexio_t* const file); + #+end_src + + + #+begin_src c :tangle has_group_hdf5.c +trexio_exit_code +trexio_hdf5_has_$group$ (trexio_t* const file) +{ + + if (file == NULL) return TREXIO_INVALID_ARG_1; + + const trexio_hdf5_t* f = (const trexio_hdf5_t*) file; + + struct H5G_info_t group_info; + + /* H5Gget_info return info about the HDF5 group as a group_info struct */ + herr_t status = H5Gget_info(f->$group$_group, &group_info); + if (status < 0) return TREXIO_FAILURE; + + /* If nlinks==0 --> the group is empty, i.e. non-existent */ + if (group_info.nlinks == (hsize_t) 0) { + return TREXIO_HAS_NOT; + } else { + return TREXIO_SUCCESS; + } + +} + #+end_src + * Template for HDF5 has/read/write a numerical attribute #+begin_src c :tangle hrw_attr_num_hdf5.h :exports none diff --git a/src/templates_text/templator_text.org b/src/templates_text/templator_text.org index 7ad22b1..d095346 100644 --- a/src/templates_text/templator_text.org +++ b/src/templates_text/templator_text.org @@ -112,6 +112,22 @@ trexio_exit_code trexio_text_inquire(const char* file_name); trexio_exit_code trexio_text_deinit(trexio_t* const file); trexio_exit_code trexio_text_lock(trexio_t* const file); trexio_exit_code trexio_text_unlock(trexio_t* const file); +bool trexio_text_file_exists(const char* file_name); + #+end_src + + #+begin_src c :tangle basic_text.c +bool +trexio_text_file_exists (const char* file_name) +{ + /* Check if the file with "file_name" exists */ + struct stat st; + + int rc = stat(file_name, &st); + + bool file_exists = rc == 0; + + return file_exists; +} #+end_src #+begin_src c :tangle basic_text.c @@ -493,6 +509,47 @@ trexio_text_read_$group$ (trexio_text_t* const file) } #+end_src +* Template for text has a group + + #+begin_src c :tangle hrw_group_text.h :exports none +trexio_exit_code trexio_text_has_$group$(trexio_t* const file); + #+end_src + + #+begin_src c :tangle has_group_text.c +trexio_exit_code +trexio_text_has_$group$ (trexio_t* const file) +{ + + if (file == NULL) return TREXIO_INVALID_ARG_1; + + /* Flush the group to make sure the group.txt file is created */ + if (file->mode != 'r') { + trexio_exit_code rc = trexio_text_flush_$group$((trexio_text_t*) file); + if (rc != TREXIO_SUCCESS) return TREXIO_FAILURE; + } + + /* Build the file name */ + char $group$_full_path[TREXIO_MAX_FILENAME_LENGTH]; + + const char* $group$_file_name = "/$group$.txt"; + + strncpy ($group$_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH); + strncat ($group$_full_path, $group$_file_name, + TREXIO_MAX_FILENAME_LENGTH-strlen($group$_file_name)); + + if ($group$_full_path[TREXIO_MAX_FILENAME_LENGTH-1] != '\0') return TREXIO_FAILURE; + + bool file_exists; + file_exists = trexio_text_file_exists($group$_full_path); + + if (file_exists) { + return TREXIO_SUCCESS; + } else { + return TREXIO_HAS_NOT; + } +} + #+end_src + * Template for text flush a group #+begin_src c :tangle flush_group_text.h :exports none @@ -1063,6 +1120,23 @@ trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, rc = fclose(f_wSize); if (rc != 0) return TREXIO_FILE_ERROR; + const char $group$_file_name[256] = "/$group$.txt"; + + memset (file_full_path, 0, TREXIO_MAX_FILENAME_LENGTH); + /* Copy directory name in file_full_path */ + strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH); + /* Append name of the file with sparse data */ + strncat (file_full_path, $group$_file_name, + TREXIO_MAX_FILENAME_LENGTH-strlen($group$_file_name)); + + bool file_exists = trexio_text_file_exists(file_full_path); + + /* Create an empty file for the trexio_text_has_group to work */ + if (!file_exists) { + FILE *fp = fopen(file_full_path, "ab+"); + fclose(fp); + } + /* Exit upon success */ return TREXIO_SUCCESS; } @@ -1533,6 +1607,24 @@ trexio_exit_code trexio_text_write_determinant_list(trexio_t* const file, rc = fclose(f); if (rc != 0) return TREXIO_FILE_ERROR; + /* Additional part for the trexio_text_has_group to work */ + const char det_file_name[256] = "/determinant.txt"; + + memset (file_full_path, 0, TREXIO_MAX_FILENAME_LENGTH); + /* Copy directory name in file_full_path */ + strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH); + /* Append name of the file with sparse data */ + strncat (file_full_path, det_file_name, + TREXIO_MAX_FILENAME_LENGTH-strlen(det_file_name)); + + bool file_exists = trexio_text_file_exists(file_full_path); + + /* Create an empty file for the trexio_text_has_group to work */ + if (!file_exists) { + FILE *fp = fopen(file_full_path, "ab+"); + fclose(fp); + } + /* Exit upon success */ return TREXIO_SUCCESS; } @@ -1602,6 +1694,24 @@ trexio_exit_code trexio_text_write_determinant_coefficient(trexio_t* const file, rc = fclose(f_wSize); if (rc != 0) return TREXIO_FILE_ERROR; + /* Additional part for the trexio_text_has_group to work */ + const char det_file_name[256] = "/determinant.txt"; + + memset (file_full_path, 0, TREXIO_MAX_FILENAME_LENGTH); + /* Copy directory name in file_full_path */ + strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH); + /* Append name of the file with sparse data */ + strncat (file_full_path, det_file_name, + TREXIO_MAX_FILENAME_LENGTH-strlen(det_file_name)); + + bool file_exists = trexio_text_file_exists(file_full_path); + + /* Create an empty file for the trexio_text_has_group to work */ + if (!file_exists) { + FILE *fp = fopen(file_full_path, "ab+"); + fclose(fp); + } + /* Exit upon success */ return TREXIO_SUCCESS; } diff --git a/tools/generator.py b/tools/generator.py index 9904921..22db593 100644 --- a/tools/generator.py +++ b/tools/generator.py @@ -65,7 +65,7 @@ for fname in files_todo['dset_sparse']: # populate group-related functions with mixed scheme for fname in files_todo['group']: # recursive scheme for delete_group functions - if 'delete' in fname: + if 'delete' in fname or 'has' in fname: recursive_populate_file(fname, template_paths, group_dict) # mixed (iterative+recursive) scheme [text backend] else: From 0bbe16efcedf14de4ae0adfb104fb565183cc5d8 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 4 Jul 2022 11:23:04 +0200 Subject: [PATCH 02/13] Adapt the TEXT back end builder script --- src/templates_text/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/templates_text/build.sh b/src/templates_text/build.sh index b5d73f6..fccd3d2 100644 --- a/src/templates_text/build.sh +++ b/src/templates_text/build.sh @@ -13,6 +13,9 @@ cat basic_text.h >> trexio_text.h cat hrw_determinant_text.h >> trexio_text.h cat *_determinant_text.c >> trexio_text.c +cat populated/pop_has_group_text.c >> trexio_text.c +cat populated/pop_hrw_group_text.h >> trexio_text.h + cat populated/pop_free_group_text.c >> trexio_text.c cat populated/pop_read_group_text.c >> trexio_text.c cat populated/pop_flush_group_text.c >> trexio_text.c From 405f19c4bc5732ebd49a2806ace359e90d718598 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 4 Jul 2022 11:23:47 +0200 Subject: [PATCH 03/13] Adapt the tests --- python/test/test_api.py | 24 +++++++++++++++++------- tests/io_dset_int_hdf5.c | 14 ++++++++++---- tests/io_dset_int_text.c | 14 ++++++++++---- tests/io_dset_sparse_hdf5.c | 15 +++++++++------ tests/io_dset_sparse_text.c | 8 ++++++++ tests/test_f.f90 | 12 ++++++++++++ 6 files changed, 66 insertions(+), 21 deletions(-) diff --git a/python/test/test_api.py b/python/test/test_api.py index e9eea8b..c156987 100644 --- a/python/test/test_api.py +++ b/python/test/test_api.py @@ -35,7 +35,7 @@ def test_void(): def test_orbital_list(): """Convert one determinant into a list of orbitals.""" orb_list_up, orb_list_dn = trexio.to_orbital_list_up_dn(int64_num, det_test) - assert orb_list_up[0] == 0 + assert orb_list_up[0] == 0 assert orb_list_dn[0] == 1 @@ -64,7 +64,7 @@ class TestIO: self.filename = filename if not mode: mode = self.mode - else: + else: self.mode = mode if not back_end: back_end = self.back_end @@ -73,7 +73,7 @@ class TestIO: self.test_file = trexio.File(filename, mode, back_end) assert self.test_file.exists - + def test_close(self): """Close the file.""" @@ -82,7 +82,7 @@ class TestIO: self.test_file.close() assert not self.test_file.isOpen - + def test_errors(self): """Test some exceptions based on trexio.Error class.""" self.open(filename='unsafe_' + self.filename, mode='w', back_end=self.back_end) @@ -103,7 +103,7 @@ class TestIO: trexio.write_nucleus_num(self.test_file, nucleus_num) assert trexio.has_nucleus_num(self.test_file) - + def test_str(self): """Write a string.""" self.open() @@ -133,7 +133,7 @@ class TestIO: """Write array of coordinates.""" self.open() if not trexio.has_nucleus_num(self.test_file): - self.test_num() + self.test_num() trexio.write_nucleus_coord(self.test_file, nucleus_coord) assert trexio.has_nucleus_coord(self.test_file) @@ -192,11 +192,21 @@ class TestIO: self.test_array_1D() self.test_array_2D() + assert trexio.has_nucleus(self.test_file) + trexio.delete_nucleus(self.test_file) assert not trexio.has_nucleus_num(self.test_file) assert not trexio.has_nucleus_charge(self.test_file) assert not trexio.has_nucleus_coord(self.test_file) + assert not trexio.has_nucleus(self.test_file) + + + def test_has_group(self): + """Check existense of a group.""" + self.open() + assert trexio.has_nucleus(self.test_file) + assert not trexio.has_rdm(self.test_file) def test_context_manager(self): @@ -315,6 +325,6 @@ class TestIO: def test_str_read(self): """Read a string.""" - self.open(mode='r') + self.open(mode='r') point_group_r = trexio.read_nucleus_point_group(self.test_file) assert point_group_r == point_group diff --git a/tests/io_dset_int_hdf5.c b/tests/io_dset_int_hdf5.c index 50a3988..42db22b 100644 --- a/tests/io_dset_int_hdf5.c +++ b/tests/io_dset_int_hdf5.c @@ -27,7 +27,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { // write numerical attribute in an empty file rc = trexio_write_basis_shell_num(file, num); assert (rc == TREXIO_SUCCESS); - + // write numerical (integer) dataset in a file rc = trexio_write_basis_nucleus_index(file, nucl_index); assert (rc == TREXIO_SUCCESS); @@ -51,10 +51,18 @@ static int test_has_dset (const char* file_name, const back_end_t backend) { /*================= START OF TEST ==================*/ - // open file + // open file file = trexio_open(file_name, 'r', backend, &rc); assert (file != NULL); + // check that the group exists + rc = trexio_has_basis(file); + assert(rc==TREXIO_SUCCESS); + + // check that the group does not exist + rc = trexio_has_mo(file); + assert(rc==TREXIO_HAS_NOT); + // check that the previously written dataset exists rc = trexio_has_basis_nucleus_index(file); assert (rc == TREXIO_SUCCESS); @@ -130,5 +138,3 @@ int main(void) { return 0; } - - diff --git a/tests/io_dset_int_text.c b/tests/io_dset_int_text.c index 456d206..d1386cc 100644 --- a/tests/io_dset_int_text.c +++ b/tests/io_dset_int_text.c @@ -27,7 +27,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) { // write numerical attribute in an empty file rc = trexio_write_basis_shell_num(file, num); assert (rc == TREXIO_SUCCESS); - + // write numerical (integer) dataset in a file rc = trexio_write_basis_nucleus_index(file, nucl_index); assert (rc == TREXIO_SUCCESS); @@ -51,10 +51,18 @@ static int test_has_dset (const char* file_name, const back_end_t backend) { /*================= START OF TEST ==================*/ - // open file + // open file file = trexio_open(file_name, 'r', backend, &rc); assert (file != NULL); + // check that the group exists + rc = trexio_has_basis(file); + assert(rc==TREXIO_SUCCESS); + + // check that the group does not exist + rc = trexio_has_mo(file); + assert(rc==TREXIO_HAS_NOT); + // check that the previously written dataset exists rc = trexio_has_basis_nucleus_index(file); assert (rc == TREXIO_SUCCESS); @@ -130,5 +138,3 @@ int main(void) { return 0; } - - diff --git a/tests/io_dset_sparse_hdf5.c b/tests/io_dset_sparse_hdf5.c index 67b8357..7e57ec6 100644 --- a/tests/io_dset_sparse_hdf5.c +++ b/tests/io_dset_sparse_hdf5.c @@ -86,6 +86,14 @@ static int test_has_dset_sparse (const char* file_name, const back_end_t backend assert (file != NULL); assert (rc == TREXIO_SUCCESS); + // check that the group exists + rc = trexio_has_mo_2e_int(file); + assert(rc==TREXIO_SUCCESS); + + // check that the group does not exist + rc = trexio_has_rdm(file); + assert(rc==TREXIO_HAS_NOT); + // first check that mo_2e_int_eri_lr (we only write non-lr component in this unit test) rc = trexio_has_mo_2e_int_eri_lr(file); assert(rc==TREXIO_HAS_NOT); @@ -147,7 +155,7 @@ static int test_read_dset_sparse (const char* file_name, const back_end_t backen assert(index_read[4*offset_data_read] == 4 * (int32_t) (offset_file_read-offset)); // now attempt to read so that one encounters end of file during reading (i.e. offset_file_read + chunk_read > size_max) - offset_file_read = 97; + offset_file_read = 97L; offset_data_read = 1; int64_t eof_read_size_check = SIZE - offset_file_read; // if offset_file_read=97 => only 3 integrals will be read out of total of 100 @@ -159,11 +167,6 @@ static int test_read_dset_sparse (const char* file_name, const back_end_t backen assert(chunk_read == eof_read_size_check); assert(index_read[4*size_r-1] == 0); assert(index_read[4*offset_data_read] == 4 * (int32_t) (offset_file_read-offset)); - /* - for(int i=0; i Date: Mon, 4 Jul 2022 11:24:30 +0200 Subject: [PATCH 04/13] Add the minimal pre-commit config --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fd16ba2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files From f3ab78376c6ccc1af06d4c0b6e7cbbd1d52ced23 Mon Sep 17 00:00:00 2001 From: q-posev Date: Mon, 4 Jul 2022 11:26:17 +0200 Subject: [PATCH 05/13] Update ChangeLog --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 13e9729..bbca1f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ CHANGES ======= +2.3 +--- + +- Added `trexio_has_group` functionality +- Added OCaml binding + 2.2 --- From 950ae7a50849c8f5e848de5dead665c2b31131de Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 15:06:19 +0200 Subject: [PATCH 06/13] make ocaml-install in Makefile.am --- Makefile.am | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 2bfe889..f119570 100644 --- a/Makefile.am +++ b/Makefile.am @@ -227,6 +227,22 @@ cppcheck.out: $(trexio_h) --language=c --std=c99 -rp --platform=unix64 \ -I../include *.c *.h 2>../$@ +################# +# OCaml binding # +################# + +ocaml/trexio/_build/default/lib/trexio.cma: + $(MAKE) -C ocaml/trexio + +ocaml: ocaml/trexio/_build/default/lib/trexio.a + +ocaml-install: ocaml/trexio/_build/default/lib/trexio.a + opam install ocaml/trexio + +################## +# Python binding # +################## + setup_py = $(srcdir)/python/setup.py setup_cfg = $(srcdir)/python/setup.cfg pytrexio_py = $(srcdir)/python/pytrexio/pytrexio.py @@ -278,6 +294,6 @@ CLEANFILES += $(pytrexio_c) \ python/src/*.c \ python/src/*.h -.PHONY: cppcheck python-test python-install python-sdist check-numpy FORCE +.PHONY: cppcheck python-test python-install python-sdist check-numpy FORCE ocaml endif From d23c3b3308ada9a2c74e854cd1e08d0bec7ca17d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 15:16:21 +0200 Subject: [PATCH 07/13] Forgot Makefile in previous commit --- ocaml/trexio/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ocaml/trexio/Makefile diff --git a/ocaml/trexio/Makefile b/ocaml/trexio/Makefile new file mode 100644 index 0000000..91d0b69 --- /dev/null +++ b/ocaml/trexio/Makefile @@ -0,0 +1,9 @@ +default: sources + dune build + +lib/trexio.ml: ../../trex.json read_json.py src/trexio.ml src/trexio.mli src/trexio_stubs.c + ./read_json.py + +sources: lib/trexio.ml + +.PHONY: sources default From 3b47f26b0a767e8ef56bec8aa2e4cf469aed88b7 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 15:17:50 +0200 Subject: [PATCH 08/13] Fix Makefile.am --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f119570..c28459d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -234,9 +234,9 @@ cppcheck.out: $(trexio_h) ocaml/trexio/_build/default/lib/trexio.cma: $(MAKE) -C ocaml/trexio -ocaml: ocaml/trexio/_build/default/lib/trexio.a +ocaml: ocaml/trexio/_build/default/lib/trexio.cma -ocaml-install: ocaml/trexio/_build/default/lib/trexio.a +ocaml-install: ocaml/trexio/_build/default/lib/trexio.cma opam install ocaml/trexio ################## From 72e44a918ea8ca6c79c43599f9a754d5e9034f68 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 16:14:20 +0200 Subject: [PATCH 09/13] Update repo name for OCaml --- ocaml/trexio/dune-project | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ocaml/trexio/dune-project b/ocaml/trexio/dune-project index 69f5bb4..be375e7 100644 --- a/ocaml/trexio/dune-project +++ b/ocaml/trexio/dune-project @@ -1,11 +1,12 @@ (lang dune 3.1) (name trexio) +(version 2.2.0) (generate_opam_files true) (source - (github trex-coe/trexio)) + (github trex-coe/trexio_ocaml)) (authors "Anthony Scemama " From 19c30fce53ff2e5ebf761dd736cf37c3d075ee44 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 16:56:45 +0200 Subject: [PATCH 10/13] Update dune file for OCaml --- ocaml/trexio/dune-project | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ocaml/trexio/dune-project b/ocaml/trexio/dune-project index be375e7..2248d22 100644 --- a/ocaml/trexio/dune-project +++ b/ocaml/trexio/dune-project @@ -25,8 +25,12 @@ (name trexio) (synopsis "Binding for the TREXIO Input/Output library") (description "TREXIO is a file format and library for storing wave functions and integrals for quantum chemistry.") - (depends ocaml dune) + (depends + dune + (dune-configurator :build) + (conf-pkg-config :build)) (tags - ("Quantum chemistry" "Library"))) + ("Quantum chemistry" "Library")) +) ; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project From d8e6f43ac192422484858def5544f4dbbd9abaa7 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 1 Jul 2022 19:41:05 +0200 Subject: [PATCH 11/13] Better packaging --- Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c28459d..830f1c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -146,7 +146,6 @@ check_PROGRAMS = $(TESTS) LDADD = src/libtrexio.la test_trexio_f = $(srcdir)/tests/trexio_f.f90 -CLEANFILES += $(test_trexio_f) $(test_trexio_f): $(trexio_f) cp $(trexio_f) $(test_trexio_f) From e953d15bbdfc298f6325127833ea249bd8107c6f Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 4 Jul 2022 12:55:09 +0200 Subject: [PATCH 12/13] Add has_group in OCaml --- ocaml/trexio/read_json.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ocaml/trexio/read_json.py b/ocaml/trexio/read_json.py index 94b2711..d41bc00 100755 --- a/ocaml/trexio/read_json.py +++ b/ocaml/trexio/read_json.py @@ -34,6 +34,17 @@ CAMLprim value caml_delete_{group}(value file) caml_failwith(trexio_string_of_error(rc)); } } + +CAMLprim value caml_has_{group}(value file) +{ + CAMLparam1(file); + trexio_exit_code rc = trexio_has_{group}( File_val(file) ); + if (rc == TREXIO_SUCCESS) { + CAMLreturn ( Val_bool(true) ); + } else { + CAMLreturn ( Val_bool(false) ); + } +} """ f.write( t.replace("{group}",group) ) @@ -437,7 +448,8 @@ def write_mli(data): f.write(content_pre) for group in data: - t = "val delete_{group}: trexio_file -> unit\n" + t = "val delete_{group}: trexio_file -> unit\n" + t += "val has_{group}: trexio_file -> bool\n" f.write( t.replace("{group}",group) ) for element in data[group]: @@ -526,7 +538,8 @@ def write_ml(data): f.write(content_pre) for group in data: - t = "external delete_{group}: trexio_file -> unit = \"caml_delete_{group}\"\n" + t = "external delete_{group}: trexio_file -> unit = \"caml_delete_{group}\"\n" + t += "external has_{group}: trexio_file -> bool = \"caml_has_{group}\"\n" f.write( t.replace("{group}",group) ) for element in data[group]: From c33e203a0b824df5c9860b9adb4a1239f95995a4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 4 Jul 2022 12:56:29 +0200 Subject: [PATCH 13/13] Update version in OCaml --- ocaml/trexio/dune-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocaml/trexio/dune-project b/ocaml/trexio/dune-project index 2248d22..7793cce 100644 --- a/ocaml/trexio/dune-project +++ b/ocaml/trexio/dune-project @@ -1,7 +1,7 @@ (lang dune 3.1) (name trexio) -(version 2.2.0) +(version 2.3.0) (generate_opam_files true)