Skip to content

Commit

Permalink
Merge branch 'develop' into issue99_337_advection
Browse files Browse the repository at this point in the history
  • Loading branch information
timspainNERSC committed Dec 2, 2024
2 parents bf27b35 + 8231348 commit de2b619
Show file tree
Hide file tree
Showing 61 changed files with 1,000 additions and 811 deletions.
27 changes: 6 additions & 21 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Periodic Docker build

on:
# Build the Docker container whenever commits are pushed to an open PR (under conditions defined below)
# Build the Docker container whenever commits are pushed to an open PR that changes one of the files listed
pull_request:
paths:
- .github/workflows/docker.yml
- Dockerfiles/Dockerfile.devenv
- Dockerfiles/install-xios.sh
- Dockerfiles/spack_devenv.yaml

# Build the Docker container at 00:00 on the first day of every 3 months
schedule:
Expand All @@ -17,29 +22,12 @@ jobs:
packages: write
steps:
- name: Checkout the repo
id: Checkout
uses: actions/checkout@v4

- name: Determine if this file changed compared with develop
if: ${{ !(github.event_name == 'schedule') }}
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
.github/workflows/docker.yml
Dockerfiles/Dockerfile.devenv
Dockerfiles/install-xios.sh
Dockerfiles/spack_devenv.yaml
base_sha: develop

- name: Setup Docker buildx
id: buildx
if: ${{ (steps.changed-files.outputs.any_changed == 'true') || (github.event_name == 'schedule') }}
uses: docker/setup-buildx-action@v3

- name: Log into GitHub Container Repository
id: login
if: ${{ (steps.changed-files.outputs.any_changed == 'true') || ( github.event_name == 'schedule') }}
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -48,11 +36,8 @@ jobs:
logout: true

- name: Build container and push to ghcr
id: build-and-push
if: ${{ (steps.changed-files.outputs.any_changed == 'true') || (github.event_name == 'schedule') }}
uses: docker/build-push-action@v5
with:
push: true
no-cache: true
file: Dockerfiles/Dockerfile.devenv
tags: ghcr.io/nextsimhub/nextsimdg-dev-env:latest
11 changes: 7 additions & 4 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ jobs:
- uses: actions/checkout@v2
- name: installs
run: |
brew install netcdf
brew install netcdf-cxx
brew install boost
brew install eigen
brew unlink pkg-config
brew install pkgconf
brew link --overwrite pkgconf
brew install cmake
pip install numpy
brew install eigen
brew install netcdf
brew install netcdf-cxx
pip install netCDF4
pip install numpy
# tmate can be used to get an interactive ssh session to the github runner
# for debugging actions. See
Expand Down
12 changes: 6 additions & 6 deletions Dockerfiles/install-xios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# use svn to obtain current version of xios
cd /
installdir="xios"
svn checkout http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk $installdir
svn checkout http://forge.ipsl.fr/ioserver/svn/XIOS/trunk $installdir
cd $installdir

cat <<EOF > arch/arch-GCC_LINUX.path
cat <<EOF >arch/arch-GCC_LINUX.path
NETCDF_INCDIR="-I \$NETCDF_INC_DIR -I \$NETCDFFORT_INC_DIR"
NETCDF_LIBDIR="-L \$NETCDF_LIB_DIR -L \$NETCDFFORT_LIB_DIR"
NETCDF_LIB="-lnetcdff -lnetcdf"
Expand All @@ -28,7 +28,7 @@ OASIS_LIBDIR="-L\$PWD/../../oasis3-mct/BLD/lib"
OASIS_LIB="-lpsmile.MPI1 -lscrip -lmct -lmpeu"
EOF

cat <<EOF > arch/arch-GCC_LINUX.env
cat <<EOF >arch/arch-GCC_LINUX.env
export HDF5_INC_DIR=\$(pkg-config --variable=prefix hdf5)/include
export HDF5_LIB_DIR=\$(pkg-config --variable=prefix hdf5)/lib
Expand All @@ -42,7 +42,7 @@ export BOOST_INC_DIR=\$HOME/boost
export BOOST_LIB_DIR=\$HOME/boost
EOF

cat <<EOF > arch/arch-GCC_LINUX.fcm
cat <<EOF >arch/arch-GCC_LINUX.fcm
################################################################################
################### Projet XIOS ###################
################################################################################
Expand Down Expand Up @@ -71,5 +71,5 @@ EOF

