Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
5b178d3
New IOceanBoundary derived module
einola May 3, 2024
0acbdf8
Put MLD into m_couplingArrays of IOceanBoundary.hpp
einola May 3, 2024
190299c
More details on where the OASIS calls go in OASISCoupledOcean
einola May 7, 2024
1a155c9
Merge remote-tracking branch 'origin/develop' into issue459_oasis_oce…
einola Aug 14, 2024
023b916
Get the MPI communicator to atm and ocean boundary
einola Aug 15, 2024
4f18732
Move as much of OASIS initialisation as I can to its own class
einola Aug 15, 2024
03b555e
Code cleanup
einola Aug 15, 2024
5549c7e
Add a destructor in OASISCoupled.hpp and call it
einola Aug 15, 2024
c227f13
More comments on how the oasis calls should look like
einola Aug 15, 2024
3713ea8
Add some OASIS calls to OASISCoupled.hpp
einola Aug 16, 2024
c9ebce5
Implement OASIS calls
einola Aug 20, 2024
3e51d86
Revert a merge mistake
einola Aug 20, 2024
ab0c304
Add OASIS time
einola Aug 21, 2024
a2e6c05
Clang formatting
einola Aug 21, 2024
3e6ccdc
Use a map for the coupling id
einola Aug 21, 2024
e8d3633
Options for the couplingId code
einola Aug 21, 2024
db21d61
Small bug fix for OASISCoupledOcean::configure
einola Aug 22, 2024
2af34fb
Merge remote-tracking branch 'origin/develop' into issue459_oasis_oce…
einola Aug 23, 2024
b9d2da5
A few comments for the OASIS team
einola Aug 29, 2024
be7905d
Minor cleaning
einola Aug 27, 2024
9411b83
Move common OASIS calls out of OASISCoupled class
einola Sep 9, 2024
f7b404a
Comments where the grid writing should be
einola Sep 9, 2024
058e86a
Move initOasis to ModelMetadata.cpp
einola Sep 9, 2024
7f8c587
Minor cleaning
einola Sep 9, 2024
d266c17
Moving oasis init & get_localcomm
einola Sep 10, 2024
a3877b0
Minor cleaning
einola Sep 10, 2024
10ffd76
Change target_include_directories to PUBLIC
einola Sep 10, 2024
6b2a99f
Revert removing OASIS_CHECK_ERR from get and put calls
einola Sep 10, 2024
133aca2
Add netcdf hooks to the oasis bit of CMakeLists.txt
einola Sep 10, 2024
9275539
Small changes to FindOASIS.cmake
einola Sep 13, 2024
bf7cd78
First steps in implementing a unit test for OASISCoupledOcean
einola Sep 13, 2024
27a72db
Issue #459 : update input and output coupling field labels lists at c…
andreapiacentini Sep 16, 2024
83cdb29
Issue #459 : complete first working version of the unit test for OASI…
andreapiacentini Sep 16, 2024
9dcf27e
Merge branch 'issue669_coupler_fluxes' into issue459_oasis_ocean_coup…
einola Feb 11, 2025
9db81c8
Get the code to compile after merge
einola Feb 12, 2025
1e3eee3
Put actual data in the oasis put calls
einola Feb 12, 2025
28e58b4
CMakeLists.txt formatting
einola Feb 12, 2025
2cac4d5
CMakeLists.txt formatting
einola Feb 12, 2025
d74a741
Minor cleaning
einola Feb 12, 2025
a616c35
Add SSH to the test
einola Feb 13, 2025
a570b63
Appropriate defaults for OASISCoupledOcean.hpp
einola Feb 13, 2025
6ada6ed
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Feb 13, 2025
88139c2
Merge branch 'issue669_coupler_fluxes' into issue459_oasis_ocean_coup…
einola Feb 13, 2025
a82d3ec
Expanded OASISCoupledOcean_test.cpp and bugfixes
einola Feb 15, 2025
9df3368
Reverse the direction of heatfluxes sent through OASIS
einola Feb 15, 2025
bc835ac
Rename variable for default for exchanging first layer
einola Mar 21, 2025
b086649
Set taux and tauy in IDynamics.hpp
einola Mar 21, 2025
7136ebb
Move definition of dimension0 and 1
einola Mar 21, 2025
761ebba
[issue459] MPI/IO compliant restart filename
andreapiacentini Mar 28, 2025
7bdc523
[issue459] Enable help-config for OASISCoupledOcean
andreapiacentini Mar 28, 2025
edc3758
[issue459] Fix ocean density
andreapiacentini Mar 28, 2025
eae6a08
[issue459] Try to please to the clang format check
andreapiacentini Mar 28, 2025
42c0bd8
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Apr 25, 2025
f914a45
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Jun 5, 2025
02416af
Minor fix after merge
einola Jun 5, 2025
bba76aa
Clang-format
einola Jun 6, 2025
7d7e27d
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Jun 15, 2025
a7aeed1
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Jul 30, 2025
a62cff7
Merge branch 'issue899_thermo_clean' into issue459_oasis_ocean_coupling
einola Jul 30, 2025
db9e053
Fix CMakeLists.txt formatting
einola Jul 31, 2025
9a3d715
Dockerfile for an image with OASIS installed
einola Aug 1, 2025
afbd83e
Remove netCDF requirements from ENABLE_OASIS case
einola Aug 20, 2025
9733f67
Explicitly allow running OpenMPI as root in dev docker image
einola Aug 21, 2025
d4c2688
Also compile pyoasis when compiling OASIS
einola Aug 21, 2025
7235a79
Install extra python libraries and modify paths in entrypoint.sh
einola Aug 21, 2025
3b0dd20
Search explicitly for all the component libraries of OASIS
einola Aug 21, 2025
9697409
Minor cleaning and comments for FindOASIS.cmake
einola Aug 22, 2025
37b40fe
Merge remote-tracking branch 'origin/develop' into issue459_oasis_oce…
einola Aug 22, 2025
3426158
Update OASISCoupledOcean_test.cpp so that it compiles
einola Aug 25, 2025
8bc61b5
Update CMakeLists.txt for testOASISCoupledOcean
einola Aug 25, 2025
42e7a7d
Merge remote-tracking branch 'origin/develop' into issue459_oasis_oce…
einola Aug 29, 2025
8660e3b
Add FracQsr to exchange fields
einola Sep 1, 2025
cd4848f
Rename the key for sending ice cover to the ocean
einola Sep 1, 2025
1199a01
Reformatting to appease linter
einola Sep 1, 2025
93a5ac3
Missing definition for FracQSWKey
einola Sep 1, 2025
e25f58a
Set fracSWAbs to one in TOPAZOcean
einola Sep 1, 2025
5a1a591
Be more careful with FracQSW
einola Sep 2, 2025
3cd099a
Merge remote-tracking branch 'origin/develop' into issue459_oasis_oce…
einola Sep 2, 2025
3bd14b7
Send mean component of cice to OASIS
einola Sep 5, 2025
4c156a0
Better variable name
einola Sep 5, 2025
7a55edc
Add vector rotation in send and receive calls for OASIS
einola Sep 19, 2025
4d8fdf4
Rotate the ice-ocean stress vectors before sending
einola Sep 23, 2025
e5b72e7
Resize ModelArrays before oasis_get
einola Sep 24, 2025
9d12d5a
Switch the rotation functions
einola Sep 25, 2025
3be6952
Interpolation to and from U/V points
einola Oct 2, 2025
f27b30b
Fix stupid bugs introduced in last commit
einola Oct 2, 2025
6c3a5b4
Minor cleaning
einola Oct 6, 2025
76f4fac
Resize arrays before use
einola Oct 7, 2025
dc681bd
Use HField for everything
einola Oct 8, 2025
ce7e4d2
Debugging output for the coupling code
einola Oct 9, 2025
d5d8650
Remove A->C and C->A grid interpolations
einola Oct 15, 2025
462530d
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Oct 17, 2025
f19f9bf
Merge branch 'develop' into issue459_oasis_ocean_coupling
einola Nov 5, 2025
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
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ project(nextsim_dg)
option(WITH_THREADS "Build with support for openmp" OFF)
option(ENABLE_MPI "Enable distributed-memory parallelization with MPI" OFF)
option(ENABLE_XIOS "Enable XIOS library for IO" OFF)
option(ENABLE_OASIS "Enable the OASIS interface" OFF)
option(BUILD_TESTS "Build the tests" ON)
set(DynamicsType
"DG2"
Expand Down Expand Up @@ -155,6 +156,20 @@ if(ENABLE_XIOS)
target_link_libraries(nextsimlib PUBLIC "${FORTRAN_RUNTIME_LIB}")
endif()

# Do we want to include the OASIS interface? It'll only work if we have MPI
if(ENABLE_OASIS)
if(ENABLE_MPI)
message(STATUS "Building with OASIS support")
find_package(OASIS REQUIRED)
target_compile_definitions(nextsimlib PUBLIC USE_OASIS)

target_link_libraries(nextsimlib PUBLIC ${OASIS_LIBRARIES})
target_include_directories(nextsimlib PUBLIC ${OASIS_INCLUDES})
else()
message(FATAL_ERROR "Cannot build with OASIS support, because MPI is not enabled" .)
endif()
endif()

# OpenMP
if(WITH_THREADS)
find_package(OpenMP REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions Dockerfiles/Dockerfile.devenv
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ COPY --from=builder /opt/views /opt/views
# Create entrypoint script
RUN { \
echo '#!/bin/sh'; \
echo 'export OMPI_ALLOW_RUN_AS_ROOT=1'; \
echo 'export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1'; \
echo '. /opt/spack-environment/activate.sh'; \
echo 'exec "$@"'; \
} > /entrypoint.sh \
Expand Down
30 changes: 30 additions & 0 deletions Dockerfiles/Dockerfile.oasis
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM nextsimdg-dev-env:latest

# A temproary Dockerfile with commands that should find their way into Dockerfile.devenv in the end

# Clone the repository
RUN git clone https://gitlab.com/cerfacs/oasis3-mct.git
WORKDIR /oasis3-mct/util/make_dir

# Set some ENV's and copy the make file include
ENV OASIS_COUPLE=/oasis3-mct
ENV OASIS_ENV=oasis_docker_spack_gcc
ENV OASIS_DIR=$OASIS_COUPLE/build.$OASIS_ENV
COPY make.oasis_docker make.$OASIS_ENV

# make!
RUN make -f TopMakefileOasis3 static-libs shared-libs pyoasis

# Install python packages that pyoasis may need
RUN apt-get install -y python3-mpi4py python3-isodate

# Append the OASIS library directory to LD_LIBRARY_PATH and append it to PYTHONPATH
# We assume the last line of the file is 'exec "$@"' and try to retain that
RUN sed -i~ '$d' /entrypoint.sh
RUN { \
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH':$OASIS_DIR/lib; \
echo 'export PYTHONPATH=$PYTHONPATH':$OASIS_DIR/python; \
echo 'exec "$@"'; \
} >> /entrypoint.sh

WORKDIR /
82 changes: 82 additions & 0 deletions Dockerfiles/make.oasis_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# Include file for OASIS3 Makefile for a Linux docker image using spack and gcc
#
###############################################################################
#
# CHAN : communication technique used in OASIS3 (MPI1/MPI2)
CHAN = MPI1
#
# Paths for libraries, object files and binaries
#
# COUPLE : path for oasis3-mct main directory
COUPLE := $(OASIS_COUPLE)
#
# ARCHDIR : directory created when compiling
ARCHDIR := $(COUPLE)/build.$(OASIS_ENV)
#
# MPI library
MPIDIR = /opt/view/
MPIBIN = $(MPIDIR)/bin
MPI_INCLUDE = $(MPIDIR)/include
MPILIB = -L$(MPIDIR)/lib -lmpi
MPIRUN = $(MPIBIN)/mpirun
#
# NETCDF library of the system
NETCDF_INCLUDE = /opt/view/include
NETCDF_LIBRARY = -L/opt/view/lib -Wl,-rpath,/opt/view/lib -lnetcdff -lnetcdf -lm
#
# Compiling and other commands
MAKE = gmake
F90 = $(MPIBIN)/mpif90 -I$(MPI_INCLUDE)
F = $(F90)
f90 = $(F90)
f = $(F90)
CC = $(MPIBIN)/mpicc -I$(MPI_INCLUDE)
LD = $(MPIBIN)/mpif90 $(MPILIB)
DYNOPT = -fPIC
LDDYNOPT = -shared
AR = ar
ARFLAGS = -ruv
# Fortran libraries for C linking
F2C_LIBS = -lmpi_mpifh -lgfortran -lm
#
# CPP keys and compiler options
#
CPPDEF = -Duse_comm_$(CHAN) -D__VERBOSE -DTREAT_OVERLAY
#
FCBASEFLAGS := -fallow-argument-mismatch -ffree-line-length-0
ifeq ($(OASIS_DEBUG), )
ifeq ($(OASIS_OPENMP), )
FCBASEFLAGS += -O2
else
FCBASEFLAGS += -O2 -fopenmp
endif
else
ifeq ($(OASIS_OPENMP), )
FCBASEFLAGS += -g -fbounds-check
else
FCBASEFLAGS += -g -fbounds-check -fopenmp
endif
endif
CCBASEFLAGS :=
ifeq ($(OASIS_OPENMP), )
CCBASEFLAGS +=
else
CCBASEFLAGS += -fopenmp
endif
#
# INC_DIR : includes all *mod for each library
INC_DIR = -I$(ARCHDIR)/include
# FLIBS : for toys when linking in local Makefile
FLIBS=${NETCDF_LIBRARY}
###################
#
F90FLAGS = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
f90FLAGS = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
FFLAGS = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
fFLAGS = $(FCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
CCFLAGS = $(CCBASEFLAGS) $(INC_DIR) $(CPPDEF) -I$(NETCDF_INCLUDE)
LDFLAGS = $(FCBASEFLAGS)
F2C_LDFLAGS = $(F2C_LIBS)
#
#############################################################################
31 changes: 31 additions & 0 deletions cmake/FindOASIS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Find oasis
#
# Please pass the -DOASIS_DIR variable to cmake (location of the OASIS libraries).

# Search for all library files individually and merge to a single OASIS_LIBRARIES variable for the parent CMakeLists.txt
find_library(LIB_OASIS NAMES oasis.cbind HINTS ${OASIS_DIR}/lib ENV LD_LIBRARY_PATH)
find_library(LIB_MCT NAMES mct HINTS ${OASIS_DIR}/lib ENV LD_LIBRARY_PATH)
find_library(LIB_MPEU NAMES mpeu HINTS ${OASIS_DIR}/lib ENV LD_LIBRARY_PATH)
find_library(LIB_PSMILE NAMES psmile.MPI1 psmile.MPI2 HINTS ${OASIS_DIR}/lib ENV LD_LIBRARY_PATH)
find_library(LIB_SCRIP NAMES scrip HINTS ${OASIS_DIR}/lib ENV LD_LIBRARY_PATH)

# Only continue if all libraries are found
if (LIB_OASIS AND LIB_MCT AND LIB_MPEU AND LIB_PSMILE AND LIB_SCRIP)
set(OASIS_LIBRARIES ${LIB_OASIS} ${LIB_MCT} ${LIB_MPEU} ${LIB_PSMILE} ${LIB_SCRIP})
endif ()

# Set OASIS_DIR (not strictly necessary, but nice to have)
get_filename_component(OASIS_LIB_DIR "${LIB_OASIS}" PATH)
set(OASIS_DIR "${OASIS_LIB_DIR}/../")
cmake_path(NORMAL_PATH OASIS_DIR)

# The oasis include file should be where oasis.cbind lives
find_path(OASIS_INCLUDES NAMES oasis_c.h HINTS ${OASIS_DIR}/include)

# handle the QUIETLY and REQUIRED arguments and set OASIS_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OASIS DEFAULT_MSG OASIS_DIR OASIS_LIBRARIES OASIS_INCLUDES)

# message (STATUS "OASIS_LIBRARIES: ${OASIS_LIBRARIES}")
# message (STATUS "OASIS_INCLUDES: ${OASIS_INCLUDES}")
# message (STATUS "OASIS_DIR: ${OASIS_DIR}")
2 changes: 2 additions & 0 deletions core/src/DevStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void DevStep::iterate(const TimestepTime& tst)
mData.incrementTime(tst.step);
if ((m_restartPeriod.seconds() > 0) && (mData.time() >= lastOutput + m_restartPeriod)) {
std::string currentFileName = mData.time().format(m_restartFileName);
// Some MPI-IO implementations does not like colon in file names
std::replace(currentFileName.begin(), currentFileName.end(), ':', '_');
pData->writeRestartFile(currentFileName);
lastOutput = mData.time();
}
Expand Down
11 changes: 11 additions & 0 deletions core/src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static const std::map<int, std::string> keyMap = {
{ Model::MISSINGVALUE_KEY, "model.missing_value" },
{ Model::RESTARTPERIOD_KEY, "model.restart_period" },
{ Model::RESTARTOUTFILE_KEY, "model.restart_file" },
#ifdef USE_OASIS
{ Model::WRITEOASISGRID_KEY, "oasis.write_grid" },
#endif
};

Model::Model()
Expand Down Expand Up @@ -122,9 +125,15 @@ void Model::configure()
// Get the coordinates from the ModelState for persistence
metadata.extractCoordinates(initialState);

#ifdef USE_OASIS
const bool writeOasisGrid = Configured::getConfiguration(keyMap.at(WRITEOASISGRID_KEY), false);
metadata.initOasis(writeOasisGrid);
#endif

modelStep.setData(pData);
modelStep.setRestartDetails(metadata.restartPeriod, metadata.finalFileName);
pData.setData(initialState.data);
pData.setMetadata(metadata);
}

Model::HelpMap& Model::getHelpText(HelpMap& map, bool getAll)
Expand Down Expand Up @@ -195,6 +204,8 @@ void Model::writeRestartFile()
{
auto& metadata = ModelMetadata::getInstance();
std::string formattedFileName = metadata.time().format(metadata.finalFileName);
// Some MPI-IO implementations does not like colon in file names
std::replace(formattedFileName.begin(), formattedFileName.end(), ':', '_');
pData.writeRestartFile(formattedFileName);
}

Expand Down
21 changes: 21 additions & 0 deletions core/src/ModelArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ ModelArray& ModelArray::clampBelow(const ModelArray& minArr)
return *this;
}

ModelArray ModelArray::sqrt()
{
ModelArray sqrted = ModelArray(type);
sqrted.m_data.array() = m_data.array().sqrt();
return sqrted;
}

ModelArray ModelArray::sin()
{
auto sined = ModelArray(type);
sined.m_data.array() = m_data.array().sin();
return sined;
}

ModelArray ModelArray::cos()
{
auto cosed = ModelArray(type);
cosed.m_data.array() = m_data.array().cos();
return cosed;
}

void ModelArray::setData(double value)
{
resize();
Expand Down
68 changes: 68 additions & 0 deletions core/src/ModelMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <ncGroup.h>
#include <ncVar.h>
#endif
#ifdef USE_OASIS
#include <oasis_c.h>
#endif

namespace Nextsim {

Expand Down Expand Up @@ -191,6 +194,71 @@ ModelState& ModelMetadata::affixCoordinates(ModelState& state) const
return state;
}

#ifdef USE_OASIS
void ModelMetadata::initOasis(const bool writeOasisGrid)
{
// Set the partitioning
/* From the manual: "[ig_paral is a] vector of integers describing the local grid partition
* in the global index space; has a different expression depending on the type of the
* partition; in OASIS3-MCT, 5 types of partition are supported: Serial (no partition),
* Apple, Box, Orange, and Points" - it looks like we should use "Box", so partInfo[0] = 2
* (aka. ig_paral).
*
* #Box partition#
* Each partition is a rectangular region of the global domain, described by the global
* offset of its upper left corner, and its local extents in the X and Y dimensions. The
* global extent in the X dimension must also be given. In this case, we have ig_paral(1:5):
* - ig_paral(1) = 2 (indicates a Box partition)
* - ig_paral(2) = the upper left corner global offset
* - ig paral(3) = the local extent in x
* - ig_paral(4) = the local extent in y
* - ig_paral(5) = the global extent in x.
*
* metdatata contains: localCornerX, localCornerY, localExtentX, localExtentY,
* globalExtentX, globalExtentY;
*/
// TODO: The contents of metadata is not certain!
const int offset = globalExtentX * localCornerY + localCornerX;
const std::vector<int> partInfo
= { OASIS_Box, offset, localExtentX, localExtentY, globalExtentX };

const int globalSize = globalExtentX * globalExtentY;
const std::string compName = "nextsim"; // Not useful for any setups we have in mind
OASIS_CHECK_ERR(oasis_c_def_partition(
&OASISPartitionId, OASIS_Box_Params, &partInfo[0], globalSize, compName.c_str()));

// TODO: Writing out grid information should be possible, but optional
if (writeOasisGrid) {
/* This needs to be figured out, but it's not a priority. Grid writing is
* not necessary for the type of coupling we'll start with.

const std::string gridName = "nxts";

int flag = 1;
OASIS_CHECK_ERR(oasis_c_start_grids_writing(&flag));

OASIS_CHECK_ERR(oasis_c_write_grid(
gridName.c_str(), nx, ny, nx_loc, ny_loc, lon, lat, OASISPartitionId));
OASIS_CHECK_ERR(oasis_c_write_corner(
gridName.c_str(), nx, ny, nx_loc, ny_loc, clo, cla, OASISPartitionId));
OASIS_CHECK_ERR(oasis_c_write_area(
gridName.c_str(), nx, ny, nx_loc, ny_loc, area, OASISPartitionId));
OASIS_CHECK_ERR(oasis_c_write_mask(
gridName.c_str(), nx, ny, nx_loc, ny_loc, angle, OASISPartitionId));

std::string companion = "land area fraction";
OASIS_CHECK_ERR(oasis_c_write_frac(
gridName.c_str(), nx, ny, nx_loc, ny_loc, mask, OASISPartitionId),
companion.c_str());
companion = "land sea mask";
OASIS_CHECK_ERR(oasis_c_write_mask(
gridName.c_str(), nx, ny, nx_loc, ny_loc, mask, OASISPartitionId),
companion.c_str());
*/
}
}
#endif

void ModelMetadata::setTimes(const TimePoint& start, const TimePoint& stop, const Duration& step)
{
this->start = start;
Expand Down
15 changes: 15 additions & 0 deletions core/src/PrognosticData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "include/NextsimModule.hpp"
#include "include/gridNames.hpp"

#ifdef USE_OASIS
#include <oasis_c.h>
#endif

namespace Nextsim {

static const std::string checkFieldsKey = "debug.check_fields";
Expand Down Expand Up @@ -111,6 +115,17 @@ void PrognosticData::setData(const ModelState::DataMap& ms)
iceGrowth.setData(ms);
}

void PrognosticData::setMetadata(const Nextsim::ModelMetadata& metadata)
{
pAtmBdy->setMetadata(metadata);
pOcnBdy->setMetadata(metadata);

#ifdef USE_OASIS
// OASIS finalising definition - can only be called once
OASIS_CHECK_ERR(oasis_c_enddef());
#endif
}

void PrognosticData::update(const TimestepTime& tst)
{
// Prepare everything
Expand Down
3 changes: 3 additions & 0 deletions core/src/include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Model : public Configured<Model> {
// Other Model configuration keys, not to be written to the restart file.
RESTARTPERIOD_KEY,
RESTARTOUTFILE_KEY,
#ifdef USE_OASIS
WRITEOASISGRID_KEY,
#endif
};

ConfigMap getConfig() const { return ConfigMap(); };
Expand Down
12 changes: 12 additions & 0 deletions core/src/include/ModelArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ class ModelArray {
* @param minArr the array of clamp minimum target values.
*/
ModelArray& clampBelow(const ModelArray& minArr);
/*!
* @brief Returns the per-element square root of the array
*/
ModelArray sqrt();
/*!
* @brief Returns the per-element sin of the array
*/
ModelArray sin();
/*!
* @brief Returns the per-element cos of the array
*/
ModelArray cos();

using MultiDim = std::vector<size_t>;

Expand Down
Loading
Loading