Skip to content

Commit

Permalink
Merge branch 'next' into options-array-ints-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
bendudson committed Dec 19, 2023
2 parents 0156c0e + 94493f9 commit c1c1b70
Show file tree
Hide file tree
Showing 56 changed files with 1,745 additions and 362 deletions.
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
1 change: 1 addition & 0 deletions .ci_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ else
. /etc/profile.d/modules.sh
module load mpi/${1}-x86_64
export OMPI_MCA_rmaps_base_oversubscribe=yes
export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe
export TRAVIS=true
export FLEXIBLAS=NETLIB
cd
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
OMP_NUM_THREADS: ${{ matrix.config.omp_num_threads }}
PYTHONPATH: ${{ github.workspace }}/tools/pylib
OMPI_MCA_rmaps_base_oversubscribe: yes
PRTE_MCA_rmaps_default_mapping_policy: ":oversubscribe"
MPIRUN: mpiexec -np
strategy:
fail-fast: true
Expand All @@ -38,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 @@ -185,9 +189,8 @@ jobs:

- name: Install pip packages
run: |
./.pip_install_for_ci.sh 'cython~=0.29' 'netcdf4~=1.5' 'sympy~=1.5' 'gcovr' 'cmake' zoidberg fastcov
# Add the pip install location to the runner's PATH
echo ~/.local/bin >> $GITHUB_PATH
python -m pip install --upgrade pip setuptools
python -m pip install -r requirements.txt
- name: Cache SUNDIALS build
uses: actions/cache@v3
Expand All @@ -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
20 changes: 0 additions & 20 deletions .pip_install_for_ci.sh

This file was deleted.

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
Loading

0 comments on commit c1c1b70

Please sign in to comment.