./make_xios --arch GCC_LINUX --job 8 --full --debug
rm -r /xios/obj /xios/bin/generic_testcase.exe /xios/src /xios/tools \
/xios/inputs /xios/doc /xios/arch /xios/xios_test_suite /xios/flags \
/xios/generic_testcase /xios/ppsrc /xios/done
/xios/inputs /xios/doc /xios/arch /xios/xios_test_suite /xios/flags \
/xios/generic_testcase /xios/ppsrc /xios/done
4 changes: 1 addition & 3 deletions core/src/PrognosticData.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file PrognosticData.cpp
*
* @date 1 Jul 2024
* @date 21 Nov 2024
* @author Tim Spain <[email protected]>
* @author Einar Ólason <[email protected]>
*/
Expand Down Expand Up @@ -82,8 +82,6 @@ void PrognosticData::setData(const ModelState::DataMap& ms)

void PrognosticData::update(const TimestepTime& tst)
{
ModelArrayRef<Shared::T_ICE, RW> ticeUpd(getStore());

pOcnBdy->updateBefore(tst);
pAtmBdy->update(tst);

Expand Down
27 changes: 21 additions & 6 deletions core/src/Xios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Xios.cpp
* @author Tom Meltzer <[email protected]>
* @author Joe Wallwork <[email protected]>
* @date 01 Nov 2024
* @date 19 Nov 2024
* @brief XIOS interface implementation
* @details
*
Expand Down Expand Up @@ -34,12 +34,26 @@ namespace Nextsim {

static const std::map<int, std::string> keyMap = { { Xios::ENABLED_KEY, "xios.enable" } };

//! Enable XIOS in the 'config'
void enableXios()
{
Configurator::clearStreams();
std::stringstream config;
config << "[xios]" << std::endl << "enable = true" << std::endl;
std::unique_ptr<std::istream> pcstream(new std::stringstream(config.str()));
Configurator::addStream(std::move(pcstream));
}

/*!
* Constructor
*
* Configure an XIOS server
*/
Xios::Xios() { configure(); }
Xios::Xios(const std::string contextId)
{
_contextId = contextId;
configure();
}

//! Destructor
Xios::~Xios() { finalize(); }
Expand All @@ -60,7 +74,7 @@ void Xios::context_finalize()
}
}

//! Close context and finialize server
//! Finalize XIOS server
void Xios::finalize()
{
if (isEnabled) {
Expand Down Expand Up @@ -98,12 +112,13 @@ void Xios::configureServer(const std::string calendarType)
MPI_Comm_size(clientComm, &mpi_size);

// Initialize 'nextSIM-DG' context
contextId = "nextSIM-DG";
cxios_context_initialize(contextId.c_str(), contextId.length(), &clientComm_F);
cxios_context_initialize(_contextId.c_str(), _contextId.length(), &clientComm_F);

// Initialize calendar wrapper for 'nextSIM-DG' context
cxios_get_current_calendar_wrapper(&clientCalendar);
cxios_set_calendar_wrapper_type(clientCalendar, calendarType.c_str(), calendarType.length());
cxios_duration timestep { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 };
cxios_set_calendar_wrapper_timestep(clientCalendar, timestep);
cxios_create_calendar(clientCalendar);
}

Expand All @@ -125,7 +140,7 @@ int Xios::getClientMPIRank() { return mpi_rank; }
bool Xios::isInitialized()
{
bool init = false;
cxios_context_is_initialized(contextId.c_str(), contextId.length(), &init);
cxios_context_is_initialized(_contextId.c_str(), _contextId.length(), &init);
return init;
}

Expand Down
12 changes: 11 additions & 1 deletion core/src/include/ConfigurationHelp.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*!
* @file ConfigurationHelp.hpp
*
* @date Aug 12, 2022
* @date 20 Nov 2024
* @author Tim Spain <[email protected]>
*/

#ifndef CONFIGURATIONHELP_HPP
#define CONFIGURATIONHELP_HPP

#include <iomanip>
#include <list>
#include <map>
#include <sstream>
#include <string>
#include <vector>

Expand All @@ -28,6 +30,14 @@ class ConfigurationHelp {
std::string defaultValue;
std::string units;
std::string text;

// Ever so slightly better formatting than std::to_string
template <typename T> static std::string toString(const T input, const int n = 6)
{
std::ostringstream output;
output << std::setprecision(n) << input;
return output.str();
}
};

} /* namespace Nextsim */
Expand Down
8 changes: 5 additions & 3 deletions core/src/include/Xios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Xios.hpp
* @author Tom Meltzer <[email protected]>
* @author Joe Wallwork <[email protected]>
* @date 21 August 2024
* @date 18 Nov 2024
* @brief XIOS interface header
* @details
*
Expand All @@ -27,9 +27,11 @@

