Skip to content

Commit d1b8951

Browse files
committed
test: working example of halo exchange
This test includes two examples for different grid layouts: - 3 x 1 grid (3 procs) - 2 x 2 grid (4 procs) Makes use of the Slice functionality
1 parent aa15779 commit d1b8951

File tree

6 files changed

+482
-4
lines changed

6 files changed

+482
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ else()
3737
set(NSDG_NetCDF_Library "netcdf-cxx4")
3838
else()
3939
set(NSDG_NetCDF_Library "netcdf_c++4")
40+
set(NSDG_NetCDF_Library "netcdf-cxx4")
4041
endif()
4142
endif()
4243
target_include_directories(nextsimlib PUBLIC "${netCDF_INCLUDE_DIR}")

core/src/include/ModelArraySlice.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class ModelArraySlice {
100100
}
101101

102102
ModelArray& copyToModelArray(ModelArray& target) const;
103-
template <typename T> T& copyToBuffer(T& buffer)
103+
template <typename T> T& copyToBuffer(T& buffer, size_t startIndex = 0)
104104
{
105105
// make no especial attempt at efficiency here
106106
SliceIter thisIter(slice, data.dimensions());
107-
auto biter = buffer.begin();
107+
auto biter = std::next(buffer.begin(), startIndex);
108108

109109
while (!thisIter.isEnd()) {
110110
// If the buffer ends before the slice, throw an exception

core/src/include/Slice.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,18 @@ class Slice {
142142
}
143143
std::ostream& print(std::ostream& os) const
144144
{
145-
return os << start << ":" << stop << ":" << step;
145+
// TODO remove me before merging into develop
146+
// this is for debugging purposes only
147+
if (start.isAll()) {
148+
os << ":*:";
149+
} else {
150+
os << start << ":";
151+
}
152+
if (stop.isAll()) {
153+
return os << "*:" << step;
154+
} else {
155+
return os << stop << ":" << step;
156+
}
146157
}
147158
friend SliceIter;
148159
};

core/test/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ if(ENABLE_MPI)
7777
)
7878
target_link_libraries(testModelMetadata_MPI3 PRIVATE nextsimlib doctest::doctest)
7979

80+
# set(ModelArrayStructure "discontinuousgalerkin")
81+
set(CoreDir "../../core/src/")
82+
83+
# set(MODEL_INCLUDE_DIR "./testmodelarraydetails")
84+
add_executable(testHaloExchange_MPI4
85+
"HaloExchange_test.cpp"
86+
"MainMPI.cpp"
87+
"../src/ModelArray.cpp"
88+
"../src/ModelArraySlice.cpp"
89+
"${MODEL_INCLUDE_DIR}/ModelArrayDetails.cpp"
90+
)
91+
target_compile_definitions(testHaloExchange_MPI4 PRIVATE USE_MPI)
92+
target_include_directories(
93+
testHaloExchange_MPI4 PRIVATE
94+
"../src"
95+
"../../dynamics/src"
96+
${MODEL_INCLUDE_DIR}
97+
)
98+
target_link_libraries(testHaloExchange_MPI4 PRIVATE doctest::doctest Eigen3::Eigen)
99+
100+
set(MODEL_INCLUDE_DIR "../../core/src/discontinuousgalerkin")
101+
80102
add_executable(testParaGrid_MPI2 "ParaGrid_test.cpp" "MainMPI.cpp")
81103
target_compile_definitions(
82104
testParaGrid_MPI2

0 commit comments

Comments
 (0)