mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-08-25 06:31:43 +02:00
Merge branch 'master' into iso_fortran_env
This commit is contained in:
commit
81c41c1ffc
5
.gitignore
vendored
5
.gitignore
vendored
@ -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*
|
||||
|
@ -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.
|
||||
|
@ -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).
|
||||
|
5
include/cmake_config.h.in
Normal file
5
include/cmake_config.h.in
Normal file
@ -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@
|
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@ -28,6 +28,7 @@ trexio_hdf5.c
|
||||
trexio_f.f90
|
||||
trexio.mod
|
||||
|
||||
trexio.py
|
||||
pytrexio.py
|
||||
pytrexio_wrap.c
|
||||
|
||||
|
@ -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,17 @@ 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)
|
||||
|
||||
endif()
|
||||
|
||||
# ============= INSTALL TREXIO ==============
|
||||
|
@ -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
|
||||
|
@ -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(<<MAX_STRING_LENGTH()>>)
|
||||
integer(trexio_exit_code), intent(in), value :: error
|
||||
character(kind=c_char), intent(out) :: string(<<MAX_STRING_LENGTH()>>)
|
||||
end subroutine trexio_string_of_error
|
||||
end interface
|
||||
#+end_src
|
||||
@ -596,7 +596,7 @@ 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
|
||||
import
|
||||
integer(c_int32_t), intent(in), value :: back_end
|
||||
@ -972,7 +972,7 @@ interface
|
||||
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
|
||||
@ -1275,29 +1275,29 @@ def _inquire(file_name: str) -> bool:
|
||||
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$~ | real(c_double) datatype of the dataset [C] | ~double/int64_t~ |
|
||||
| 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$~ | real(c_double) 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~ |
|
||||
| ~$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,
|
||||
@ -1717,8 +1717,8 @@ def has_$group_num$(trexio_file) -> bool:
|
||||
| ~trexio_write_safe_$group_dset$~ | Write a bounded dataset | Double |
|
||||
| ~trexio_read_$group_dset$_32~ | Read a dataset in single precision | Single |
|
||||
| ~trexio_write_$group_dset$_32~ | Write a dataset in single precision | Single |
|
||||
| ~trexio_read_$group_dset$_64~ | Read a dataset in real(c_double) | Double |
|
||||
| ~trexio_write_$group_dset$_64~ | Write a dataset in real(c_double) | Double |
|
||||
| ~trexio_read_$group_dset$_64~ | Read a dataset in real(c_double) | Double |
|
||||
| ~trexio_write_$group_dset$_64~ | Write a dataset in real(c_double) | Double |
|
||||
|
||||
*** C templates for front end
|
||||
|
||||
@ -2845,7 +2845,7 @@ interface
|
||||
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(*)
|
||||
real(c_double), intent(in) :: value_sparse(*)
|
||||
end function trexio_write_$group_dset$
|
||||
end interface
|
||||
|
||||
@ -2861,7 +2861,7 @@ interface
|
||||
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(*)
|
||||
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
|
||||
@ -2878,7 +2878,7 @@ interface
|
||||
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(*)
|
||||
real(c_double), intent(out) :: value_sparse(*)
|
||||
end function trexio_read_$group_dset$
|
||||
end interface
|
||||
|
||||
@ -2894,7 +2894,7 @@ interface
|
||||
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(*)
|
||||
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
|
||||
@ -3417,7 +3417,7 @@ interface
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int64_t), intent(in), value :: trex_file
|
||||
character, intent(in) :: dset(*)
|
||||
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
|
||||
@ -3428,9 +3428,9 @@ interface
|
||||
integer(trexio_exit_code) function trexio_read_$group_dset$_low (trex_file, dset, max_str_len) bind(C)
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int64_t), intent(in), value :: trex_file
|
||||
character, intent(out) :: dset(*)
|
||||
integer(c_int32_t), 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
|
||||
@ -3737,7 +3737,7 @@ interface
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int64_t), intent(in), value :: trex_file
|
||||
character, intent(in) :: str(*)
|
||||
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
|
||||
@ -3750,7 +3750,7 @@ interface
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int64_t), intent(in), value :: trex_file
|
||||
character, intent(out) :: str(*)
|
||||
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
|
||||
@ -3894,7 +3894,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
|
||||
@ -3958,9 +3958,9 @@ contains
|
||||
implicit none
|
||||
|
||||
integer(c_int64_t), 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(kind=c_char), intent(in) :: str_flat(*)
|
||||
character(len=*), intent(inout) :: str_array(*)
|
||||
|
||||
character(len=max_len_str) :: tmp_str
|
||||
integer(c_int64_t) :: i, j, k, ind, offset
|
||||
@ -3969,7 +3969,6 @@ contains
|
||||
len_flat = (max_len_str+1)*max_num_str + 1
|
||||
|
||||
ind=1
|
||||
offset=1
|
||||
do i=1,max_num_str
|
||||
k = 1
|
||||
tmp_str=''
|
||||
@ -3982,7 +3981,6 @@ contains
|
||||
k = k + 1
|
||||
enddo
|
||||
str_array(i)=tmp_str
|
||||
offset=ind
|
||||
enddo
|
||||
|
||||
end subroutine trexio_str2strarray
|
||||
@ -3997,8 +3995,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
|
||||
@ -4008,7 +4006,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
|
||||
|
@ -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 $<TARGET_FILE:test_f>)
|
||||
|
Loading…
Reference in New Issue
Block a user