From 883c338c08c8761b09f263ee4d39709101d4aa23 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 17 Jan 2024 14:00:09 +0100 Subject: [PATCH 01/17] Fixed building --- external/external_build.cmake | 1 + sample/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/external/external_build.cmake b/external/external_build.cmake index 65ee8b8..997cc4d 100644 --- a/external/external_build.cmake +++ b/external/external_build.cmake @@ -206,6 +206,7 @@ if (INTERNAL_NETCDF) DOWNLOAD_DIR ${SOURCE_PREFIX}/downloads URL ${NETCDFCXX_URL} CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_SHARED_LIBS=OFF diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 03709a7..6d019a7 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,4 +1,8 @@ SET(tolink ${CosmoTool_local} ${CosmoTool_LIBS} ${GSL_LIBRARIES} ${DL_LIBRARY}) +if (RT_LIBRARY) + SET(tolink ${tolink} ${RT_LIBRARY}) +endif() + include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${FFTW3_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${GSL_INCLUDE_PATH}) if(YORICK_SUPPORT) From 54a59b5246407b0b8d226eddb90e8151f829278b Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 16 Jan 2024 07:54:48 +0100 Subject: [PATCH 02/17] Fix manifest --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 5c4f363..2344e64 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -17,7 +17,7 @@ include doc/source/index.rst include doc/source/intro.rst include doc/source/pythonmodule.rst include external/external_build.cmake -include external/libsharp-6077806.tar.gz +include external/libsharp-8d51946.tar.gz include external/omptl-20120422.tar.bz2 include external/patch-omptl include python/CMakeLists.txt From f2a5092cf119760a9a0f03da81980b791dbf9389 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 07:53:06 +0100 Subject: [PATCH 03/17] Fix MANIFEST --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 2344e64..6400359 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,6 +16,8 @@ include doc/source/cpplibrary.rst include doc/source/index.rst include doc/source/intro.rst include doc/source/pythonmodule.rst +include external/config.guess +include external/config.sub include external/external_build.cmake include external/libsharp-8d51946.tar.gz include external/omptl-20120422.tar.bz2 From 1db266b4ea982284c200739bf4e24f3166346b88 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 08:19:54 +0100 Subject: [PATCH 04/17] Add pyproject.toml --- MANIFEST.in | 1 + pyproject.toml | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in index 6400359..4bc4264 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include .gitignore +include pyproject.toml include CMakeLists.txt include FindNumPy.cmake include FindPyLibs.cmake diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..890c3fc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + From 1151d0c8b6008e095a692c166afbeef807557f24 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 08:25:14 +0100 Subject: [PATCH 05/17] Add cython back to dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7c07d3a..63377a0 100644 --- a/setup.py +++ b/setup.py @@ -240,7 +240,7 @@ setup(name='cosmotool', version='1.3.5', packages=["cosmotool"], package_dir={'cosmotool': 'python/cosmotool'}, - install_requires=['numpy','cffi','numexpr','h5py'], + install_requires=['cython','numpy','cffi','numexpr','h5py'], setup_requires=['cython','cffi','numpy','numexpr'], ext_modules=[CosmoTool_extension], description='A small cosmotool box of useful functions', From 1548fd84508ed84c6c5a00bd7da570967e2edf7c Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 09:15:36 +0100 Subject: [PATCH 06/17] Add missing pyx in MANIFEST --- MANIFEST.in | 1 + pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 4bc4264..309d4fc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -27,6 +27,7 @@ include python/CMakeLists.txt include python/_cosmo_bispectrum.cpp include python/_cosmo_cic.pyx include python/_cosmo_power.pyx +include python/_cosmomath.pyx include python/_cosmotool.pyx include python/_fast_interp.pyx include python/_project.pyx diff --git a/pyproject.toml b/pyproject.toml index 890c3fc..32826dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools","wheel","cython"] build-backend = "setuptools.build_meta" From 1d59533b175b5bbe0c8a3ce02fe2808a1fdc5e51 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:28:58 +0100 Subject: [PATCH 07/17] Add python in search path --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 368eed6..1b3fe10 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,7 +2,7 @@ set(CMAKE_SHARED_MODULE_PREFIX) set(PYTHON_INCLUDES ${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/python) -include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) +include_directories(${CMAKE_SOURCE_DIR}/python ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src) IF(CYTHON) add_custom_command( From 4bcc5f32704867a6ff9068ac1cc8e328476d6fe9 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:37:52 +0100 Subject: [PATCH 08/17] Add missing numpy_adaptors --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 309d4fc..105a2d6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -97,6 +97,7 @@ include sample/testkd3.cpp include setup.py include src/CMakeLists.txt include src/algo.hpp +include src/numpy_adaptors.hpp include src/bqueue.hpp include src/bqueue.tcc include src/bsp_simple.hpp From 47d63a25cec1f8a823aa14edaa10f6aa1fc93412 Mon Sep 17 00:00:00 2001 From: "guilhem.lavaux@iap.fr" Date: Tue, 13 Feb 2024 10:47:28 +0100 Subject: [PATCH 09/17] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 63377a0..0b98cce 100644 --- a/setup.py +++ b/setup.py @@ -237,7 +237,7 @@ class BuildCMakeExt(build_ext): CosmoTool_extension = CMakeExtension(name="cosmotool") setup(name='cosmotool', - version='1.3.5', + version='1.3.6', packages=["cosmotool"], package_dir={'cosmotool': 'python/cosmotool'}, install_requires=['cython','numpy','cffi','numexpr','h5py'], From be64c7fd7afe1c1c173401c64842b2ca99f27a6f Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 25 Apr 2024 17:05:54 +0200 Subject: [PATCH 10/17] Remove support for old python --- builder/build-wheels.sh | 6 +++--- builder/start.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/build-wheels.sh b/builder/build-wheels.sh index 60a8bfc..8f529dd 100755 --- a/builder/build-wheels.sh +++ b/builder/build-wheels.sh @@ -16,7 +16,7 @@ ln -fs /usr/bin/cmake3 /usr/bin/cmake test -d /io/wheelhouse || mkdir /io/wheelhouse test -d /io/wheelhouse/fix || mkdir /io/wheelhouse/fix -ALL_PYTHON="cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310" +ALL_PYTHON="cp39-cp39 cp310-cp310" # Compile wheels for pkg in $ALL_PYTHON; do @@ -24,11 +24,11 @@ for pkg in $ALL_PYTHON; do # "${PYBIN}/pip" install -r /io/dev-requirements.txt "${PYBIN}/pip" install setuptools wheel Cython "${PYBIN}/pip" install -r /io/requirements.txt - "${PYBIN}/pip" wheel -vvv /io/ -w wheelhouse/ + "${PYBIN}/pip" wheel -vvv /io/ -w /io/wheelhouse/ done # Bundle external shared libraries into the wheels -for whl in /io/wheelhouse/cosmotool*.whl; do +for whl in /io/wheelhouse/cosmotool*linux*.whl; do auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/fix done diff --git a/builder/start.sh b/builder/start.sh index 9fbc185..31f95f0 100755 --- a/builder/start.sh +++ b/builder/start.sh @@ -9,4 +9,4 @@ if ! [ -e ${d}/setup.py ] ; then exit 1 fi -podman run -ti --rm -e PLAT=manylinux2010_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2010_x86_64 /io/builder/build-wheels.sh +podman run -ti --rm -e PLAT=manylinux2014_x86_64 -v ${d}:/io:Z quay.io/pypa/manylinux2014_x86_64 /io/builder/build-wheels.sh From 924047de22b6c1e1e367d807e0508d6641c5ea24 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 25 Apr 2024 18:11:02 +0200 Subject: [PATCH 11/17] Add possibility to have an external state --- src/hdf5_array.hpp | 2 +- src/sphSmooth.hpp | 4 +++- src/sphSmooth.tcc | 37 +++++++++++++++++++++---------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/hdf5_array.hpp b/src/hdf5_array.hpp index db75a33..55dc87b 100644 --- a/src/hdf5_array.hpp +++ b/src/hdf5_array.hpp @@ -426,7 +426,7 @@ namespace CosmoTool { #define CTOOL_HDF5_INSERT_ELEMENT(r, STRUCT, element) \ { \ ::CosmoTool::get_hdf5_data_type t; \ - long position = HOFFSET(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \ + long position = offsetof(STRUCT, BOOST_PP_TUPLE_ELEM(2, 1, element)); \ const char *field_name = BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, element)); \ type.insertMember(field_name, position, t.type()); \ } diff --git a/src/sphSmooth.hpp b/src/sphSmooth.hpp index fdada71..f9c468b 100644 --- a/src/sphSmooth.hpp +++ b/src/sphSmooth.hpp @@ -72,7 +72,9 @@ namespace CosmoTool { void fetchNeighbours(const typename SPHTree::coords &c, SPHState *state = 0); - void fetchNeighbours(const typename SPHTree::coords &c, uint32_t newNsph); + void fetchNeighbours( + const typename SPHTree::coords &c, uint32_t newNsph, + SPHState *state = 0); void fetchNeighboursOnVolume( const typename SPHTree::coords &c, ComputePrecision radius); const typename SPHTree::coords &getCurrentCenter() const { diff --git a/src/sphSmooth.tcc b/src/sphSmooth.tcc index c163feb..c50fb7e 100644 --- a/src/sphSmooth.tcc +++ b/src/sphSmooth.tcc @@ -35,32 +35,38 @@ namespace CosmoTool { template void SPHSmooth::fetchNeighbours( - const typename SPHTree::coords &c, uint32_t newNngb) { + const typename SPHTree::coords &c, uint32_t newNngb, SPHState *state) { ComputePrecision d2, max_dist = 0; uint32_t requested = newNngb; - if (requested > maxNgb) { - maxNgb = requested; - internal.ngb = boost::shared_ptr(new P_SPHCell[maxNgb]); - internal.distances = - boost::shared_ptr(new CoordType[maxNgb]); + if (state != 0) { + state->distances = boost::shared_ptr(new CoordType[Nsph]); + state->ngb = boost::shared_ptr(new SPHCell *[Nsph]); + } else { + state = &internal; + if (requested > maxNgb) { + maxNgb = requested; + internal.ngb = boost::shared_ptr(new P_SPHCell[maxNgb]); + internal.distances = + boost::shared_ptr(new CoordType[maxNgb]); + } } - memcpy(internal.currentCenter, c, sizeof(c)); + memcpy(state->currentCenter, c, sizeof(c)); tree->getNearestNeighbours( - c, requested, (SPHCell **)internal.ngb.get(), - (CoordType *)internal.distances.get()); + c, requested, (SPHCell **)state->ngb.get(), + (CoordType *)state->distances.get()); - internal.currentNgb = 0; - for (uint32_t i = 0; i < requested && (internal.ngb)[i] != 0; - i++, internal.currentNgb++) { - internal.distances[i] = sqrt(internal.distances[i]); - d2 = internal.distances[i]; + state->currentNgb = 0; + for (uint32_t i = 0; i < requested && (state->ngb)[i] != 0; + i++, state->currentNgb++) { + state->distances[i] = sqrt(state->distances[i]); + d2 = state->distances[i]; if (d2 > max_dist) max_dist = d2; } - internal.smoothRadius = max_dist / 2; + state->smoothRadius = max_dist / 2; } template @@ -241,5 +247,4 @@ namespace CosmoTool { const SPHSmooth &s2) { return (s1.getSmoothingLen() < s2.getSmoothingLen()); } - }; // namespace CosmoTool From fb51ffd35e5f111bbf7a679a0dffc562530c1cb1 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Fri, 26 Apr 2024 08:53:38 +0200 Subject: [PATCH 12/17] Fixup for sph --- src/sphSmooth.tcc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sphSmooth.tcc b/src/sphSmooth.tcc index c50fb7e..6643dd3 100644 --- a/src/sphSmooth.tcc +++ b/src/sphSmooth.tcc @@ -40,8 +40,8 @@ namespace CosmoTool { uint32_t requested = newNngb; if (state != 0) { - state->distances = boost::shared_ptr(new CoordType[Nsph]); - state->ngb = boost::shared_ptr(new SPHCell *[Nsph]); + state->distances = boost::shared_ptr(new CoordType[newNngb]); + state->ngb = boost::shared_ptr(new SPHCell *[newNngb]); } else { state = &internal; if (requested > maxNgb) { @@ -212,7 +212,7 @@ namespace CosmoTool { ComputePrecision d = state->distances[i]; SPHCell &cell = *(state->ngb[i]); double kernel_value = getKernel(d / state->smoothRadius) / r3; -#pragma omp atomic +#pragma omp atomic update cell.val.weight += kernel_value; } } From 736531e9fd4c9a53d3ab63a9674aab42e4a5a7e3 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 9 May 2024 09:55:02 +0300 Subject: [PATCH 13/17] Add towncrier experimental --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 32826dd..7a031e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,7 @@ requires = ["setuptools","wheel","cython"] build-backend = "setuptools.build_meta" + +[tool.towncrier] +directory = "changes" + From 70f6f88802a145caab0ebeb1edcde6d66923d5ea Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 11 Mar 2025 14:26:57 -0400 Subject: [PATCH 14/17] Add ZLIB package --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b1743..02a93d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ ENDIF(BUILD_PYTHON) MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module") +find_package(ZLIB) find_library(ZLIB_LIBRARY z) find_library(DL_LIBRARY dl) find_library(RT_LIBRARY rt) @@ -82,7 +83,7 @@ SET(CPACK_PACKAGE_VERSION_MINOR "3") SET(CPACK_PACKAGE_VERSION_PATCH "4${EXTRA_VERSION}") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") SET(CPACK_STRIP_FILES "lib/libCosmoTool.so") -SET(CPACK_SOURCE_IGNORE_FILES +SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile") add_subdirectory(src) From 36905042612f805723ca712e1457e4ee9d587224 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sun, 8 Jun 2025 11:02:51 +0200 Subject: [PATCH 15/17] fix: Force PIC building in all cases --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c075396..38c1901 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,7 @@ if (HDF5_FOUND) loadFlash.cpp ) add_dependencies(CosmoHDF5 ${cosmotool_DEPS}) - set_property(TARGET CosmoHDF5 PROPERTY POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}) + set_property(TARGET CosmoHDF5 PROPERTY POSITION_INDEPENDENT_CODE ON) target_include_directories(CosmoHDF5 BEFORE PRIVATE ${HDF5_INCLUDE_DIR}) else(HDF5_FOUND) add_library(CosmoHDF5 OBJECT From dc79f6b6a257373e0b7ae0feb3968e7c1927cba4 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 2 Jul 2025 11:38:01 +0200 Subject: [PATCH 16/17] fix: update readflash to more moderne HDF5 --- src/h5_readFlash.cpp | 85 ++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/src/h5_readFlash.cpp b/src/h5_readFlash.cpp index 6e2ec3a..bc2a080 100644 --- a/src/h5_readFlash.cpp +++ b/src/h5_readFlash.cpp @@ -7,16 +7,16 @@ This software is a computer program whose purpose is to provide a toolbox for co data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...) This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, +abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". +"http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited -liability. +liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -25,9 +25,9 @@ that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. @@ -59,8 +59,8 @@ int ipvz_out = 5; /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ -/* n*_runtime_parameters should be set by the caller to - the maximum number of runtime parameters to read. +/* n*_runtime_parameters should be set by the caller to + the maximum number of runtime parameters to read. */ void h5_read_runtime_parameters @@ -100,12 +100,12 @@ void h5_read_runtime_parameters nreal_runtime_parameters = MAX_PARM; /* integer runtime parameters */ - int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t)); + int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t)); rank = 1; DataSet dataset = file->openDataSet("integer runtime parameters"); - - IntType int_rt_type = dataset.getIntType(); + + IntType int_rt_type = dataset.getIntType(); //int_rt_type = H5Dget_type(dataset); DataSpace dataspace = dataset.getSpace(); @@ -124,6 +124,8 @@ void h5_read_runtime_parameters //memspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset.read(int_rt_parms, int_rt_type, memspace, dataspace); + //status = H5Dread(dataset, int_rt_type, memspace, dataspace, + // H5P_DEFAULT, int_rt_parms); for (i = 0; i < nint_runtime_parameters; i++) { @@ -142,14 +144,14 @@ void h5_read_runtime_parameters /* reals */ - real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t)); - + real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t)); + rank = 1; dataset = file->openDataSet("real runtime parameters"); - //dataset = H5Dopen(*file_identifier, "real runtime parameters"); - + //dataset = H5Dopen(*file_identifier, "real runtime parameters"); + dataspace = dataset.getSpace(); - FloatType real_rt_type = dataset.getFloatType(); + FloatType real_rt_type = dataset.getFloatType(); ndims = dataspace.getSimpleExtentDims(&dimens_1d, NULL); //dataspace = H5Dget_space(dataset); //real_rt_type = H5Dget_type(dataset); @@ -165,6 +167,8 @@ void h5_read_runtime_parameters //memspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset.read(real_rt_parms, real_rt_type, memspace, dataspace); + //status = H5Dread(dataset, real_rt_type, memspace, dataspace, +// H5P_DEFAULT, real_rt_parms); for (i = 0; i < nreal_runtime_parameters; i++) { @@ -187,7 +191,7 @@ void h5_read_runtime_parameters *LBox = real_runtime_parameter_values[i]; } if (strncmp(real_runtime_parameter_names[i],"hubbleconstant", 14) == 0 ) { - *hubble = real_runtime_parameter_values[i]; + *hubble = real_runtime_parameter_values[i]; } if (strncmp(real_runtime_parameter_names[i],"omegamatter", 11) == 0 ) { *omegam = real_runtime_parameter_values[i]; @@ -199,7 +203,7 @@ void h5_read_runtime_parameters *omegalambda = real_runtime_parameter_values[i]; } } - + for (i = 0; i < nint_runtime_parameters; i++) { if (strncmp(int_runtime_parameter_names[i],"pt_numx",7) == 0 ) { *numPart = int_runtime_parameter_values[i]; @@ -208,7 +212,7 @@ void h5_read_runtime_parameters } } - + /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ void h5_read_flash3_particles (H5File* file, int* totalparticles, @@ -235,8 +239,8 @@ void h5_read_flash3_particles (H5File* file, char *propName; double *partBuffer; char part_names[50][OUTPUT_PROP_LENGTH]; - int string_size; - + int string_size; + // char part_names[NPART_PROPS][OUTPUT_PROP_LENGTH]; hsize_t dimens_2d[2], maxdimens_2d[2]; hsize_t start_2d[2], count_2d[2], stride_2d[2]; @@ -259,12 +263,12 @@ void h5_read_flash3_particles (H5File* file, //total number of particle properties numProps = dimens_2d[0]; - + string_size = OUTPUT_PROP_LENGTH; StrType string_type = H5Tcopy(H5T_C_S1); string_type.setSize(string_size); //status = H5Tset_size(string_type, string_size); - + rank = 2; start_2d[0] = 0; @@ -276,20 +280,22 @@ void h5_read_flash3_particles (H5File* file, count_2d[0] = dimens_2d[0]; count_2d[1] = dimens_2d[1]; - dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); + dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); //status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d, // stride_2d, count_2d, NULL); DataSpace memspace(rank, dimens_2d); //memspace = H5Screate_simple(rank, dimens_2d, NULL); - dataset.read(part_names, string_type); - + dataset.read(part_names, string_type, H5S_ALL, H5S_ALL); + //status = H5Dread(dataset, string_type, H5S_ALL, H5S_ALL, + // H5P_DEFAULT, part_names); + string_type.close(); memspace.close(); dataspace.close(); - dataset.close(); + dataset.close(); //H5Tclose(string_type); //H5Sclose(memspace); //H5Sclose(dataspace); @@ -305,7 +311,7 @@ void h5_read_flash3_particles (H5File* file, if (strncmp(part_names[i], "velz", 4) == 0) { ipvz = i+1; } } - if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) || + if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) || (ipvy < 0) || (ipvz < 0) ) { printf("One or more required particle attributes not found in file!\n"); return; @@ -317,7 +323,7 @@ void h5_read_flash3_particles (H5File* file, //read particles dataset = file->openDataSet("tracer particles"); //dataset = H5Dopen(*file_identifier, "tracer particles"); - + FloatType datatype = dataset.getFloatType(); //datatype = H5Dget_type(dataset); @@ -330,7 +336,7 @@ void h5_read_flash3_particles (H5File* file, ndims = dataspace.getSimpleExtentDims(dimens_2d, NULL); //dataspace = H5Dget_space(dataset); //H5Sget_simple_extent_dims(dataspace, dimens_2d, maxdimens_2d); - + /*insert particle properties (numPartBuffer) particles at a time*/ pstack = (*localnp); poffset = 0; @@ -358,7 +364,7 @@ void h5_read_flash3_particles (H5File* file, dimens_2d[0] = (pcount); dimens_2d[1] = (numProps); - dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); + dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); //status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d, // stride_2d, count_2d, NULL); @@ -367,6 +373,7 @@ void h5_read_flash3_particles (H5File* file, /* read data from the dataset */ dataset.read(partBuffer, datatype, memspace, dataspace); + //status = H5Dread(dataset, datatype, memspace, dataspace, H5P_DEFAULT, partBuffer); /* convert buffer into particle struct */ @@ -382,8 +389,8 @@ void h5_read_flash3_particles (H5File* file, pos3[p+poffset] = (float) *(partBuffer+ipz-1+p*numProps); } } - - + + if (vel1 && vel2 && vel3) { for(p=0; p < (pcount); p++) { vel1[p+poffset] = (float) *(partBuffer+ipvx-1+p*numProps); @@ -414,7 +421,7 @@ void h5_read_flash3_particles (H5File* file, //status = H5Sclose(dataspace); //status = H5Dclose(dataset); } - + /*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ @@ -442,7 +449,7 @@ void h5_read_flash3_header_info(H5File* file, H5std_string DATASET_NAME; - string_type = H5Tcopy(H5T_C_S1); + string_type = H5Tcopy(H5T_C_S1); H5Tset_size(string_type, MAX_STRING_LENGTH); DataSet dataset = file->openDataSet("real scalars"); @@ -458,13 +465,13 @@ void h5_read_flash3_header_info(H5File* file, /* malloc a pointer to a list of real_list_t's */ real_list = (real_list_t *) malloc(dimens_1d * sizeof(real_list_t)); - // create a new simple dataspace of 1 dimension and size of 'dimens_1d' + // create a new simple dataspace of 1 dimension and size of 'dimens_1d' DataSpace memspace(1, &dimens_1d); - // create an empty vessel sized to hold one real_list_t's worth of data + // create an empty vessel sized to hold one real_list_t's worth of data CompType real_list_type( sizeof(real_list_t) ); - // subdivide the empty vessel into its component sections (name and value) + // subdivide the empty vessel into its component sections (name and value) real_list_type.insertMember( "name", HOFFSET(real_list_t, name), @@ -475,7 +482,7 @@ void h5_read_flash3_header_info(H5File* file, HOFFSET(real_list_t, value), PredType::NATIVE_DOUBLE); - // read the data into 'real_list' + // read the data into 'real_list' dataset.read( real_list, real_list_type, memspace, dataspace); From 63158017ea7b693cf2b8b2f840e24fb1f6882558 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Wed, 2 Jul 2025 13:43:18 +0200 Subject: [PATCH 17/17] Revert "fix: update readflash to more moderne HDF5" This reverts commit dc79f6b6a257373e0b7ae0feb3968e7c1927cba4. --- src/h5_readFlash.cpp | 85 ++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/src/h5_readFlash.cpp b/src/h5_readFlash.cpp index bc2a080..6e2ec3a 100644 --- a/src/h5_readFlash.cpp +++ b/src/h5_readFlash.cpp @@ -7,16 +7,16 @@ This software is a computer program whose purpose is to provide a toolbox for co data analysis (e.g. filters, generalized Fourier transforms, power spectra, ...) This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can use, +abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". +"http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited -liability. +liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -25,9 +25,9 @@ that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. @@ -59,8 +59,8 @@ int ipvz_out = 5; /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ -/* n*_runtime_parameters should be set by the caller to - the maximum number of runtime parameters to read. +/* n*_runtime_parameters should be set by the caller to + the maximum number of runtime parameters to read. */ void h5_read_runtime_parameters @@ -100,12 +100,12 @@ void h5_read_runtime_parameters nreal_runtime_parameters = MAX_PARM; /* integer runtime parameters */ - int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t)); + int_rt_parms = (int_runtime_params_t *) malloc(nint_runtime_parameters * sizeof(int_runtime_params_t)); rank = 1; DataSet dataset = file->openDataSet("integer runtime parameters"); - - IntType int_rt_type = dataset.getIntType(); + + IntType int_rt_type = dataset.getIntType(); //int_rt_type = H5Dget_type(dataset); DataSpace dataspace = dataset.getSpace(); @@ -124,8 +124,6 @@ void h5_read_runtime_parameters //memspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset.read(int_rt_parms, int_rt_type, memspace, dataspace); - //status = H5Dread(dataset, int_rt_type, memspace, dataspace, - // H5P_DEFAULT, int_rt_parms); for (i = 0; i < nint_runtime_parameters; i++) { @@ -144,14 +142,14 @@ void h5_read_runtime_parameters /* reals */ - real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t)); - + real_rt_parms = (real_runtime_params_t *) malloc(nreal_runtime_parameters * sizeof(real_runtime_params_t)); + rank = 1; dataset = file->openDataSet("real runtime parameters"); - //dataset = H5Dopen(*file_identifier, "real runtime parameters"); - + //dataset = H5Dopen(*file_identifier, "real runtime parameters"); + dataspace = dataset.getSpace(); - FloatType real_rt_type = dataset.getFloatType(); + FloatType real_rt_type = dataset.getFloatType(); ndims = dataspace.getSimpleExtentDims(&dimens_1d, NULL); //dataspace = H5Dget_space(dataset); //real_rt_type = H5Dget_type(dataset); @@ -167,8 +165,6 @@ void h5_read_runtime_parameters //memspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset.read(real_rt_parms, real_rt_type, memspace, dataspace); - //status = H5Dread(dataset, real_rt_type, memspace, dataspace, -// H5P_DEFAULT, real_rt_parms); for (i = 0; i < nreal_runtime_parameters; i++) { @@ -191,7 +187,7 @@ void h5_read_runtime_parameters *LBox = real_runtime_parameter_values[i]; } if (strncmp(real_runtime_parameter_names[i],"hubbleconstant", 14) == 0 ) { - *hubble = real_runtime_parameter_values[i]; + *hubble = real_runtime_parameter_values[i]; } if (strncmp(real_runtime_parameter_names[i],"omegamatter", 11) == 0 ) { *omegam = real_runtime_parameter_values[i]; @@ -203,7 +199,7 @@ void h5_read_runtime_parameters *omegalambda = real_runtime_parameter_values[i]; } } - + for (i = 0; i < nint_runtime_parameters; i++) { if (strncmp(int_runtime_parameter_names[i],"pt_numx",7) == 0 ) { *numPart = int_runtime_parameter_values[i]; @@ -212,7 +208,7 @@ void h5_read_runtime_parameters } } - + /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ void h5_read_flash3_particles (H5File* file, int* totalparticles, @@ -239,8 +235,8 @@ void h5_read_flash3_particles (H5File* file, char *propName; double *partBuffer; char part_names[50][OUTPUT_PROP_LENGTH]; - int string_size; - + int string_size; + // char part_names[NPART_PROPS][OUTPUT_PROP_LENGTH]; hsize_t dimens_2d[2], maxdimens_2d[2]; hsize_t start_2d[2], count_2d[2], stride_2d[2]; @@ -263,12 +259,12 @@ void h5_read_flash3_particles (H5File* file, //total number of particle properties numProps = dimens_2d[0]; - + string_size = OUTPUT_PROP_LENGTH; StrType string_type = H5Tcopy(H5T_C_S1); string_type.setSize(string_size); //status = H5Tset_size(string_type, string_size); - + rank = 2; start_2d[0] = 0; @@ -280,22 +276,20 @@ void h5_read_flash3_particles (H5File* file, count_2d[0] = dimens_2d[0]; count_2d[1] = dimens_2d[1]; - dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); + dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); //status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d, // stride_2d, count_2d, NULL); DataSpace memspace(rank, dimens_2d); //memspace = H5Screate_simple(rank, dimens_2d, NULL); - dataset.read(part_names, string_type, H5S_ALL, H5S_ALL); - //status = H5Dread(dataset, string_type, H5S_ALL, H5S_ALL, - // H5P_DEFAULT, part_names); + dataset.read(part_names, string_type); + - string_type.close(); memspace.close(); dataspace.close(); - dataset.close(); + dataset.close(); //H5Tclose(string_type); //H5Sclose(memspace); //H5Sclose(dataspace); @@ -311,7 +305,7 @@ void h5_read_flash3_particles (H5File* file, if (strncmp(part_names[i], "velz", 4) == 0) { ipvz = i+1; } } - if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) || + if ((iptag < 0) || (ipx < 0) || (ipy < 0) || (ipz < 0) || (ipvx < 0) || (ipvy < 0) || (ipvz < 0) ) { printf("One or more required particle attributes not found in file!\n"); return; @@ -323,7 +317,7 @@ void h5_read_flash3_particles (H5File* file, //read particles dataset = file->openDataSet("tracer particles"); //dataset = H5Dopen(*file_identifier, "tracer particles"); - + FloatType datatype = dataset.getFloatType(); //datatype = H5Dget_type(dataset); @@ -336,7 +330,7 @@ void h5_read_flash3_particles (H5File* file, ndims = dataspace.getSimpleExtentDims(dimens_2d, NULL); //dataspace = H5Dget_space(dataset); //H5Sget_simple_extent_dims(dataspace, dimens_2d, maxdimens_2d); - + /*insert particle properties (numPartBuffer) particles at a time*/ pstack = (*localnp); poffset = 0; @@ -364,7 +358,7 @@ void h5_read_flash3_particles (H5File* file, dimens_2d[0] = (pcount); dimens_2d[1] = (numProps); - dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); + dataspace.selectHyperslab(H5S_SELECT_SET, count_2d, start_2d); //status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d, // stride_2d, count_2d, NULL); @@ -373,7 +367,6 @@ void h5_read_flash3_particles (H5File* file, /* read data from the dataset */ dataset.read(partBuffer, datatype, memspace, dataspace); - //status = H5Dread(dataset, datatype, memspace, dataspace, H5P_DEFAULT, partBuffer); /* convert buffer into particle struct */ @@ -389,8 +382,8 @@ void h5_read_flash3_particles (H5File* file, pos3[p+poffset] = (float) *(partBuffer+ipz-1+p*numProps); } } - - + + if (vel1 && vel2 && vel3) { for(p=0; p < (pcount); p++) { vel1[p+poffset] = (float) *(partBuffer+ipvx-1+p*numProps); @@ -421,7 +414,7 @@ void h5_read_flash3_particles (H5File* file, //status = H5Sclose(dataspace); //status = H5Dclose(dataset); } - + /*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ @@ -449,7 +442,7 @@ void h5_read_flash3_header_info(H5File* file, H5std_string DATASET_NAME; - string_type = H5Tcopy(H5T_C_S1); + string_type = H5Tcopy(H5T_C_S1); H5Tset_size(string_type, MAX_STRING_LENGTH); DataSet dataset = file->openDataSet("real scalars"); @@ -465,13 +458,13 @@ void h5_read_flash3_header_info(H5File* file, /* malloc a pointer to a list of real_list_t's */ real_list = (real_list_t *) malloc(dimens_1d * sizeof(real_list_t)); - // create a new simple dataspace of 1 dimension and size of 'dimens_1d' + // create a new simple dataspace of 1 dimension and size of 'dimens_1d' DataSpace memspace(1, &dimens_1d); - // create an empty vessel sized to hold one real_list_t's worth of data + // create an empty vessel sized to hold one real_list_t's worth of data CompType real_list_type( sizeof(real_list_t) ); - // subdivide the empty vessel into its component sections (name and value) + // subdivide the empty vessel into its component sections (name and value) real_list_type.insertMember( "name", HOFFSET(real_list_t, name), @@ -482,7 +475,7 @@ void h5_read_flash3_header_info(H5File* file, HOFFSET(real_list_t, value), PredType::NATIVE_DOUBLE); - // read the data into 'real_list' + // read the data into 'real_list' dataset.read( real_list, real_list_type, memspace, dataspace);