From 12a7454c0cff4d703432e4b7dcd5cd46eaf7d713 Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Tue, 18 Jan 2022 09:50:11 +0000
Subject: [PATCH 1/7] Fix cmake compilation.
This includes:
* Declare generated source files in include/ as GENERATED in
TREXIO_DEVEL mode.
* Generate include/config.h with version components from project
delcaration, and for good measure have src/templates_front/build.sh
set version components to 0 if not present.
---
src/CMakeLists.txt | 22 +++++++++++++++++++++-
src/templates_front/build.sh | 8 ++++----
tests/CMakeLists.txt | 4 ++++
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9e87cd9..b612608 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -91,6 +91,8 @@ FortranCInterface_VERIFY()
# Fortran module
set(TREXIO_MOD_FILE ${CMAKE_SOURCE_DIR}/include/trexio_f.f90)
+# Export to parent scope so tests directory picks this up.
+set(TREXIO_MOD_FILE ${TREXIO_MOD_FILE} PARENT_SCOPE)
# Add TREXIO Fortran module as a library.
add_library(trexio_f SHARED)
target_sources(trexio_f PUBLIC ${TREXIO_MOD_FILE})
@@ -114,10 +116,28 @@ if(TREXIO_DEVEL)
${TREXIO_PRIVATE_HEADERS}
${TREXIO_MOD_FILE}
COMMAND ./build_trexio.sh
- DEPENDS ${ORG_FILES}
+ DEPENDS ${ORG_FILES} ${CMAKE_SOURCE_DIR}/include/config.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools
COMMENT "Generating TREXIO source code from org-mode files."
VERBATIM)
+
+ set_source_files_properties(${TREXIO_SOURCES}
+ ${TREXIO_PUBLIC_HEADERS}
+ ${TREXIO_PRIVATE_HEADERS}
+ ${TREXIO_MOD_FILE}
+ PROPERTIES GENERATED TRUE)
+
+ add_custom_command(
+ OUTPUT ${CMAKE_SOURCE_DIR}/include/config.h
+ COMMAND bash -c "echo -e '#define TREXIO_PACKAGE_VERSION \"${PROJECT_VERSION}\"\\n#define TREXIO_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}\\n#define TREXIO_VERSION_MINOR ${PROJECT_VERSION_MINOR}\\n#define TREXIO_VERSION_PATCH ${PROJECT_VERSION_PATCH}' > config.h"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/include
+ COMMENT "Generates minimal include/config.h without using autotools."
+ VERBATIM)
+
+ set_source_files_properties(
+ ${CMAKE_SOURCE_DIR}/include/config.h
+ PROPERTIES GENERATED TRUE)
+
endif()
# ============= INSTALL TREXIO ==============
diff --git a/src/templates_front/build.sh b/src/templates_front/build.sh
index 4d75e07..895dff4 100644
--- a/src/templates_front/build.sh
+++ b/src/templates_front/build.sh
@@ -12,10 +12,10 @@ VERSION_PATCH_VAL=`grep "VERSION_PATCH" ../../include/config.h | cut -d " " -f 3
# grep some usefull constants from the config.h
echo "" >> trexio.h
-echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL}" >> trexio.h
-echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL}" >> trexio.h
-echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL}" >> trexio.h
-echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL}" >> trexio.h
+echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL:='0.0.0'}" >> trexio.h
+echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL:=0}" >> trexio.h
+echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL:=0}" >> trexio.h
+echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL:=0}" >> trexio.h
echo "" >> trexio.h
cat prefix_s_front.h > trexio_s.h
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 94fe414..4af2ac1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -44,4 +44,8 @@ endforeach()
# Add Fortran test and link it with trexio_f (Fortran module) library.
add_executable(test_f test_f.f90)
target_link_libraries(test_f PRIVATE trexio_f)
+if(TREXIO_DEVEL)
+ set_source_files_properties(${TREXIO_MOD_FILE}
+ PROPERTIES GENERATED TRUE)
+endif()
add_test(NAME test_f COMMAND $)
From f89e542f26a5a6a3bf6807d1df41864d3e50bf1d Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Tue, 18 Jan 2022 14:13:17 +0000
Subject: [PATCH 2/7] gitignore editor swap/backup files, suggested build
directory, build byproducts
---
.gitignore | 5 +++--
src/.gitignore | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2a962ab..ed98b3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,6 @@ m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
autom4te.cache/
-build-config/
ar-lib
compile
config.guess
@@ -23,7 +22,6 @@ config.h.in
config.h
depcomp
include/config.h.in
-include/config.h.in~
include/stamp-h1
install-sh
libtool
@@ -40,3 +38,6 @@ test-suite.log
*.h5
trexio-*.tar.gz
trex.json
+*~
+.*.swp
+/build*
diff --git a/src/.gitignore b/src/.gitignore
index 8847478..0ce847a 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -28,6 +28,7 @@ trexio_hdf5.c
trexio_f.f90
trexio.mod
+trexio.py
pytrexio.py
pytrexio_wrap.c
From 223f91a9b19a1319347c1cda41e09a4bc9efba60 Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Tue, 18 Jan 2022 14:38:48 +0000
Subject: [PATCH 3/7] README.md: added a bit more compilation help
---
README.md | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 127ee0a..7a3a26c 100644
--- a/README.md
+++ b/README.md
@@ -26,8 +26,9 @@ TREX library for efficient I/O.
7. `sudo make install`
-**Note: on systems with no `sudo` access, one can replace `./configure` with `./configure prefix=${PWD}/_install` in order to execute `make install/uninstall` commands without `sudo` privileges.**
+**Note: on systems with no `sudo` access, one can replace `./configure` with `./configure prefix=${PWD}/build` in order to execute `make install/uninstall` commands without `sudo` privileges.**
+**Note: when linking against an MPI-enabled HDF5 library one usually has to specify the MPI wrapper for the C compiler by adding, e.g., `CC=mpicc` to the `./configure` command.**
## Additional requirements (for developers):
@@ -56,6 +57,10 @@ The aforementioned instructions rely on [Autotools](https://www.gnu.org/software
4. `ctest` (or `make test`)
5. `sudo make install`
+**Note: on systems with no `sudo` access, one can add `-DCMAKE_INSTALL_PREFIX=build` as an argument to the `cmake` command so that `make install/uninstall` can be run without `sudo` privileges.**
+
+**Note: when linking against an MPI-enabled HDF5 library one usually has to specify the MPI wrapper for the C compiler by adding, e.g., `-DCMAKE_C_COMPILER=mpicc` to the `cmake` command.**
+
## Compilation without the HDF5 library
By default, the configuration step proceeds to search for the [HDF5 library](https://portal.hdfgroup.org/display/HDF5/HDF5).
From 0e9b9f190065e2809533ba9159bb0230a3fc7953 Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Tue, 18 Jan 2022 16:46:21 +0000
Subject: [PATCH 4/7] trexio_f: fix complaints from gfortran 11, including data
type issues
This includes:
* Define kind of arguments of bind(C) procedures using the relevant C
types provided by iso_c_binding.
* Replaced "call exit(1)" with "error stop 1".
* Fixed a couple of implicit type conversions between 4-/8-byte
integers.
The first two fix compilation of the Fortran module with -std=f2008.
---
src/templates_front/templator_front.org | 271 ++++++++++++------------
tools/generator_tools.py | 12 +-
2 files changed, 140 insertions(+), 143 deletions(-)
diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org
index 4f06b14..b45ca35 100644
--- a/src/templates_front/templator_front.org
+++ b/src/templates_front/templator_front.org
@@ -83,8 +83,8 @@ module trexio
use, intrinsic :: iso_c_binding
implicit none
- integer, parameter :: trexio_exit_code = 4
- integer, parameter :: trexio_backend = 4
+ integer, parameter :: trexio_exit_code = c_int
+ integer, parameter :: trexio_backend = c_int
character(kind=c_char), parameter :: TREXIO_DELIM = c_new_line
#+end_src
@@ -492,8 +492,8 @@ interface
subroutine trexio_string_of_error (error, string) bind(C, name='trexio_string_of_error_f')
use, intrinsic :: iso_c_binding
import
- integer (trexio_exit_code), intent(in), value :: error
- character, intent(out) :: string(<>)
+ integer(trexio_exit_code), intent(in), value :: error
+ character(kind=c_char), intent(out) :: string(<>)
end subroutine trexio_string_of_error
end interface
#+end_src
@@ -596,9 +596,9 @@ bool trexio_has_backend(back_end_t back_end) {
#+begin_src f90 :tangle prefix_fortran.f90
interface
- logical function trexio_has_backend (back_end) bind(C)
+ logical(c_bool) function trexio_has_backend (back_end) bind(C)
use, intrinsic :: iso_c_binding
- integer(4), intent(in), value :: back_end
+ integer(c_int), intent(in), value :: back_end
end function trexio_has_backend
end interface
#+end_src
@@ -958,11 +958,11 @@ trexio_open(const char* file_name, const char mode,
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer(8) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open")
+ integer(c_long) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open")
use, intrinsic :: iso_c_binding
import
character(kind=c_char), dimension(*) :: filename
- character, intent(in), value :: mode
+ character(kind=c_char), intent(in), value :: mode
integer(trexio_backend), intent(in), value :: backend
integer(trexio_exit_code), intent(out) :: rc_open
end function trexio_open_c
@@ -1036,9 +1036,9 @@ trexio_exit_code trexio_set_one_based(trexio_t* file)
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer function trexio_set_one_based(trex_file) bind(C)
+ integer(c_int) function trexio_set_one_based(trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_set_one_based
end interface
#+end_src
@@ -1139,9 +1139,9 @@ trexio_close (trexio_t* file)
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer function trexio_close (trex_file) bind(C)
+ integer(c_int) function trexio_close (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_close
end interface
#+end_src
@@ -1192,29 +1192,29 @@ def close(trexio_file):
example, in ~#define~ statements). More detailed description of
each variable can be found below:
- | Template variable | Description | Example |
- |--------------------------------+-----------------------------------------------------+-----------------------|
- | ~$group$~ | Name of the group | ~nucleus~ |
- | ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ |
- | ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ |
- | ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ |
- | ~$group_dset_rank$~ | Rank of the dataset | ~2~ |
- | ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ |
- | ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ |
- | ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ |
- | ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ |
- | ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ |
- | ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ |
- | ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ |
- | ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ |
- | ~$group_dset_dtype_double$~ | Double precision datatype of the dataset [C] | ~double/int64_t~ |
- | ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(8)/integer(4)~ |
- | ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(4)/integer(4)~ |
- | ~$group_dset_f_dtype_double$~ | Double precision datatype of the dataset [Fortran] | ~real(8)/integer(8)~ |
- | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ |
- | ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ |
- | ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ |
- | ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ |
+ | Template variable | Description | Example |
+ |--------------------------------+-----------------------------------------------------+-----------------------------------|
+ | ~$group$~ | Name of the group | ~nucleus~ |
+ | ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ |
+ | ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ |
+ | ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ |
+ | ~$group_dset_rank$~ | Rank of the dataset | ~2~ |
+ | ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ |
+ | ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ |
+ | ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ |
+ | ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ |
+ | ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ |
+ | ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ |
+ | ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ |
+ | ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ |
+ | ~$group_dset_dtype_double$~ | Double precision datatype of the dataset [C] | ~double/int64_t~ |
+ | ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(c_double)/integer(c_int)~ |
+ | ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(c_float)/integer(c_int)~ |
+ | ~$group_dset_f_dtype_double$~ | Double precision datatype of the dataset [Fortran] | ~real(c_double)/integer(c_long)~ |
+ | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ |
+ | ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ |
+ | ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ |
+ | ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ |
Some of the aforementioned template variables with ~group_dset~ prefix are duplicated with ~group_num~ prefix,
@@ -1467,9 +1467,9 @@ trexio_has_$group_num$ (trexio_t* const file)
#+begin_src f90 :tangle write_attr_num_64_front_fortran.f90
interface
- integer function trexio_write_$group_num$_64 (trex_file, num) bind(C)
+ integer(c_int) function trexio_write_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(in), value :: num
end function trexio_write_$group_num$_64
end interface
@@ -1477,9 +1477,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_64_front_fortran.f90
interface
- integer function trexio_read_$group_num$_64 (trex_file, num) bind(C)
+ integer(c_int) function trexio_read_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(out) :: num
end function trexio_read_$group_num$_64
end interface
@@ -1487,9 +1487,9 @@ end interface
#+begin_src f90 :tangle write_attr_num_32_front_fortran.f90
interface
- integer function trexio_write_$group_num$_32 (trex_file, num) bind(C)
+ integer(c_int) function trexio_write_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(in), value :: num
end function trexio_write_$group_num$_32
end interface
@@ -1497,9 +1497,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_32_front_fortran.f90
interface
- integer function trexio_read_$group_num$_32 (trex_file, num) bind(C)
+ integer(c_int) function trexio_read_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(out) :: num
end function trexio_read_$group_num$_32
end interface
@@ -1507,9 +1507,9 @@ end interface
#+begin_src f90 :tangle write_attr_num_def_front_fortran.f90
interface
- integer function trexio_write_$group_num$ (trex_file, num) bind(C)
+ integer(c_int) function trexio_write_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(in), value :: num
end function trexio_write_$group_num$
end interface
@@ -1517,9 +1517,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_def_front_fortran.f90
interface
- integer function trexio_read_$group_num$ (trex_file, num) bind(C)
+ integer(c_int) function trexio_read_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(out) :: num
end function trexio_read_$group_num$
end interface
@@ -1527,9 +1527,9 @@ end interface
#+begin_src f90 :tangle has_attr_num_front_fortran.f90
interface
- integer function trexio_has_$group_num$ (trex_file) bind(C)
+ integer(c_int) function trexio_has_$group_num$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_has_$group_num$
end interface
#+end_src
@@ -2130,9 +2130,9 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_data_64_front_fortran.f90
interface
- integer function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
+ integer(c_int) function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_64
end interface
@@ -2140,9 +2140,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_64_front_fortran.f90
interface
- integer function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
+ integer(c_int) function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_64
end interface
@@ -2150,9 +2150,9 @@ end interface
#+begin_src f90 :tangle write_dset_data_32_front_fortran.f90
interface
- integer function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
+ integer(c_int) function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_32
end interface
@@ -2160,9 +2160,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_32_front_fortran.f90
interface
- integer function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
+ integer(c_int) function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_32
end interface
@@ -2170,9 +2170,9 @@ end interface
#+begin_src f90 :tangle write_dset_data_def_front_fortran.f90
interface
- integer function trexio_write_$group_dset$ (trex_file, dset) bind(C)
+ integer(c_int) function trexio_write_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$
end interface
@@ -2180,9 +2180,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_def_front_fortran.f90
interface
- integer function trexio_read_$group_dset$ (trex_file, dset) bind(C)
+ integer(c_int) function trexio_read_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$
end interface
@@ -2190,9 +2190,9 @@ end interface
#+begin_src f90 :tangle has_dset_data_front_fortran.f90
interface
- integer function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -2739,82 +2739,82 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_sparse_front_fortran.f90
interface
- integer function trexio_write_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, value_sparse) bind(C)
+ integer(c_int) function trexio_write_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- integer(8), intent(in), value :: offset_file
- integer(8), intent(in), value :: buffer_size
- integer(4), intent(in) :: index_sparse(*)
- double precision, intent(in) :: value_sparse(*)
+ integer(c_long), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: offset_file
+ integer(c_long), intent(in), value :: buffer_size
+ integer(c_int), intent(in) :: index_sparse(*)
+ real(c_double), intent(in) :: value_sparse(*)
end function trexio_write_$group_dset$
end interface
interface
- integer function trexio_write_safe_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, index_size, &
- value_sparse, value_size) bind(C)
+ integer(c_int) function trexio_write_safe_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, index_size, &
+ value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- integer(8), intent(in), value :: offset_file
- integer(8), intent(in), value :: buffer_size
- integer(4), intent(in) :: index_sparse(*)
- integer(8), intent(in), value :: index_size
- double precision, intent(in) :: value_sparse(*)
- integer(8), intent(in), value :: value_size
+ integer(c_long), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: offset_file
+ integer(c_long), intent(in), value :: buffer_size
+ integer(c_int), intent(in) :: index_sparse(*)
+ integer(c_long), intent(in), value :: index_size
+ real(c_double), intent(in) :: value_sparse(*)
+ integer(c_long), intent(in), value :: value_size
end function trexio_write_safe_$group_dset$
end interface
#+end_src
#+begin_src f90 :tangle read_dset_sparse_front_fortran.f90
interface
- integer function trexio_read_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, value_sparse) bind(C)
+ integer(c_int) function trexio_read_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- integer(8), intent(in), value :: offset_file
- integer(8), intent(inout) :: buffer_size
- integer(4), intent(out) :: index_sparse(*)
- double precision, intent(out) :: value_sparse(*)
+ integer(c_long), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: offset_file
+ integer(c_long), intent(inout) :: buffer_size
+ integer(c_int), intent(out) :: index_sparse(*)
+ real(c_double), intent(out) :: value_sparse(*)
end function trexio_read_$group_dset$
end interface
interface
- integer function trexio_read_safe_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, index_size, &
- value_sparse, value_size) bind(C)
+ integer(c_int) function trexio_read_safe_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, index_size, &
+ value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- integer(8), intent(in), value :: offset_file
- integer(8), intent(inout) :: buffer_size
- integer(4), intent(out) :: index_sparse(*)
- integer(8), intent(in), value :: index_size
- double precision, intent(out) :: value_sparse(*)
- integer(8), intent(in), value :: value_size
+ integer(c_long), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: offset_file
+ integer(c_long), intent(inout) :: buffer_size
+ integer(c_int), intent(out) :: index_sparse(*)
+ integer(c_long), intent(in), value :: index_size
+ real(c_double), intent(out) :: value_sparse(*)
+ integer(c_long), intent(in), value :: value_size
end function trexio_read_safe_$group_dset$
end interface
#+end_src
#+begin_src f90 :tangle read_dset_sparse_size_front_fortran.f90
interface
- integer function trexio_read_$group_dset$_size (trex_file, &
- size_max) bind(C)
+ integer(c_int) function trexio_read_$group_dset$_size (trex_file, &
+ size_max) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- integer(8), intent(out) :: size_max
+ integer(c_long), intent(in), value :: trex_file
+ integer(c_long), intent(out) :: size_max
end function trexio_read_$group_dset$_size
end interface
#+end_src
#+begin_src f90 :tangle has_dset_sparse_front_fortran.f90
interface
- integer function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -3310,31 +3310,31 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_str_front_fortran.f90
interface
- integer function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
+ integer(c_int) function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- character, intent(in) :: dset(*)
- integer(4), intent(in), value :: max_str_len
+ integer(c_long), intent(in), value :: trex_file
+ character(kind=c_char), intent(in) :: dset(*)
+ integer(c_int), intent(in), value :: max_str_len
end function trexio_write_$group_dset$_low
end interface
#+end_src
#+begin_src f90 :tangle read_dset_str_front_fortran.f90
interface
- integer function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
+ integer(c_int) function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- character, intent(out) :: dset(*)
- integer(4), intent(in), value :: max_str_len
+ integer(c_long), intent(in), value :: trex_file
+ character(kind=c_char), intent(out) :: dset(*)
+ integer(c_int), intent(in), value :: max_str_len
end function trexio_read_$group_dset$_low
end interface
#+end_src
#+begin_src f90 :tangle has_dset_str_front_fortran.f90
interface
- integer function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -3348,7 +3348,7 @@ end interface
character, allocatable :: str_compiled(:)
integer(8) :: $group_dset_dim$
- integer :: rc
+ integer(4) :: rc
rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$)
if (rc /= TREXIO_SUCCESS) trexio_read_$group_dset$ = rc
@@ -3369,7 +3369,7 @@ end interface
#+end_src
#+begin_src f90 :tangle helper_write_dset_str_front_fortran.fh_90
- integer function trexio_write_$group_dset$ (trex_file, dset, max_str_len)
+ integer(4) function trexio_write_$group_dset$ (trex_file, dset, max_str_len)
implicit none
integer(8), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len
@@ -3626,33 +3626,33 @@ trexio_has_$group_str$ (trexio_t* const file)
#+begin_src f90 :tangle write_attr_str_front_fortran.f90
interface
- integer function trexio_write_$group_str$_c (trex_file, str, max_str_len) &
- bind(C, name="trexio_write_$group_str$")
+ integer(c_int) function trexio_write_$group_str$_c (trex_file, str, max_str_len) &
+ bind(C, name="trexio_write_$group_str$")
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- character, intent(in) :: str(*)
- integer(4), intent(in), value :: max_str_len
+ integer(c_long), intent(in), value :: trex_file
+ character(kind=c_char), intent(in) :: str(*)
+ integer(c_int), intent(in), value :: max_str_len
end function trexio_write_$group_str$_c
end interface
#+end_src
#+begin_src f90 :tangle read_attr_str_front_fortran.f90
interface
- integer function trexio_read_$group_str$_c (trex_file, str, max_str_len) &
- bind(C, name="trexio_read_$group_str$")
+ integer(c_int) function trexio_read_$group_str$_c (trex_file, str, max_str_len) &
+ bind(C, name="trexio_read_$group_str$")
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
- character, intent(out) :: str(*)
- integer(4), intent(in), value :: max_str_len
+ integer(c_long), intent(in), value :: trex_file
+ character(kind=c_char), intent(out) :: str(*)
+ integer(c_int), intent(in), value :: max_str_len
end function trexio_read_$group_str$_c
end interface
#+end_src
#+begin_src f90 :tangle has_attr_str_front_fortran.f90
interface
- integer function trexio_has_$group_str$ (trex_file) bind(C)
+ integer(c_int) function trexio_has_$group_str$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(8), intent(in), value :: trex_file
+ integer(c_long), intent(in), value :: trex_file
end function trexio_has_$group_str$
end interface
#+end_src
@@ -3814,7 +3814,7 @@ contains
integer, intent(in), value :: max_len_str ! maximum length of a string in an array
character(len=*), intent(in) :: str_array(*)
character(len=:), allocatable, intent(out) :: str_res
- integer :: i
+ integer(8) :: i
str_res = ''
do i = 1, max_num_str
@@ -3837,13 +3837,11 @@ contains
character(len=*), intent(inout) :: str_array(*)
character(len=max_len_str) :: tmp_str
- integer :: i, j, k, ind, offset
- integer(8) :: len_flat
+ integer(8) :: len_flat, i, j, k, ind
len_flat = (max_len_str+1)*max_num_str + 1
ind=1
- offset=1
do i=1,max_num_str
k = 1
tmp_str=''
@@ -3856,7 +3854,6 @@ contains
k = k + 1
enddo
str_array(i)=tmp_str
- offset=ind
enddo
end subroutine trexio_str2strarray
@@ -3882,7 +3879,7 @@ contains
else
call trexio_string_of_error(trexio_rc, str)
print *, trim(str)
- call exit(1)
+ error stop 1
endif
end subroutine trexio_assert
diff --git a/tools/generator_tools.py b/tools/generator_tools.py
index 420b3c0..72df212 100644
--- a/tools/generator_tools.py
+++ b/tools/generator_tools.py
@@ -494,9 +494,9 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
'default_prec' : '64',
f'group_{target}_dtype' : 'double',
f'group_{target}_h5_dtype' : 'native_double',
- f'group_{target}_f_dtype_default' : 'real(8)',
- f'group_{target}_f_dtype_double' : 'real(8)',
- f'group_{target}_f_dtype_single' : 'real(4)',
+ f'group_{target}_f_dtype_default' : 'real(c_double)',
+ f'group_{target}_f_dtype_double' : 'real(c_double)',
+ f'group_{target}_f_dtype_single' : 'real(c_float)',
f'group_{target}_dtype_default' : 'double',
f'group_{target}_dtype_double' : 'double',
f'group_{target}_dtype_single' : 'float',
@@ -509,9 +509,9 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
'default_prec' : '32',
f'group_{target}_dtype' : 'int64_t',
f'group_{target}_h5_dtype' : 'native_int64',
- f'group_{target}_f_dtype_default' : 'integer(4)',
- f'group_{target}_f_dtype_double' : 'integer(8)',
- f'group_{target}_f_dtype_single' : 'integer(4)',
+ f'group_{target}_f_dtype_default' : 'integer(c_int)',
+ f'group_{target}_f_dtype_double' : 'integer(c_long)',
+ f'group_{target}_f_dtype_single' : 'integer(c_int)',
f'group_{target}_dtype_default' : 'int32_t',
f'group_{target}_dtype_double' : 'int64_t',
f'group_{target}_dtype_single' : 'int32_t',
From 36a05c184dcf312bc43c0899633ffd87ce9fea0d Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Wed, 19 Jan 2022 10:02:34 +0000
Subject: [PATCH 5/7] Use cmake's configure_file() as suggested by Evgeny
Posenitskiy.
---
CMakeLists.txt | 4 +++-
include/cmake_config.h.in | 5 +++++
src/CMakeLists.txt | 11 -----------
3 files changed, 8 insertions(+), 12 deletions(-)
create mode 100644 include/cmake_config.h.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42e0030..7bec4cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
# Optional configure for developer mode to generate source code from org-mode files.
option(TREXIO_DEVEL "TREXIO developer mode (for code generation)." OFF)
-if(EXISTS ".git/config")
+if(EXISTS "${CMAKE_SOURCE_DIR}/.git/config")
set(TREXIO_DEVEL ON)
find_package(Python3 REQUIRED)
if(Python3_FOUND)
@@ -32,6 +32,8 @@ if(EXISTS ".git/config")
else()
message(FATAL_ERROR "EMACS not found. It is required to produce TREXIO source code from org-mode files.")
endif()
+ configure_file(${CMAKE_SOURCE_DIR}/include/cmake_config.h.in
+ ${CMAKE_SOURCE_DIR}/include/config.h)
endif()
# Set directories to be included at build time.
diff --git a/include/cmake_config.h.in b/include/cmake_config.h.in
new file mode 100644
index 0000000..109829c
--- /dev/null
+++ b/include/cmake_config.h.in
@@ -0,0 +1,5 @@
+#define PACKAGE_VERSION "@PROJECT_VERSION@"
+#define VERSION "@PROJECT_VERSION@"
+#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+#define VERSION_MINOR @PROJECT_VERSION_MINOR@
+#define VERSION_PATCH @PROJECT_VERSION_PATCH@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b612608..1e46d5f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -127,17 +127,6 @@ if(TREXIO_DEVEL)
${TREXIO_MOD_FILE}
PROPERTIES GENERATED TRUE)
- add_custom_command(
- OUTPUT ${CMAKE_SOURCE_DIR}/include/config.h
- COMMAND bash -c "echo -e '#define TREXIO_PACKAGE_VERSION \"${PROJECT_VERSION}\"\\n#define TREXIO_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}\\n#define TREXIO_VERSION_MINOR ${PROJECT_VERSION_MINOR}\\n#define TREXIO_VERSION_PATCH ${PROJECT_VERSION_PATCH}' > config.h"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/include
- COMMENT "Generates minimal include/config.h without using autotools."
- VERBATIM)
-
- set_source_files_properties(
- ${CMAKE_SOURCE_DIR}/include/config.h
- PROPERTIES GENERATED TRUE)
-
endif()
# ============= INSTALL TREXIO ==============
From 9e5d81b2923c4f30fae9cc9eb1a1c383b8090bc0 Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Wed, 19 Jan 2022 10:23:11 +0000
Subject: [PATCH 6/7] Use c_int64_t and c_int32_t as requested by Evgeny
Posenitskiy.
---
src/templates_front/templator_front.org | 270 ++++++++++++------------
tools/generator_tools.py | 6 +-
2 files changed, 138 insertions(+), 138 deletions(-)
diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org
index b45ca35..47ebcd9 100644
--- a/src/templates_front/templator_front.org
+++ b/src/templates_front/templator_front.org
@@ -83,8 +83,8 @@ module trexio
use, intrinsic :: iso_c_binding
implicit none
- integer, parameter :: trexio_exit_code = c_int
- integer, parameter :: trexio_backend = c_int
+ integer, parameter :: trexio_exit_code = c_int32_t
+ integer, parameter :: trexio_backend = c_int32_t
character(kind=c_char), parameter :: TREXIO_DELIM = c_new_line
#+end_src
@@ -598,7 +598,7 @@ bool trexio_has_backend(back_end_t back_end) {
interface
logical(c_bool) function trexio_has_backend (back_end) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_int), intent(in), value :: back_end
+ integer(c_int32_t), intent(in), value :: back_end
end function trexio_has_backend
end interface
#+end_src
@@ -958,7 +958,7 @@ trexio_open(const char* file_name, const char mode,
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer(c_long) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open")
+ integer(c_int64_t) function trexio_open_c (filename, mode, backend, rc_open) bind(C, name="trexio_open")
use, intrinsic :: iso_c_binding
import
character(kind=c_char), dimension(*) :: filename
@@ -1036,9 +1036,9 @@ trexio_exit_code trexio_set_one_based(trexio_t* file)
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer(c_int) function trexio_set_one_based(trex_file) bind(C)
+ integer(c_int32_t) function trexio_set_one_based(trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_set_one_based
end interface
#+end_src
@@ -1139,9 +1139,9 @@ trexio_close (trexio_t* file)
#+begin_src f90 :tangle prefix_fortran.f90
interface
- integer(c_int) function trexio_close (trex_file) bind(C)
+ integer(c_int32_t) function trexio_close (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_close
end interface
#+end_src
@@ -1192,29 +1192,29 @@ def close(trexio_file):
example, in ~#define~ statements). More detailed description of
each variable can be found below:
- | Template variable | Description | Example |
- |--------------------------------+-----------------------------------------------------+-----------------------------------|
- | ~$group$~ | Name of the group | ~nucleus~ |
- | ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ |
- | ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ |
- | ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ |
- | ~$group_dset_rank$~ | Rank of the dataset | ~2~ |
- | ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ |
- | ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ |
- | ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ |
- | ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ |
- | ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ |
- | ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ |
- | ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ |
- | ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ |
- | ~$group_dset_dtype_double$~ | Double precision datatype of the dataset [C] | ~double/int64_t~ |
- | ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(c_double)/integer(c_int)~ |
- | ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(c_float)/integer(c_int)~ |
- | ~$group_dset_f_dtype_double$~ | Double precision datatype of the dataset [Fortran] | ~real(c_double)/integer(c_long)~ |
- | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ |
- | ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ |
- | ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ |
- | ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ |
+ | Template variable | Description | Example |
+ |--------------------------------+-----------------------------------------------------+-------------------------------------|
+ | ~$group$~ | Name of the group | ~nucleus~ |
+ | ~$group_num$~ | Name of the numerical attribute (scalar) | ~nucleus_num~ |
+ | ~$group_str$~ | Name of the string attribute (scalar) | ~nucleus_point_group~ |
+ | ~$group_dset$~ | Name of the dataset (vector/matrix/tensor) | ~nucleus_coord~ |
+ | ~$group_dset_rank$~ | Rank of the dataset | ~2~ |
+ | ~$group_dset_dim$~ | Selected dimension of the dataset | ~nucleus_num~ |
+ | ~$group_dset_dim_list$~ | All dimensions of the dataset | ~{nucleus_num, 3}~ |
+ | ~$group_dset_dtype$~ | Basic type of the dataset (int/float/char) | ~float~ |
+ | ~$group_dset_h5_dtype$~ | Type of the dataset in HDF5 | ~double~ |
+ | ~$group_dset_format_scanf$~ | Input type of the dataset in TEXT [fscanf] | ~%lf~ |
+ | ~$group_dset_format_printf$~ | Output type of the dataset in TEXT [fprintf] | ~%24.16e~ |
+ | ~$group_dset_dtype_default$~ | Default datatype of the dataset [C] | ~double/int32_t~ |
+ | ~$group_dset_dtype_single$~ | Single precision datatype of the dataset [C] | ~float/int32_t~ |
+ | ~$group_dset_dtype_double$~ | Double precision datatype of the dataset [C] | ~double/int64_t~ |
+ | ~$group_dset_f_dtype_default$~ | Default datatype of the dataset [Fortran] | ~real(c_double)/integer(c_int32_t)~ |
+ | ~$group_dset_f_dtype_single$~ | Single precision datatype of the dataset [Fortran] | ~real(c_float)/integer(c_int32_t)~ |
+ | ~$group_dset_f_dtype_double$~ | Double precision datatype of the dataset [Fortran] | ~real(c_double)/integer(c_int64_t)~ |
+ | ~$group_dset_f_dims$~ | Dimensions in Fortran | ~(:,:)~ |
+ | ~$group_dset_py_dtype$~ | Standard datatype of the dataset [Python] | ~float/int~ |
+ | ~$default_prec$~ | Default precision for read/write without suffix [C] | ~64/32~ |
+ | ~$is_index$~ | Expands to ~true~ if dataset has a type ~index~ [C] | ~true/false~ |
Some of the aforementioned template variables with ~group_dset~ prefix are duplicated with ~group_num~ prefix,
@@ -1467,9 +1467,9 @@ trexio_has_$group_num$ (trexio_t* const file)
#+begin_src f90 :tangle write_attr_num_64_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_num$_64 (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_write_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(in), value :: num
end function trexio_write_$group_num$_64
end interface
@@ -1477,9 +1477,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_64_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_num$_64 (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_read_$group_num$_64 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_double$, intent(out) :: num
end function trexio_read_$group_num$_64
end interface
@@ -1487,9 +1487,9 @@ end interface
#+begin_src f90 :tangle write_attr_num_32_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_num$_32 (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_write_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(in), value :: num
end function trexio_write_$group_num$_32
end interface
@@ -1497,9 +1497,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_32_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_num$_32 (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_read_$group_num$_32 (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_single$, intent(out) :: num
end function trexio_read_$group_num$_32
end interface
@@ -1507,9 +1507,9 @@ end interface
#+begin_src f90 :tangle write_attr_num_def_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_num$ (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_write_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(in), value :: num
end function trexio_write_$group_num$
end interface
@@ -1517,9 +1517,9 @@ end interface
#+begin_src f90 :tangle read_attr_num_def_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_num$ (trex_file, num) bind(C)
+ integer(c_int32_t) function trexio_read_$group_num$ (trex_file, num) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_num_f_dtype_default$, intent(out) :: num
end function trexio_read_$group_num$
end interface
@@ -1527,9 +1527,9 @@ end interface
#+begin_src f90 :tangle has_attr_num_front_fortran.f90
interface
- integer(c_int) function trexio_has_$group_num$ (trex_file) bind(C)
+ integer(c_int32_t) function trexio_has_$group_num$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_$group_num$
end interface
#+end_src
@@ -2130,9 +2130,9 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_data_64_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_64
end interface
@@ -2140,9 +2140,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_64_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_double$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_64
end interface
@@ -2150,9 +2150,9 @@ end interface
#+begin_src f90 :tangle write_dset_data_32_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$_32
end interface
@@ -2160,9 +2160,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_32_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_single$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$_32
end interface
@@ -2170,9 +2170,9 @@ end interface
#+begin_src f90 :tangle write_dset_data_def_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_dset$ (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_write_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(in) :: dset$group_dset_f_dims$
end function trexio_write_$group_dset$
end interface
@@ -2180,9 +2180,9 @@ end interface
#+begin_src f90 :tangle read_dset_data_def_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$ (trex_file, dset) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
$group_dset_f_dtype_default$, intent(out) :: dset$group_dset_f_dims$
end function trexio_read_$group_dset$
end interface
@@ -2190,9 +2190,9 @@ end interface
#+begin_src f90 :tangle has_dset_data_front_fortran.f90
interface
- integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int32_t) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -2739,82 +2739,82 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_sparse_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, value_sparse) bind(C)
+ integer(c_int32_t) function trexio_write_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- integer(c_long), intent(in), value :: offset_file
- integer(c_long), intent(in), value :: buffer_size
- integer(c_int), intent(in) :: index_sparse(*)
- real(c_double), intent(in) :: value_sparse(*)
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: offset_file
+ integer(c_int64_t), intent(in), value :: buffer_size
+ integer(c_int32_t), intent(in) :: index_sparse(*)
+ real(c_double), intent(in) :: value_sparse(*)
end function trexio_write_$group_dset$
end interface
interface
- integer(c_int) function trexio_write_safe_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, index_size, &
- value_sparse, value_size) bind(C)
+ integer(c_int32_t) function trexio_write_safe_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, index_size, &
+ value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- integer(c_long), intent(in), value :: offset_file
- integer(c_long), intent(in), value :: buffer_size
- integer(c_int), intent(in) :: index_sparse(*)
- integer(c_long), intent(in), value :: index_size
- real(c_double), intent(in) :: value_sparse(*)
- integer(c_long), intent(in), value :: value_size
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: offset_file
+ integer(c_int64_t), intent(in), value :: buffer_size
+ integer(c_int32_t), intent(in) :: index_sparse(*)
+ integer(c_int64_t), intent(in), value :: index_size
+ real(c_double), intent(in) :: value_sparse(*)
+ integer(c_int64_t), intent(in), value :: value_size
end function trexio_write_safe_$group_dset$
end interface
#+end_src
#+begin_src f90 :tangle read_dset_sparse_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, value_sparse) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, value_sparse) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- integer(c_long), intent(in), value :: offset_file
- integer(c_long), intent(inout) :: buffer_size
- integer(c_int), intent(out) :: index_sparse(*)
- real(c_double), intent(out) :: value_sparse(*)
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: offset_file
+ integer(c_int64_t), intent(inout) :: buffer_size
+ integer(c_int32_t), intent(out) :: index_sparse(*)
+ real(c_double), intent(out) :: value_sparse(*)
end function trexio_read_$group_dset$
end interface
interface
- integer(c_int) function trexio_read_safe_$group_dset$ (trex_file, &
- offset_file, buffer_size, &
- index_sparse, index_size, &
- value_sparse, value_size) bind(C)
+ integer(c_int32_t) function trexio_read_safe_$group_dset$ (trex_file, &
+ offset_file, buffer_size, &
+ index_sparse, index_size, &
+ value_sparse, value_size) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- integer(c_long), intent(in), value :: offset_file
- integer(c_long), intent(inout) :: buffer_size
- integer(c_int), intent(out) :: index_sparse(*)
- integer(c_long), intent(in), value :: index_size
- real(c_double), intent(out) :: value_sparse(*)
- integer(c_long), intent(in), value :: value_size
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: offset_file
+ integer(c_int64_t), intent(inout) :: buffer_size
+ integer(c_int32_t), intent(out) :: index_sparse(*)
+ integer(c_int64_t), intent(in), value :: index_size
+ real(c_double), intent(out) :: value_sparse(*)
+ integer(c_int64_t), intent(in), value :: value_size
end function trexio_read_safe_$group_dset$
end interface
#+end_src
#+begin_src f90 :tangle read_dset_sparse_size_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$_size (trex_file, &
- size_max) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$_size (trex_file, &
+ size_max) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- integer(c_long), intent(out) :: size_max
+ integer(c_int64_t), intent(in), value :: trex_file
+ integer(c_int64_t), intent(out) :: size_max
end function trexio_read_$group_dset$_size
end interface
#+end_src
#+begin_src f90 :tangle has_dset_sparse_front_fortran.f90
interface
- integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int32_t) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -3310,31 +3310,31 @@ trexio_has_$group_dset$ (trexio_t* const file)
#+begin_src f90 :tangle write_dset_str_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
+ integer(c_int32_t) function trexio_write_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- character(kind=c_char), intent(in) :: dset(*)
- integer(c_int), intent(in), value :: max_str_len
+ integer(c_int64_t), intent(in), value :: trex_file
+ character(kind=c_char), intent(in) :: dset(*)
+ integer(c_int32_t), intent(in), value :: max_str_len
end function trexio_write_$group_dset$_low
end interface
#+end_src
#+begin_src f90 :tangle read_dset_str_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
+ integer(c_int32_t) function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- character(kind=c_char), intent(out) :: dset(*)
- integer(c_int), intent(in), value :: max_str_len
+ integer(c_int64_t), intent(in), value :: trex_file
+ character(kind=c_char), intent(out) :: dset(*)
+ integer(c_int32_t), intent(in), value :: max_str_len
end function trexio_read_$group_dset$_low
end interface
#+end_src
#+begin_src f90 :tangle has_dset_str_front_fortran.f90
interface
- integer(c_int) function trexio_has_$group_dset$ (trex_file) bind(C)
+ integer(c_int32_t) function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_$group_dset$
end interface
#+end_src
@@ -3342,8 +3342,8 @@ end interface
#+begin_src f90 :tangle helper_read_dset_str_front_fortran.fh_90
integer function trexio_read_$group_dset$ (trex_file, dset, max_str_len)
implicit none
- integer(8), intent(in), value :: trex_file
- integer(4), intent(in), value :: max_str_len
+ integer(8), intent(in), value :: trex_file
+ integer(4), intent(in), value :: max_str_len
character(len=*), intent(inout) :: dset(*)
character, allocatable :: str_compiled(:)
@@ -3373,7 +3373,7 @@ end interface
implicit none
integer(8), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len
- character(len=*), intent(in) :: dset(*)
+ character(len=*), intent(in) :: dset(*)
character(len=:), allocatable :: str_compiled
integer(8) :: $group_dset_dim$
@@ -3626,33 +3626,33 @@ trexio_has_$group_str$ (trexio_t* const file)
#+begin_src f90 :tangle write_attr_str_front_fortran.f90
interface
- integer(c_int) function trexio_write_$group_str$_c (trex_file, str, max_str_len) &
- bind(C, name="trexio_write_$group_str$")
+ integer(c_int32_t) function trexio_write_$group_str$_c (trex_file, str, max_str_len) &
+ bind(C, name="trexio_write_$group_str$")
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- character(kind=c_char), intent(in) :: str(*)
- integer(c_int), intent(in), value :: max_str_len
+ integer(c_int64_t), intent(in), value :: trex_file
+ character(kind=c_char), intent(in) :: str(*)
+ integer(c_int32_t), intent(in), value :: max_str_len
end function trexio_write_$group_str$_c
end interface
#+end_src
#+begin_src f90 :tangle read_attr_str_front_fortran.f90
interface
- integer(c_int) function trexio_read_$group_str$_c (trex_file, str, max_str_len) &
- bind(C, name="trexio_read_$group_str$")
+ integer(c_int32_t) function trexio_read_$group_str$_c (trex_file, str, max_str_len) &
+ bind(C, name="trexio_read_$group_str$")
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
- character(kind=c_char), intent(out) :: str(*)
- integer(c_int), intent(in), value :: max_str_len
+ integer(c_int64_t), intent(in), value :: trex_file
+ character(kind=c_char), intent(out) :: str(*)
+ integer(c_int32_t), intent(in), value :: max_str_len
end function trexio_read_$group_str$_c
end interface
#+end_src
#+begin_src f90 :tangle has_attr_str_front_fortran.f90
interface
- integer(c_int) function trexio_has_$group_str$ (trex_file) bind(C)
+ integer(c_int32_t) function trexio_has_$group_str$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding
- integer(c_long), intent(in), value :: trex_file
+ integer(c_int64_t), intent(in), value :: trex_file
end function trexio_has_$group_str$
end interface
#+end_src
@@ -3675,7 +3675,7 @@ end interface
implicit none
integer(8), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len
- character(len=*), intent(in) :: str
+ character(len=*), intent(in) :: str
character(len=len_trim(str)+1) :: str_c
@@ -3785,7 +3785,7 @@ contains
character, intent(in), value :: mode
integer(trexio_backend), intent(in), value :: backend
integer(trexio_exit_code), intent(out) :: rc_open
- character(len=len_trim(filename)+1) :: filename_c
+ character(len=len_trim(filename)+1) :: filename_c
integer(trexio_exit_code) :: rc
filename_c = trim(filename) // c_null_char
@@ -3832,9 +3832,9 @@ contains
implicit none
integer(8), intent(in), value :: max_num_str ! number of elements in strign array
- integer, intent(in), value :: max_len_str ! maximum length of a string in an array
- character, intent(in) :: str_flat(*)
- character(len=*), intent(inout) :: str_array(*)
+ integer, intent(in), value :: max_len_str ! maximum length of a string in an array
+ character, intent(in) :: str_flat(*)
+ character(len=*), intent(inout) :: str_array(*)
character(len=max_len_str) :: tmp_str
integer(8) :: len_flat, i, j, k, ind
@@ -3868,8 +3868,8 @@ contains
subroutine trexio_assert(trexio_rc, check_rc, success_message)
implicit none
- integer, intent(in), value :: trexio_rc
- integer, intent(in), value :: check_rc
+ integer, intent(in), value :: trexio_rc
+ integer, intent(in), value :: check_rc
character(len=*), intent(in), optional :: success_message
character*(128) :: str
diff --git a/tools/generator_tools.py b/tools/generator_tools.py
index 72df212..6e64fbb 100644
--- a/tools/generator_tools.py
+++ b/tools/generator_tools.py
@@ -509,9 +509,9 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
'default_prec' : '32',
f'group_{target}_dtype' : 'int64_t',
f'group_{target}_h5_dtype' : 'native_int64',
- f'group_{target}_f_dtype_default' : 'integer(c_int)',
- f'group_{target}_f_dtype_double' : 'integer(c_long)',
- f'group_{target}_f_dtype_single' : 'integer(c_int)',
+ f'group_{target}_f_dtype_default' : 'integer(c_int32_t)',
+ f'group_{target}_f_dtype_double' : 'integer(c_int64_t)',
+ f'group_{target}_f_dtype_single' : 'integer(c_int32_t)',
f'group_{target}_dtype_default' : 'int32_t',
f'group_{target}_dtype_double' : 'int64_t',
f'group_{target}_dtype_single' : 'int32_t',
From 57973eaca02aea6e3d3eb64abed4f5e930d80629 Mon Sep 17 00:00:00 2001
From: Pablo Lopez Rios
Date: Wed, 19 Jan 2022 10:38:01 +0000
Subject: [PATCH 7/7] templator_front.org: undo two unnecessary changes
---
src/templates_front/templator_front.org | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org
index 47ebcd9..ac8ede4 100644
--- a/src/templates_front/templator_front.org
+++ b/src/templates_front/templator_front.org
@@ -3348,7 +3348,7 @@ end interface
character, allocatable :: str_compiled(:)
integer(8) :: $group_dset_dim$
- integer(4) :: rc
+ integer :: rc
rc = trexio_read_$group_dset_dim$_64(trex_file, $group_dset_dim$)
if (rc /= TREXIO_SUCCESS) trexio_read_$group_dset$ = rc
@@ -3369,7 +3369,7 @@ end interface
#+end_src
#+begin_src f90 :tangle helper_write_dset_str_front_fortran.fh_90
- integer(4) function trexio_write_$group_dset$ (trex_file, dset, max_str_len)
+ integer function trexio_write_$group_dset$ (trex_file, dset, max_str_len)
implicit none
integer(8), intent(in), value :: trex_file
integer(4), intent(in), value :: max_str_len