From d67ad053ed34c623dc0213b67398ad7a0ba537d7 Mon Sep 17 00:00:00 2001 From: arnav-singhal <43693924+arnav-singhal@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:46:06 -0700 Subject: [PATCH] Make HDF5 optional (#64) * make hdf5 optional * mention conda env --- CMakeLists.txt | 1 - README.md | 14 ++++++++++++-- src/IO.cpp | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1645e9f..216026c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,6 @@ set(AMReX_TINY_PROFILE ON) set(AMReX_SPACEDIM 2 CACHE INTERNAL "") set(AMReX_PRECISION SINGLE CACHE INTERNAL "") set(AMReX_PARTICLES_PRECISION SINGLE CACHE INTERNAL "") -set(AMReX_HDF5 TRUE) # # Fetch amrex repo diff --git a/README.md b/README.md index 89457cc..45ba264 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,18 @@ This demo uses CMake version 3.14 or higher. To build it: To build with GPU support, use the `-DAMReX_GPU_BACKEND=CUDA` CMake option. -For convenience, a script for setting up the module environment for Perlmutter is -provided in etc/perlmutter_environment.sh. To use it, do: +To write output as (compressed) HDF5, use the `-DAMReX_HDF5=TRUE` CMake option. +Parallel HDF5 installation is required. On perlmutter, a conda environment is +available at: + + conda activate /global/common/software/m3623/exaepi + +Compression level can be altered in src/IO.cpp file. The environment variable +HDF5_CHUNK_SIZE controls the chunk size if compression is used. A value of +around 100,000 is recommended to start. + +For convenience, a script for setting up the module environment without HDF5 +for Perlmutter is provided in etc/perlmutter_environment.sh. To use it, do: source etc/perlmutter_environment.sh diff --git a/src/IO.cpp b/src/IO.cpp index 4558d3d..5ffba02 100644 --- a/src/IO.cpp +++ b/src/IO.cpp @@ -88,6 +88,7 @@ void writePlotFile (const AgentContainer& pc, /*!< Agent (particle) container */ plt_varnames.push_back("Tract"); plt_varnames.push_back("comm"); +#ifdef AMREX_USE_HDF5 WriteSingleLevelPlotfileHDF5MultiDset( amrex::Concatenate("plt", step, 5), output_mf, plt_varnames, @@ -95,6 +96,14 @@ void writePlotFile (const AgentContainer& pc, /*!< Agent (particle) container */ cur_time, step, "ZLIB@3" ); +#else + WriteSingleLevelPlotfile( amrex::Concatenate("plt", step, 5), + output_mf, + plt_varnames, + pc.ParticleGeom(0), + cur_time, + step ); +#endif } { @@ -136,6 +145,7 @@ void writePlotFile (const AgentContainer& pc, /*!< Agent (particle) container */ } } +#ifdef AMREX_USE_HDF5 pc.WritePlotFileHDF5( amrex::Concatenate("plt", step, 5), "agents", write_real_comp, @@ -143,6 +153,14 @@ void writePlotFile (const AgentContainer& pc, /*!< Agent (particle) container */ real_varnames, int_varnames, "ZLIB@3" ); +#else + pc.WritePlotFile( amrex::Concatenate("plt", step, 5), + "agents", + write_real_comp, + write_int_comp, + real_varnames, + int_varnames ); +#endif } }