diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml index 7fdcd203fb..b27df6b708 100644 --- a/.github/workflows/clang-tidy-review.yml +++ b/.github/workflows/clang-tidy-review.yml @@ -18,8 +18,6 @@ jobs: libnetcdf-dev libnetcdf-c++4-dev netcdf-bin - hdf5-tools - libhdf5-mpi-dev openmpi-bin libopenmpi-dev petsc-dev @@ -39,7 +37,6 @@ jobs: -DBOUT_ENABLE_OPENMP=ON \ -DBOUT_USE_PETSC=ON \ -DBOUT_USE_SLEPC=ON \ - -DBOUT_USE_HDF5=ON \ -DBOUT_USE_SUNDIALS=ON \ -DBOUT_BUILD_EXAMPLES=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On @@ -49,6 +46,6 @@ jobs: id: review with: build_dir: build - apt_packages: "libfftw3-dev,libnetcdf-c++4-dev,libhdf5-mpi-dev,libopenmpi-dev,petsc-dev,slepc-dev,liblapack-dev,libparpack2-dev,libsundials-dev" + apt_packages: "libfftw3-dev,libnetcdf-c++4-dev,libopenmpi-dev,petsc-dev,slepc-dev,liblapack-dev,libparpack2-dev,libsundials-dev" clang_tidy_checks: '-*,performance-*,readability-*,bugprone-*,clang-analyzer-*,cppcoreguidelines-*,mpi-*,misc-*,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e3cd8195d3..bb38b721a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,6 @@ jobs: os: ubuntu-18.04 configure_options: "--with-petsc --with-slepc - --with-hdf5 --with-sundials=/home/runner/local" script_flags: "-uim" @@ -44,7 +43,6 @@ jobs: --disable-backtrace --with-petsc --with-slepc - --with-hdf5 --with-sundials=/home/runner/local" script_flags: "-uim -t shared -t python" @@ -54,7 +52,6 @@ jobs: --enable-sigfpe --enable-debug --enable-track - --with-hdf5 --with-petsc --with-slepc --with-sundials=/home/runner/local" @@ -66,7 +63,6 @@ jobs: --enable-openmp --with-petsc --with-slepc - --with-hdf5 --with-sundials=/home/runner/local" script_flags: "-uim" omp_num_threads: 2 @@ -77,7 +73,6 @@ jobs: -DBOUT_ENABLE_OPENMP=ON -DBOUT_USE_PETSC=ON -DBOUT_USE_SLEPC=ON - -DBOUT_USE_HDF5=ON -DBOUT_USE_SUNDIALS=ON -DSUNDIALS_ROOT=/home/runner/local" omp_num_threads: 2 @@ -89,7 +84,6 @@ jobs: --enable-debug --enable-track --with-lapack - --with-hdf5 --with-petsc --with-slepc --with-sundials=/home/runner/local" @@ -114,14 +108,12 @@ jobs: libnetcdf-dev libnetcdf-c++4-dev netcdf-bin - hdf5-tools python3 python3-pip python3-pytest python3-numpy python3-scipy lcov - libhdf5-mpi-dev openmpi-bin libopenmpi-dev petsc-dev diff --git a/.travis_fedora.sh b/.travis_fedora.sh index 9ffda6082a..9afd5d6a9c 100755 --- a/.travis_fedora.sh +++ b/.travis_fedora.sh @@ -37,7 +37,7 @@ then cat /etc/os-release # Ignore weak depencies echo "install_weak_deps=False" >> /etc/dnf/dnf.conf - time dnf -y install dnf-plugins-core {petsc,hdf5}-${mpi}-devel /usr/lib/rpm/redhat/redhat-hardened-cc1 python3-h5py + time dnf -y install dnf-plugins-core petsc-${mpi}-devel /usr/lib/rpm/redhat/redhat-hardened-cc1 python3-h5py # Allow to override packages - see #2073 time dnf copr enable -y davidsch/fixes4bout || : time dnf -y upgrade diff --git a/CHANGELOG.md b/CHANGELOG.md index dba003c9d0..b93363159e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ - `PhysicsModel` expects the options `datadir` and `dump_format` to have been set; this is only a problem if you don't call `BoutInitialise`. [\#2062](https://github.com/boutproject/BOUT-dev/pull/2062) +- Support for reading/writing HDF5 files has been removed ahead of completely + refactoring the I/O systems. [\#2208](https://github.com/boutproject/BOUT-dev/pull/2208) ## [v4.3.2](https://github.com/boutproject/BOUT-dev/tree/v4.3.2) (2020-10-19) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bd73f0edd..01149b4a9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,8 +166,6 @@ set(BOUT_SOURCES ./src/fileio/formatfactory.cxx ./src/fileio/formatfactory.hxx ./src/fileio/impls/emptyformat.hxx - ./src/fileio/impls/hdf5/h5_format.cxx - ./src/fileio/impls/hdf5/h5_format.hxx ./src/fileio/impls/netcdf/nc_format.cxx ./src/fileio/impls/netcdf/nc_format.hxx ./src/fileio/impls/netcdf4/ncxx4.cxx @@ -518,15 +516,6 @@ endif() message(STATUS "NetCDF support: ${BOUT_USE_NETCDF}") set(BOUT_HAS_NETCDF ${BOUT_USE_NETCDF}) -option(BOUT_USE_HDF5 "Enable support for HDF5 output" OFF) -if (BOUT_USE_HDF5) - find_package(HDF5 REQUIRED COMPONENTS CXX) - target_link_libraries(bout++ PUBLIC "${HDF5_CXX_LIBRARIES}") - target_include_directories(bout++ PUBLIC "${HDF5_CXX_INCLUDE_DIRS}") -endif() -message(STATUS "HDF5 support: ${BOUT_USE_HDF5}") -set(BOUT_HAS_HDF5 ${BOUT_USE_HDF5}) - option(BOUT_USE_FFTW "Enable support for FFTW" ON) if (BOUT_USE_FFTW) find_package(FFTW REQUIRED) @@ -873,7 +862,6 @@ message(" SLEPc support : ${BOUT_HAS_SLEPC} SUNDIALS support : ${BOUT_HAS_SUNDIALS} NetCDF support : ${BOUT_HAS_NETCDF} - HDF5 support : ${BOUT_HAS_HDF5} FFTW support : ${BOUT_HAS_FFTW} LAPACK support : ${BOUT_HAS_LAPACK} OpenMP support : ${BOUT_USE_OPENMP} diff --git a/README.md b/README.md index b136fa8f79..9d0367717a 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,7 @@ BOUT++ needs the following: * A C++14 compiler * MPI -* Either NetCDF or HDF5 - -Note that some of the tests require NetCDF rather than HDF5 +* NetCDF BOUT++ has the following optional dependencies: diff --git a/autoconf_build_defines.hxx.in b/autoconf_build_defines.hxx.in index 925fe967ec..fa2d95d3e8 100644 --- a/autoconf_build_defines.hxx.in +++ b/autoconf_build_defines.hxx.in @@ -15,9 +15,6 @@ /* NLS support */ #undef BOUT_HAS_GETTEXT -/* HDF5 support */ -#undef BOUT_HAS_HDF5 - /* IDA support */ #undef BOUT_HAS_IDA diff --git a/bin/bout-config.in b/bin/bout-config.in index bfcea24c04..a354f6a1d6 100755 --- a/bin/bout-config.in +++ b/bin/bout-config.in @@ -31,7 +31,6 @@ pythonpath="@PYTHONCONFIGPATH@" has_netcdf="@BOUT_HAS_NETCDF@" has_legacy_netcdf="@BOUT_HAS_LEGACY_NETCDF@" has_pnetcdf="@BOUT_HAS_PNETCDF@" -has_hdf5="@BOUT_HAS_HDF5@" has_pvode="@BOUT_HAS_PVODE@" has_cvode="@BOUT_HAS_CVODE@" has_ida="@BOUT_HAS_IDA@" @@ -71,7 +70,6 @@ Available values for OPTION include: --has-netcdf NetCDF file support --has-legacy-netcdf Legacy NetCDF file support --has-pnetcdf Parallel NetCDF file support - --has-hdf5 HDF5 file support --has-pvode PVODE solver support --has-cvode SUNDIALS CVODE solver support --has-ida SUNDIALS IDA solver support @@ -107,7 +105,6 @@ all() echo " --has-netcdf -> $has_netcdf" echo " --has-legacy-netcdf -> $has_legacy_netcdf" echo " --has-pnetcdf -> $has_pnetcdf" - echo " --has-hdf5 -> $has_hdf5" echo " --has-pvode -> $has_pvode" echo " --has-cvode -> $has_cvode" echo " --has-ida -> $has_ida" @@ -200,10 +197,6 @@ while test $# -gt 0; do echo $has_pnetcdf ;; - --has-hdf5) - echo $has_hdf5 - ;; - --has-pvode) echo $has_pvode ;; diff --git a/bin/bout-v5-macro-upgrader.py b/bin/bout-v5-macro-upgrader.py index 16d3b3ed5b..b6db6da427 100755 --- a/bin/bout-v5-macro-upgrader.py +++ b/bin/bout-v5-macro-upgrader.py @@ -9,7 +9,8 @@ # List of macros, their replacements and what header to find them # in. Each element should be a dict with "old", "new" and "headers" # keys, with "old" and "new" values being strings, and "headers" being a -# list of strings +# list of strings. "new" can also be None if the macro has been removed, which +# will cause an error to be printed if the macro is found. MACRO_REPLACEMENTS = [ { "old": "REVISION", @@ -63,8 +64,8 @@ }, { "old": "HAS_HDF5", - "new": "BOUT_HAS_HDF5", - "headers": "bout/build_config.hxx", + "new": None, + "headers": [], "macro": True, "always_defined": True, }, @@ -140,8 +141,8 @@ }, { "old": "HDF5", - "new": "BOUT_HAS_HDF5", - "headers": "bout/build_config.hxx", + "new": None, + "headers": [], "macro": True, "always_defined": True, }, @@ -297,6 +298,13 @@ def apply_fixes(replacements, source): modified = copy.deepcopy(source) for replacement in replacements: + if replacement["new"] is None: + print( + "'%s' has been removed, please delete from your code" + % replacement["old"] + ) + continue + modified = fix_include_version_header( replacement["old"], replacement["headers"], modified ) diff --git a/bout++Config.cmake.in b/bout++Config.cmake.in index f216af16aa..5d46b3edf0 100644 --- a/bout++Config.cmake.in +++ b/bout++Config.cmake.in @@ -58,9 +58,6 @@ endif() if(EXISTS "@netCDFCxx_ROOT@") set(netCDFCxx_ROOT "@netCDFCxx_ROOT@") endif() -if(EXISTS "@HDF5F_ROOT@") - set(HDF5F_ROOT "@HDF5F_ROOT@") -endif() if(EXISTS "@PVODE_ROOT@") set(PVODE_ROOT "@PVODE_ROOT@") endif() @@ -85,9 +82,6 @@ endif() if (BOUT_HAS_NETCDF) find_dependency(netCDFCxx @netCDFCxx_VERSION@) endif() -if (BOUT_HAS_HDF5) - find_dependency(HDF5 @HDF5_VERSION@) -endif() if (BOUT_HAS_PVODE) find_dependency(PVODE @PVODE_VERSION@) endif() diff --git a/cmake_build_defines.hxx.in b/cmake_build_defines.hxx.in index d3edbb752a..f7bee53892 100644 --- a/cmake_build_defines.hxx.in +++ b/cmake_build_defines.hxx.in @@ -9,7 +9,6 @@ #cmakedefine01 BOUT_HAS_CVODE #cmakedefine01 BOUT_HAS_FFTW #cmakedefine01 BOUT_HAS_GETTEXT -#cmakedefine01 BOUT_HAS_HDF5 #cmakedefine01 BOUT_HAS_IDA #cmakedefine01 BOUT_HAS_LAPACK #cmakedefine01 BOUT_HAS_NETCDF diff --git a/configure b/configure index cb5593809b..0c4e13bee2 100755 --- a/configure +++ b/configure @@ -647,7 +647,6 @@ BOUT_HAS_LEGACY_NETCDF BOUT_HAS_NETCDF BOUT_HAS_LAPACK BOUT_HAS_IDA -BOUT_HAS_HDF5 BOUT_HAS_GETTEXT BOUT_HAS_FFTW BOUT_HAS_CVODE @@ -707,26 +706,10 @@ PETSC_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG -PARALLELHDF5_TYPE -PARALLELHDF5_LIBS -PARALLELHDF5_LDFLAGS -PARALLELHDF5_CPPFLAGS -PARALLELHDF5_CFLAGS -PARALLELHDF5_CC -PARALLELHDF5_VERSION -PARALLELH5CC -HDF5_TYPE -HDF5_LIBS -HDF5_LDFLAGS -HDF5_CPPFLAGS -HDF5_CFLAGS -HDF5_CC -HDF5_VERSION CPP ac_ct_CC CFLAGS CC -H5CC AWK NCMPIDUMP_PATH NCCONF @@ -844,8 +827,6 @@ with_openmp_schedule enable_pvode_openmp with_gcov enable_code_coverage -with_hdf5 -with_parallelhdf5 enable_nls with_gnu_ld enable_rpath @@ -1527,9 +1508,6 @@ Optional Packages: --with-openmp-schedule=static/dynamic/guided/auto Set OpenMP schedule (default: static) --with-gcov=GCOV use given GCOV for coverage (GCOV=gcov). - --with-hdf5=yes/no/PATH location of h5cc for serial HDF5 configuration - --with-parallelhdf5=yes/no/PATH - location of h5pcc for parallel HDF5 configuration --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir @@ -7474,1468 +7452,6 @@ $as_echo "$as_me: Parallel-NetCDF support enabled" >&6;} fi -############################################################# -# HDF5 library -############################################################# - -BOUT_HAS_HDF5="no" -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - -if test "serial" = "" ; then - : # Recognized value -elif test "serial" = "serial" ; then - : # Recognized value -elif test "serial" = "parallel"; then - : # Recognized value -else - as_fn_error $? " -Unrecognized value for AX_LIB_HDF5 within configure.ac. -If supplied, argument 1 must be either 'serial' or 'parallel'. -" "$LINENO" 5 -fi - - -# Check whether --with-hdf5 was given. -if test "${with_hdf5+set}" = set; then : - withval=$with_hdf5; if test "$withval" = "no"; then - with_hdf5="no" - elif test "$withval" = "yes"; then - with_hdf5="yes" - else - with_hdf5="yes" - H5CC="$withval" - fi -else - with_hdf5="guess" - -fi - - -HDF5_CC="" -HDF5_VERSION="" -HDF5_CFLAGS="" -HDF5_CPPFLAGS="" -HDF5_LDFLAGS="" -HDF5_LIBS="" -HDF5_FC="" -HDF5_FFLAGS="" -HDF5_FLIBS="" -HDF5_TYPE="" - -if test "$with_hdf5" = "yes" || test "$with_hdf5" = "guess"; then - if test -z "$H5CC"; then - for ac_prog in h5cc -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_H5CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $H5CC in - [\\/]* | ?:[\\/]*) - ac_cv_path_H5CC="$H5CC" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_H5CC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -H5CC=$ac_cv_path_H5CC -if test -n "$H5CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $H5CC" >&5 -$as_echo "$H5CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$H5CC" && break -done - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Using provided HDF5 C wrapper" >&5 -$as_echo_n "checking Using provided HDF5 C wrapper... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $H5CC" >&5 -$as_echo "$H5CC" >&6; } - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HDF5 type" >&5 -$as_echo_n "checking for HDF5 type... " >&6; } - case $H5CC in #( - *h5pcc) : - HDF5_TYPE=parallel ;; #( - *h5cc) : - HDF5_TYPE=serial ;; #( - *) : - HDF5_TYPE=neither ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HDF5_TYPE" >&5 -$as_echo "$HDF5_TYPE" >&6; } - if test ! -f "$H5CC" || test ! -x "$H5CC"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can compile HDF5 program without helper script" >&5 -$as_echo_n "checking if we can compile HDF5 program without helper script... " >&6; } - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - -int -main () -{ -H5Fcreate(0, 0, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_hdf5_h=yes - ac_cv_libhdf5=yes -else - ac_cv_hdf5_h=no - ac_cv_libhdf5=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libhdf5" >&5 -$as_echo "$ac_cv_libhdf5" >&6; } - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - if test "$ac_cv_libhdf5" = "no" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to compile HDF5 test program" >&5 -$as_echo "$as_me: WARNING: Unable to compile HDF5 test program" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: -Unable to locate serial HDF5 compilation helper script 'h5cc'. -Please specify --with-hdf5= as the full path to h5cc. -HDF5 support is being disabled (equivalent to --with-hdf5=no). -" >&5 -$as_echo "$as_me: WARNING: -Unable to locate serial HDF5 compilation helper script 'h5cc'. -Please specify --with-hdf5= as the full path to h5cc. -HDF5 support is being disabled (equivalent to --with-hdf5=no). -" >&2;} - if test "$with_hdf5" = "yes"; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "HDF5 was requested, but could not be compiled -See \`config.log' for more details" "$LINENO" 5; } - fi - with_hdf5="no" - else - with_hdf5="yes" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HDF5 libraries" >&5 -$as_echo_n "checking for HDF5 libraries... " >&6; } - HDF5_SHOW=$(eval $H5CC -show) - - HDF5_CC=$(eval $H5CC -show | $AWK '{print $1}') - if test "$HDF5_CC" = "ccache"; then - HDF5_CC=$(eval $H5CC -show | $AWK '{print $2}') - fi - - - HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' \ - | $AWK '{print $3}') - - HDF5_tmp_flags=$(eval $H5CC -showconfig \ - | $GREP 'FLAGS\|Extra libraries:' \ - | $AWK -F: '{printf("%s "), $2}' ) - - HDF5_tmp_inst=$(eval $H5CC -showconfig \ - | $GREP 'Installation point:' \ - | $AWK '{print $NF}' ) - - HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include" - - for arg in $HDF5_SHOW $HDF5_tmp_flags ; do - case "$arg" in - -I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_CPPFLAGS="$HDF5_CPPFLAGS $arg" - ;; - -L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_LDFLAGS="$HDF5_LDFLAGS $arg" - ;; - -l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_LIBS="$HDF5_LIBS $arg" - ;; - esac - done - - HDF5_LIBS="-lhdf5 $HDF5_LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $HDF5_VERSION)" >&5 -$as_echo "yes (version $HDF5_VERSION)" >&6; } - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ax_lib_hdf5_save_CC=$CC - ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS - ax_lib_hdf5_save_LIBS=$LIBS - ax_lib_hdf5_save_LDFLAGS=$LDFLAGS - CC=$HDF5_CC - CPPFLAGS=$HDF5_CPPFLAGS - LIBS=$HDF5_LIBS - LDFLAGS=$HDF5_LDFLAGS - ac_fn_c_check_header_mongrel "$LINENO" "hdf5.h" "ac_cv_header_hdf5_h" "$ac_includes_default" -if test "x$ac_cv_header_hdf5_h" = xyes; then : - ac_cv_hdf5_h=yes -else - ac_cv_hdf5_h=no -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5Fcreate in -lhdf5" >&5 -$as_echo_n "checking for H5Fcreate in -lhdf5... " >&6; } -if ${ac_cv_lib_hdf5_H5Fcreate+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lhdf5 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char H5Fcreate (); -int -main () -{ -return H5Fcreate (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_hdf5_H5Fcreate=yes -else - ac_cv_lib_hdf5_H5Fcreate=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_H5Fcreate" >&5 -$as_echo "$ac_cv_lib_hdf5_H5Fcreate" >&6; } -if test "x$ac_cv_lib_hdf5_H5Fcreate" = xyes; then : - ac_cv_libhdf5=yes -else - ac_cv_libhdf5=no -fi - - if test "$ac_cv_hdf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then - if test "$with_hdf5" = "yes"; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "Unable to compile HDF5 test program -See \`config.log' for more details" "$LINENO" 5; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to compile HDF5 test program" >&5 -$as_echo "$as_me: WARNING: Unable to compile HDF5 test program" >&2;} - fi - fi - with_hdf5=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lhdf5_hl" >&5 -$as_echo_n "checking for main in -lhdf5_hl... " >&6; } -if ${ac_cv_lib_hdf5_hl_main+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lhdf5_hl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ -return main (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_hdf5_hl_main=yes -else - ac_cv_lib_hdf5_hl_main=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_hl_main" >&5 -$as_echo "$ac_cv_lib_hdf5_hl_main" >&6; } -if test "x$ac_cv_lib_hdf5_hl_main" = xyes; then : - HDF5_LIBS="-lhdf5_hl $HDF5_LIBS" -fi -ac_cv_lib_hdf5_hl=ac_cv_lib_hdf5_hl_main - - - CC=$ax_lib_hdf5_save_CC - CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS - LIBS=$ax_lib_hdf5_save_LIBS - LDFLAGS=$ax_lib_hdf5_save_LDFLAGS - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - - - - - - - - -$as_echo "#define HAVE_HDF5 1" >>confdefs.h - - fi -fi - -if test "$with_hdf5" = "yes"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: Found HDF5" >&5 -$as_echo "$as_me: Found HDF5" >&6;} - EXTRA_INCS="$EXTRA_INCS $HDF5_CPPFLAGS" - EXTRA_LIBS="$EXTRA_LIBS $HDF5_LDFLAGS $HDF5_LIBS" - BOUT_HAS_HDF5="yes" - file_formats="$file_formats HDF5" - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: Serial HDF5 support disabled" >&5 -$as_echo "$as_me: Serial HDF5 support disabled" >&6;} - -fi - -BOUT_HAS_PHDF5="no" - - - - - - - -# Check whether --with-parallelhdf5 was given. -if test "${with_parallelhdf5+set}" = set; then : - withval=$with_parallelhdf5; if test "$withval" = "no"; then - with_parallelhdf5="no" - elif test "$withval" = "yes"; then - with_parallelhdf5="yes" - else - with_parallelhdf5="yes" - PARALLELH5CC="$withval" - fi -else - with_parallelhdf5="no" - -fi - - -PARALLELHDF5_CC="" -PARALLELHDF5_VERSION="" -PARALLELHDF5_CFLAGS="" -PARALLELHDF5_CPPFLAGS="" -PARALLELHDF5_LDFLAGS="" -PARALLELHDF5_LIBS="" -PARALLELHDF5_FC="" -PARALLELHDF5_FFLAGS="" -PARALLELHDF5_FLIBS="" -PARALLELHDF5_TYPE="" - -if test "$with_parallelhdf5" = "yes"; then - if test -z "$PARALLELH5CC"; then - for ac_prog in h5pcc - -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PARALLELH5CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PARALLELH5CC in - [\\/]* | ?:[\\/]*) - ac_cv_path_PARALLELH5CC="$PARALLELH5CC" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PARALLELH5CC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PARALLELH5CC=$ac_cv_path_PARALLELH5CC -if test -n "$PARALLELH5CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PARALLELH5CC" >&5 -$as_echo "$PARALLELH5CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$PARALLELH5CC" && break -done - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Using provided HDF5 C wrapper" >&5 -$as_echo_n "checking Using provided HDF5 C wrapper... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PARALLELH5CC" >&5 -$as_echo "$PARALLELH5CC" >&6; } - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HDF5 type" >&5 -$as_echo_n "checking for HDF5 type... " >&6; } - case $PARALLELH5CC in #( - *h5pcc) : - PARALLELHDF5_TYPE=parallel ;; #( - *h5cc) : - PARALLELHDF5_TYPE=serial ;; #( - *) : - PARALLELHDF5_TYPE=neither ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PARALLELHDF5_TYPE" >&5 -$as_echo "$PARALLELHDF5_TYPE" >&6; } - - if test ! -f "$PARALLELH5CC" || test ! -x "$PARALLELH5CC"; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can compile parallel HDF5 program without helper script" >&5 -$as_echo_n "checking if we can compile parallel HDF5 program without helper script... " >&6; } - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - -int -main () -{ -H5Fcreate(0, 0, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_parallelhdf5_h=yes - ac_cv_libparallelhdf5=yes -else - ac_cv_parallelhdf5_h=no - ac_cv_libparallelhdf5=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_parallelhdf5_h" >&5 -$as_echo "$ac_cv_parallelhdf5_h" >&6; } - - if test "$ac_cv_parallelhdf5_h" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if found HDF5 is parallel" >&5 -$as_echo_n "checking if found HDF5 is parallel... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #ifdef H5_HAVE_PARALLEL - yes - #endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1; then : - ac_cv_parallelhdf5_h=yes -else - ac_cv_parallelhdf5_h=no -fi -rm -f conftest* - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_parallelhdf5_h" >&5 -$as_echo "$ac_cv_parallelhdf5_h" >&6; } - fi - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - if test "$ac_cv_parallelhdf5_h" = "no" ; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? " -Unable to locate parallel HDF5 compilation helper script 'h5pcc'. -Please specify --with-parallelhdf5= as the full path to h5pcc. -HDF5 support is being disabled (equivalent to --with-parallelhdf5=no). - -See \`config.log' for more details" "$LINENO" 5; } - with_parallelhdf5="no" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HDF5 libraries" >&5 -$as_echo_n "checking for HDF5 libraries... " >&6; } - PARALLELHDF5_SHOW=$(eval $PARALLELH5CC -show) - - PARALLELHDF5_CC=$(eval $PARALLELH5CC -show | $AWK '{print $1}') - if test "$PARALLELHDF5_CC" = "ccache"; then - PARALLELHDF5_CC=$(eval $PARALLELH5CC -show | $AWK '{print $2}') - fi - - - PARALLELHDF5_VERSION=$(eval $PARALLELH5CC -showconfig | $GREP 'HDF5 Version:' \ - | $AWK '{print $3}') - - PARALLELHDF5_tmp_flags=$(eval $PARALLELH5CC -showconfig \ - | $GREP 'FLAGS\|Extra libraries:' \ - | $AWK -F: '{printf("%s "), $2}' ) - - PARALLELHDF5_tmp_inst=$(eval $PARALLELH5CC -showconfig \ - | $GREP 'Installation point:' \ - | $AWK '{print $NF}' ) - - PARALLELHDF5_CPPFLAGS="-I${PARALLELHDF5_tmp_inst}/include" - - for arg in $PARALLELHDF5_SHOW $PARALLELHDF5_tmp_flags ; do - case "$arg" in - -I*) echo $PARALLELHDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_CPPFLAGS="$PARALLELHDF5_CPPFLAGS $arg" - ;; - -L*) echo $PARALLELHDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_LDFLAGS="$PARALLELHDF5_LDFLAGS $arg" - ;; - -l*) echo $PARALLELHDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_LIBS="$PARALLELHDF5_LIBS $arg" - ;; - esac - done - - PARALLELHDF5_LIBS="-lhdf5 $PARALLELHDF5_LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $PARALLELHDF5_VERSION)" >&5 -$as_echo "yes (version $PARALLELHDF5_VERSION)" >&6; } - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ax_lib_parallelhdf5_save_CC=$CC - ax_lib_parallelhdf5_save_CPPFLAGS=$CPPFLAGS - ax_lib_parallelhdf5_save_LIBS=$LIBS - ax_lib_parallelhdf5_save_LDFLAGS=$LDFLAGS - CC=$PARALLELHDF5_CC - CPPFLAGS=$PARALLELHDF5_CPPFLAGS - LIBS=$PARALLELHDF5_LIBS - LDFLAGS=$PARALLELHDF5_LDFLAGS - ac_fn_c_check_header_mongrel "$LINENO" "hdf5.h" "ac_cv_header_hdf5_h" "$ac_includes_default" -if test "x$ac_cv_header_hdf5_h" = xyes; then : - ac_cv_parallelhdf5_h=yes -else - ac_cv_parallelhdf5_h=no -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for H5Fcreate in -lhdf5" >&5 -$as_echo_n "checking for H5Fcreate in -lhdf5... " >&6; } -if ${ac_cv_lib_hdf5_H5Fcreate+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lhdf5 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char H5Fcreate (); -int -main () -{ -return H5Fcreate (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_hdf5_H5Fcreate=yes -else - ac_cv_lib_hdf5_H5Fcreate=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_H5Fcreate" >&5 -$as_echo "$ac_cv_lib_hdf5_H5Fcreate" >&6; } -if test "x$ac_cv_lib_hdf5_H5Fcreate" = xyes; then : - ac_cv_libparallelhdf5=yes -else - ac_cv_libparallelhdf5=no -fi - - if test "$ac_cv_parallelhdf5_h" = "no" && test "$ac_cv_libparallelhdf5" = "no" ; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "Unable to compile HDF5 test program -See \`config.log' for more details" "$LINENO" 5; } - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lhdf5_hl" >&5 -$as_echo_n "checking for main in -lhdf5_hl... " >&6; } -if ${ac_cv_lib_hdf5_hl_main+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lhdf5_hl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ -return main (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_hdf5_hl_main=yes -else - ac_cv_lib_hdf5_hl_main=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hdf5_hl_main" >&5 -$as_echo "$ac_cv_lib_hdf5_hl_main" >&6; } -if test "x$ac_cv_lib_hdf5_hl_main" = xyes; then : - PARALLELHDF5_LIBS="-lhdf5_hl $PARALLELHDF5_LIBS" -fi -ac_cv_lib_hdf5_hl=ac_cv_lib_hdf5_hl_main - - - CC=$ax_lib_parallelhdf5_save_CC - CPPFLAGS=$ax_lib_parallelhdf5_save_CPPFLAGS - LIBS=$ax_lib_parallelhdf5_save_LIBS - LDFLAGS=$ax_lib_parallelhdf5_save_LDFLAGS - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - - - - - - - - -$as_echo "#define HAVE_PARALLELHDF5 1" >>confdefs.h - - fi -fi - -if test "$with_parallelhdf5" = "yes"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: Found parallel HDF5" >&5 -$as_echo "$as_me: Found parallel HDF5" >&6;} - CXXFLAGS="$CXXFLAGS -DPHDF5" - EXTRA_INCS="$EXTRA_INCS $PARALLELHDF5_CPPFLAGS" - EXTRA_LIBS="$EXTRA_LIBS $PARALLELHDF5_LDFLAGS $PARALLELHDF5_LIBS" - BOUT_HAS_PHDF5="yes" - file_formats="$file_formats Parallel HDF5" - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: Parallel HDF5 support disabled" >&5 -$as_echo "$as_me: Parallel HDF5 support disabled" >&6;} - -fi - ############################################################# # Check file formats ############################################################# @@ -16326,18 +14842,6 @@ fi -if test "x$BOUT_HAS_HDF5" = "xyes"; then : - -$as_echo "#define BOUT_HAS_HDF5 1" >>confdefs.h - -else - -$as_echo "#define BOUT_HAS_HDF5 0" >>confdefs.h - -fi - - - if test "x$BOUT_HAS_IDA" = "xyes"; then : $as_echo "#define BOUT_HAS_IDA 1" >>confdefs.h @@ -18069,8 +16573,6 @@ $as_echo "$as_me: FFTW support : $BOUT_HAS_FFTW" >&6;} $as_echo "$as_me: NetCDF support : $BOUT_HAS_NETCDF (legacy: $BOUT_HAS_LEGACY_NETCDF)" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: Parallel-NetCDF support : $BOUT_HAS_PNETCDF" >&5 $as_echo "$as_me: Parallel-NetCDF support : $BOUT_HAS_PNETCDF" >&6;} -{ $as_echo "$as_me:${as_lineno-$LINENO}: HDF5 support : $BOUT_HAS_HDF5 (parallel: $BOUT_HAS_PHDF5)" >&5 -$as_echo "$as_me: HDF5 support : $BOUT_HAS_HDF5 (parallel: $BOUT_HAS_PHDF5)" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: Lapack support : $BOUT_HAS_LAPACK" >&5 $as_echo "$as_me: Lapack support : $BOUT_HAS_LAPACK" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: Scorep support : $BOUT_HAS_SCOREP" >&5 diff --git a/configure.ac b/configure.ac index 1f6614f9c3..263bbc074a 100644 --- a/configure.ac +++ b/configure.ac @@ -63,8 +63,6 @@ AC_ARG_WITH(scorep, [AS_HELP_STRING([--with-scorep], AC_ARG_WITH(system_mpark, [AS_HELP_STRING([--with-system-mpark], [Use mpark.variant already installed rather then the bundled one])],,[with_system_mpark=auto]) -dnl --with-hdf5 flags are set in AX_LIB_{PARALLEL}HDF5 - AC_ARG_ENABLE(warnings, [AS_HELP_STRING([--disable-warnings], [Disable compiler warnings])],,[]) AC_ARG_ENABLE(checks, [AS_HELP_STRING([--enable-checks=no/1/2/3], @@ -636,35 +634,6 @@ AS_IF([test "x$PNCPATH" = "x"], [ AC_MSG_NOTICE([Parallel-NetCDF support enabled]) ]) -############################################################# -# HDF5 library -############################################################# - -BOUT_HAS_HDF5="no" -AX_LIB_HDF5([serial]) -AS_IF([test "$with_hdf5" = "yes"], [ - AC_MSG_NOTICE([Found HDF5]) - EXTRA_INCS="$EXTRA_INCS $HDF5_CPPFLAGS" - EXTRA_LIBS="$EXTRA_LIBS $HDF5_LDFLAGS $HDF5_LIBS" - BOUT_HAS_HDF5="yes" - file_formats="$file_formats HDF5" - ], [ - AC_MSG_NOTICE([Serial HDF5 support disabled]) -]) - -BOUT_HAS_PHDF5="no" -AX_LIB_PARALLELHDF5() -AS_IF([test "$with_parallelhdf5" = "yes"], [ - AC_MSG_NOTICE([Found parallel HDF5]) - CXXFLAGS="$CXXFLAGS -DPHDF5" - EXTRA_INCS="$EXTRA_INCS $PARALLELHDF5_CPPFLAGS" - EXTRA_LIBS="$EXTRA_LIBS $PARALLELHDF5_LDFLAGS $PARALLELHDF5_LIBS" - BOUT_HAS_PHDF5="yes" - file_formats="$file_formats Parallel HDF5" - ], [ - AC_MSG_NOTICE([Parallel HDF5 support disabled]) -]) - ############################################################# # Check file formats ############################################################# @@ -1343,7 +1312,6 @@ BOUT_DEFINE_SUBST(BOUT_HAS_ARKODE, [ARKODE support]) BOUT_DEFINE_SUBST(BOUT_HAS_CVODE, [CVODE support]) BOUT_DEFINE_SUBST(BOUT_HAS_FFTW, [FFTW support]) BOUT_DEFINE_SUBST(BOUT_HAS_GETTEXT, [NLS support]) -BOUT_DEFINE_SUBST(BOUT_HAS_HDF5, [HDF5 support]) BOUT_DEFINE_SUBST(BOUT_HAS_IDA, [IDA support]) BOUT_DEFINE_SUBST(BOUT_HAS_LAPACK, [LAPACK support]) BOUT_DEFINE_SUBST(BOUT_HAS_NETCDF, [NETCDF support]) @@ -1397,7 +1365,6 @@ AC_MSG_NOTICE([ ARKODE support : $BOUT_HAS_ARKODE]) AC_MSG_NOTICE([ FFTW support : $BOUT_HAS_FFTW]) AC_MSG_NOTICE([ NetCDF support : $BOUT_HAS_NETCDF (legacy: $BOUT_HAS_LEGACY_NETCDF)]) AC_MSG_NOTICE([ Parallel-NetCDF support : $BOUT_HAS_PNETCDF]) -AC_MSG_NOTICE([ HDF5 support : $BOUT_HAS_HDF5 (parallel: $BOUT_HAS_PHDF5)]) AC_MSG_NOTICE([ Lapack support : $BOUT_HAS_LAPACK]) AC_MSG_NOTICE([ Scorep support : $BOUT_HAS_SCOREP]) AC_MSG_NOTICE([ OpenMP support : $BOUT_USE_OPENMP (schedule: $OPENMP_SCHEDULE)]) diff --git a/include/bout/build_config.hxx b/include/bout/build_config.hxx index acd8a6b33b..07bd38dd95 100644 --- a/include/bout/build_config.hxx +++ b/include/bout/build_config.hxx @@ -14,7 +14,6 @@ constexpr auto openmp_schedule = STRINGIFY(BOUT_OPENMP_SCHEDULE); constexpr auto has_fftw = static_cast(BOUT_HAS_FFTW); constexpr auto has_gettext = static_cast(BOUT_HAS_GETTEXT); -constexpr auto has_hdf5 = static_cast(BOUT_HAS_HDF5); constexpr auto has_lapack = static_cast(BOUT_HAS_LAPACK); constexpr auto has_legacy_netcdf = static_cast(BOUT_HAS_LEGACY_NETCDF); constexpr auto has_netcdf = static_cast(BOUT_HAS_NETCDF); diff --git a/include/dataformat.hxx b/include/dataformat.hxx index 204d103483..b8d1321464 100644 --- a/include/dataformat.hxx +++ b/include/dataformat.hxx @@ -1,7 +1,7 @@ /*! * \file dataformat.hxx * - * \brief Generic interface for file formats e.g. netCDF, HDF5 + * \brief Generic interface for file formats e.g. netCDF * * \author B.Dudson * \date April 2009 diff --git a/m4/ax_lib_hdf5.m4 b/m4/ax_lib_hdf5.m4 deleted file mode 100644 index edd10839ab..0000000000 --- a/m4/ax_lib_hdf5.m4 +++ /dev/null @@ -1,303 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIB_HDF5([serial/parallel]) -# -# DESCRIPTION -# -# This macro provides tests of the availability of HDF5 library. -# -# The optional macro argument should be either 'serial' or 'parallel'. The -# former only looks for serial HDF5 installations via h5cc. The latter -# only looks for parallel HDF5 installations via h5pcc. If the optional -# argument is omitted, serial installations will be preferred over -# parallel ones. -# -# The macro adds a --with-hdf5 option accepting one of three values: -# -# no - do not check for the HDF5 library. -# yes - do check for HDF5 library in standard locations. -# path - complete path to the HDF5 helper script h5cc or h5pcc. -# -# If HDF5 is successfully found, this macro calls -# -# AC_SUBST(HDF5_VERSION) -# AC_SUBST(HDF5_CC) -# AC_SUBST(HDF5_CFLAGS) -# AC_SUBST(HDF5_CPPFLAGS) -# AC_SUBST(HDF5_LDFLAGS) -# AC_SUBST(HDF5_LIBS) -# AC_SUBST(HDF5_FC) -# AC_SUBST(HDF5_FFLAGS) -# AC_SUBST(HDF5_FLIBS) -# AC_SUBST(HDF5_TYPE) -# AC_DEFINE(HAVE_HDF5) -# -# and sets with_hdf5="yes". Additionally, the macro sets -# with_hdf5_fortran="yes" if a matching Fortran wrapper script is found. -# Note that Autconf's Fortran support is not used to perform this check. -# H5CC and H5FC will contain the appropriate serial or parallel HDF5 -# wrapper script locations. -# -# If HDF5 is disabled or not found, this macros sets with_hdf5="no" and -# with_hdf5_fortran="no". -# -# Your configuration script can test $with_hdf to take any further -# actions. HDF5_{C,CPP,LD}FLAGS may be used when building with C or C++. -# HDF5_F{FLAGS,LIBS} should be used when building Fortran applications. -# -# To use the macro, one would code one of the following in "configure.ac" -# before AC_OUTPUT: -# -# 1) dnl Check for HDF5 support -# AX_LIB_HDF5() -# -# 2) dnl Check for serial HDF5 support -# AX_LIB_HDF5([serial]) -# -# 3) dnl Check for parallel HDF5 support -# AX_LIB_HDF5([parallel]) -# -# One could test $with_hdf5 for the outcome or display it as follows -# -# echo "HDF5 support: $with_hdf5" -# -# You could also for example, override the default CC in "configure.ac" to -# enforce compilation with the compiler that HDF5 uses: -# -# AX_LIB_HDF5([parallel]) -# if test "$with_hdf5" = "yes"; then -# CC="$HDF5_CC" -# else -# AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.]) -# fi -# -# The HDF5_TYPE environment variable returns "parallel" or "serial", -# depending on which type of library is found. -# -# LICENSE -# -# Copyright (c) 2009 Timothy Brown -# Copyright (c) 2010 Rhys Ulerich -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 15 - -AC_DEFUN([AX_LIB_HDF5], [ - -AC_REQUIRE([AC_PROG_SED]) -AC_REQUIRE([AC_PROG_AWK]) -AC_REQUIRE([AC_PROG_GREP]) - -dnl Check first argument is one of the recognized values. -dnl Fail eagerly if is incorrect as this simplifies case statements below. -if test "m4_normalize(m4_default([$1],[]))" = "" ; then - : # Recognized value -elif test "m4_normalize(m4_default([$1],[]))" = "serial" ; then - : # Recognized value -elif test "m4_normalize(m4_default([$1],[]))" = "parallel"; then - : # Recognized value -else - AC_MSG_ERROR([ -Unrecognized value for AX[]_LIB_HDF5 within configure.ac. -If supplied, argument 1 must be either 'serial' or 'parallel'. -]) -fi - -dnl Add a default --with-hdf5 configuration option. -AC_ARG_WITH([hdf5], - AS_HELP_STRING( - [--with-hdf5=[yes/no/PATH]], - m4_case(m4_normalize([$1]), - [serial], [location of h5cc for serial HDF5 configuration], - [parallel], [location of h5pcc for parallel HDF5 configuration], - [location of h5cc or h5pcc for HDF5 configuration]) - ), - [if test "$withval" = "no"; then - with_hdf5="no" - elif test "$withval" = "yes"; then - with_hdf5="yes" - else - with_hdf5="yes" - H5CC="$withval" - fi], - [with_hdf5="guess"] -) - -dnl Set defaults to blank -HDF5_CC="" -HDF5_VERSION="" -HDF5_CFLAGS="" -HDF5_CPPFLAGS="" -HDF5_LDFLAGS="" -HDF5_LIBS="" -HDF5_FC="" -HDF5_FFLAGS="" -HDF5_FLIBS="" -HDF5_TYPE="" - -dnl Try and find hdf5 compiler tools and options. -if test "$with_hdf5" = "yes" || test "$with_hdf5" = "guess"; then - if test -z "$H5CC"; then - dnl Check to see if H5CC is in the path. - AC_PATH_PROGS( - [H5CC], - m4_case(m4_normalize([$1]), - [serial], [h5cc], - [parallel], [h5pcc], - [h5cc h5pcc]), - []) - else - AC_MSG_CHECKING([Using provided HDF5 C wrapper]) - AC_MSG_RESULT([$H5CC]) - fi - AC_MSG_CHECKING([for HDF5 type]) - AS_CASE([$H5CC], - [*h5pcc], [HDF5_TYPE=parallel], - [*h5cc], [HDF5_TYPE=serial], - [HDF5_TYPE=neither]) - AC_MSG_RESULT([$HDF5_TYPE]) - if test ! -f "$H5CC" || test ! -x "$H5CC"; then - - AC_MSG_CHECKING([if we can compile HDF5 program without helper script]) - AC_LANG_PUSH([C++]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([ - #include - ], [H5Fcreate(0, 0, 0, 0);])], - [ac_cv_hdf5_h=yes - ac_cv_libhdf5=yes], - [ac_cv_hdf5_h=no - ac_cv_libhdf5=no]) - AC_MSG_RESULT([$ac_cv_libhdf5]) - AC_LANG_POP([C++]) - - if test "$ac_cv_libhdf5" = "no" ; then - AC_MSG_WARN([Unable to compile HDF5 test program]) - AC_MSG_WARN(m4_case(m4_normalize([$1]), - [serial], [ -Unable to locate serial HDF5 compilation helper script 'h5cc'. -Please specify --with-hdf5= as the full path to h5cc. -HDF5 support is being disabled (equivalent to --with-hdf5=no). -], [parallel],[ -Unable to locate parallel HDF5 compilation helper script 'h5pcc'. -Please specify --with-hdf5= as the full path to h5pcc. -HDF5 support is being disabled (equivalent to --with-hdf5=no). -], [ -Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'. -Please specify --with-hdf5= as the full path to h5cc or h5pcc. -HDF5 support is being disabled (equivalent to --with-hdf5=no). -])) - if test "$with_hdf5" = "yes"; then - AC_MSG_FAILURE([HDF5 was requested, but could not be compiled]) - fi - with_hdf5="no" - else - with_hdf5="yes" - fi - else - AC_MSG_CHECKING([for HDF5 libraries]) - dnl Get the h5cc output - HDF5_SHOW=$(eval $H5CC -show) - - dnl Get the actual compiler used - HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]1}') - if test "$HDF5_CC" = "ccache"; then - HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]2}') - fi - - dnl h5cc provides both AM_ and non-AM_ options - dnl depending on how it was compiled either one of - dnl these are empty. Lets roll them both into one. - - dnl Look for "HDF5 Version: X.Y.Z" - HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' \ - | $AWK '{print $[]3}') - - dnl A ideal situation would be where everything we needed was - dnl in the AM_* variables. However most systems are not like this - dnl and seem to have the values in the non-AM variables. - dnl - dnl We try the following to find the flags: - dnl (1) Look for "NAME:" tags - dnl (2) Look for "H5_NAME:" tags - dnl (3) Look for "AM_NAME:" tags - dnl - HDF5_tmp_flags=$(eval $H5CC -showconfig \ - | $GREP 'FLAGS\|Extra libraries:' \ - | $AWK -F: '{printf("%s "), $[]2}' ) - - dnl Find the installation directory and append include/ - HDF5_tmp_inst=$(eval $H5CC -showconfig \ - | $GREP 'Installation point:' \ - | $AWK '{print $[]NF}' ) - - dnl Add this to the CPPFLAGS - HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include" - - dnl Now sort the flags out based upon their prefixes - for arg in $HDF5_SHOW $HDF5_tmp_flags ; do - case "$arg" in - -I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_CPPFLAGS="$HDF5_CPPFLAGS $arg" - ;; - -L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_LDFLAGS="$HDF5_LDFLAGS $arg" - ;; - -l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ - || HDF5_LIBS="$HDF5_LIBS $arg" - ;; - esac - done - - HDF5_LIBS="-lhdf5 $HDF5_LIBS" - AC_MSG_RESULT([yes (version $[HDF5_VERSION])]) - - dnl See if we can compile - AC_LANG_PUSH([C]) - ax_lib_hdf5_save_CC=$CC - ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS - ax_lib_hdf5_save_LIBS=$LIBS - ax_lib_hdf5_save_LDFLAGS=$LDFLAGS - CC=$HDF5_CC - CPPFLAGS=$HDF5_CPPFLAGS - LIBS=$HDF5_LIBS - LDFLAGS=$HDF5_LDFLAGS - AC_CHECK_HEADER([hdf5.h], [ac_cv_hdf5_h=yes], [ac_cv_hdf5_h=no]) - AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libhdf5=yes], - [ac_cv_libhdf5=no]) - if test "$ac_cv_hdf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then - if test "$with_hdf5" = "yes"; then - AC_MSG_FAILURE([Unable to compile HDF5 test program]) - else - AC_MSG_WARN([Unable to compile HDF5 test program]) - fi - fi - with_hdf5=yes - dnl Look for HDF5's high level library - AC_HAVE_LIBRARY([hdf5_hl], [HDF5_LIBS="-lhdf5_hl $HDF5_LIBS"], [], []) - - CC=$ax_lib_hdf5_save_CC - CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS - LIBS=$ax_lib_hdf5_save_LIBS - LDFLAGS=$ax_lib_hdf5_save_LDFLAGS - AC_LANG_POP([C]) - - AC_SUBST([HDF5_VERSION]) - AC_SUBST([HDF5_CC]) - AC_SUBST([HDF5_CFLAGS]) - AC_SUBST([HDF5_CPPFLAGS]) - AC_SUBST([HDF5_LDFLAGS]) - AC_SUBST([HDF5_LIBS]) - AC_SUBST([HDF5_TYPE]) - AC_DEFINE([HAVE_HDF5], [1], [Defined if you have HDF5 support]) - fi -fi -]) diff --git a/m4/ax_lib_parallelhdf5.m4 b/m4/ax_lib_parallelhdf5.m4 deleted file mode 100644 index 28d4c952a6..0000000000 --- a/m4/ax_lib_parallelhdf5.m4 +++ /dev/null @@ -1,273 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIB_HDF5([serial/parallel]) -# -# DESCRIPTION -# -# This macro provides tests of the availability of HDF5 library. -# -# The optional macro argument should be either 'serial' or 'parallel'. The -# former only looks for serial HDF5 installations via h5cc. The latter -# only looks for parallel HDF5 installations via h5pcc. If the optional -# argument is omitted, serial installations will be preferred over -# parallel ones. -# -# The macro adds a --with-hdf5 option accepting one of three values: -# -# no - do not check for the HDF5 library. -# yes - do check for HDF5 library in standard locations. -# path - complete path to the HDF5 helper script h5cc or h5pcc. -# -# If HDF5 is successfully found, this macro calls -# -# AC_SUBST(HDF5_VERSION) -# AC_SUBST(HDF5_CC) -# AC_SUBST(HDF5_CFLAGS) -# AC_SUBST(HDF5_CPPFLAGS) -# AC_SUBST(HDF5_LDFLAGS) -# AC_SUBST(HDF5_LIBS) -# AC_SUBST(HDF5_FC) -# AC_SUBST(HDF5_FFLAGS) -# AC_SUBST(HDF5_FLIBS) -# AC_SUBST(HDF5_TYPE) -# AC_DEFINE(HAVE_HDF5) -# -# and sets with_hdf5="yes". Additionally, the macro sets -# with_hdf5_fortran="yes" if a matching Fortran wrapper script is found. -# Note that Autconf's Fortran support is not used to perform this check. -# H5CC and H5FC will contain the appropriate serial or parallel HDF5 -# wrapper script locations. -# -# If HDF5 is disabled or not found, this macros sets with_hdf5="no" and -# with_hdf5_fortran="no". -# -# Your configuration script can test $with_hdf to take any further -# actions. HDF5_{C,CPP,LD}FLAGS may be used when building with C or C++. -# HDF5_F{FLAGS,LIBS} should be used when building Fortran applications. -# -# To use the macro, one would code one of the following in "configure.ac" -# before AC_OUTPUT: -# -# 1) dnl Check for HDF5 support -# AX_LIB_HDF5() -# -# 2) dnl Check for serial HDF5 support -# AX_LIB_HDF5([serial]) -# -# 3) dnl Check for parallel HDF5 support -# AX_LIB_HDF5([parallel]) -# -# One could test $with_hdf5 for the outcome or display it as follows -# -# echo "HDF5 support: $with_hdf5" -# -# You could also for example, override the default CC in "configure.ac" to -# enforce compilation with the compiler that HDF5 uses: -# -# AX_LIB_HDF5([parallel]) -# if test "$with_hdf5" = "yes"; then -# CC="$HDF5_CC" -# else -# AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.]) -# fi -# -# The HDF5_TYPE environment variable returns "parallel" or "serial", -# depending on which type of library is found. -# -# LICENSE -# -# Copyright (c) 2009 Timothy Brown -# Copyright (c) 2010 Rhys Ulerich -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 15 - -AC_DEFUN([AX_LIB_PARALLELHDF5], [ - -AC_REQUIRE([AC_PROG_SED]) -AC_REQUIRE([AC_PROG_AWK]) -AC_REQUIRE([AC_PROG_GREP]) - -dnl Add a default --with-parallelhdf5 configuration option. -AC_ARG_WITH([parallelhdf5], - AS_HELP_STRING( - [--with-parallelhdf5=[yes/no/PATH]], - [location of h5pcc for parallel HDF5 configuration] - ), - [if test "$withval" = "no"; then - with_parallelhdf5="no" - elif test "$withval" = "yes"; then - with_parallelhdf5="yes" - else - with_parallelhdf5="yes" - PARALLELH5CC="$withval" - fi], - [with_parallelhdf5="no"] -) - -dnl Set defaults to blank -PARALLELHDF5_CC="" -PARALLELHDF5_VERSION="" -PARALLELHDF5_CFLAGS="" -PARALLELHDF5_CPPFLAGS="" -PARALLELHDF5_LDFLAGS="" -PARALLELHDF5_LIBS="" -PARALLELHDF5_FC="" -PARALLELHDF5_FFLAGS="" -PARALLELHDF5_FLIBS="" -PARALLELHDF5_TYPE="" - -dnl Try and find hdf5 compiler tools and options. -if test "$with_parallelhdf5" = "yes"; then - if test -z "$PARALLELH5CC"; then - dnl Check to see if H5CC is in the path. - AC_PATH_PROGS( - [PARALLELH5CC], [h5pcc] - []) - else - AC_MSG_CHECKING([Using provided HDF5 C wrapper]) - AC_MSG_RESULT([$PARALLELH5CC]) - fi - AC_MSG_CHECKING([for HDF5 type]) - AS_CASE([$PARALLELH5CC], - [*h5pcc], [PARALLELHDF5_TYPE=parallel], - [*h5cc], [PARALLELHDF5_TYPE=serial], - [PARALLELHDF5_TYPE=neither]) - AC_MSG_RESULT([$PARALLELHDF5_TYPE]) - - if test ! -f "$PARALLELH5CC" || test ! -x "$PARALLELH5CC"; then - - AC_MSG_CHECKING([if we can compile parallel HDF5 program without helper script]) - AC_LANG_PUSH([C++]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([ - #include - ], [H5Fcreate(0, 0, 0, 0);])], - [ac_cv_parallelhdf5_h=yes - ac_cv_libparallelhdf5=yes], - [ac_cv_parallelhdf5_h=no - ac_cv_libparallelhdf5=no]) - AC_MSG_RESULT([$ac_cv_parallelhdf5_h]) - - if test "$ac_cv_parallelhdf5_h" = "yes"; then - AC_MSG_CHECKING([if found HDF5 is parallel]) - AC_EGREP_CPP([yes], [ - #include - #ifdef H5_HAVE_PARALLEL - yes - #endif - ], [ac_cv_parallelhdf5_h=yes], [ac_cv_parallelhdf5_h=no]) - AC_MSG_RESULT([$ac_cv_parallelhdf5_h]) - fi - AC_LANG_POP([C++]) - - if test "$ac_cv_parallelhdf5_h" = "no" ; then - AC_MSG_FAILURE([ -Unable to locate parallel HDF5 compilation helper script 'h5pcc'. -Please specify --with-parallelhdf5= as the full path to h5pcc. -HDF5 support is being disabled (equivalent to --with-parallelhdf5=no). -]) - with_parallelhdf5="no" - fi - else - AC_MSG_CHECKING([for HDF5 libraries]) - dnl Get the h5cc output - PARALLELHDF5_SHOW=$(eval $PARALLELH5CC -show) - - dnl Get the actual compiler used - PARALLELHDF5_CC=$(eval $PARALLELH5CC -show | $AWK '{print $[]1}') - if test "$PARALLELHDF5_CC" = "ccache"; then - PARALLELHDF5_CC=$(eval $PARALLELH5CC -show | $AWK '{print $[]2}') - fi - - dnl h5cc provides both AM_ and non-AM_ options - dnl depending on how it was compiled either one of - dnl these are empty. Lets roll them both into one. - - dnl Look for "HDF5 Version: X.Y.Z" - PARALLELHDF5_VERSION=$(eval $PARALLELH5CC -showconfig | $GREP 'HDF5 Version:' \ - | $AWK '{print $[]3}') - - dnl A ideal situation would be where everything we needed was - dnl in the AM_* variables. However most systems are not like this - dnl and seem to have the values in the non-AM variables. - dnl - dnl We try the following to find the flags: - dnl (1) Look for "NAME:" tags - dnl (2) Look for "H5_NAME:" tags - dnl (3) Look for "AM_NAME:" tags - dnl - PARALLELHDF5_tmp_flags=$(eval $PARALLELH5CC -showconfig \ - | $GREP 'FLAGS\|Extra libraries:' \ - | $AWK -F: '{printf("%s "), $[]2}' ) - - dnl Find the installation directory and append include/ - PARALLELHDF5_tmp_inst=$(eval $PARALLELH5CC -showconfig \ - | $GREP 'Installation point:' \ - | $AWK '{print $[]NF}' ) - - dnl Add this to the CPPFLAGS - PARALLELHDF5_CPPFLAGS="-I${PARALLELHDF5_tmp_inst}/include" - - dnl Now sort the flags out based upon their prefixes - for arg in $PARALLELHDF5_SHOW $PARALLELHDF5_tmp_flags ; do - case "$arg" in - -I*) echo $PARALLELHDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_CPPFLAGS="$PARALLELHDF5_CPPFLAGS $arg" - ;; - -L*) echo $PARALLELHDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_LDFLAGS="$PARALLELHDF5_LDFLAGS $arg" - ;; - -l*) echo $PARALLELHDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \ - || PARALLELHDF5_LIBS="$PARALLELHDF5_LIBS $arg" - ;; - esac - done - - PARALLELHDF5_LIBS="-lhdf5 $PARALLELHDF5_LIBS" - AC_MSG_RESULT([yes (version $[PARALLELHDF5_VERSION])]) - - dnl See if we can compile - AC_LANG_PUSH([C]) - ax_lib_parallelhdf5_save_CC=$CC - ax_lib_parallelhdf5_save_CPPFLAGS=$CPPFLAGS - ax_lib_parallelhdf5_save_LIBS=$LIBS - ax_lib_parallelhdf5_save_LDFLAGS=$LDFLAGS - CC=$PARALLELHDF5_CC - CPPFLAGS=$PARALLELHDF5_CPPFLAGS - LIBS=$PARALLELHDF5_LIBS - LDFLAGS=$PARALLELHDF5_LDFLAGS - AC_CHECK_HEADER([hdf5.h], [ac_cv_parallelhdf5_h=yes], [ac_cv_parallelhdf5_h=no]) - AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libparallelhdf5=yes], - [ac_cv_libparallelhdf5=no]) - if test "$ac_cv_parallelhdf5_h" = "no" && test "$ac_cv_libparallelhdf5" = "no" ; then - AC_MSG_FAILURE([Unable to compile HDF5 test program]) - fi - dnl Look for HDF5's high level library - AC_HAVE_LIBRARY([hdf5_hl], [PARALLELHDF5_LIBS="-lhdf5_hl $PARALLELHDF5_LIBS"], [], []) - - CC=$ax_lib_parallelhdf5_save_CC - CPPFLAGS=$ax_lib_parallelhdf5_save_CPPFLAGS - LIBS=$ax_lib_parallelhdf5_save_LIBS - LDFLAGS=$ax_lib_parallelhdf5_save_LDFLAGS - AC_LANG_POP([C]) - - AC_SUBST([PARALLELHDF5_VERSION]) - AC_SUBST([PARALLELHDF5_CC]) - AC_SUBST([PARALLELHDF5_CFLAGS]) - AC_SUBST([PARALLELHDF5_CPPFLAGS]) - AC_SUBST([PARALLELHDF5_LDFLAGS]) - AC_SUBST([PARALLELHDF5_LIBS]) - AC_SUBST([PARALLELHDF5_TYPE]) - AC_DEFINE([HAVE_PARALLELHDF5], [1], [Defined if you have parallel HDF5 support]) - fi -fi -]) diff --git a/manual/doxygen/Doxyfile b/manual/doxygen/Doxyfile index 6442efc567..9a00766741 100644 --- a/manual/doxygen/Doxyfile +++ b/manual/doxygen/Doxyfile @@ -2061,7 +2061,6 @@ PREDEFINED = BACKTRACE \ CHECK=3 \ DEPRECATED(func)=func \ HAS_PRETTY_FUNCTION \ - HDF5 \ LAPACK \ LOGCOLOR \ NCDF \ @@ -2069,7 +2068,6 @@ PREDEFINED = BACKTRACE \ PETSC_HAS_SUNDIALS \ PETSC_RELEASE \ PETSC_VERSION=3.8 \ - PHDF5 \ PNCDF \ SIGHANDLE \ TRACK \ diff --git a/manual/doxygen/Doxyfile_readthedocs b/manual/doxygen/Doxyfile_readthedocs index d2d00e0997..a0f8a669af 100644 --- a/manual/doxygen/Doxyfile_readthedocs +++ b/manual/doxygen/Doxyfile_readthedocs @@ -1021,7 +1021,6 @@ PREDEFINED = BACKTRACE \ CHECK=3 \ DEPRECATED(func)=func \ HAS_PRETTY_FUNCTION \ - HDF5 \ LAPACK \ LOGCOLOR \ NCDF \ @@ -1029,7 +1028,6 @@ PREDEFINED = BACKTRACE \ PETSC_HAS_SUNDIALS \ PETSC_RELEASE \ PETSC_VERSION=3.8 \ - PHDF5 \ PNCDF \ SIGHANDLE \ TRACK \ diff --git a/manual/sphinx/developer_docs/code_layout.rst b/manual/sphinx/developer_docs/code_layout.rst index b796f8a069..741e71e44b 100644 --- a/manual/sphinx/developer_docs/code_layout.rst +++ b/manual/sphinx/developer_docs/code_layout.rst @@ -150,13 +150,6 @@ The current source code files are: - :doc:`emptyformat.hxx<../_breathe_autogen/file/emptyformat_8hxx>` - - hdf5 - - - :doc:`h5_format.cxx<../_breathe_autogen/file/h5__format_8cxx>` implements an - interface to the HDF5 library - - - :doc:`h5_format.hxx<../_breathe_autogen/file/h5__format_8hxx>` - - netcdf - :doc:`nc_format.cxx<../_breathe_autogen/file/nc__format_8cxx>` implements an diff --git a/manual/sphinx/developer_docs/file_io.rst b/manual/sphinx/developer_docs/file_io.rst index d5cc038a76..9910baed05 100644 --- a/manual/sphinx/developer_docs/file_io.rst +++ b/manual/sphinx/developer_docs/file_io.rst @@ -10,12 +10,12 @@ and the `Datafile` class :doc:`datafile.cxx<../_breathe_autogen/file/datafile_8cxx>`). All other parts which need to read or write data go through these methods. -Several different file formats are commonly used, such as HDF, HDF5, -and netCDF. For historical reasons (inherited from BOUT), BOUT++ -originally used the Portable Data Binary (PDB) format developed at -LLNL [1]_. To separate the basic file format functions from the higher -level grid and Datafile classes, these use an abstract class -`DataFormat`. Any class which implements the functions listed in +netCDF is used for binary I/O. For historical reasons (inherited from +BOUT), BOUT++ originally used the Portable Data Binary (PDB) format +developed at LLNL [1]_. HDF5 was also previously supported. To +separate the basic file format functions from the higher level grid +and Datafile classes, these use an abstract class `DataFormat`. Any +class which implements the functions listed in :doc:`dataformat.hxx<../_breathe_autogen/file/dataformat_8hxx>` can therefore be passed to grid or datafile. This makes implementing a new file format, and switching between formats at run-time, relatively diff --git a/manual/sphinx/user_docs/advanced_install.rst b/manual/sphinx/user_docs/advanced_install.rst index d39aa9658a..d4ec77cb33 100644 --- a/manual/sphinx/user_docs/advanced_install.rst +++ b/manual/sphinx/user_docs/advanced_install.rst @@ -254,11 +254,11 @@ Finally example configurations for BOUT++, where you should replace <...> by app * for an optimized build (some experimentation with optimisation flags would be welcome, please share the results if you do!):: - ./configure --enable-optimize=3 --enable-checks=no --without-hdf5 --enable-static --with-netcdf=<...> --with-sundials=<...> --with-fftw=<...> --with-petsc=<...> + ./configure --enable-optimize=3 --enable-checks=no --enable-static --with-netcdf=<...> --with-sundials=<...> --with-fftw=<...> --with-petsc=<...> * for a debugging build:: - ./configure --enable-debug --without-hdf5 --enable-static --with-netcdf=<...> --with-sundials=<...> --with-fftw=<...> --with-petsc=<...> + ./configure --enable-debug --enable-static --with-netcdf=<...> --with-sundials=<...> --with-fftw=<...> --with-petsc=<...> Ubgl ~~~~ @@ -271,21 +271,16 @@ Ubgl File formats ------------ -BOUT++ can currently use two different file formats: NetCDF-4_, and -HDF5_ and experimental support for parallel flavours of both. NetCDF -is a widely used format and so has many more tools for viewing and -manipulating files. HDF5 is another widely used format. If you have -multiple libraries installed then BOUT++ can use them simultaneously, -for example reading in grid files in NetCDF format, but writing output -data in HDF5 format. +BOUT++ can currently use the NetCDF-4_ file format, with experimental +support for the parallel flavour. NetCDF is a widely used format and +has many tools for viewing and manipulating files. .. _NetCDF-4: https://www.unidata.ucar.edu/software/netcdf/ -.. _HDF5: https://www.hdfgroup.org/HDF5/ -BOUT++ will try to use NetCDF by default. It will look for -``ncxx4-config`` or ``nc-config`` in your ``$PATH``. If it cannot find -the libraries, or finds a different version than the one you want, you -can point it at the correct version using:: +BOUT++ will look for ``ncxx4-config`` or ``nc-config`` in your +``$PATH``. If it cannot find the libraries, or finds a different +version than the one you want, you can point it at the correct version +using:: ./configure --with-netcdf=/path/to/ncxx4-config @@ -293,16 +288,6 @@ where ``/path/to/ncxx4-config`` is the location of the ``ncxx4-config`` tool (``nc-config`` will also work, but ``ncxx4-config`` is preferred). -To use HDF5, you will need to explicitly enable it:: - - ./configure --with-hdf5 - -BOUT++ will look for ``h5cc`` in your ``$PATH``. Similar to NetCDF, -you can pass the location of the particular version you wish to use -with:: - - ./configure --with-hdf5=/path/to/h5cc - .. _sec-netcdf-from-source: diff --git a/manual/sphinx/user_docs/bout_options.rst b/manual/sphinx/user_docs/bout_options.rst index 4758163ac1..201aa09798 100644 --- a/manual/sphinx/user_docs/bout_options.rst +++ b/manual/sphinx/user_docs/bout_options.rst @@ -4,7 +4,7 @@ BOUT++ options ============== The inputs to BOUT++ are a text file containing options, command-line options, -and for complex grids a binary grid file in NetCDF or HDF5 format. Generating input +and for complex grids a binary grid file in NetCDF format. Generating input grids for tokamaks is described in :ref:`sec-gridgen`. The grid file describes the size and topology of the X-Y domain, metric tensor components and usually some initial profiles. The option file specifies @@ -437,20 +437,10 @@ may be useful anyway. See :ref:`sec-output` for more details. Input and Output ---------------- -The format of the output (dump) files can be controlled, if support for -more than one output format has been configured, by setting the -top-level option **dump\_format** to one of the recognised file -extensions: ‘nc’ for NetCDF; ‘hdf5’, ‘hdf’ or ‘h5’ for HDF5. For example -to select HDF5 instead of the default NetCDF format put - -.. code-block:: cfg - - dump_format = hdf5 - -before any section headers. The output (dump) files with time-history -are controlled by settings in a section called “output”. Restart files -contain a single time-slice, and are controlled by a section called -“restart”. The options available are listed in table :numref:`tab-outputopts`. +The output (dump) files with time-history are controlled by settings +in a section called “output”. Restart files contain a single +time-slice, and are controlled by a section called “restart”. The +options available are listed in table :numref:`tab-outputopts`. .. _tab-outputopts: .. table:: Output file options diff --git a/manual/sphinx/user_docs/input_grids.rst b/manual/sphinx/user_docs/input_grids.rst index 7c19db8eec..b4383bfb30 100644 --- a/manual/sphinx/user_docs/input_grids.rst +++ b/manual/sphinx/user_docs/input_grids.rst @@ -100,9 +100,9 @@ e.g. “``section:variable``”. More complex meshes can be created by supplying an input grid file to describe the grid points, geometry, and starting profiles. Currently -BOUT++ supports NetCDF and HDF5 format binary files. During startup, -BOUT++ looks in the grid file for the following variables. If any are -not found, a warning will be printed and the default values used. +BOUT++ supports NetCDF format binary files. During startup, BOUT++ +looks in the grid file for the following variables. If any are not +found, a warning will be printed and the default values used. - X and Y grid sizes (integers) ``nx`` and ``ny`` **REQUIRED** @@ -117,14 +117,9 @@ not found, a warning will be printed and the default values used. ``g13[nx][ny]``, and ``g23[nx][ny]``. If not found, these will be set to 0. -- Z shift for interpolation between field-aligned coordinates and - shifted coordinates (see ``manual/coordinates.pdf``). Perpendicular - differential operators are calculated in shifted coordinates when - ``ShiftXderivs`` in ``mesh/mesh.hxx`` is enabled. ``ShiftXderivs`` - can be set in the root section of ``BOUT.inp`` as - ``ShiftXderivs = true``. The shifts must be provided in the gridfile - in a field ``zshift[nx][ny]``. If not found, ``zshift`` is set to - zero. +- Z shift for interpolation between the base and field-aligned grids, see + :ref:`sec-parallel-transforms`. The shifts must be provided in the gridfile + in a field ``zShift(nx, ny)``. If not found, ``zShift`` is set to zero. The remaining quantities determine the topology of the grid. These are based on tokamak single/double-null configurations, but can be adapted @@ -766,4 +761,3 @@ with the following formula: where :math:`R_0` is the major radius, :math:`a` is the minor radius, :math:`\epsilon` is the elongation (``elong``), :math:`\delta` the triangularity (``triang``), and :math:`b` the indentation (``indent``). - diff --git a/manual/sphinx/user_docs/installing.rst b/manual/sphinx/user_docs/installing.rst index 8f95d79831..5b8ea28d01 100644 --- a/manual/sphinx/user_docs/installing.rst +++ b/manual/sphinx/user_docs/installing.rst @@ -71,10 +71,10 @@ then run:: This should give a terminal in a "boutuser" home directory, in which there is "BOUT-next", containing BOUT++ configured and compiled with -NetCDF, HDF5, SUNDIALS, PETSc and SLEPc. Python 3 is also installed, -with ipython, NumPy, Scipy and Matplotlib libaries. To plot to screen -an X11 display is needed. Alternatively a shared directory can be -created to pass files between the docker image and host. The following +NetCDF, SUNDIALS, PETSc and SLEPc. Python 3 is also installed, with +ipython, NumPy, Scipy and Matplotlib libaries. To plot to screen an +X11 display is needed. Alternatively a shared directory can be created +to pass files between the docker image and host. The following commands both enable X11 and create a shared directory:: $ mkdir shared @@ -253,8 +253,7 @@ directory with the ``–with-fftw=`` option e.g:: Configure should now find FFTW, and search for the NetCDF library. If configure finishes successfully, then skip to the next section, but if you see a message ``NetCDF support disabled`` then configure couldn’t -find the NetCDF library. Unless you have another file format (like HDF5) installed, this -will be followed by a message +find the NetCDF library. This will be followed by a message ``ERROR: At least one file format must be supported``. Check that you have NetCDF installed (See the previous section on :ref:`installing dependencies ` ). @@ -274,7 +273,6 @@ configuration:: ARKODE support: yes NetCDF support: yes Parallel-NetCDF support: no - HDF5 support: yes (parallel: no) If not, see :ref:`sec-advancedinstall` for some things you can try to resolve common problems. diff --git a/manual/sphinx/user_docs/output_and_post.rst b/manual/sphinx/user_docs/output_and_post.rst index 8f1182b63d..bcc6b94240 100644 --- a/manual/sphinx/user_docs/output_and_post.rst +++ b/manual/sphinx/user_docs/output_and_post.rst @@ -183,9 +183,8 @@ There are several modules available for reading NetCDF files, so to provide a consistent interface, file access is wrapped into a class DataFile. This provides a simple interface for reading and writing files from any of the following modules: ``netCDF4``; -``Scientific.IO.NetCDF``; and ``scipy.io.netcdf``. The DataFile class -also provides allows access to HDF5 files through the same interface, -using the ``h5py`` module. To open a file using DataFile: +``Scientific.IO.NetCDF``; and ``scipy.io.netcdf``. To open a file +using DataFile: .. code-block:: python @@ -195,16 +194,6 @@ using the ``h5py`` module. To open a file using DataFile: var = f.read("variable") # Read a variable from the file f.close() # Close the file -or similarly for an HDF5 file - -.. code-block:: python - - from boututils.datafile import DataFile - - f = DataFile("file.hdf5") # Open the file - var = f.read("variable") # Read a variable from the file - f.close() # Close the file - A more robust way to read from DataFiles is to use the context manager syntax: @@ -212,7 +201,7 @@ syntax: from boututils.datafile import DataFile - with DataFile("file.hdf5") as f: # Open the file + with DataFile("file.nc") as f: # Open the file var = f.read("variable") # Read a variable from the file This way the DataFile is automatically closed at the end of the ``with`` @@ -403,8 +392,7 @@ several optional keywords with ``[min,max]`` ranges: Summary of IDL file routines ---------------------------- -Functions file\_ can currently only read/write NetCDF files. HDF5 is not -supported yet. +Functions file\_ can currently only read/write NetCDF files. Open a NetCDF file: diff --git a/manual/sphinx/user_docs/physics_models.rst b/manual/sphinx/user_docs/physics_models.rst index 93249a4350..19ba2724bf 100644 --- a/manual/sphinx/user_docs/physics_models.rst +++ b/manual/sphinx/user_docs/physics_models.rst @@ -869,9 +869,7 @@ in ``init``, you then: name; actual opening of the file happens later when the data is written. If you are not using parallel I/O, the processor number is also inserted into the file name before the last “.”, so mydata.nc” - becomes “mydata.0.nc”, “mydata.1.nc” etc. The file format used - depends on the extension, so “.nc” will open NetCDF, and “.hdf5” or - “.h5” an HDF5 file. + becomes “mydata.0.nc”, “mydata.1.nc” etc. (see e.g. src/fileio/datafile.cxx line 139, which calls src/fileio/dataformat.cxx line 23, which then calls the file format diff --git a/manual/sphinx/user_docs/python.rst b/manual/sphinx/user_docs/python.rst index 7141d76861..0a0eac3a7a 100644 --- a/manual/sphinx/user_docs/python.rst +++ b/manual/sphinx/user_docs/python.rst @@ -7,9 +7,8 @@ boututils --------- - ``class Datafile`` provides a convenient way to read and write NetCDF - or HDF5 files. There are many different NetCDF libraries available - for Python, so this class tries to provide a consistent interface to - many of them, as well as to h5py. + files. There are many different NetCDF libraries available for Python, so + this class tries to provide a consistent interface to many of them. - ``deriv()`` diff --git a/manual/sphinx/user_docs/running_bout.rst b/manual/sphinx/user_docs/running_bout.rst index 6493817c75..d681f70e01 100644 --- a/manual/sphinx/user_docs/running_bout.rst +++ b/manual/sphinx/user_docs/running_bout.rst @@ -144,7 +144,7 @@ some requirements such as SciPy; see section :ref:`sec-python-requirements` for details. To print a list of variables in the output files, one way is to use the ``DataFile`` -class. This is a wrapper around the various NetCDF and HDF5 libraries for python: +class. This is a wrapper around the various NetCDF libraries for python: .. code-block:: pycon diff --git a/manual/sphinx/user_docs/testing.rst b/manual/sphinx/user_docs/testing.rst index 954e59e4c4..9189223a10 100644 --- a/manual/sphinx/user_docs/testing.rst +++ b/manual/sphinx/user_docs/testing.rst @@ -109,11 +109,11 @@ specify #requires petsc Currently the requirements which can be combined are ``travis``, -``netcdf``, ``pnetcdf``, ``hdf5``, ``pvode``, ``cvode``, -``ida``, ``lapack``, ``petsc``, ``slepc``, ``arkode``, -``openmp`` and ``make``. The ``make`` requirement is set to True when -the tests are being compiled (but not run), and False when the scripts -are run. It's used for tests which do not have a compilation stage. +``netcdf``, ``pnetcdf``, ``pvode``, ``cvode``, ``ida``, ``lapack``, +``petsc``, ``slepc``, ``arkode``, ``openmp`` and ``make``. The +``make`` requirement is set to True when the tests are being compiled +(but not run), and False when the scripts are run. It's used for tests +which do not have a compilation stage. .. _sec-mms: diff --git a/src/bout++.cxx b/src/bout++.cxx index a35433c73a..27915938ae 100644 --- a/src/bout++.cxx +++ b/src/bout++.cxx @@ -486,7 +486,6 @@ void printCompileTimeOptions() { output_info.write(_("\tFFT support {}\n"), is_enabled(has_fftw)); output_info.write(_("\tNatural language support {}\n"), is_enabled(has_gettext)); - output_info.write(_("\tHDF5 support {}\n"), is_enabled(has_hdf5)); output_info.write(_("\tLAPACK support {}\n"), is_enabled(has_lapack)); // Horrible nested ternary to set this at compile time constexpr auto netcdf_flavour = @@ -642,7 +641,6 @@ Datafile setupDumpFile(Options& options, Mesh& mesh, const std::string& data_dir // Add compile-time options dump_file.addOnce(const_cast(bout::build::has_fftw), "has_fftw"); dump_file.addOnce(const_cast(bout::build::has_gettext), "has_gettext"); - dump_file.addOnce(const_cast(bout::build::has_hdf5), "has_hdf5"); dump_file.addOnce(const_cast(bout::build::has_lapack), "has_lapack"); dump_file.addOnce(const_cast(bout::build::has_netcdf), "has_netcdf"); dump_file.addOnce(const_cast(bout::build::has_legacy_netcdf), diff --git a/src/fileio/formatfactory.cxx b/src/fileio/formatfactory.cxx index 0586bfb1b1..03ecc2eadc 100644 --- a/src/fileio/formatfactory.cxx +++ b/src/fileio/formatfactory.cxx @@ -8,7 +8,6 @@ #include "impls/netcdf4/ncxx4.hxx" #include "impls/netcdf/nc_format.hxx" -#include "impls/hdf5/h5_format.hxx" #include "impls/pnetcdf/pnetcdf.hxx" #include @@ -48,13 +47,8 @@ std::unique_ptr FormatFactory::createDataFormat(const char *filename return bout::utils::make_unique(mesh_in); #else -#if BOUT_HAS_HDF5 - return bout::utils::make_unique(mesh_in); -#else - #error No file format available; aborting. -#endif // BOUT_HAS_HDF5 #endif // BOUT_HAS_LEGACY_NETCDF #endif // BOUT_HAS_NETCDF #endif // PNCDF @@ -96,18 +90,6 @@ std::unique_ptr FormatFactory::createDataFormat(const char *filename } #endif -#if BOUT_HAS_HDF5 - const char *hdf5_match[] = {"h5","hdf","hdf5"}; - if(matchString(s, 3, hdf5_match) != -1) { - output.write("\tUsing HDF5 format for file '{:s}'\n", filename); -#ifdef PHDF5 - return bout::utils::make_unique(parallel); -#else - return bout::utils::make_unique(); -#endif - } -#endif - throw BoutException("\tFile extension not recognised for '{:s}'\n", filename); return nullptr; } diff --git a/src/fileio/impls/hdf5/h5_format.cxx b/src/fileio/impls/hdf5/h5_format.cxx deleted file mode 100644 index 002b83bf62..0000000000 --- a/src/fileio/impls/hdf5/h5_format.cxx +++ /dev/null @@ -1,1475 +0,0 @@ -/************************************************************************** - * Copyright 2015 J.T.Omotani, B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu - * - * Contact: Ben Dudson, bd512@york.ac.uk - * - * This file is part of BOUT++. - * - * BOUT++ is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * BOUT++ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with BOUT++. If not, see . - * - **************************************************************************/ - -#include "bout/build_config.hxx" - -#include -#include "h5_format.hxx" - -#if BOUT_HAS_HDF5 - -#include -#include -#include -#include - -#include -#include -#include -#include - -H5Format::H5Format(bool parallel_in, Mesh* mesh_in) : DataFormat(mesh_in) { - parallel = parallel_in; - x0 = y0 = z0 = t0 = 0; - lowPrecision = false; - fname = nullptr; - dataFile = -1; - chunk_length = 10; // could change this to try to optimize IO performance (i.e. allocate new chunks of disk space less often) - - dataFile_plist = H5Pcreate(H5P_FILE_ACCESS); - if (dataFile_plist < 0) - throw BoutException("Failed to create dataFile_plist"); - -#ifdef PHDF5 - if (parallel) - if (H5Pset_fapl_mpio(dataFile_plist, BoutComm::get(), MPI_INFO_NULL) < 0) - throw BoutException("Failed to set dataFile_plist"); -#endif - - dataSet_plist = H5Pcreate(H5P_DATASET_XFER); - if (dataSet_plist < 0) - throw BoutException("Failed to create dataSet_plist"); - -#ifdef PHDF5 - if (parallel) - if (H5Pset_dxpl_mpio(dataSet_plist, H5FD_MPIO_INDEPENDENT) < 0) // Default, independent writes -// if (H5Pset_dxpl_mpio(dataSet_plist, H5FD_MPIO_COLLECTIVE) < 0) // Alternative, collective writes - throw BoutException("Failed to set dataSet_plist"); -#endif - - // Disable automatic printing of error messages so that we can catch - // errors without printing error messages to stdout - if (H5Eset_auto(H5E_DEFAULT, nullptr, nullptr) < 0) - throw BoutException("Failed to set error stack to not print errors"); -} - -H5Format::H5Format(const char *name, bool parallel_in, Mesh* mesh_in) - : DataFormat(mesh_in) { - parallel = parallel_in; - x0 = y0 = z0 = t0 = 0; - lowPrecision = false; - fname = nullptr; - dataFile = -1; - chunk_length = 10; // could change this to try to optimize IO performance (i.e. allocate new chunks of disk space less often) - - dataFile_plist = H5Pcreate(H5P_FILE_ACCESS); - if (dataFile_plist < 0) - throw BoutException("Failed to create dataFile_plist"); - -#ifdef PHDF5 - if (parallel) - if (H5Pset_fapl_mpio(dataFile_plist, BoutComm::get(), MPI_INFO_NULL) < 0) - throw BoutException("Failed to set dataFile_plist"); -#endif - - dataSet_plist = H5Pcreate(H5P_DATASET_XFER); - if (dataSet_plist < 0) - throw BoutException("Failed to create dataSet_plist"); - -#ifdef PHDF5 - if (parallel) - if (H5Pset_dxpl_mpio(dataSet_plist, H5FD_MPIO_COLLECTIVE) < 0) - throw BoutException("Failed to set dataSet_plist"); -#endif - - // Disable automatic printing of error messages so that we can catch - // errors without printing error messages to stdout - if (H5Eset_auto(H5E_DEFAULT, nullptr, nullptr) < 0) - throw BoutException("Failed to set error stack to not print errors"); - - H5Format::openr(name); -} - -H5Format::~H5Format() { - H5Format::close(); - H5Pclose(dataFile_plist); -} - -bool H5Format::openr(const char *name) { - TRACE("H5Format::openr"); - - if(dataFile > 0) // Already open. Close then re-open - close(); - - dataFile = H5Fopen(name, H5F_ACC_RDONLY, dataFile_plist); - if( dataFile < 0 ) { - throw BoutException("Failed to open dataFile"); - } - - return true; -} - -bool H5Format::openw(const char *name, bool append) { - TRACE("H5Format::openw"); - - if(dataFile > 0) // Already open. Close then re-open - close(); - - if(append) { - dataFile = H5Fopen(name, H5F_ACC_RDWR, dataFile_plist); - } - else { - dataFile = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, dataFile_plist); - } - if( dataFile < 0 ) { - throw BoutException("Failed to open dataFile"); - } - - fname = copy_string(name); - - return true; -} - -bool H5Format::is_valid() { return dataFile >= 0; } - -void H5Format::close() { - TRACE("H5Format::close"); - - if (H5Format::is_valid()) { - H5Fclose(dataFile); - dataFile = -1; - } -} - -void H5Format::flush() { - if(!is_valid()) - return; - - if (H5Fflush(dataFile,H5F_SCOPE_LOCAL) < 0) { - throw BoutException("Failed to flush dataFile"); - } -} - -const std::vector H5Format::getSize(const char *name) { - TRACE("H5Format::getSize"); - - std::vector size; - - if(!is_valid()) - return size; - - hid_t dataSet = H5Dopen(dataFile, name, H5P_DEFAULT); - if (dataSet < 0) { - // variable does not exist in file, so return empty size - return size; - } - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - - int nd = H5Sget_simple_extent_ndims(dataSpace); - if (nd < 0) - throw BoutException("Failed to get dataSpace ndims"); - - if (nd==0) { - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - size.push_back(1); - return size; - } else { - std::vector dims(nd); - int error = H5Sget_simple_extent_dims(dataSpace, dims.data(), nullptr); - if (error < 0) - throw BoutException("Failed to get dimensions of dataSpace"); - - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - std::copy(begin(dims), end(dims), std::back_inserter(size)); - } - - return size; -} - -const std::vector H5Format::getSize(const std::string &var) { - return getSize(var.c_str()); -} - -bool H5Format::setGlobalOrigin(int x, int y, int z) { - x0 = x; - y0 = y; - z0 = z; - x0_local = 0; - y0_local = 0; - z0_local = 0; - - return true; -} - -bool H5Format::setLocalOrigin(int x, int y, int z, int offset_x, int offset_y, int offset_z) { - - if(!setGlobalOrigin(x + mesh->OffsetX, y + mesh->OffsetY, z + mesh->OffsetZ)) - return false; - - x0_local = offset_x; - y0_local = offset_y; - z0_local = offset_z; - - return true; -} - -bool H5Format::setRecord(int t) { - t0 = t; - - return true; -} - -// Add a variable to the file -bool H5Format::addVar(const std::string &name, bool repeat, hid_t write_hdf5_type, - std::string datatype, int lx, int ly, int lz) { - hid_t dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet >= 0) { // >=0 means variable already exists, so return. - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - return true; - } - - int nd = 0; - if (datatype == "scalar") { - nd = 0; - } else if (datatype == "vector" or datatype == "string" or datatype == "FieldX") { - nd = 1; - } else if (datatype == "Field2D" or datatype == "FieldPerp") { - nd = 2; - } else if (datatype == "Field3D") { - nd = 3; - } else { - throw BoutException("Unrecognized datatype '"+datatype+"'"); - } - - if (repeat) { - // add time dimension - datatype += "_t"; - nd += 1; - - hsize_t init_size[4]; - if (parallel) { - init_size[0]=0; - init_size[1] = lx == 0 ? mesh->GlobalNx-2*mesh->xstart : lx; - if (datatype == "FieldPerp_t") { - init_size[2] = lz == 0 ? mesh->GlobalNz : lz; - } else { - init_size[2] = ly == 0 ? mesh->GlobalNy - mesh->numberOfYBoundaries()*2*mesh->ystart : ly; - } - init_size[3] = lz == 0 ? mesh->GlobalNz : lz; - } - else { - init_size[0]=0; - init_size[1] = lx == 0 ? mesh->LocalNx : lx; - if (datatype == "FieldPerp_t") { - init_size[2] = lz == 0 ? mesh->LocalNz : lz; - } else { - init_size[2] = ly == 0 ? mesh->LocalNy : ly; - } - init_size[3] = lz == 0 ? mesh->LocalNz : lz; - } - - // Modify dataset creation properties, i.e. enable chunking. - hid_t propertyList = H5Pcreate(H5P_DATASET_CREATE); - if (propertyList < 0) - throw BoutException("Failed to create propertyList"); - hsize_t chunk_dims[4],max_dims[4]; - max_dims[0] = H5S_UNLIMITED; max_dims[1]=init_size[1]; max_dims[2]=init_size[2]; max_dims[3]=init_size[3]; - chunk_dims[0] = chunk_length; chunk_dims[1]=init_size[1]; chunk_dims[2]=init_size[2]; chunk_dims[3]=init_size[3]; - if (H5Pset_chunk(propertyList, nd, chunk_dims) < 0) - throw BoutException("Failed to set chunk property"); - - hid_t init_space = H5Screate_simple(nd, init_size, max_dims); - if (init_space < 0) - throw BoutException("Failed to create init_space"); - dataSet = H5Dcreate(dataFile, name.c_str(), write_hdf5_type, init_space, H5P_DEFAULT, propertyList, H5P_DEFAULT); - if (dataSet < 0) - throw BoutException("Failed to create dataSet"); - - // Add attribute to say what kind of field this is - - // Create new dataspace for attribute - hid_t attribute_dataspace = H5Screate(H5S_SCALAR); - if (attribute_dataspace < 0) - throw BoutException("Failed to create attribute_dataspace"); - - // Create new string datatype for attribute - hid_t variable_length_string_type = H5Tcopy(H5T_C_S1); - if (variable_length_string_type < 0) - throw BoutException("Failed to create variable_length_string_type"); - if (H5Tset_size(variable_length_string_type, H5T_VARIABLE) < 0) - throw BoutException("Failed to create string type"); - - // Create attribute and write to it - hid_t myatt_in = H5Acreate(dataSet, "bout_type", variable_length_string_type, attribute_dataspace, H5P_DEFAULT, H5P_DEFAULT); - if (myatt_in < 0) - throw BoutException("Failed to create attribute"); - if (H5Awrite(myatt_in, variable_length_string_type, &datatype) < 0) - throw BoutException("Failed to write attribute"); - - if (H5Pclose(propertyList) < 0) - throw BoutException("Failed to close propertyList"); - if (H5Sclose(init_space) < 0) - throw BoutException("Failed to close init_space"); - if (H5Sclose(attribute_dataspace) < 0) - throw BoutException("Failed to close attribute_dataspace"); - if (H5Tclose(variable_length_string_type) < 0) - throw BoutException("Failed to close variable_length_string_type"); - if (H5Aclose(myatt_in) < 0) - throw BoutException("Failed to close myatt_in"); - } else { - dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. file does not exist, so create: - hsize_t init_size[3]; - if (parallel) { - init_size[0] = lx == 0 ? mesh->GlobalNx - 2 * mesh->xstart : lx; - if (datatype == "FieldPerp") { - init_size[1] = lz == 0 ? mesh->GlobalNz : lz; - } else { - init_size[1] = ly == 0 ? mesh->GlobalNy - mesh->numberOfYBoundaries() * 2 * mesh->ystart : ly; - } - init_size[2] = lz == 0 ? mesh->GlobalNz : lz; - } else { - init_size[0] = lx == 0 ? mesh->LocalNx : lx; - if (datatype == "FieldPerp") { - init_size[1] = lz == 0 ? mesh->LocalNz : lz; - } else { - init_size[1] = ly == 0 ? mesh->LocalNy : ly; - } - init_size[2] = lz == 0 ? mesh->LocalNz : lz; - } - - // Create value for attribute to say what kind of field this is - - if (nd==0) { - // Need to write a scalar, not a 0-d array - nd = 1; - init_size[0] = 1; - } - - hid_t init_space = H5Screate_simple(nd, init_size, init_size); - if (init_space < 0) - throw BoutException("Failed to create init_space"); - dataSet = H5Dcreate(dataFile, name.c_str(), write_hdf5_type, init_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (dataSet < 0) - throw BoutException("Failed to create dataSet"); - - // Add attribute to say what kind of field this is - setAttribute(dataSet, "bout_type", datatype); - } - } - - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - return true; -} - -bool H5Format::addVarInt(const std::string &name, bool repeat) { - return addVar(name, repeat, H5T_NATIVE_INT, "scalar"); -} - -bool H5Format::addVarIntVec(const std::string &name, bool repeat, size_t size) { - return addVar(name, repeat, H5T_NATIVE_INT, "vector", size); -} - -bool H5Format::addVarString(const std::string &name, bool repeat, size_t size) { - return addVar(name, repeat, H5T_C_S1, "string", size); -} - -bool H5Format::addVarBoutReal(const std::string &name, bool repeat) { - auto h5_float_type = lowPrecision ? H5T_NATIVE_FLOAT : H5T_NATIVE_DOUBLE; - return addVar(name, repeat, h5_float_type, "scalar"); -} - -bool H5Format::addVarField2D(const std::string &name, bool repeat) { - auto h5_float_type = lowPrecision ? H5T_NATIVE_FLOAT : H5T_NATIVE_DOUBLE; - return addVar(name, repeat, h5_float_type, "Field2D"); -} - -bool H5Format::addVarField3D(const std::string &name, bool repeat) { - auto h5_float_type = lowPrecision ? H5T_NATIVE_FLOAT : H5T_NATIVE_DOUBLE; - return addVar(name, repeat, h5_float_type, "Field3D"); -} - -bool H5Format::addVarFieldPerp(const std::string &name, bool repeat) { - auto h5_float_type = lowPrecision ? H5T_NATIVE_FLOAT : H5T_NATIVE_DOUBLE; - return addVar(name, repeat, h5_float_type, "FieldPerp"); -} - -bool H5Format::read(int *data, const char *name, int lx, int ly, int lz) { - return read(data, H5T_NATIVE_INT, name, lx, ly, lz); -} - -bool H5Format::read(int *var, const std::string &name, int lx, int ly, int lz) { - return read(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::read(char *data, const char *name, int n) { - return read(data, H5T_C_S1, name, n); -} - -bool H5Format::read(char *var, const std::string &name, int n) { - return read(var, name.c_str(), n); -} - -bool H5Format::read(BoutReal *data, const char *name, int lx, int ly, int lz) { - return read(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); -} - -bool H5Format::read(BoutReal *var, const std::string &name, int lx, int ly, int lz) { - return read(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::read(void *data, hid_t hdf5_type, const char *name, int lx, int ly, int lz) { - TRACE("H5Format::read(void)"); - - if(!is_valid()) - return false; - - if((lx < 0) || (ly < 0) || (lz < 0)) - return false; - - int nd = 0; // Number of dimensions - if(lx != 0) nd = 1; - if(ly != 0) nd = 2; - if(lz != 0) nd = 3; - hsize_t counts[3],offset[3],offset_local[3],init_size_local[3]; - counts[0]=lx; counts[1]=ly; counts[2]=lz; - offset[0]=x0; offset[1]=y0; offset[2]=z0; - offset_local[0]=x0_local; - offset_local[1]=y0_local; - offset_local[2]=z0_local; - - // Want to be able to use without needing mesh to be initialised; makes hyperslab selection redundant - init_size_local[0]=offset_local[0]+counts[0]; - init_size_local[1]=offset_local[1]+counts[1]; - init_size_local[2]=offset_local[2]+counts[2]; - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - - hid_t dataSet = H5Dopen(dataFile, name, H5P_DEFAULT); - if (dataSet < 0) { - return false; - } - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (nd > 0 && !(nd==1 && lx==1)) - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dread(dataSet, hdf5_type, mem_space, dataSpace, H5P_DEFAULT, data) < 0) - throw BoutException("Failed to read data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::read_perp(BoutReal *data, const std::string& name, int lx, int lz) { - TRACE("H5Format::read(void)"); - - hid_t hdf5_type = H5T_NATIVE_DOUBLE; - - if(!is_valid()) - return false; - - if((lx < 0) || (lz < 0)) - return false; - - int nd = 0; // Number of dimensions - if(lx != 0) nd = 1; - if(lz != 0) nd = 2; - hsize_t counts[2],offset[2],offset_local[2],init_size_local[2]; - counts[0]=lx; counts[1]=lz; - offset[0]=x0; offset[1]=z0; - offset_local[0]=x0_local; - offset_local[1]=z0_local; - - // Want to be able to use without needing mesh to be initialised; makes hyperslab selection redundant - init_size_local[0]=offset_local[0]+counts[0]; - init_size_local[1]=offset_local[1]+counts[1]; - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - - hid_t dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - return false; - } - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (nd > 0 && !(nd==1 && lx==1)) - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dread(dataSet, hdf5_type, mem_space, dataSpace, H5P_DEFAULT, data) < 0) - throw BoutException("Failed to read data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::write(int *data, const char *name, int lx, int ly, int lz) { - return write(data, H5T_NATIVE_INT, name, lx, ly, lz); -} - -bool H5Format::write(int *var, const std::string &name, int lx, int ly, int lz) { - return write(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::write(char *data, const char *name, int n) { - return write(data, H5T_C_S1, name, n); -} - -bool H5Format::write(char *var, const std::string &name, int n) { - return write(var, name.c_str(), n); -} - -bool H5Format::write(BoutReal *data, const char *name, int lx, int ly, int lz) { - - if(lowPrecision) { - // An out of range value can make the conversion - // corrupt the whole dataset. Make sure everything - // is in the range of a float - int i_max=1; - if (lx>0) i_max*=lx; - if (ly>0) i_max*=ly; - if (lz>0) i_max*=lz; - - for(int i=0;i 1e20) - data[i] = 1e20; - if(data[i] < -1e20) - data[i] = -1e20; - } - - return write(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); - } - else { - return write(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); - } - -} - -bool H5Format::write(BoutReal *var, const std::string &name, int lx, int ly, int lz) { - return write(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::write(void *data, hid_t mem_hdf5_type, const char *name, int lx, int ly, - int lz) { - TRACE("H5Format::write(void)"); - - if(!is_valid()) - return false; - - if((lx < 0) || (ly < 0) || (lz < 0)) - return false; - - int nd = 0; // Number of dimensions - if(lx != 0) nd = 1; - if(ly != 0) nd = 2; - if(lz != 0) nd = 3; - hsize_t counts[3], offset[3], offset_local[3], init_size_local[3]; - counts[0] = lx; - counts[1] = ly; - counts[2] = lz; - offset[0] = x0; - offset[1] = y0; - offset[2] = z0; - offset_local[0] = x0_local; - offset_local[1] = y0_local; - offset_local[2] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNy; - init_size_local[2] = mesh->LocalNz; - - if (nd==0) { - // Need to write a scalar, not a 0-d array - nd = 1; - counts[0] = 1; - offset[0] = 0; - offset_local[0] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name, H5P_DEFAULT); - if (dataSet < 0) { - output_error.write("ERROR: HDF5 variable '{:s}' has not been added to file '{:s}'\n", name, fname); - return false; - } - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dwrite(dataSet, mem_hdf5_type, mem_space, dataSpace, dataSet_plist, data) < 0) - throw BoutException("Failed to write data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::write_perp(BoutReal *data, const std::string& name, int lx, int lz) { - TRACE("H5Format::write_perp(void)"); - - hid_t mem_hdf5_type = H5T_NATIVE_DOUBLE; - - if(!is_valid()) - return false; - - if((lx < 0) || (lz < 0)) - return false; - - int nd = 0; // Number of dimensions - if(lx != 0) nd = 1; - if(lz != 0) nd = 2; - hsize_t counts[2], offset[2], offset_local[2], init_size_local[2]; - counts[0] = lx; - counts[1] = lz; - offset[0] = x0; - offset[1] = z0; - offset_local[0] = x0_local; - offset_local[1] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNz; - - if (nd==0) { - // Need to write a scalar, not a 0-d array - nd = 1; - counts[0] = 1; - offset[0] = 0; - offset_local[0] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - output_error.write("ERROR: HDF5 variable '{:s}' has not been added to file '{:s}'\n", name, fname); - return false; - } - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dwrite(dataSet, mem_hdf5_type, mem_space, dataSpace, dataSet_plist, data) < 0) - throw BoutException("Failed to write data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -/*************************************************************************** - * Record-based (time-dependent) data - ***************************************************************************/ - -bool H5Format::read_rec(int *data, const char *name, int lx, int ly, int lz) { - return read_rec(data, H5T_NATIVE_INT, name, lx, ly, lz); -} - -bool H5Format::read_rec(int *var, const std::string &name, int lx, int ly, int lz) { - return read_rec(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::read_rec(char *data, const char *name, int n) { - return read_rec(data, H5T_C_S1, name, n); -} - -bool H5Format::read_rec(char *var, const std::string &name, int n) { - return read_rec(var, name.c_str(), n); -} - -bool H5Format::read_rec(BoutReal *data, const char *name, int lx, int ly, int lz) { - - return read_rec(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); - -} - -bool H5Format::read_rec(BoutReal *var, const std::string &name, int lx, int ly, int lz) { - return read_rec(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::read_rec(void *data, hid_t hdf5_type, const char *name, int lx, int ly, - int lz) { - if (!is_valid()) { - return false; - } - - if ((lx < 0) || (ly < 0) || (lz < 0)) { - return false; - } - - int nd = 1; // Number of dimensions - if (lx != 0) { - nd = 2; - } - if (ly != 0) { - nd = 3; - } - if (lz != 0) { - nd = 4; - } - hsize_t counts[4], offset[4]; - hsize_t offset_local[3], init_size_local[3]; - counts[0] = 1; - counts[1] = lx; - counts[2] = ly; - counts[3] = lz; - offset[0] = t0; - offset[1] = x0; - offset[2] = y0; - offset[3] = z0; - offset_local[0] = x0_local; - offset_local[1] = y0_local; - offset_local[2] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNy; - init_size_local[2] = mesh->LocalNz; - - if (nd == 1) { - // Need to write a time-series of scalars - nd = 1; - counts[1] = 1; - offset[1] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name, H5P_DEFAULT); - if (dataSet < 0) - throw BoutException("Failed to open dataSet"); - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dread(dataSet, hdf5_type, mem_space, dataSpace, H5P_DEFAULT, data) < 0) - throw BoutException("Failed to read data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::read_rec_perp(BoutReal *data, const std::string& name, int lx, int lz) { - if (!is_valid()) { - return false; - } - - hid_t hdf5_type = H5T_NATIVE_DOUBLE; - - if ((lx < 0) || (lz < 0)) { - return false; - } - - int nd = 1; // Number of dimensions - if (lx != 0) { - nd = 2; - } - if (lz != 0) { - nd = 3; - } - hsize_t counts[3], offset[3]; - hsize_t offset_local[2], init_size_local[2]; - counts[0] = 1; - counts[1] = lx; - counts[2] = lz; - offset[0] = t0; - offset[1] = x0; - offset[2] = z0; - offset_local[0] = x0_local; - offset_local[1] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNz; - - if (nd == 1) { - // Need to write a time-series of scalars - nd = 1; - counts[1] = 1; - offset[1] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet < 0) - throw BoutException("Failed to open dataSet"); - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dread(dataSet, hdf5_type, mem_space, dataSpace, H5P_DEFAULT, data) < 0) - throw BoutException("Failed to read data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::write_rec(int *data, const char *name, int lx, int ly, int lz) { - return write_rec(data, H5T_NATIVE_INT, name, lx, ly, lz); -} - -bool H5Format::write_rec(int *var, const std::string &name, int lx, int ly, int lz) { - return write_rec(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::write_rec(char *data, const char *name, int n) { - return write_rec(data, H5T_C_S1, name, n); -} - -bool H5Format::write_rec(char *var, const std::string &name, int n) { - return write_rec(var, name.c_str(), n); -} - -bool H5Format::write_rec(BoutReal *data, const char *name, int lx, int ly, int lz) { - - if(lowPrecision) { - // An out of range value can make the conversion - // corrupt the whole dataset. Make sure everything - // is in the range of a float - int i_max=1; - if (lx>0) i_max*=lx; - if (ly>0) i_max*=ly; - if (lz>0) i_max*=lz; - - for(int i=0;i 1e20) - data[i] = 1e20; - if(data[i] < -1e20) - data[i] = -1e20; - } - return write_rec(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); - } - - return write_rec(data, H5T_NATIVE_DOUBLE, name, lx, ly, lz); -} - -bool H5Format::write_rec(BoutReal *var, const std::string &name, int lx, int ly, int lz) { - return write_rec(var, name.c_str(), lx, ly, lz); -} - -bool H5Format::write_rec(void *data, hid_t mem_hdf5_type, const char *name, int lx, int ly, int lz) { - if(!is_valid()) - return false; - - if((lx < 0) || (ly < 0) || (lz < 0)) - return false; - - int nd = 1; // Number of dimensions - if(lx != 0) nd = 2; - if(ly != 0) nd = 3; - if(lz != 0) nd = 4; - int nd_local = nd-1; - hsize_t counts[4], offset[4]; - hsize_t counts_local[3], offset_local[3], init_size_local[3]; - counts[0] = 1; - counts[1] = lx; - counts[2] = ly; - counts[3] = lz; - counts_local[0] = lx; - counts_local[1] = ly; - counts_local[2] = lz; - // Do this later, after setting t0// offset[0]=t0; - offset[1] = x0; - offset[2] = y0; - offset[3] = z0; - offset_local[0] = x0_local; - offset_local[1] = y0_local; - offset_local[2] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNy; - init_size_local[2] = mesh->LocalNz; - - if (nd_local == 0) { - nd_local = 1; - // Need to write a time-series of scalars - counts_local[0] = 1; - offset_local[0] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd_local, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts_local, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name, H5P_DEFAULT); - if (dataSet >= 0) { // >=0 means file exists, so open. Else error. - - hsize_t dims[4] = {}; - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sget_simple_extent_dims(dataSpace, dims, /*maxdims=*/nullptr) < 0) - throw BoutException("Failed to get dims"); - dims[0]+=1; - if (t0 == -1) { - // Want t0 to be last record - t0 = dims[0]-1; - } - - if (H5Dset_extent(dataSet, dims) < 0) - throw BoutException("Failed to extend dataSet"); - - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - - } - else { - output_error.write("ERROR: HDF5 variable '{:s}' has not been added to file '{:s}'\n", name, fname); - return false; - } - - offset[0]=t0; - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dwrite(dataSet, mem_hdf5_type, mem_space, dataSpace, dataSet_plist, data) < 0) - throw BoutException("Failed to write data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - -bool H5Format::write_rec_perp(BoutReal *data, const std::string& name, int lx, int lz) { - if(!is_valid()) - return false; - - hid_t mem_hdf5_type = H5T_NATIVE_DOUBLE; - - if((lx < 0) || (lz < 0)) - return false; - - int nd = 1; // Number of dimensions - if(lx != 0) nd = 2; - if(lz != 0) nd = 3; - int nd_local = nd-1; - hsize_t counts[3], offset[3]; - hsize_t counts_local[2], offset_local[2], init_size_local[2]; - counts[0] = 1; - counts[1] = lx; - counts[2] = lz; - counts_local[0] = lx; - counts_local[1] = lz; - // Do this later, after setting t0// offset[0]=t0; - offset[1] = x0; - offset[2] = z0; - offset_local[0] = x0_local; - offset_local[1] = z0_local; - init_size_local[0] = mesh->LocalNx; - init_size_local[1] = mesh->LocalNz; - - if (nd_local == 0) { - nd_local = 1; - // Need to write a time-series of scalars - counts_local[0] = 1; - offset_local[0] = 0; - init_size_local[0] = 1; - } - - hid_t mem_space = H5Screate_simple(nd_local, init_size_local, init_size_local); - if (mem_space < 0) - throw BoutException("Failed to create mem_space"); - if (H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, offset_local, /*stride=*/nullptr, - counts_local, /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - hid_t dataSet = H5Dopen(dataFile, name.c_str(), H5P_DEFAULT); - if (dataSet >= 0) { // >=0 means file exists, so open. Else error. - - hsize_t dims[3] = {}; - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sget_simple_extent_dims(dataSpace, dims, /*maxdims=*/nullptr) < 0) - throw BoutException("Failed to get dims"); - dims[0]+=1; - if (t0 == -1) { - // Want t0 to be last record - t0 = dims[0]-1; - } - - if (H5Dset_extent(dataSet, dims) < 0) - throw BoutException("Failed to extend dataSet"); - - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - - } - else { - output_error.write("ERROR: HDF5 variable '{:s}' has not been added to file '{:s}'\n", name, fname); - return false; - } - - offset[0]=t0; - - hid_t dataSpace = H5Dget_space(dataSet); - if (dataSpace < 0) - throw BoutException("Failed to create dataSpace"); - if (H5Sselect_hyperslab(dataSpace, H5S_SELECT_SET, offset, /*stride=*/nullptr, counts, - /*block=*/nullptr) < 0) - throw BoutException("Failed to select hyperslab"); - - if (H5Dwrite(dataSet, mem_hdf5_type, mem_space, dataSpace, dataSet_plist, data) < 0) - throw BoutException("Failed to write data"); - - if (H5Sclose(mem_space) < 0) - throw BoutException("Failed to close mem_space"); - if (H5Sclose(dataSpace) < 0) - throw BoutException("Failed to close dataSpace"); - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return true; -} - - -/*************************************************************************** - * Attributes - ***************************************************************************/ - -void H5Format::setAttribute(const std::string &varname, const std::string &attrname, - const std::string &text) { - TRACE("H5Format::setAttribute(varname, attrname, string)"); - - std::string existing_att; - if (getAttribute(varname, attrname, existing_att)) { - if (text != existing_att) { - output_warn.write("Overwriting attribute '{:s}' of variable '{:s}' with '{:s}', " - "was previously '{:s}'", - attrname, varname, text, existing_att); - } - } - // else: attribute does not exist, so just write it - - if (varname == "") { - // attribute of file - setAttribute(dataFile, attrname, text); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to create attribute for variable that does not exist"); - } - - setAttribute(dataSet, attrname, text); - - if (H5Dclose(dataSet) < 0) { - throw BoutException("Failed to close dataSet"); - } - } -} - -void H5Format::setAttribute(const std::string &varname, const std::string &attrname, - int value) { - TRACE("H5Format::setAttribute(varname, attrname, int)"); - - int existing_att; - if (getAttribute(varname, attrname, existing_att)) { - if (value != existing_att) { - output_warn.write("Overwriting attribute '{:s}' of variable '{:s}' with '{:d}', was previously '{:d}'", attrname, varname, value, existing_att); - } - } - // else: attribute does not exist, so just write it - - if (varname == "") { - // attribute of file - setAttribute(dataFile, attrname, value); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to create attribute for variable that does not exist"); - } - - setAttribute(dataSet, attrname, value); - - if (H5Dclose(dataSet) < 0) { - throw BoutException("Failed to close dataSet"); - } - } -} - -void H5Format::setAttribute(const std::string &varname, const std::string &attrname, - BoutReal value) { - TRACE("H5Format::setAttribute(varname, attrname, BoutReal)"); - - BoutReal existing_att; - if (getAttribute(varname, attrname, existing_att)) { - if (value != existing_att) { - output_warn.write("Overwriting attribute '{:s}' of variable '{:s}' with '{:f}', was previously '{:f}'", attrname, varname, value, existing_att); - } - } - // else: attribute does not exist, so just write it - - if (varname == "") { - // attribute of file - setAttribute(dataFile, attrname, value); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to create attribute for variable that does not exist"); - } - - setAttribute(dataSet, attrname, value); - - if (H5Dclose(dataSet) < 0) { - throw BoutException("Failed to close dataSet"); - } - } -} - -void H5Format::setAttribute(const hid_t &dataSet, const std::string &attrname, - const std::string &text) { - TRACE("H5Format::setAttribute(dataSet, attrname, string)"); - - // Create new dataspace for attribute - hid_t attribute_dataspace = H5Screate(H5S_SCALAR); - if (attribute_dataspace < 0) - throw BoutException("Failed to create attribute_dataspace"); - - // Create new string datatype for attribute - hid_t variable_length_string_type = H5Tcopy(H5T_C_S1); - if (variable_length_string_type < 0) - throw BoutException("Failed to create variable_length_string_type"); - if (H5Tset_size(variable_length_string_type, H5T_VARIABLE) < 0) - throw BoutException("Failed to create string type"); - - // Create attribute if it does not exist and write to it - hid_t myatt_in = H5Aopen(dataSet, attrname.c_str(), H5P_DEFAULT); - if (myatt_in < 0) { - // Need to create attribute - myatt_in = H5Acreate(dataSet, attrname.c_str(), variable_length_string_type, attribute_dataspace, H5P_DEFAULT, H5P_DEFAULT); - if (myatt_in < 0) - throw BoutException("Failed to create attribute"); - } - // Need to pass `const char**` to HDF5 for reasons, and - // `&text.c_str()` isn't valid (can't take address of an - // r-value/temporary), so we need an intermediate variable - const char* c_text = text.c_str(); - if (H5Awrite(myatt_in, variable_length_string_type, &c_text) < 0) - throw BoutException("Failed to write attribute"); - - if (H5Sclose(attribute_dataspace) < 0) - throw BoutException("Failed to close attribute_dataspace"); - if (H5Tclose(variable_length_string_type) < 0) - throw BoutException("Failed to close variable_length_string_type"); - if (H5Aclose(myatt_in) < 0) - throw BoutException("Failed to close myatt_in"); -} - -void H5Format::setAttribute(const hid_t &dataSet, const std::string &attrname, - int value) { - TRACE("H5Format::setAttribute(dataSet, attrname, int)"); - - // Create new dataspace for attribute - hid_t attribute_dataspace = H5Screate(H5S_SCALAR); - if (attribute_dataspace < 0) - throw BoutException("Failed to create attribute_dataspace"); - - // Create attribute and write to it - hid_t myatt_in = H5Acreate(dataSet, attrname.c_str(), H5T_NATIVE_INT, attribute_dataspace, H5P_DEFAULT, H5P_DEFAULT); - if (myatt_in < 0) - throw BoutException("Failed to create attribute"); - if (H5Awrite(myatt_in, H5T_NATIVE_INT, &value) < 0) - throw BoutException("Failed to write attribute"); - - if (H5Sclose(attribute_dataspace) < 0) - throw BoutException("Failed to close attribute_dataspace"); - if (H5Aclose(myatt_in) < 0) - throw BoutException("Failed to close myatt_in"); -} - -void H5Format::setAttribute(const hid_t &dataSet, const std::string &attrname, - BoutReal value) { - TRACE("H5Format::setAttribute(dataSet, attrname, BoutReal)"); - - // Create new dataspace for attribute - hid_t attribute_dataspace = H5Screate(H5S_SCALAR); - if (attribute_dataspace < 0) - throw BoutException("Failed to create attribute_dataspace"); - - // Create attribute and write to it - hid_t myatt_in = H5Acreate(dataSet, attrname.c_str(), H5T_NATIVE_DOUBLE, attribute_dataspace, H5P_DEFAULT, H5P_DEFAULT); - if (myatt_in < 0) - throw BoutException("Failed to create attribute"); - if (H5Awrite(myatt_in, H5T_NATIVE_DOUBLE, &value) < 0) - throw BoutException("Failed to write attribute"); - - if (H5Sclose(attribute_dataspace) < 0) - throw BoutException("Failed to close attribute_dataspace"); - if (H5Aclose(myatt_in) < 0) - throw BoutException("Failed to close myatt_in"); -} - -bool H5Format::getAttribute(const std::string &varname, const std::string &attrname, std::string &text) { - TRACE("H5Format::getAttribute(varname, attrname, string)"); - - if (varname == "") { - // attribute of file - return getAttribute(dataFile, attrname, text); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to read attribute for variable that does not exist"); - } - - bool result = getAttribute(dataSet, attrname, text); - - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return result; - } -} - -bool H5Format::getAttribute(const std::string &varname, const std::string &attrname, int &value) { - TRACE("H5Format::getAttribute(varname, attrname, int)"); - - if (varname == "") { - // attribute of file - return getAttribute(dataFile, attrname, value); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to read attribute for variable that does not exist"); - } - - bool result = getAttribute(dataSet, attrname, value); - - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return result; - } -} - -bool H5Format::getAttribute(const std::string &varname, const std::string &attrname, BoutReal &value) { - TRACE("H5Format::getAttribute(varname, attrname, BoutReal)"); - - if (varname == "") { - // attribute of file - return getAttribute(dataFile, attrname, value); - } else { - // attribute of variable - hid_t dataSet = H5Dopen(dataFile, varname.c_str(), H5P_DEFAULT); - if (dataSet < 0) { - // Negative value indicates error, i.e. variable does not exist - throw BoutException("Trying to read attribute for variable that does not exist"); - } - - bool result = getAttribute(dataSet, attrname, value); - - if (H5Dclose(dataSet) < 0) - throw BoutException("Failed to close dataSet"); - - return result; - } -} - -bool H5Format::getAttribute(const hid_t &dataSet, const std::string &attrname, std::string &text) { - TRACE("H5Format::getAttribute(hid_t, attrname, string)"); - - // Open attribute - hid_t myatt = H5Aopen(dataSet, attrname.c_str(), H5P_DEFAULT); - if (myatt < 0) { - return false; - } - - // Create new string datatype for attribute - hid_t variable_length_string_type = H5Tcopy(H5T_C_S1); - if (variable_length_string_type < 0) - throw BoutException("Failed to create variable_length_string_type"); - if (H5Tset_size(variable_length_string_type, H5T_VARIABLE) < 0) - throw BoutException("Failed to create string type"); - - // Read attribute: Need to pass `char**` to HDF5 for reasons, but - // luckliy it will allocate c_text for us - char* c_text; - if (H5Aread(myatt, variable_length_string_type, &c_text) < 0) - throw BoutException("Failed to read attribute"); - text = c_text; - // Release resources allocated by HDF5 - free(c_text); - - if (H5Tclose(variable_length_string_type) < 0) - throw BoutException("Failed to close variable_length_string_type"); - if (H5Aclose(myatt) < 0) - throw BoutException("Failed to close myatt_in"); - - return true; -} - -bool H5Format::getAttribute(const hid_t &dataSet, const std::string &attrname, int &value) { - TRACE("H5Format::getAttribute(hid_t, attrname, int)"); - - // Open attribute - hid_t myatt = H5Aopen(dataSet, attrname.c_str(), H5P_DEFAULT); - if (myatt < 0) { - return false; - } - - // Read attribute - if (H5Aread(myatt, H5T_NATIVE_INT, &value) < 0) - throw BoutException("Failed to read attribute"); - - if (H5Aclose(myatt) < 0) - throw BoutException("Failed to close myatt_in"); - - return true; -} - -bool H5Format::getAttribute(const hid_t &dataSet, const std::string &attrname, BoutReal &value) { - TRACE("H5Format::getAttribute(hid_t, attrname, BoutReal)"); - - // Open attribute - hid_t myatt = H5Aopen(dataSet, attrname.c_str(), H5P_DEFAULT); - if (myatt < 0) { - return false; - } - - // Read attribute - if (H5Aread(myatt, H5T_NATIVE_DOUBLE, &value) < 0) - throw BoutException("Failed to read attribute"); - - if (H5Aclose(myatt) < 0) - throw BoutException("Failed to close myatt_in"); - - return true; -} - -#endif // BOUT_HAS_HDF5 diff --git a/src/fileio/impls/hdf5/h5_format.hxx b/src/fileio/impls/hdf5/h5_format.hxx deleted file mode 100644 index 767d51ec1c..0000000000 --- a/src/fileio/impls/hdf5/h5_format.hxx +++ /dev/null @@ -1,183 +0,0 @@ -/*! - * \file h5_format.hxx - * - * \brief HDF5 data format interface - * - * \author John Omotani - * \date 2015 - * - * Records: In netCDF, the time dimension for each dimension must be - * the same. Hence when a record is appended to a variable, the size - * of all variables is increased. To work out which record to write to, - * a map of variable names to record number is kept. - * - ************************************************************************** - * Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu - * - * Contact: Ben Dudson, bd512@york.ac.uk - * - * This file is part of BOUT++. - * - * BOUT++ is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * BOUT++ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with BOUT++. If not, see . - * - */ - -#include "bout/build_config.hxx" - -#if !BOUT_HAS_HDF5 - -#include "../emptyformat.hxx" -using H5Format = EmptyFormat; - -#else - -class H5Format; - -#ifndef __H5FORMAT_H__ -#define __H5FORMAT_H__ - -#include "dataformat.hxx" - -#include - -#include -#include - -class H5Format : public DataFormat { - public: - H5Format(bool parallel_in = false, Mesh* mesh_in = nullptr); - H5Format(const char *name, bool parallel_in = false, Mesh* mesh_in = nullptr); - H5Format(const std::string &name, bool parallel_in = false, Mesh* mesh_in = nullptr) - : H5Format(name.c_str(), parallel_in, mesh_in) {} - ~H5Format(); - - using DataFormat::openr; - bool openr(const char *name) override; - using DataFormat::openw; - bool openw(const char *name, bool append=false) override; - - bool is_valid() override; - - void close() override; - - void flush() override; - - const char* filename() { return fname; }; - - const std::vector getSize(const char *var) override; - const std::vector getSize(const std::string &var) override; - - // Set the origin for all subsequent calls - bool setGlobalOrigin(int x = 0, int y = 0, int z = 0) override; - bool setLocalOrigin(int x = 0, int y = 0, int z = 0, int offset_x = 0, int offset_y = 0, int offset_z = 0) override; - bool setRecord(int t) override; // negative -> latest - - // Add a variable to the file - bool addVarInt(const std::string &name, bool repeat) override; - bool addVarIntVec(const std::string &name, bool repeat, size_t size) override; - bool addVarString(const std::string &name, bool repeat, size_t size) override; - bool addVarBoutReal(const std::string &name, bool repeat) override; - bool addVarField2D(const std::string &name, bool repeat) override; - bool addVarField3D(const std::string &name, bool repeat) override; - bool addVarFieldPerp(const std::string &name, bool repeat) override; - - // Read / Write simple variables up to 3D - - bool read(int *var, const char *name, int lx = 1, int ly = 0, int lz = 0) override; - bool read(int *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) override; - bool read(char *var, const char *name, int n = 1) override; - bool read(char *var, const std::string &name, int n = 1) override; - bool read(BoutReal *var, const char *name, int lx = 1, int ly = 0, int lz = 0) override; - bool read(BoutReal *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) override; - bool read_perp(BoutReal *var, const std::string &name, int lx = 1, int lz = 0) override; - - bool write(int *var, const char *name, int lx = 0, int ly = 0, int lz = 0) override; - bool write(int *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) override; - bool write(char *var, const char *name, int n = 1) override; - bool write(char *var, const std::string &name, int n = 1) override; - bool write(BoutReal *var, const char *name, int lx = 0, int ly = 0, int lz = 0) override; - bool write(BoutReal *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) override; - bool write_perp(BoutReal *var, const std::string &name, int lx = 0, int lz = 0) override; - - // Read / Write record-based variables - - bool read_rec(int *var, const char *name, int lx = 1, int ly = 0, int lz = 0) override; - bool read_rec(int *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) override; - bool read_rec(char *var, const char *name, int n = 1) override; - bool read_rec(char *var, const std::string &name, int n = 1) override; - bool read_rec(BoutReal *var, const char *name, int lx = 1, int ly = 0, int lz = 0) override; - bool read_rec(BoutReal *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) override; - bool read_rec_perp(BoutReal *var, const std::string &name, int lx = 1, int lz = 0) override; - - bool write_rec(int *var, const char *name, int lx = 0, int ly = 0, int lz = 0) override; - bool write_rec(int *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) override; - bool write_rec(char *var, const char *name, int n = 1) override; - bool write_rec(char *var, const std::string &name, int n = 1) override; - bool write_rec(BoutReal *var, const char *name, int lx = 0, int ly = 0, int lz = 0) override; - bool write_rec(BoutReal *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) override; - bool write_rec_perp(BoutReal *var, const std::string &name, int lx = 0, int lz = 0) override; - - void setLowPrecision() override { lowPrecision = true; } - - // Attributes - - void setAttribute(const std::string &varname, const std::string &attrname, - const std::string &text) override; - void setAttribute(const std::string &varname, const std::string &attrname, - int value) override; - void setAttribute(const std::string &varname, const std::string &attrname, - BoutReal value) override; - bool getAttribute(const std::string &varname, const std::string &attrname, std::string &text) override; - bool getAttribute(const std::string &varname, const std::string &attrname, int &value) override; - bool getAttribute(const std::string &varname, const std::string &attrname, BoutReal &value) override; - - private: - - char *fname; ///< Current file name - - hid_t dataFile; - hid_t dataFile_plist; - hid_t dataSet_plist; - - bool lowPrecision; ///< When writing, down-convert to floats - bool parallel; - - int x0, y0, z0, t0; ///< Data origins for file access - int x0_local, y0_local, z0_local; ///< Data origins for memory access - - hsize_t chunk_length; - - bool addVar(const std::string &name, bool repeat, hid_t write_hdf5_type, std::string datatype, - int lx = 0, int ly = 0, int lz = 0); - bool read(void *var, hid_t hdf5_type, const char *name, int lx = 1, int ly = 0, int lz = 0); - bool write(void *var, hid_t mem_hdf5_type, const char *name, int lx = 0, int ly = 0, int lz = 0); - bool read_rec(void *var, hid_t hdf5_type, const char *name, int lx = 1, int ly = 0, int lz = 0); - bool write_rec(void *var, hid_t mem_hdf5_type, const char *name, int lx = 0, int ly = 0, int lz = 0); - - // Attributes - - void setAttribute(const hid_t &dataSet, const std::string &attrname, - const std::string &text); - void setAttribute(const hid_t &dataSet, const std::string &attrname, - int value); - void setAttribute(const hid_t &dataSet, const std::string &attrname, - BoutReal value); - bool getAttribute(const hid_t &dataSet, const std::string &attrname, std::string &text); - bool getAttribute(const hid_t &dataSet, const std::string &attrname, int &value); - bool getAttribute(const hid_t &dataSet, const std::string &attrname, BoutReal &value); -}; - -#endif // __H5FORMAT_H__ - -#endif // BOUT_HAS_HDF5 diff --git a/src/fileio/impls/hdf5/makefile b/src/fileio/impls/hdf5/makefile deleted file mode 100644 index 3497f0de9f..0000000000 --- a/src/fileio/impls/hdf5/makefile +++ /dev/null @@ -1,8 +0,0 @@ - -BOUT_TOP = ../../../.. - -SOURCEC = h5_format.cxx -SOURCEH = $(SOURCEC:%.cxx=%.hxx) -TARGET = lib - -include $(BOUT_TOP)/make.config diff --git a/src/fileio/impls/makefile b/src/fileio/impls/makefile index 04dd6285bc..fee18c202d 100644 --- a/src/fileio/impls/makefile +++ b/src/fileio/impls/makefile @@ -1,7 +1,7 @@ BOUT_TOP = ../../.. -DIRS = netcdf netcdf4 pnetcdf hdf5 +DIRS = netcdf netcdf4 pnetcdf TARGET = lib include $(BOUT_TOP)/make.config diff --git a/tests/integrated/.gitignore b/tests/integrated/.gitignore index 0d4bfd1528..3eaa8b2d7e 100644 --- a/tests/integrated/.gitignore +++ b/tests/integrated/.gitignore @@ -13,7 +13,6 @@ BOUT.settings /test-interchange-instability/2fluid /test-invpar/test_invpar /test-io/test_io -/test-io_hdf5/test_io_hdf5 /test-laplace/test_laplace /test-restarting/test_restarting /test-smooth/test_smooth @@ -30,7 +29,6 @@ BOUT.settings /test-fci-slab/fci_slab /test-fieldgroupComm/test /test-interpolate/test_interpolate -/test-io_hdf5/test_io /test-multigrid_laplace/test_multigrid_laplace /test-petsc_laplace/test_petsc_laplace /test-petsc_laplace_MAST-grid/test_petsc_laplace_MAST_grid diff --git a/tests/integrated/CMakeLists.txt b/tests/integrated/CMakeLists.txt index 05d58e1956..1026829560 100644 --- a/tests/integrated/CMakeLists.txt +++ b/tests/integrated/CMakeLists.txt @@ -18,7 +18,6 @@ add_subdirectory(test-interpolate-z) add_subdirectory(test-invertable-operator) add_subdirectory(test-invpar) add_subdirectory(test-io) -add_subdirectory(test-io_hdf5) add_subdirectory(test-laplace) add_subdirectory(test-laplace-petsc3d) add_subdirectory(test-laplacexy-fv) @@ -29,7 +28,6 @@ add_subdirectory(test-options-netcdf) add_subdirectory(test-petsc_laplace) add_subdirectory(test-petsc_laplace_MAST-grid) add_subdirectory(test-restart-io) -add_subdirectory(test-restart-io_hdf5) add_subdirectory(test-restarting) add_subdirectory(test-slepc-solver) add_subdirectory(test-smooth) diff --git a/tests/integrated/test-drift-instability/doc/drift_instability.bib b/tests/integrated/test-drift-instability/doc/drift_instability.bib index dc74fdcd87..a84ff5c1e0 100644 --- a/tests/integrated/test-drift-instability/doc/drift_instability.bib +++ b/tests/integrated/test-drift-instability/doc/drift_instability.bib @@ -25,14 +25,6 @@ @string{CiCP @string{JPCS = {Journal of Physics: Conference Series}} @string{CPC = {Comp. Phys. Comm.}} -%% HDF5 - -@Misc{hdf5-www, - author = {{The HDF Group}}, - title = {{HDF5}}, - note = {{http://www.hdfgroup.org/HDF5/index.html}} -} - %% netCDF @Article{brown-1993, diff --git a/tests/integrated/test-io_hdf5/CMakeLists.txt b/tests/integrated/test-io_hdf5/CMakeLists.txt deleted file mode 100644 index 25eb3a4e6f..0000000000 --- a/tests/integrated/test-io_hdf5/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -bout_add_integrated_test(test-io-hdf5 - SOURCES test_io_hdf5.cxx - USE_RUNTEST - USE_DATA_BOUT_INP - EXTRA_FILES test_io.grd.hdf5 data/benchmark.out.0.hdf5 - REQUIRES BOUT_HAS_HDF5 -) diff --git a/tests/integrated/test-io_hdf5/README.md b/tests/integrated/test-io_hdf5/README.md deleted file mode 100644 index 6748d9a3bc..0000000000 --- a/tests/integrated/test-io_hdf5/README.md +++ /dev/null @@ -1,23 +0,0 @@ -test-io_hdf5 -============ - -Test if variables can be read and written correctly for different number of -processes, using the HDF5 file format. - -The test reads variables from gridfile, then writes them to the output file. The -output file is compared to existing benchmark files with a tolerance of 1e-10. -The test is run using 1, 2 and 4 MPI processes. - -The following types are read in then immediately written to the output file: - -- int -- BoutReal -- Field2D -- Field3D - -Additionally, the following types are evolved: - -- int -- BoutReal -- Vector2D -- Vector3D diff --git a/tests/integrated/test-io_hdf5/data/BOUT.inp b/tests/integrated/test-io_hdf5/data/BOUT.inp deleted file mode 100644 index 0985e6bde4..0000000000 --- a/tests/integrated/test-io_hdf5/data/BOUT.inp +++ /dev/null @@ -1,13 +0,0 @@ -# Simple I/O test -# -# Load variables from a grid file, then write them out -# to a data file. -# - -NOUT = 0 # No timesteps - -MZ = 4 # Z size - -grid = "test_io.grd.hdf5" - -dump_format = "hdf5" # HDF5 format. Alternative is "pdb" or "nc" diff --git a/tests/integrated/test-io_hdf5/data/benchmark.out.0.hdf5 b/tests/integrated/test-io_hdf5/data/benchmark.out.0.hdf5 deleted file mode 100644 index 2bbc88cbd6..0000000000 Binary files a/tests/integrated/test-io_hdf5/data/benchmark.out.0.hdf5 and /dev/null differ diff --git a/tests/integrated/test-io_hdf5/generate.py b/tests/integrated/test-io_hdf5/generate.py deleted file mode 100644 index ea8e6478a8..0000000000 --- a/tests/integrated/test-io_hdf5/generate.py +++ /dev/null @@ -1,31 +0,0 @@ -# Create an input file for testing - -from h5py import File -import numpy -from sys import exit - -# number of components -nx = 12 -ny = 12 -nz = 5 - -ivar = 1 -rvar = numpy.pi -f2d = numpy.random.rand(nx, ny) -fperp = numpy.random.rand(nx, nz) -fperp2 = numpy.random.rand(nx, nz) -f3d = numpy.random.rand(nx, ny, nz) - -with File('test_io.grd.hdf5', 'w') as f: - f['nx'] = nx - f['ny'] = nx - f['ivar'] = ivar - f['rvar'] = rvar - - f['f2d'] = f2d - f['fperp'] = fperp - f['fperp2'] = fperp2 - f['fperp2'].attrs['yindex_global'] = 11 - f['f3d'] = f3d - -exit(0) diff --git a/tests/integrated/test-io_hdf5/makefile b/tests/integrated/test-io_hdf5/makefile deleted file mode 100644 index 0e55654a3a..0000000000 --- a/tests/integrated/test-io_hdf5/makefile +++ /dev/null @@ -1,6 +0,0 @@ - -BOUT_TOP = ../../.. - -SOURCEC = test_io_hdf5.cxx - -include $(BOUT_TOP)/make.config diff --git a/tests/integrated/test-io_hdf5/run.sh b/tests/integrated/test-io_hdf5/run.sh deleted file mode 100755 index 9158bdd67e..0000000000 --- a/tests/integrated/test-io_hdf5/run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -make - -./test_io - -benchmark=`md5sum data/benchmark.out.0.nc | head -c 32` -output=`md5sum data/test_io.out.0.nc | head -c 32` - -echo "== Checksums ==" -echo $benchmark -echo $output -echo "" - -if test "$benchmark" = "$output"; then - echo "=> TEST PASSED" -else - echo "=> TEST FAILED" -fi - diff --git a/tests/integrated/test-io_hdf5/runtest b/tests/integrated/test-io_hdf5/runtest deleted file mode 100755 index 0efc929a27..0000000000 --- a/tests/integrated/test-io_hdf5/runtest +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/env python3 - -# -# Run the test, compare results against the benchmark -# - -# Requires: hdf5 -# Cores: 4 - -from boututils.run_wrapper import build_and_log, shell, launch_safe -from boutdata.collect import collect -from boututils.datafile import DataFile -import numpy as np -from sys import exit - - -build_and_log("I/O test") - -# Read benchmark values - -vars = [ - "ivar", - "ivar_vec", - "svar", - "rvar", - "bvar", - "f2d", - "f3d", - "fperp", - "fperp2", - "ivar_evol", - "ivar_vec_evol", - "svar_evol", - "rvar_evol", - "bvar_evol", - "v2d_evol_x", - "v2d_evol_y", - "v2d_evol_z", - "fperp2_evol", -] - -field_vars = [ - "f2d", - "f3d", - "fperp", - "fperp2", - "v2d_evol_x", - "v2d_evol_y", - "v2d_evol_z", - "fperp2_evol", -] # Field quantities, not scalars - -tol = 1e-10 - -print("Reading benchmark data") -bmk = {} -for v in vars: - if "ivar_vec" in v or "svar" in v: - f = DataFile("data/benchmark.out.0.hdf5") - bmk[v] = f[v][...] - else: - bmk[v] = collect(v, path="data", prefix="benchmark.out", info=False) - - -# Executable name -test_exe = "./test_io_hdf5" - - -def check_output(): - success = True - for v in vars: - print(" Checking variable " + v + " ... ", end="") - if "ivar_vec" in v or "svar" in v: - f = DataFile("data/BOUT.dmp.0.hdf5") - result = f[v][...] - else: - result = collect(v, path="data", info=False) - - # Compare benchmark and output - if np.shape(bmk[v]) != np.shape(result): - print("Fail, wrong shape") - success = False - continue - - if result.dtype.kind not in np.typecodes["AllFloat"]: - # Non-float types should be identical - if not np.all(bmk[v] == result): - print("Fail") - success = False - continue - else: - diff = np.max(np.abs(bmk[v] - result)) - if diff > tol: - print("Fail, maximum difference = " + str(diff)) - success = False - continue - - for attrname in bmk[v].attributes: - bmkattr = bmk[v].attributes[attrname] - resattr = result.attributes[attrname] - if not bmkattr == resattr: - print( - "Fail: Attribute {} not the same for {}. Expected {}, got {}".format( - attrname, v, bmkattr, resattr - ) - ) - success = False - - if v in field_vars: - # Check cell location - if "cell_location" not in result.attributes: - print("Fail: {0} has no cell_location attribute".format(v)) - success = False - continue - - if result.attributes["cell_location"] != "CELL_CENTRE": - print( - "Fail: Expecting cell_location == CELL_CENTRE, but got {0}".format( - result.attributes["cell_location"] - ) - ) - success = False - continue - - print("Pass") - - return success - - -print("Running I/O test") -success = True -for nproc in [1, 2, 4]: - for split in [None, "NXPE", "NYPE"]: - if split is not None: - npe_max = nproc - else: - npe_max = 1 - for np_split in [i for i in [1, 2, 4] if i <= npe_max]: - - if split is not None: - extra_args = " {}={}".format(split, np_split) - else: - extra_args = "" - - cmd = test_exe + extra_args - - # On some machines need to delete dmp files first - # or data isn't written correctly - shell("rm -f data/BOUT.dmp.*") - - # Run test case - print(" %d processor...." % (nproc) + extra_args) - s, out = launch_safe(cmd, nproc=nproc, pipe=True) - with open("run.log." + str(nproc), "w") as f: - f.write(out) - - # Check processor splitting - if split is not None: - print(" Checking " + split + " ... ", end="") - v = collect(split, path="data", info=False) - if v != np_split: - print( - "Fail, wrong {} expecting {}, got {}".format(split, np_split, v) - ) - success = False - else: - print("Pass") - - # Check output - if not check_output(): - success = False - -# Test double-adding variables -print("Checking with identical variable added twice") -s, out = launch_safe(test_exe + " check_double_add=true", nproc=nproc, pipe=True) -if not check_output(): - success = False - -print("Checking with different variables added with same name (expected throw)") -# Test incorrectly double-adding variables - should throw exception -for check_incorrect_add in [ - "ivar", - "ivar_vec", - "rvar", - "bvar", - "f2d", - "f3d", - "fperp", - "ivar_evol", - "ivar_vec_evol", - "rvar_evol", - "bvar_evol", - "v2d_evol", - "v3d_evol", -]: - print(" Checking variable {} ... ".format(check_incorrect_add), end="") - try: - s, out = launch_safe( - test_exe + " check_incorrect_add=" + check_incorrect_add, - nproc=nproc, - pipe=True, - ) - except RuntimeError as e: - if ( - "Variable with name '" + check_incorrect_add + "' already added to Datafile" - in str(e) - ): - print("Pass") - else: - print( - "Fail: Incorrect error message for check_incorrect_add=" - + check_incorrect_add - ) - success = False - else: - # was supposed to fail and raise an exception - print( - "Fail: Did not raise an exception for incorrect double-add of " - + check_incorrect_add - ) - success = False - -if success: - print(" => All I/O tests passed") - exit(0) -else: - print(" => Some failed tests") - exit(1) diff --git a/tests/integrated/test-io_hdf5/test_io.grd.hdf5 b/tests/integrated/test-io_hdf5/test_io.grd.hdf5 deleted file mode 100644 index cf9ef5057d..0000000000 Binary files a/tests/integrated/test-io_hdf5/test_io.grd.hdf5 and /dev/null differ diff --git a/tests/integrated/test-io_hdf5/test_io_hdf5.cxx b/tests/integrated/test-io_hdf5/test_io_hdf5.cxx deleted file mode 100644 index 3ce5f9f861..0000000000 --- a/tests/integrated/test-io_hdf5/test_io_hdf5.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Input/Output regression test - * - * Read from and write to data files to check that - * the I/O routines are working. - * - * Test evolving and non-evolving variables - */ - -#include - -using bout::globals::dump; -using bout::globals::mesh; - -int main(int argc, char **argv) { - - // Initialise BOUT++, setting up mesh - BoutInitialise(argc, argv); - - // Variables to be read and written - int ivar, ivar_evol; - std::vector ivar_vec = {1, 2, 3}; - std::vector ivar_vec_evol = {4, 5, 6}; - std::string svar = "ab"; - std::string svar_evol = "cde"; - BoutReal rvar, rvar_evol; - bool bvar, bvar_evol; - Field2D f2d; - Field3D f3d; - // fperp is at yindex_global=0. - // fperp2 is at yindex_global=11, it is included to make sure the test does not pass - // only for the special case of the FieldPerp being present on processor number 0. - FieldPerp fperp, fperp2, fperp2_evol; - Vector2D v2d; - Vector3D v3d; - bool check_double_add = Options::root()["check_double_add"].withDefault(false); - auto check_incorrect_add = Options::root()["check_incorrect_add"].withDefault("none"); - - f2d = 0.0; - f3d = 0.0; - fperp = 0.0; - fperp2 = 0.0; - - // Read data from grid file - mesh->get(ivar, "ivar"); - mesh->get(rvar, "rvar"); - mesh->get(bvar, "bvar"); - mesh->get(f2d, "f2d"); - mesh->get(f3d, "f3d"); - mesh->get(fperp, "fperp"); - mesh->get(fperp2, "fperp2"); - - // Non-evolving variables - dump.add(ivar, "ivar", false); - dump.add(ivar_vec, "ivar_vec"); - dump.add(svar, "svar"); - dump.add(rvar, "rvar", false); - dump.add(bvar, "bvar", false); - dump.add(f2d, "f2d", false); - dump.add(f3d, "f3d", false); - dump.add(fperp, "fperp", false); - dump.add(fperp2, "fperp2", false); - - // Evolving variables - dump.add(ivar_evol, "ivar_evol", true); - dump.add(ivar_vec_evol, "ivar_vec_evol", true); - dump.add(svar_evol, "svar_evol", true); - dump.add(rvar_evol, "rvar_evol", true); - dump.add(bvar_evol, "bvar_evol", true); - dump.add(v2d, "v2d_evol", true); - dump.add(v3d, "v3d_evol", true); - dump.add(fperp2_evol, "fperp2_evol", true); - - if (check_double_add) { - // Add all variables twice to check this does not cause an error - dump.add(ivar, "ivar", false); - dump.add(ivar_vec, "ivar_vec"); - dump.add(svar, "svar"); - dump.add(rvar, "rvar", false); - dump.add(bvar, "bvar", false); - dump.add(f2d, "f2d", false); - dump.add(f3d, "f3d", false); - dump.add(fperp, "fperp", false); - dump.add(fperp2, "fperp2", false); - dump.add(ivar_evol, "ivar_evol", true); - dump.add(ivar_vec_evol, "ivar_vec_evol"); - dump.add(svar_evol, "svar_evol"); - dump.add(rvar_evol, "rvar_evol", true); - dump.add(bvar_evol, "bvar_evol", true); - dump.add(v2d, "v2d_evol", true); - dump.add(v3d, "v3d_evol", true); - dump.add(fperp2_evol, "fperp2_evol", true); - } - - // Cases to check expected fails - if (check_incorrect_add == "ivar") { - int dummy = 0; - dump.add(dummy, "ivar", false); - } else if (check_incorrect_add == "ivar_vec") { - std::vector dummy = {-1}; - dump.add(dummy, "ivar_vec", false); - } else if (check_incorrect_add == "svar") { - std::string dummy = "y"; - dump.add(dummy, "svar", false); - } else if (check_incorrect_add == "rvar") { - BoutReal dummy = 0.0; - dump.add(dummy, "rvar", false); - } else if (check_incorrect_add == "bvar") { - bool dummy = false; - dump.add(dummy, "bvar", false); - } else if (check_incorrect_add == "f2d") { - Field2D dummy = 0.0; - dump.add(dummy, "f2d", false); - } else if (check_incorrect_add == "f3d") { - Field3D dummy = 0.0; - dump.add(dummy, "f3d", false); - } else if (check_incorrect_add == "fperp") { - FieldPerp dummy = 0.0; - dump.add(dummy, "fperp", false); - } else if (check_incorrect_add == "ivar_evol") { - int dummy = 0; - dump.add(dummy, "ivar_evol", true); - } else if (check_incorrect_add == "ivar_vec_evol") { - std::vector dummy = {-1}; - dump.add(dummy, "ivar_vec_evol", false); - } else if (check_incorrect_add == "svar_evol") { - std::string dummy = "y"; - dump.add(dummy, "svar_evol", false); - } else if (check_incorrect_add == "rvar_evol") { - BoutReal dummy = 0.0; - dump.add(dummy, "rvar_evol", true); - } else if (check_incorrect_add == "bvar_evol") { - bool dummy = false; - dump.add(dummy, "bvar_evol", true); - } else if (check_incorrect_add == "v2d_evol") { - Vector2D dummy; - dump.add(dummy, "v2d_evol", true); - } else if (check_incorrect_add == "v3d_evol") { - Vector3D dummy; - dump.add(dummy, "v3d_evol", true); - } - - int MYPE; - MPI_Comm_rank(BoutComm::get(), &MYPE); - - bvar_evol = bvar; - for(int i=0;i<3;i++) { - ivar_evol = ivar + i; - ivar_vec_evol[0] += i; ivar_vec_evol[1] += i; ivar_vec_evol[2] += i; - svar_evol[0] += i; svar_evol[1] += i; svar_evol[2] += i; - rvar_evol = rvar + 0.5 * i; - bvar_evol = !bvar_evol; - v2d.x = v2d.y = v2d.z = f2d; - v3d.x = v3d.y = v3d.z = f3d; - fperp2_evol = fperp2; - - dump.write(); - } - - dump.close(); // Ensure data is written - - // Need to wait for all processes to finish writing - MPI_Barrier(BoutComm::get()); - - /// Finished, tidy up and free memory - BoutFinalise(); - - return 0; -} diff --git a/tests/integrated/test-restart-io_hdf5/.gitignore b/tests/integrated/test-restart-io_hdf5/.gitignore deleted file mode 100644 index 3f5630137c..0000000000 --- a/tests/integrated/test-restart-io_hdf5/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test-restart-io diff --git a/tests/integrated/test-restart-io_hdf5/CMakeLists.txt b/tests/integrated/test-restart-io_hdf5/CMakeLists.txt deleted file mode 100644 index 09cdf40f1d..0000000000 --- a/tests/integrated/test-restart-io_hdf5/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -bout_add_integrated_test(test-restart-io-hdf5 - SOURCES test-restart-io.cxx - USE_RUNTEST - USE_DATA_BOUT_INP - REQUIRES BOUT_HAS_HDF5 - ) diff --git a/tests/integrated/test-restart-io_hdf5/data/BOUT.inp b/tests/integrated/test-restart-io_hdf5/data/BOUT.inp deleted file mode 100644 index bdacaef63b..0000000000 --- a/tests/integrated/test-restart-io_hdf5/data/BOUT.inp +++ /dev/null @@ -1,19 +0,0 @@ -restart = true -timestep = 1 -dump_format = h5 - -[mesh] -nx = 12 -ny = 16 -nz = 4 - -# no periodic region -ixseps1 = -1 -ixseps2 = -1 - -[solver] -type = euler -timestep = 0.5 - -[all] -bndry_all = none diff --git a/tests/integrated/test-restart-io_hdf5/makefile b/tests/integrated/test-restart-io_hdf5/makefile deleted file mode 100644 index 4be85e426e..0000000000 --- a/tests/integrated/test-restart-io_hdf5/makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOUT_TOP = ../../.. - -SOURCEC = test-restart-io.cxx - -include $(BOUT_TOP)/make.config diff --git a/tests/integrated/test-restart-io_hdf5/runtest b/tests/integrated/test-restart-io_hdf5/runtest deleted file mode 100755 index 1be2e9a22e..0000000000 --- a/tests/integrated/test-restart-io_hdf5/runtest +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python3 -# -# Test file I/O by loading from restart files and writing to dump files -# -# requires: hdf5 -# cores: 4 - -from boutdata import restart -from boutdata.collect import collect -from boututils.boutarray import BoutArray -from boututils.datafile import DataFile -from boututils.run_wrapper import build_and_log, shell, launch_safe -import numpy -import os -from sys import exit -import uuid - -nx = 8 -ny = 16 -nz = 4 -mxg = 2 -myg = 2 - -build_and_log("restart I/O test") - -x = numpy.linspace(0., 1., nx+2*mxg)[:, numpy.newaxis, numpy.newaxis] -y = numpy.linspace(0., 1., ny+2*myg)[numpy.newaxis, :, numpy.newaxis] -z = numpy.linspace(0., 1., nz)[numpy.newaxis, numpy.newaxis, :] - -testvars = {} -testvars['f3d'] = BoutArray(numpy.exp(numpy.sin(x + y + z)), attributes = {'bout_type':'Field3D'}) -testvars['f2d'] = BoutArray(numpy.exp(numpy.sin(x + y + 1.))[:, :, 0], attributes = {'bout_type':'Field2D'}) -testvars['fperp_lower'] = BoutArray(numpy.exp(numpy.sin(x + z + 2.))[:, 0, :], attributes = {'bout_type':'FieldPerp', 'yindex_global':0}) -testvars['fperp_upper'] = BoutArray(numpy.exp(numpy.sin(x + z + 3.))[:, 0, :], attributes = {'bout_type':'FieldPerp', 'yindex_global':ny-1}) - -# make restart file -restartdir = os.path.join('data', 'restart') -try: - os.mkdir(restartdir) -except FileExistsError: - pass - -with DataFile(os.path.join(restartdir, 'BOUT.restart.0.h5'), create=True) as base_restart: - base_restart.write('MXSUB', nx) - base_restart.write('MYSUB', ny) - base_restart.write('MZSUB', nz) - base_restart.write('MXG', mxg) - base_restart.write('MYG', myg) - base_restart.write('MZG', 0) - base_restart.write('nx', nx+2*mxg) - base_restart.write('ny', ny) - base_restart.write('nz', nz) - base_restart.write('MZ', nz) - base_restart.write('NXPE', 1) - base_restart.write('NYPE', 1) - base_restart.write('NZPE', 1) - base_restart.write('tt', 0.) - base_restart.write('hist_hi', 0) - # set BOUT_VERSION to stop collect from changing nz or printing a warning - base_restart.write('BOUT_VERSION', 4.) - base_restart.write('f3d', testvars['f3d']) - base_restart.write('f2d', testvars['f2d']) - base_restart.write('fperp_lower', testvars['fperp_lower']) - base_restart.write('fperp_upper', testvars['fperp_upper']) - - # make run_id an array of characters because NetCDF doesn't like generic strings - run_id_string = '36 character run_id test string ****' - run_id = numpy.array(list(run_id_string), dtype='S1') - run_id = BoutArray(run_id, attributes = {'bout_type': 'string'}) - base_restart.write('run_id', run_id) - run_restart_from = numpy.array( - list('36 character run_restart_from string'), dtype='S1' - ) - run_restart_from = BoutArray( - run_restart_from, attributes = {'bout_type': 'string'} - ) - base_restart.write('run_restart_from', run_restart_from) - -success = True - -# Note: expect this to fail for 16 processors, because when there are 2 -# y-points per processor, the fperp_lower FieldPerp is in the grid cells of one -# set of processors and also in the guard cells of anoether set. This means -# valid FieldPerps get written to output files with different -# y-processor-indices, and collect() cannot handle this. -for nproc in [1, 2, 4]: - # delete any existing output - shell("rm -f data/BOUT.dmp.*.h5 data/BOUT.restart.*.h5") - - # create restart files for the run - restart.redistribute(nproc, path=restartdir, output='data') - - print(" %d processor...." % (nproc)) - - # run the test executable - s, out = launch_safe('./test-restart-io', nproc=nproc, pipe=True) - with open("run.log."+str(nproc), "w") as f: - f.write(out) - - # check the results - for name in testvars.keys(): - # check non-evolving version - result = collect(name+"_once", path='data', xguards=True, yguards=True, info=False) - testvar = testvars[name] - - if not numpy.all(testvar == result): - success = False - print(name+' is different') - # Don't plot anything by default - if False: - from boututils.showdata import showdata - showdata([result, testvar]) - if name == 'fperp_lower' or name == 'fperp_upper': - yindex_result = result.attributes['yindex_global'] - yindex_test = testvar.attributes['yindex_global'] - if not yindex_result == yindex_test: - success = False - print('Fail: yindex_global of '+name+' is '+str(yindex_result)+' should be '+str(yindex_test)) - - # check evolving versions - result = collect(name, path='data', xguards=True, yguards=True, info=False) - - for result_timeslice in result: - if not numpy.all(testvar == result_timeslice): - success = False - print(name+' evolving version is different') - if name == 'fperp_lower' or name == 'fperp_upper': - yindex_result = result.attributes['yindex_global'] - yindex_test = testvar.attributes['yindex_global'] - if not yindex_result == yindex_test: - success = False - print('Fail: yindex_global of '+name+' evolving version is '+str(yindex_result)+' should be '+str(yindex_test)) - - # check the run_id - run_id = collect('run_id', path='data', info=False) - # check run_id can be converted to a valid UUID - try: - uuid.UUID(run_id.tobytes().decode()) - except ValueError: - success = False - print('run_id=' + str(run_id) + ' is not a valid UUID') - run_restart_from = collect('run_restart_from', path='data', info=False) - if not run_restart_from.tobytes().decode() == run_id_string: - success = False - print( - 'incorrect run_restart_from=' + run_restart_from.tobytes().decode() - + '. Expected ' + run_id_string - ) - -if success: - print('=> All restart I/O tests passed') - # clean up binary files - shell("rm -f data/BOUT.dmp.*.h5 data/BOUT.restart.*.h5 data/restart/BOUT.restart.0.h5") - exit(0) - -print("=> Some failed tests") -exit(1) diff --git a/tests/integrated/test-restart-io_hdf5/test-restart-io.cxx b/tests/integrated/test-restart-io_hdf5/test-restart-io.cxx deleted file mode 100644 index ad8d3a043d..0000000000 --- a/tests/integrated/test-restart-io_hdf5/test-restart-io.cxx +++ /dev/null @@ -1,34 +0,0 @@ -#include "bout/physicsmodel.hxx" - -class TestRestartIO : public PhysicsModel { - int init(bool UNUSED(restarting)) { - solver->add(f3d, "f3d"); - solver->add(f2d, "f2d"); - dump.addRepeat(fperp_lower, "fperp_lower"); - dump.addRepeat(fperp_upper, "fperp_upper"); - restart.addOnce(fperp_lower, "fperp_lower"); - restart.addOnce(fperp_upper, "fperp_upper"); - - dump.addOnce(f3d, "f3d_once"); - dump.addOnce(f2d, "f2d_once"); - dump.addOnce(fperp_lower, "fperp_lower_once"); - dump.addOnce(fperp_upper, "fperp_upper_once"); - - return 0; - } - - int rhs(BoutReal UNUSED(time)) { - ddt(f3d) = 0.; - ddt(f2d) = 0.; - return 0; - } - - Field3D f3d; - Field2D f2d; - // fperp_lower is at yindex_global=0. - // fperp_upper is at yindex_global=16, it is included to make sure the test does not - // pass only for the special case of the FieldPerp being present on prcossor number 0. - FieldPerp fperp_lower, fperp_upper; -}; - -BOUTMAIN(TestRestartIO); diff --git a/tests/requirements/requirements.py b/tests/requirements/requirements.py index cc46cb02b2..944dc18a57 100755 --- a/tests/requirements/requirements.py +++ b/tests/requirements/requirements.py @@ -17,7 +17,7 @@ class Requirements(object): #requires not make - #requires not (travis and hdf5) + #requires not (travis and netcdf) The individual requirements (netcdf, make, travis, etc.) are gathered from the bout-config scipt, or from executable diff --git a/tools/pylib/boutconfig/__init__.py.cin b/tools/pylib/boutconfig/__init__.py.cin index 1ec4263b9e..069823de7c 100644 --- a/tools/pylib/boutconfig/__init__.py.cin +++ b/tools/pylib/boutconfig/__init__.py.cin @@ -19,7 +19,6 @@ config = { "has_netcdf": "@BOUT_HAS_NETCDF@", "has_legacy_netcdf": "@BOUT_HAS_LEGACY_NETCDF@", "has_pnetcdf": "OFF", - "has_hdf5": "@BOUT_HAS_HDF5@", "has_pvode": "@BOUT_HAS_PVODE@", "has_cvode": "@BOUT_HAS_CVODE@", "has_ida": "@BOUT_HAS_IDA@",