Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADIOS 2 I/O #2766

Merged
merged 42 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4f5f52c
Add adios2 dependency (BOUT_HAS_ADIOS flag), and starting .hxx file
pnorbert Aug 23, 2023
0fa73d6
Added adios_object.* files to initialize/finalize adios (in BoutIniti…
pnorbert Sep 1, 2023
0769805
fix include of adios
pnorbert Sep 5, 2023
58aeacd
Introduce OptionsIO as parent virtual class of OptionsNetCDF/OptionsA…
pnorbert Sep 5, 2023
3fd53b9
save daily work
pnorbert Sep 6, 2023
db995f2
Finally compiles, but invalid type use for adios: adios2::Engine::Put…
pnorbert Sep 11, 2023
93933a2
conduction example compiles
pnorbert Sep 11, 2023
686f9e0
test-options-adios: writes correctly settings.bp and test-out.bp
pnorbert Sep 11, 2023
2d7078e
fix build errors with cmake
pnorbert Sep 11, 2023
4aba3e1
ADIOS2 and array index mapping
bendudson Sep 12, 2023
eb309dc
Handle ADIOS steps boundary controlled by OptionsIO::verifyTimesteps(…
pnorbert Sep 12, 2023
4f55840
Added singleWriteFile argument to OptionsIO() which must be set true …
pnorbert Sep 13, 2023
958b7d4
Implement reading arrays (BoutReal type only).
pnorbert Sep 13, 2023
54d4d13
Fix function signature for when ADIOS/NetCDF is not used
pnorbert Sep 13, 2023
c0759ed
fix writeDefaultOutputFile
bendudson Oct 2, 2023
85aea5a
configure.ac: Add BOUT_HAS_ADIOS
bendudson Oct 3, 2023
115ed0a
Update configure script
bendudson Oct 3, 2023
0db37d6
Trying again with autoreconf
bendudson Oct 3, 2023
88eb401
Autoconf build: Add options_io.cxx
bendudson Oct 3, 2023
37fbcd4
test-options-adios requires ADIOS
bendudson Oct 4, 2023
59492be
Apply clang-format changes
bendudson Oct 12, 2023
ec60cd5
remove files that are removed in next
pnorbert Dec 5, 2023
259f138
Merge branch 'next' into adios-io-next-rebase
pnorbert Dec 5, 2023
fb7a962
Build adios2 for the first ubuntu build
pnorbert Dec 5, 2023
f4b24d7
options_adios: Address Clang-tidy comments
bendudson Dec 6, 2023
b959473
options_adios: Clang format
bendudson Dec 6, 2023
d7e8865
Use generic Factory for OptionsIO
bendudson Dec 7, 2023
ffc1e94
adios2 build - turn off building testing, pass to cmake ADIOS2_ROOT i…
pnorbert Dec 7, 2023
3b2abb8
Fix compilation of OptionsADIOS
bendudson Dec 7, 2023
1809086
Add BOUT_DOWNLOAD_ADIOS CMake flag
bendudson Dec 7, 2023
1399e20
test_options_netcdf: Change to OptionsIO interface
bendudson Dec 8, 2023
f62b5e5
Adding documentation and fixing tests
bendudson Dec 8, 2023
2c1f341
unit tests build gmock
bendudson Dec 8, 2023
1725c81
Fix calls to writeDefaultOutputFile
bendudson Dec 8, 2023
eeb9177
More integrated test fixes
bendudson Dec 8, 2023
9ec8857
Fix MMS-spatial-fci test
bendudson Dec 8, 2023
365ce52
writeDefaultOutputFile: Add mesh variables
bendudson Dec 13, 2023
63b2541
writeDefaultOutputFile: Add BOUT++ version and flags
bendudson Dec 14, 2023
77eb501
ADIOS reading of groups, more test fixes
bendudson Dec 15, 2023
af6610f
test-solver: Remove BoutInitialise and BoutFinalise
bendudson Dec 15, 2023
e543cd4
test-beuler: Remove BoutInitialise and BoutFinalise
bendudson Dec 15, 2023
721157a
CI: Change ADIOS install directory
bendudson Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .build_adios2_for_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

set -e

if test $BUILD_ADIOS2 ; then
if [[ ! -d $HOME/local/adios/include/adios2.h ]] || test $1 ; then
echo "****************************************"
echo "Building ADIOS2"
echo "****************************************"

branch=${1:-release_29}
if [ ! -d adios2 ]; then
git clone -b $branch https://github.com/ornladios/ADIOS2.git adios2 --depth=1
fi

pushd adios2
rm -rf build
mkdir -p build
pushd build

cmake .. \
-DCMAKE_INSTALL_PREFIX=$HOME/local \
-DADIOS2_USE_MPI=ON \
-DADIOS2_USE_Fortran=OFF \
-DADIOS2_USE_Python=OFF \
-DADIOS2_BUILD_EXAMPLES=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_TESTING=OFF \
-DADIOS2_USE_SST=OFF \
-DADIOS2_USE_MGARD=OFF \
-DADIOS2_USE_HDF5=OFF \
-DADIOS2_USE_BZip2=OFF \
-DADIOS2_USE_Blosc2=OFF \
-DADIOS2_USE_SZ=OFF \
-DADIOS2_USE_ZFP=OFF \
-DADIOS2_USE_DAOS=OFF \
-DADIOS2_USE_UCX=OFF \
-DADIOS2_USE_LIBPRESSIO=OFF \
-DADIOS2_USE_Sodium=OFF \
-DADIOS2_USE_ZeroMQ=OFF \
-DADIOS2_USE_MHS=OFF \
-DADIOS2_USE_DataMan=OFF

make -j 4 && make install
popd

echo "****************************************"
echo " Finished building ADIOS2"
echo "****************************************"

else

echo "****************************************"
echo " ADIOS2 already installed"
echo "****************************************"
fi
else
echo "****************************************"
echo " ADIOS2 not requested"
echo "****************************************"
fi
8 changes: 7 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,23 @@ jobs:
is_cron:
- ${{ github.event_name == 'cron' }}
config:
- name: "CMake, PETSc unreleased"
- name: "CMake, PETSc unreleased, ADIOS"
os: ubuntu-20.04
cmake_options: "-DBUILD_SHARED_LIBS=ON
-DBOUT_ENABLE_METRIC_3D=ON
-DBOUT_ENABLE_OPENMP=ON
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_ADIOS2=ON
-DBOUT_ENABLE_PYTHON=ON
-DADIOS2_ROOT=/home/runner/local/adios2
-DSUNDIALS_ROOT=/home/runner/local
-DPETSC_DIR=/home/runner/local/petsc
-DSLEPC_DIR=/home/runner/local/slepc"
build_petsc: -petsc-main
build_petsc_branch: main
build_adios2: true
on_cron: true

- name: "Default options, Ubuntu 20.04"
Expand Down Expand Up @@ -201,6 +204,9 @@ jobs:
- name: Build PETSc
run: BUILD_PETSC=${{ matrix.config.build_petsc }} ./.build_petsc_for_ci.sh ${{ matrix.config.build_petsc_branch }}

- name: Build ADIOS2
run: BUILD_ADIOS2=${{ matrix.config.build_adios2 }} ./.build_adios2_for_ci.sh

- name: Build BOUT++
run: UNIT_ONLY=${{ matrix.config.unit_only }} ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }}