namespace Nextsim {

void enableXios();

class Xios : public Configured<Xios> {
public:
Xios();
Xios(const std::string contextId = "nextSIM-DG");
~Xios();

/* Initialization and finalization */
Expand Down Expand Up @@ -144,7 +146,7 @@ class Xios : public Configured<Xios> {
bool isEnabled;

std::string clientId;
std::string contextId;
std::string _contextId;
MPI_Comm clientComm;
MPI_Fint clientComm_F;
MPI_Fint nullComm_F;
Expand Down
105 changes: 104 additions & 1 deletion core/src/modules/DynamicsModule/BBMDynamics.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file BBMDynamics.cpp
*
* @date Jul 1, 2024
* @date 20 Nov 2024
* @author Tim Spain <[email protected]>
* @author Einar Ólason <[email protected]>
*/
Expand All @@ -16,6 +16,53 @@ static const std::vector<std::string> namedFields = { hiceName, ciceName, uName,
static const std::map<std::string, std::pair<ModelArray::Type, double>> defaultFields = {
{ damageName, { ModelArray::Type::H, 1.0 } },
};

// TODO: We should use getName() here, but it isn't static.
static const std::string prefix = "BBMDynamics"; // MEVPDynamics::getName();
static const std::map<int, std::string> keyMap = {
{ BBMDynamics::C_KEY, prefix + ".C" },
{ BBMDynamics::NU_KEY, prefix + ".nu" },
{ BBMDynamics::YOUNG_KEY, prefix + ".young" },
{ BBMDynamics::P0_KEY, prefix + ".P0" },
{ BBMDynamics::LAMBDA0_KEY, prefix + ".lambda0" },
{ BBMDynamics::ALPHA_KEY, prefix + ".alpha" },
{ BBMDynamics::EXPPMAX_KEY, prefix + ".exppmax" },
{ BBMDynamics::MU_KEY, prefix + ".mu" },
{ BBMDynamics::NMAX_KEY, prefix + ".namx" },
{ BBMDynamics::CLAB_KEY, prefix + ".clab" },
{ BBMDynamics::NSTEPS_KEY, prefix + ".nsteps" },
{ BBMDynamics::RHOI_KEY, prefix + ".rho_ice" },
{ BBMDynamics::RHOA_KEY, prefix + ".rho_atm" },
{ BBMDynamics::RHOO_KEY, prefix + ".rho_ocean" },
{ BBMDynamics::CATM_KEY, prefix + ".drag_atm" },
{ BBMDynamics::COCEAN_KEY, prefix + ".drag_ocean" },
{ BBMDynamics::FC_KEY, prefix + ".Coriolis_parameter" },
{ BBMDynamics::ANGLE_KEY, prefix + ".ocean_turning_angle" },
};

void BBMDynamics::configure()
{
params.compactionParam = Configured::getConfiguration(keyMap.at(C_KEY), compactionParamDefault);
params.nu0 = Configured::getConfiguration(keyMap.at(NU_KEY), nu0Default);
params.young = Configured::getConfiguration(keyMap.at(YOUNG_KEY), youngDefault);
params.P0 = Configured::getConfiguration(keyMap.at(P0_KEY), P0Default);
params.lambda0 = Configured::getConfiguration(keyMap.at(LAMBDA0_KEY), lambda0Default);
params.alpha = Configured::getConfiguration(keyMap.at(ALPHA_KEY), alphaDefault);
params.expPMax = Configured::getConfiguration(keyMap.at(EXPPMAX_KEY), expPMaxDefault);
params.mu = Configured::getConfiguration(keyMap.at(MU_KEY), muDefault);
params.comprCap = Configured::getConfiguration(keyMap.at(NMAX_KEY), comprCapDefault);
params.cLab = Configured::getConfiguration(keyMap.at(CLAB_KEY), cLabDefault);
params.nSteps = Configured::getConfiguration(keyMap.at(NSTEPS_KEY), nStepsDefault);
params.rhoIce = Configured::getConfiguration(keyMap.at(RHOI_KEY), rhoIceDefault);
params.rhoAtm = Configured::getConfiguration(keyMap.at(RHOA_KEY), rhoAtmDefault);
params.rhoOcean = Configured::getConfiguration(keyMap.at(RHOO_KEY), rhoOceanDefault);
params.CAtm = Configured::getConfiguration(keyMap.at(CATM_KEY), CAtmDefault);
params.COcean = Configured::getConfiguration(keyMap.at(COCEAN_KEY), COceanDefault);
params.fc = Configured::getConfiguration(keyMap.at(FC_KEY), fcDefault);
params.oceanTurningAngle
= Configured::getConfiguration(keyMap.at(ANGLE_KEY), oceanTurningAngleDefault);
}

BBMDynamics::BBMDynamics()
: IDynamics(true)
, kernel(params)
Expand Down Expand Up @@ -132,4 +179,60 @@ ModelState BBMDynamics::getStateRecursive(const OutputSpec& os) const
return state;
}

BBMDynamics::HelpMap& BBMDynamics::getHelpText(HelpMap& map, bool getAll)
{
map["BBMDynamics"] = {
{ keyMap.at(C_KEY), ConfigType::NUMERIC, { "-∞", "0" },
ConfigurationHelp::toString(compactionParamDefault), "[None]",
"The compaction parameter C" },
{ keyMap.at(NU_KEY), ConfigType::NUMERIC, { "-∞", "0" },
ConfigurationHelp::toString(nu0Default), "[None]", "Poisson's ratio, 𝜈" },
{ keyMap.at(YOUNG_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(youngDefault), "Pa", "Young's modulus, Y" },
{ keyMap.at(P0_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(P0Default), "Pa", "Ice strength scaling parameter" },
{ keyMap.at(LAMBDA0_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(lambda0Default), "s", "Undamaged relaxation time scale" },
{ keyMap.at(ALPHA_KEY), ConfigType::NUMERIC, { "2", "" },
ConfigurationHelp::toString(alphaDefault), "[None]", "Damage parameter" },
{ keyMap.at(EXPPMAX_KEY), ConfigType::NUMERIC, { "0", "2" },
ConfigurationHelp::toString(expPMaxDefault), "[None]",
"Exponent for thickness scaling of P_{max}" },
{ keyMap.at(MU_KEY), ConfigType::NUMERIC, { "0", "1" },
ConfigurationHelp::toString(expPMaxDefault), "[None]",
"Internal friction coefficient, 𝜇" },
{ keyMap.at(NMAX_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(expPMaxDefault), "Pa",
"Maximum compressive strength (at the lab scale)" },
{ keyMap.at(CLAB_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(cLabDefault), "Pa", "Cohesion (at the lab scale)" },
{ keyMap.at(NSTEPS_KEY), ConfigType::NUMERIC, { "1", "" },
ConfigurationHelp::toString(nStepsDefault), "[No unit]",
"The number of sub-cycling steps" },
{ keyMap.at(RHOI_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(rhoIceDefault), "kg/m^3", "Density of sea ice" },
{ keyMap.at(RHOA_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(rhoAtmDefault), "kg/m^3", "Density of air" },
{ keyMap.at(RHOO_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(rhoOceanDefault), "kg/m^3", "Density of ocean" },
{ keyMap.at(CATM_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(CAtmDefault), "[No unit]",
"Ice-atmosphere drag coefficient" },
{ keyMap.at(COCEAN_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(COceanDefault), "[No unit]", "Ice-ocean drag coefficient" },
{ keyMap.at(FC_KEY), ConfigType::NUMERIC, { "0", "" },
ConfigurationHelp::toString(fcDefault), "[No unit]",
"Coriolis parameter (constant across the domain)" },
{ keyMap.at(ANGLE_KEY), ConfigType::NUMERIC, { "0", "90" },
ConfigurationHelp::toString(oceanTurningAngleDefault), "degrees",
"Oceanic turning angle" },
};
return map;
}

BBMDynamics::HelpMap& BBMDynamics::getHelpRecursive(HelpMap& map, bool getAll)
{
return getHelpText(map, getAll);
}

} /* namespace Nextsim */
Loading

0 comments on commit de2b619

Please sign in to comment.