Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
368 changes: 157 additions & 211 deletions core/src/Xios.cpp

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions core/src/include/Xios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,19 @@ class Xios : public Configured<Xios> {

/* File */
void createFile(const std::string fileId, const int fieldType);
void setFileType(const std::string fileId, const std::string fileType);
void setFileOutputFreq(const std::string fileId, const Duration outputFreq);
void setFileParAccess(const std::string fileId, const std::string parAccess);
std::string getFileType(const std::string fileId);
void setFileOutputFreq(
const std::string fileId, const Duration outputFreq, const int fieldType);
Duration getFileOutputFreq(const std::string fileId);
std::string getFileMode(const std::string fileId);
std::string getFileParAccess(const std::string fileId);
void fileAddField(const std::string fileId, const std::string fieldId);
std::vector<std::string> fileGetFieldIds(const std::string fileId);

enum {
ENABLED_KEY,
OUTPUT_FIELD_NAMES_KEY,
OUTPUT_SPLITFREQ_KEY,
INPUT_FIELD_NAMES_KEY,
DIAGNOSTIC_PERIOD_KEY,
DIAGNOSTIC_FILE_KEY,
DIAGNOSTIC_FIELD_NAMES_KEY,
DIAGNOSTIC_SPLITFREQ_KEY,
FORCING_PERIOD_KEY,
FORCING_FILE_KEY,
FORCING_FIELD_NAMES_KEY,
Expand Down Expand Up @@ -189,7 +183,6 @@ class Xios : public Configured<Xios> {
/* File */
xios::CFileGroup* getFileGroup();
xios::CFile* getFile(const std::string fileId);
void setFileMode(const std::string fileId, const std::string mode);
std::string outputFileId;
std::string inputFileId;
std::string diagnosticFilename;
Expand Down
10 changes: 7 additions & 3 deletions core/src/include/xios_c_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ bool cxios_is_defined_domain_lat_name(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_lon_name(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_ni_glo(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_nj_glo(xios::CDomain* domain_hdl);
void cxios_set_domain_lonvalue_1d(xios::CDomain* domain_hdl, double* data, const int* ni);
void cxios_set_domain_latvalue_1d(xios::CDomain* domain_hdl, double* data, const int* nj);
bool cxios_is_defined_domain_ni(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_nj(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_ibegin(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_jbegin(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_lonvalue_1d(xios::CDomain* domain_hdl);
bool cxios_is_defined_domain_latvalue_1d(xios::CDomain* domain_hdl);

// grid group methods
void cxios_gridgroup_handle_create(xios::CGridGroup** _ret, const char* _id, int _id_len);
Expand Down Expand Up @@ -142,16 +146,16 @@ void cxios_set_file_output_freq(xios::CFile* file_hdl, cxios_duration output_fre
void cxios_set_file_split_freq(xios::CFile* file_hdl, cxios_duration split_freq_c);
void cxios_set_file_mode(xios::CFile* file_hdl, const char* mode, int mode_size);
void cxios_set_file_par_access(xios::CFile* file_hdl, const char* par_access, int par_access_size);
void cxios_get_file_type(xios::CFile* file_hdl, char* type, int type_size);
void cxios_set_file_split_freq_format(
xios::CFile* file_hdl, const char* split_freq_format, int split_freq_format_size);
void cxios_get_file_output_freq(xios::CFile* file_hdl, cxios_duration* output_freq_c);
void cxios_get_file_mode(xios::CFile* file_hdl, char* mode, int mode_size);
void cxios_get_file_par_access(xios::CFile* file_hdl, char* par_access, int par_access_size);
bool cxios_is_defined_file_name(xios::CFile* file_hdl);
bool cxios_is_defined_file_type(xios::CFile* file_hdl);
bool cxios_is_defined_file_output_freq(xios::CFile* file_hdl);
bool cxios_is_defined_file_split_freq(xios::CFile* file_hdl);
bool cxios_is_defined_file_mode(xios::CFile* file_hdl);
bool cxios_is_defined_file_par_access(xios::CFile* file_hdl);
bool cxios_is_defined_file_split_freq_format(xios::CFile* file_hdl);
void cxios_xml_tree_add_fieldtofile(
xios::CFile* file, xios::CField** field, const char* _id, int _id_len);

Expand Down
6 changes: 3 additions & 3 deletions core/src/iodef.xml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<!-- Axes defining extrusions for certain fields based on degrees of freedom per node -->
<axis_definition>
<axis id="DGAxis" n_glo="{{ DGCOMP }}" name="dg_comp" dim_name="DGAxis"/>
<axis id="DGSAxis" n_glo="{{ DGSTRESSCOMP }}" name="dgstress_comp" dim_name="DGSAxis"/>
<axis id="VertexAxis" n_glo="2" name="ncoords" dim_name="VertexAxis"/>
<axis id="DGAxis" n_glo="{{ DGCOMP }}" name="dg_comp" dim_name="dg_comp"/>
<axis id="DGSAxis" n_glo="{{ DGSTRESSCOMP }}" name="dgstress_comp" dim_name="dgstress_comp"/>
<axis id="VertexAxis" n_glo="2" name="ncoords" dim_name="ncoords"/>
</axis_definition>

<grid_definition>
Expand Down
15 changes: 3 additions & 12 deletions core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,6 @@ if(ENABLE_MPI)
)
target_link_libraries(testXiosField_MPI3 PRIVATE nextsimlib doctest::doctest)

add_executable(testXiosFile_MPI2 "XiosFile_test.cpp" "MainMPI.cpp")
target_compile_definitions(testXiosFile_MPI2 PRIVATE USE_XIOS)
target_include_directories(
testXiosFile_MPI2
PRIVATE
${PHYSICS_INCLUDE_DIRS}
"${MODEL_INCLUDE_DIR}"
"${XIOS_INCLUDE_LIST}"
"${ModulesRoot}/StructureModule"
)
target_link_libraries(testXiosFile_MPI2 PRIVATE nextsimlib doctest::doctest)

add_executable(testXiosRead_MPI2 "XiosRead_test.cpp" "MainMPI.cpp")
target_compile_definitions(testXiosRead_MPI2
PRIVATE
Expand Down Expand Up @@ -271,6 +259,9 @@ if(ENABLE_MPI)
)

add_mpi_test("${XIOS_TESTS}")

# Ensure XiosWrite_test is run before XiosRead_test
set_tests_properties(testXiosRead_MPI2 PROPERTIES DEPENDS testXiosWrite_MPI2)
else()
add_executable(testHaloExchangeCB_MPI3
"HaloExchangeCB_test.cpp"
Expand Down
142 changes: 0 additions & 142 deletions core/test/XiosFile_test.cpp

This file was deleted.

22 changes: 16 additions & 6 deletions core/test/XiosRead_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <filesystem>

const std::string testFilesDir = TEST_FILES_DIR;
const std::string restartFilename = testFilesDir + "/xios_test_input.nc";
const std::string inputFilename
= testFilesDir + "/restart_2023-03-17T17:11:00Z-2023-03-17T20:10:59Z.nc";
const std::string forcingFilename = testFilesDir + "/xios_test_forcing.nc";

static const int DGCOMP = 6;
Expand All @@ -42,8 +43,7 @@ MPI_TEST_CASE("TestXiosRead", 2)
config << "start = 2023-03-17T17:11:00Z" << std::endl;
config << "stop = 2023-03-17T23:11:00Z" << std::endl;
config << "time_step = P0-0T01:30:00" << std::endl;
config << "init_file = " << restartFilename << std::endl;
config << "restart_period = P0-0T01:30:00" << std::endl;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restart period needs to be provided, otherwise XIOS stalls.

config << "init_file = " << inputFilename << std::endl;
config << "partition_file = xios_test_partition_metadata_2.nc" << std::endl;
config << "[XiosInput]" << std::endl;
config << "field_names = " << maskName << "," << coordsName << "," << hiceName << ","
Expand Down Expand Up @@ -79,8 +79,11 @@ MPI_TEST_CASE("TestXiosRead", 2)

xiosHandler.close_context_definition();

// Check the input files exists
REQUIRE(std::filesystem::exists(restartFilename));
// Check the input files exist
if (!std::filesystem::exists(inputFilename)) {
throw std::runtime_error(
"XiosRead_test: Input file not found. Did you run XiosWrite_test?");
}
REQUIRE(std::filesystem::exists(forcingFilename));

// Check calendar step is zero initially
Expand All @@ -93,7 +96,7 @@ MPI_TEST_CASE("TestXiosRead", 2)
REQUIRE(ModelArray::size(ModelArray::Dimension::DG) == DGCOMP);

// Read restarts from file and check they take the expected values
ModelState restarts = grid.getModelState(restartFilename);
ModelState restarts = grid.getModelState(inputFilename);
int rank;
MPI_Comm_rank(test_comm, &rank);
for (auto& entry : restarts.data) {
Expand Down Expand Up @@ -169,6 +172,13 @@ MPI_TEST_CASE("TestXiosRead", 2)
REQUIRE(xiosHandler.getCalendarStep() == ts + 1);
}

if (rank == 0) {
std::filesystem::remove("restart_2023-03-17T17:11:00Z-2023-03-17T20:10:59Z.nc");
std::filesystem::remove("restart_2023-03-17T20:11:00Z-2023-03-17T23:10:59Z.nc");
std::filesystem::remove("diagnostic_2023-03-17T17:11:00Z-2023-03-17T20:10:59Z.nc");
std::filesystem::remove("diagnostic_2023-03-17T20:11:00Z-2023-03-17T23:10:59Z.nc");
}

xiosHandler.context_finalize();
Finalizer::finalize();
}
Expand Down
Loading
Loading