Expand Down
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function(bout_update_submodules)
endfunction()

set(BOUT_SOURCES
./include/bout/adios_object.hxx
./include/bout/array.hxx
./include/bout/assert.hxx
./include/bout/boundary_factory.hxx
Expand Down Expand Up @@ -146,7 +147,7 @@ set(BOUT_SOURCES
./include/bout/openmpwrap.hxx
./include/bout/operatorstencil.hxx
./include/bout/options.hxx
./include/bout/options_netcdf.hxx
./include/bout/options_io.hxx
./include/bout/optionsreader.hxx
./include/bout/output.hxx
./include/bout/output_bout_types.hxx
Expand Down Expand Up @@ -325,6 +326,7 @@ set(BOUT_SOURCES
./src/solver/impls/split-rk/split-rk.cxx
./src/solver/impls/split-rk/split-rk.hxx
./src/solver/solver.cxx
./src/sys/adios_object.cxx
./src/sys/bout_types.cxx
./src/sys/boutcomm.cxx
./src/sys/boutexception.cxx
Expand All @@ -338,7 +340,11 @@ set(BOUT_SOURCES
./src/sys/options/optionparser.hxx
./src/sys/options/options_ini.cxx
./src/sys/options/options_ini.hxx
./src/sys/options/options_io.cxx
./src/sys/options/options_netcdf.cxx
./src/sys/options/options_netcdf.hxx
./src/sys/options/options_adios.cxx
./src/sys/options/options_adios.hxx
./src/sys/optionsreader.cxx
./src/sys/output.cxx
./src/sys/petsclib.cxx
Expand Down Expand Up @@ -930,6 +936,7 @@ message("
SUNDIALS support : ${BOUT_HAS_SUNDIALS}
HYPRE support : ${BOUT_HAS_HYPRE}
NetCDF support : ${BOUT_HAS_NETCDF}
ADIOS support : ${BOUT_HAS_ADIOS}
FFTW support : ${BOUT_HAS_FFTW}
LAPACK support : ${BOUT_HAS_LAPACK}
OpenMP support : ${BOUT_USE_OPENMP}
Expand Down
7 changes: 7 additions & 0 deletions bin/bout-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ idlpath="@IDLCONFIGPATH@"
pythonpath="@PYTHONCONFIGPATH@"

has_netcdf="@BOUT_HAS_NETCDF@"
has_adios="@BOUT_HAS_ADIOS@"
has_legacy_netcdf="@BOUT_HAS_LEGACY_NETCDF@"
has_pnetcdf="@BOUT_HAS_PNETCDF@"
has_pvode="@BOUT_HAS_PVODE@"
Expand Down Expand Up @@ -71,6 +72,7 @@ Available values for OPTION include:
--python Python path

--has-netcdf NetCDF file support
--has-adios ADIOS file support
--has-legacy-netcdf Legacy NetCDF file support
--has-pnetcdf Parallel NetCDF file support
--has-pvode PVODE solver support
Expand Down Expand Up @@ -109,6 +111,7 @@ all()
echo " --python -> $pythonpath"
echo
echo " --has-netcdf -> $has_netcdf"
echo " --has-adios -> $has_adios"
echo " --has-legacy-netcdf -> $has_legacy_netcdf"
echo " --has-pnetcdf -> $has_pnetcdf"
echo " --has-pvode -> $has_pvode"
Expand Down Expand Up @@ -197,6 +200,10 @@ while test $# -gt 0; do
echo $has_netcdf
;;

--has-adios)
echo $has_adios
;;

--has-legacy-netcdf)
echo $has_legacy_netcdf
;;
Expand Down
1 change: 1 addition & 0 deletions bout++Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(BOUT_USE_METRIC_3D @BOUT_USE_METRIC_3D@)

set(BOUT_HAS_PVODE @BOUT_HAS_PVODE@)
set(BOUT_HAS_NETCDF @BOUT_HAS_NETCDF@)
set(BOUT_HAS_ADIOS @BOUT_HAS_ADIOS@)
set(BOUT_HAS_FFTW @BOUT_HAS_FFTW@)
set(BOUT_HAS_LAPACK @BOUT_HAS_LAPACK@)
set(BOUT_HAS_PETSC @BOUT_HAS_PETSC@)
Expand Down
39 changes: 39 additions & 0 deletions cmake/SetupBOUTThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ option(BOUT_USE_NETCDF "Enable support for NetCDF output" ON)
option(BOUT_DOWNLOAD_NETCDF_CXX4 "Download and build netCDF-cxx4" OFF)
if (BOUT_USE_NETCDF)
if (BOUT_DOWNLOAD_NETCDF_CXX4)
message(STATUS "Downloading and configuring NetCDF-cxx4")
include(FetchContent)
FetchContent_Declare(
netcdf-cxx4
Expand Down Expand Up @@ -185,6 +186,44 @@ endif()
message(STATUS "NetCDF support: ${BOUT_USE_NETCDF}")
set(BOUT_HAS_NETCDF ${BOUT_USE_NETCDF})

option(BOUT_USE_ADIOS "Enable support for ADIOS output" ON)
option(BOUT_DOWNLOAD_ADIOS "Download and build ADIOS2" OFF)
if (BOUT_USE_ADIOS)
if (BOUT_DOWNLOAD_ADIOS)
message(STATUS "Downloading and configuring ADIOS2")
include(FetchContent)
FetchContent_Declare(
adios2
GIT_REPOSITORY https://github.com/ornladios/ADIOS2.git
GIT_TAG origin/master
GIT_SHALLOW 1
)
set(ADIOS2_USE_MPI ON CACHE BOOL "" FORCE)
set(ADIOS2_USE_Fortran OFF CACHE BOOL "" FORCE)
set(ADIOS2_USE_Python OFF CACHE BOOL "" FORCE)
set(ADIOS2_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
# Disable testing, or ADIOS will try to find or install GTEST
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# Note: SST requires <rdma/fabric.h> but doesn't check at configure time
set(ADIOS2_USE_SST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(adios2)
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi)
message(STATUS "ADIOS2 done configuring")
else()
find_package(ADIOS2)
if (ADIOS2_FOUND)
ENABLE_LANGUAGE(C)
find_package(MPI REQUIRED COMPONENTS C)
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi MPI::MPI_C)
else()
set(BOUT_USE_ADIOS OFF)
endif()
endif()
endif()
message(STATUS "ADIOS support: ${BOUT_USE_ADIOS}")
set(BOUT_HAS_ADIOS ${BOUT_USE_ADIOS})


option(BOUT_USE_FFTW "Enable support for FFTW" ON)
if (BOUT_USE_FFTW)
find_package(FFTW REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions cmake_build_defines.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#cmakedefine01 BOUT_HAS_IDA
#cmakedefine01 BOUT_HAS_LAPACK
#cmakedefine01 BOUT_HAS_NETCDF
#cmakedefine01 BOUT_HAS_ADIOS
#cmakedefine01 BOUT_HAS_PETSC
#cmakedefine01 BOUT_HAS_PRETTY_FUNCTION
#cmakedefine01 BOUT_HAS_PVODE
Expand Down
83 changes: 83 additions & 0 deletions include/bout/adios_object.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*!************************************************************************
* Provides access to the ADIOS library, handling initialisation and
* finalisation.
*
* Usage
* -----
*
* #include <bout/adios_object.hxx>
*
**************************************************************************/

#ifndef ADIOS_OBJECT_HXX
#define ADIOS_OBJECT_HXX

#include "bout/build_config.hxx"

#if BOUT_HAS_ADIOS

#include <adios2.h>
#include <memory>
#include <mpi.h>

namespace bout {

void ADIOSInit(MPI_Comm comm);
void ADIOSInit(const std::string configFile, MPI_Comm comm);
void ADIOSFinalize();

using ADIOSPtr = std::shared_ptr<adios2::ADIOS>;
using EnginePtr = std::shared_ptr<adios2::Engine>;
using IOPtr = std::shared_ptr<adios2::IO>;

ADIOSPtr GetADIOSPtr();
IOPtr GetIOPtr(const std::string IOName);

class ADIOSStream {
public:
adios2::IO io;
adios2::Engine engine;
adios2::Variable<double> vTime;
adios2::Variable<int> vStep;
int adiosStep = 0;
bool isInStep = false; // true if BeginStep was called and EndStep was not yet called

/** create or return the ADIOSStream based on the target file name */
static ADIOSStream& ADIOSGetStream(const std::string& fname);

~ADIOSStream();

template <class T>
adios2::Variable<T> GetValueVariable(const std::string& varname) {
auto v = io.InquireVariable<T>(varname);
if (!v) {
v = io.DefineVariable<T>(varname);
}
return v;
}

template <class T>
adios2::Variable<T> GetArrayVariable(const std::string& varname, adios2::Dims& shape) {
adios2::Variable<T> v = io.InquireVariable<T>(varname);
if (!v) {
adios2::Dims start(shape.size());
v = io.DefineVariable<T>(varname, shape, start, shape);
} else {
v.SetShape(shape);
}
return v;
}

private:
ADIOSStream(const std::string fname) : fname(fname){};
std::string fname;
};

/** Set user parameters for an IO group */
void ADIOSSetParameters(const std::string& input, const char delimKeyValue,
const char delimItem, adios2::IO& io);

} // namespace bout

#endif //BOUT_HAS_ADIOS
#endif //ADIOS_OBJECT_HXX
10 changes: 4 additions & 6 deletions include/bout/bout.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
*
* @mainpage BOUT++
*
* @version 3.0
*
* @par Description
* Framework for the solution of partial differential
* equations, in particular fluid models in plasma physics.
Expand Down Expand Up @@ -33,8 +31,8 @@
*
**************************************************************************/

#ifndef __BOUT_H__
#define __BOUT_H__
#ifndef BOUT_H
#define BOUT_H

#include "bout/build_config.hxx"

Expand All @@ -44,7 +42,7 @@
#include "bout/field3d.hxx"
#include "bout/globals.hxx"
#include "bout/mesh.hxx"
#include "bout/options_netcdf.hxx"
#include "bout/options_io.hxx"
#include "bout/output.hxx"
#include "bout/smoothing.hxx" // Smoothing functions
#include "bout/solver.hxx"
Expand Down Expand Up @@ -206,4 +204,4 @@ private:
*/
int BoutFinalise(bool write_settings = true);

#endif // __BOUT_H__
#endif // BOUT_H
1 change: 1 addition & 0 deletions include/bout/build_config.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ constexpr auto has_gettext = static_cast<bool>(BOUT_HAS_GETTEXT);
constexpr auto has_lapack = static_cast<bool>(BOUT_HAS_LAPACK);
constexpr auto has_legacy_netcdf = static_cast<bool>(BOUT_HAS_LEGACY_NETCDF);
constexpr auto has_netcdf = static_cast<bool>(BOUT_HAS_NETCDF);
constexpr auto has_adios = static_cast<bool>(BOUT_HAS_ADIOS);
constexpr auto has_petsc = static_cast<bool>(BOUT_HAS_PETSC);
constexpr auto has_hypre = static_cast<bool>(BOUT_HAS_HYPRE);
constexpr auto has_umpire = static_cast<bool>(BOUT_HAS_UMPIRE);
Expand Down
6 changes: 3 additions & 3 deletions include/bout/generic_factory.hxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Base type for factories

#pragma once
#ifndef __BOUT_GENERIC_FACTORY_H__
#define __BOUT_GENERIC_FACTORY_H__
#ifndef BOUT_GENERIC_FACTORY_H
#define BOUT_GENERIC_FACTORY_H

#include "bout/boutexception.hxx"
#include "bout/options.hxx"
Expand Down Expand Up @@ -259,4 +259,4 @@ public:
};
};

#endif // __BOUT_GENERIC_FACTORY_H__
#endif // BOUT_GENERIC_FACTORY_H
Loading
Loading