diff --git a/CMakeLists.txt b/CMakeLists.txt index 36c9914ec..04ae6fd14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ else() set(NSDG_NetCDF_Library "netcdf-cxx4") else() set(NSDG_NetCDF_Library "netcdf_c++4") + set(NSDG_NetCDF_Library "netcdf-cxx4") endif() endif() target_include_directories(nextsimlib PUBLIC "${netCDF_INCLUDE_DIR}") diff --git a/core/test/HaloExchange_test.cpp b/core/test/HaloExchange_test.cpp index 3d2aa915d..2df7ffe58 100644 --- a/core/test/HaloExchange_test.cpp +++ b/core/test/HaloExchange_test.cpp @@ -18,9 +18,9 @@ using Slice = ArraySlicer::Slice; using SliceIter = ArraySlicer::SliceIter; -const auto nx = 9; -const auto ny = 5; -const auto nz = 3; +const auto nx = 6; +const auto ny = 3; +const auto nz = 2; namespace Nextsim { @@ -55,7 +55,7 @@ MPI_TEST_CASE("test halo exchange", 3) // Create the ParametricMesh object auto CoordinateSystem = Nextsim::CARTESIAN; ParametricMesh smesh(CoordinateSystem); - smesh.nx = nx + 2; + smesh.nx = localNx + 2; smesh.ny = ny + 2; smesh.nnodes = smesh.nx * smesh.ny; smesh.nelements = smesh.nnodes; @@ -66,13 +66,32 @@ MPI_TEST_CASE("test halo exchange", 3) smesh.vertices(i * ny + j, 1) = j; } } - // DGModelArray::ma2dg(testfield, dgvec); DGVector dgvec(smesh); - ModelArraySlice source(testfield, { { {}, {} } }); + SliceIter::MultiDim eigDim = { smesh.nx, smesh.ny }; + Slice centreBlock { { { 1, -1 }, { 1, -1 } } }; + SliceIter eigCentre(centreBlock, eigDim); + Slice wholeArray { { {}, {} } }; - source.copyToDataSlice(dgvec, { { { 1, localNx + 1 }, { 1, ny + 1 } } }); + // all spatial dims are collapsed into the first dimension (0). The other dimensions are for + // higher-order DG components + auto eig0 = dgvec.array().col(0); + + testfield[wholeArray].copyToSlicedBuffer(eig0, eigCentre); + // testfield[{{{}, {}}}].copyToSlicedBuffer(eig0, { { { 1, localNx + 1 }, { 1, ny + 1 } } }); + + for (size_t j = 0; j < ny; ++j) { + for (size_t i = 0; i < localNx; ++i) { + printf("testfield[%zu, %zu, 0] = %f\n", i, j, testfield(i, j)); + } + } + for (size_t j = 0; j < smesh.ny; ++j) { + for (size_t i = 0; i < smesh.nx; ++i) { + size_t targetPoint = ModelArray::indexFromLocation(ModelArray::Type::DG, { i, j }); + printf("dgvec[%zu, %zu, 0] = %f\n", i, j, dgvec(targetPoint, 0)); + } + } int ierr; enum Edge { BOTTOM, RIGHT, TOP, LEFT, N_EDGE }; @@ -97,17 +116,6 @@ MPI_TEST_CASE("test halo exchange", 3) slice.copyToBuffer(vectorBuffer); - // ModelArray source(ModelArray::Type::H); - // source.resize(); - // // Fill with data - // for (size_t i = 0; i < nx; ++i) { - // for (size_t j = 0; j < ny; j++) { - // source(i, j) = j + mx * (i); - // } - // } - - // CHECK(source(14, 12) == 12 + mx * (14)); - // ierr = MPI_Scatterv() if (test_rank == 0) { @@ -119,5 +127,4 @@ MPI_TEST_CASE("test halo exchange", 3) exit(1); } } - } diff --git a/run/config_benchmark.cfg b/run/config_benchmark.cfg index 8881e516e..9e414fc39 100644 --- a/run/config_benchmark.cfg +++ b/run/config_benchmark.cfg @@ -1,7 +1,7 @@ [model] init_file = init_benchmark_32x32.nc start = 2023-01-01T00:00:00Z -stop = 2023-01-03T00:00:00Z +stop = 2023-01-02T00:00:00Z time_step = P0-0T00:02:00 [Modules]