From 5e60bee27eb4e63f8f50e3d6fb151786bd0b2dd3 Mon Sep 17 00:00:00 2001 From: Michael Waxmonsky Date: Wed, 24 Jun 2026 21:18:56 -0600 Subject: [PATCH 1/5] Initial boundary exchange implementation. --- test_mom/CMakeLists.txt | 37 +++----- test_mom/boundary/CMakeLists.txt | 1 + .../MOM_fixed_initialization_0000.bin | Bin 0 -> 13536 bytes .../MOM_fixed_initialization_0000.meta | 10 +++ .../MOM_fixed_initialization_0001.bin | Bin 0 -> 13536 bytes .../MOM_fixed_initialization_0001.meta | 10 +++ .../MOM_fixed_initialization_0002.bin | Bin 0 -> 13536 bytes .../MOM_fixed_initialization_0002.meta | 10 +++ .../MOM_fixed_initialization_0003.bin | Bin 0 -> 13536 bytes .../MOM_fixed_initialization_0003.meta | 10 +++ test_mom/boundary/test_boundary_exchange.cpp | 85 ++++++++++++++++++ test_mom/cmake/add_mpi_test.cmake | 27 ++++++ test_mom/common/CMakeLists.txt | 8 ++ test_mom/common/captured_io.cpp | 17 ++-- test_mom/mom_continuity_ppm/CMakeLists.txt | 11 +++ 15 files changed, 195 insertions(+), 31 deletions(-) create mode 100644 test_mom/boundary/CMakeLists.txt create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.bin create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.meta create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.bin create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.meta create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.bin create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.meta create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.bin create mode 100644 test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.meta create mode 100644 test_mom/boundary/test_boundary_exchange.cpp create mode 100644 test_mom/cmake/add_mpi_test.cmake create mode 100644 test_mom/common/CMakeLists.txt create mode 100644 test_mom/mom_continuity_ppm/CMakeLists.txt diff --git a/test_mom/CMakeLists.txt b/test_mom/CMakeLists.txt index 82cd7df..19a1cad 100644 --- a/test_mom/CMakeLists.txt +++ b/test_mom/CMakeLists.txt @@ -17,8 +17,9 @@ cmake_minimum_required(VERSION 3.20) project(test_mom CXX) +enable_language(C Fortran) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -83,14 +84,6 @@ endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../mom/cpp ${CMAKE_CURRENT_BINARY_DIR}/mom_cpp) -# --- mom_continuity_ppm test ---------------------------------------------- -add_executable(test_mom_continuity_ppm - test_mom_main.cpp - common/captured_io.cpp - common/amrex_assertions.cpp - mom_continuity_ppm/test_mom_continuity_ppm.cpp -) - # Every source in this target includes AMReX headers. With the CUDA backend # those headers use __host__/__device__ qualifiers and CUDA kernel-launch # syntax, so nvcc must compile them. CMake won't infer this from .cpp, so we @@ -101,23 +94,15 @@ if(AMReX_GPU_BACKEND STREQUAL "CUDA") common/captured_io.cpp common/amrex_assertions.cpp mom_continuity_ppm/test_mom_continuity_ppm.cpp + boundary/test_boundary_exchange.cpp PROPERTIES LANGUAGE CUDA) endif() -target_include_directories(test_mom_continuity_ppm - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/common -) -target_link_libraries(test_mom_continuity_ppm - PRIVATE - mom_continuity - GTest::gtest -) -gtest_discover_tests(test_mom_continuity_ppm - EXTRA_ARGS --data-dir=${TEST_MOM_DATA_DIR} - # Discover at test-run time rather than build time. With the CUDA backend - # the binary calls amrex::Initialize() which aborts on hosts without a GPU - # (e.g. Derecho login nodes), so running it at POST_BUILD would break the - # build. - DISCOVERY_MODE PRE_TEST -) +include(cmake/add_mpi_test.cmake) +add_subdirectory(common) + +add_library(data_driven_shared_main OBJECT test_mom_main.cpp) +target_link_libraries(data_driven_shared_main PUBLIC common) + +add_subdirectory(mom_continuity_ppm) +add_subdirectory(boundary) diff --git a/test_mom/boundary/CMakeLists.txt b/test_mom/boundary/CMakeLists.txt new file mode 100644 index 0000000..8d705f5 --- /dev/null +++ b/test_mom/boundary/CMakeLists.txt @@ -0,0 +1 @@ +add_mpi_test(test_boundary_exchange test_boundary_exchange.cpp double_gyre_init_pass_var) diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.bin b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.bin new file mode 100644 index 0000000000000000000000000000000000000000..1d2fb8c27083712600cee6ba2d0c1c55880aa74e GIT binary patch literal 13536 zcmeI&c{J2}9|v&Bo;E@oQr#ORA++3bO-Kt7g(#*{%+#nr{C}+J>N?>g;otZAeH^|Y2mgEP0M05*ul!jJAo0}) z$u_y5%*cE*zRm#DyR0d1y8IAoePzd$vK~Y}mw9tnM+`Lf5!wFONuXz}?47L<1V&c! zUe2-UU|yUZ)HzNWERyn8o1Pco{J1dWgV=L$v-Ik>Z8-wIrt2}j~p@Ew7#rLzn0z!9eF}>YyhRA3A_gAk! z0a~oWq>Vb_pr=MG?7Q?FjGKuj^Ipb*8UJk3p$$KQb;P&4O3@RX*_$(JLjZ1uV&NK6 zC-`%6o1I)-A@DqMO3H21Xr06T#Jy9jO$u^s86H35W%d63y;}3zWk>kBB4a56C+DhE3U@PM`b0tVICL7y)egkDf zvb&$bZBR3UPE^U8Ak=))!tj7}L_QqYw${iUw5VkUn}e2veyy%l|3U{CNlTT^YCHgw zB`D}2Re|Laqh78Z4$jnj26c1I!A)rHQ2t~A{xk{6UtbzP;A9YH<0ms(=Wsu9@1zMv zF)i0XihA+$hr;=w$n;g_I%a~J645(rD;J>~1~mhQx)FK*g_B;F31~l`+mt1L8T89V zv!_yp-h>N-pB7&NGdgBP?T`Lo?Vp+DRo4uTLhWRQEC+BeT)8953;PQOp zilUOh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RYs*oMVBQe`K{-@i?po4pW%_kv|=-mU*FFVW-U`}_aA4fp;2e%<$R_&NfA z_j(u_8XEYz2|xOK&h#G`-@kjlzJK1=Rq*$(ga7w&6}6n{Th}k&nom*7nTUHuD`z6^ z6|J0!xL34tCgNVv%9)6JMJs0_?iH<^iMUs^awfuF5zCo~dqpc}BJLHfoQb$sv~nim zUeU^#h$x+Z*^IN2E^V*vT@ZDgVr1Mh9nn_d9)%XK5u@soR^9CfW=a0`9OHJd_PVu1 zspf!PzGMCu4dL&HHDfL=Oo;+-xA#2$wHojb+o_~266UA2tw+-{I}talRj_1s&PZMV zuJ7C4joB%3k}KhT@YSpj+1KDVBPl6s?jZ!)3~kiywMH<_EadinXM`uMm>DvGf-^U~ ze&9K|A!@yyTgZ)`t=a=G)>8=YJQWp>4y4~*MY%mQkq>O2IfyS3m2{RMr?ldN2BO;uyvZmxnrck@l`9a$@c^Iaz%5w!C3H8 qf_CfG>449CLU&gl1A$G1+M%!t2tMT)zcuk1sqbHXf4y%wXZk0)D&746 literal 0 HcmV?d00001 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.meta b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.meta new file mode 100644 index 0000000..0107984 --- /dev/null +++ b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0000.meta @@ -0,0 +1,10 @@ +G%Domain%niglobal integer 1 +G%Domain%njglobal integer 5 +G%Domain%nihalo integer 9 +G%Domain%njhalo integer 13 +G%bathyT_brefore RealArray_t 17 +G%bathyT_brefore%isd_global integer 6769 +G%bathyT_brefore%jsd_global integer 6773 +G%bathyT_after RealArray_t 6777 +G%bathyT_after%isd_global integer 13529 +G%bathyT_after%jsd_global integer 13533 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.bin b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.bin new file mode 100644 index 0000000000000000000000000000000000000000..683b7e23a177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T);MF~ za$&Ay5~3W-%B#<>M7Twtahh5YLg#AsO+CuRiP96LDvf~%T*hEm6`cY>`^46P=U4vB LJDe2$)tUYYY^T+o literal 0 HcmV?d00001 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.meta b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.meta new file mode 100644 index 0000000..0107984 --- /dev/null +++ b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0001.meta @@ -0,0 +1,10 @@ +G%Domain%niglobal integer 1 +G%Domain%njglobal integer 5 +G%Domain%nihalo integer 9 +G%Domain%njhalo integer 13 +G%bathyT_brefore RealArray_t 17 +G%bathyT_brefore%isd_global integer 6769 +G%bathyT_brefore%jsd_global integer 6773 +G%bathyT_after RealArray_t 6777 +G%bathyT_after%isd_global integer 13529 +G%bathyT_after%jsd_global integer 13533 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.bin b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.bin new file mode 100644 index 0000000000000000000000000000000000000000..fc73b62104b756a288c36b9ee1521a675e373e3f GIT binary patch literal 13536 zcmeI%c{J2*z?miXK(;_JfDP_yPlVva%`!dF0%nT~JrO1*c z$yy=Go`fQIMT@j>hstk$zefFapZUY{ob&jdoO7LPaAwZDXXg9;&UL-GxVYAHadAnr z1`m61vu1JD5M_-S?A!l4vwokcxub`5i}mws{`ETi`W*cKI}Tt<*f^tCEe}qGR?jAC zTH%$nLBKn6Cy05yYp;=JA&BQVpU4~~gsF5tQXZaX}?BQ z&N)zZ1XNs8LJ-f(6UB&Gi3G;i$1>*+AW`V~CK};A=(Z1D6HjgfBW-ly_=BZj-nf4& zHdh8o>Ccxwu2VuX{_g}V#T1f99cKE@;d0!)Ks}_G8l$VYnd6{VA>cg&6U?f((wU@yuy!2UNMlgWmWNi zzIX49Z2no>;bhUdV(>-=yhO6Hilokhcx+;?!l)id(ffjKo;E{h);7_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H)5@VfyEDN8iHsxTwyApC4?4H58Lq3cxn`&3sqif~ofYy8o|z z>0kTO|GoRt6B83(S?`Y^YfQ_Rp_d1edPbM^bH%#td{kvvP=Pj7#f19tK zdKk|9#B` zuY4FN!{sRtorgfZe&q=7fBY8w%nmD|E|u-$Kl+YHb6?$iHFmN7ZtJp8h|&~=sSwkRS-X4TbC023PFaO zk6-TkjIgw$U3c$&Mbv|Hp2uAN26;f(;8MYAP}(loKdr9^HRGt;M?MAC{$<0=qOgUa zao_KH_RIr`#LXYZzpe$ncai98$v?mpqo-Ndvi9keHl@gjl_6QilE=ujX7c$?b>`el zv9)eYDuz?Ligdltad@?GoAfOS1o6?8mkj|t2vR&^sQNVxVNUh#ggOaC#Rh8~%uWKi zX5rPQ$itvy7nKqv4}j`dG@$oP9r0VQQ%=l&frJ*jMaPS3k*L*3e_H1Y`j!5XoxUz$ zJpVAKZ?ij?Uk}C7Yq(`xRiev9Ib0)So<^1#~wnwpjigWMua;8ad z`r%JMJnFkoaqgX7&NS&wKm2LZqu4&hxp#Uw6Wg0Ae)<#Jqu4&hv3Hs|6Wg0u-%ls~ ziS1ErpW@s*y_{*%n|}Dyq(`xRigWMuawfJnjsNtgNss#OQyhDznKQAyss5)wu|10I zQ=EIJmorUz(@%ez^r-JX#j$sqITPEPSpGigPm>d((!W{>1huwoh^H zonFqw_9nL<{`AA6zWWr%-f8AcY;O|!=}(g$_1&j9_D(ZrVtbS4Pk&;26x*jb_D(Zr dn)Ifh{xs=P-+hWx@2~&=a;9I-^xyAH{{u&wkw5?d literal 0 HcmV?d00001 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.meta b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.meta new file mode 100644 index 0000000..0107984 --- /dev/null +++ b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0002.meta @@ -0,0 +1,10 @@ +G%Domain%niglobal integer 1 +G%Domain%njglobal integer 5 +G%Domain%nihalo integer 9 +G%Domain%njhalo integer 13 +G%bathyT_brefore RealArray_t 17 +G%bathyT_brefore%isd_global integer 6769 +G%bathyT_brefore%jsd_global integer 6773 +G%bathyT_after RealArray_t 6777 +G%bathyT_after%isd_global integer 13529 +G%bathyT_after%jsd_global integer 13533 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.bin b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.bin new file mode 100644 index 0000000000000000000000000000000000000000..bed18efc848fe6378c1d1b46a2fe4c091268c2a3 GIT binary patch literal 13536 zcmeI%c{Ejf{|9hG(V(P~%2ZJ)4dSLyw|9f^R3t?qC1aUqna5-13=U^RMOOn!8InS7 zAu1U{66!XPM4}8g&$<0N=l9?5-nBf>UB7E}*7~mRKIiPc*Lv^$-QT_U=f%gzw}y|8 zPl3~>d~X7rUWU`8IF0}N@*h3tyP)>A4$czi^P~T99Da<0$#)$f72gK-pY|!4uOyyU ztAc&w!L7vHRbXWd&mDaz0jA@_cOl1q21ERnGCkk}Xsq9#t~#?H$wE^SSY$a+4MfyE z)1p8j?A0p2dK#p&(s$c)uOUIdFSAst5Had)&1!>Uh?sIjSaP}=LaueLyh4}`zm#<% z{#hDuE3kVpUfB+-fDQbeyY5eP9{SUqsY|+2HZ3bc%8@RYYXt*fJD5o1t~Ub9)NLjE zVjGwW)bzDE6wvDrt{z#M3!0hTTat7!lB&xMiZlm6mA1)!HslA&p=igu`(A?N8KA29 zRuTzQZF*iFw?*`@lVN#MHwX`nCC!x9AtZ{ny(?A)e&(L3HjNaxk)KbW`O{5USyj}p z{~GmQ&zn+yrFGG6I@sfK3aeYZ!4?n5^>4}pOL$6~=z`nxLr82d6A&%ctU_@@3RK`?w}st=b3fWGdv0F!?zlFOgye%0tCxErZ^VbbiBEa0Vxp!zyEf{mcW+piA1Ffn#ZpHcSNVe>tZ?g^p z^`%2=O{OCfwY*m5=jDM+5r5tFW+jM~p+_~JNg%F4F?8Hb4N;$btb?q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zWWi^lX$)~xtxjT zMLa*^deS#v8o?xUCY~2@{fOsD-+YPlTtB&-iRVQ;KjL~4*O$0G_xFFcGx5BL=SN&m z`sPc=G0B{X=S5sU;(5|HUs{Vv=1e><;`z~cPx>EU^28)_CY~4Z{D|vG-+XC4CYdww zyol>ZJWu-OOFo!n&cyQ~o*!{NiR(+;p8NX`XZoW){bzNuAOHVxlztqiALHOZI}SK| I`{qpl25*Fkxc~qF literal 0 HcmV?d00001 diff --git a/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.meta b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.meta new file mode 100644 index 0000000..0107984 --- /dev/null +++ b/test_mom/boundary/double_gyre_init_pass_var/MOM_fixed_initialization_0003.meta @@ -0,0 +1,10 @@ +G%Domain%niglobal integer 1 +G%Domain%njglobal integer 5 +G%Domain%nihalo integer 9 +G%Domain%njhalo integer 13 +G%bathyT_brefore RealArray_t 17 +G%bathyT_brefore%isd_global integer 6769 +G%bathyT_brefore%jsd_global integer 6773 +G%bathyT_after RealArray_t 6777 +G%bathyT_after%isd_global integer 13529 +G%bathyT_after%jsd_global integer 13533 diff --git a/test_mom/boundary/test_boundary_exchange.cpp b/test_mom/boundary/test_boundary_exchange.cpp new file mode 100644 index 0000000..2d4259b --- /dev/null +++ b/test_mom/boundary/test_boundary_exchange.cpp @@ -0,0 +1,85 @@ +#include +#include + +#include + +#include +#include +#include +#include + +#include "amrex_assertions.hpp" +#include "captured_io.hpp" +#include "data_dir.hpp" + +using test_mom::expect_arrays_equal; +using test_mom::to_host_fab; + +TEST(BoundaryExchange, BoundaryMatchesAfterOneTimeStep) { + int myRank = amrex::ParallelDescriptor::MyProc(); + test_mom::CapturedFile captured(test_mom::data_dir / + ("MOM_fixed_initialization_" + std::format("{:04}", myRank))); + + auto bathyTBefore = captured.fab_host("G%bathyT_brefore"); + auto bathyTAfter = captured.fab_host("G%bathyT_after" ); + int nihalo = captured.integer("G%Domain%nihalo"); + int njhalo = captured.integer("G%Domain%njhalo"); + int niglobal = captured.integer("G%Domain%niglobal"); + int njglobal = captured.integer("G%Domain%njglobal"); + + amrex::BoxList boxList; + amrex::Vector processBoxList; + int iLocalGridSize = bathyTBefore.box().length(0) - (2*nihalo); + int jLocalGridSize = bathyTBefore.box().length(1) - (2*njhalo); + + // Assumes equally sized grids + for(int i = 0; i < amrex::ParallelDescriptor::NProcs(); i++) + { + test_mom::CapturedFile rankc(test_mom::data_dir / + ("MOM_fixed_initialization_" + std::format("{:04}", i))); + int iGridStartLoc = rankc.integer("G%bathyT_brefore%isd_global") + nihalo; + int jGridStartLoc = rankc.integer("G%bathyT_brefore%jsd_global") + njhalo; + amrex::IntVect lo(iGridStartLoc, jGridStartLoc, 0); + amrex::IntVect hi(lo[0] + iLocalGridSize - 1, lo[1] + jLocalGridSize - 1, 0); + amrex::Box b(lo, hi); + boxList.push_back(b); + processBoxList.push_back(i); + } + + // Setup multifab + amrex::BoxArray boxes(boxList); + amrex::DistributionMapping dm(processBoxList); + amrex::IntVect fourRowTwo2DGhostCells{nihalo, njhalo, 0}; + amrex::MultiFab mf(boxes, dm, /*ncomp=*/1, fourRowTwo2DGhostCells); + + // Setup box + amrex::Box globalComputationalDomain(amrex::IntVect( 0, 0, 0), + amrex::IntVect(niglobal - 1, njglobal - 1, 0)); + amrex::RealBox realBox({0.0, 0.0, 0.0}, {1.0, 1.0, 1.0}); + amrex::Geometry geom(globalComputationalDomain, &realBox); + + // Verify that the loops iterate only the expected number of times + int mf_iterations = 0; + for (amrex::MFIter mfi(mf, /*tiling=*/false); mfi.isValid(); ++mfi) + { + amrex::FArrayBox& localValidFab = mf[mfi]; + ASSERT_EQ(bathyTBefore.box(), localValidFab.box()); + + localValidFab.copy(bathyTBefore); + mf_iterations++; + } + ASSERT_EQ(1, mf_iterations); + + mf.FillBoundary(geom.periodicity()); + + mf_iterations = 0; + for (amrex::MFIter mfi(mf, /*tiling=*/false); mfi.isValid(); ++mfi) + { + amrex::FArrayBox& localValidFab = mf[mfi]; + ASSERT_EQ(bathyTAfter.box(), localValidFab.box()); + + expect_arrays_equal(bathyTAfter, localValidFab, "G%bathyT"); + mf_iterations++; + } + ASSERT_EQ(1, mf_iterations); +} diff --git a/test_mom/cmake/add_mpi_test.cmake b/test_mom/cmake/add_mpi_test.cmake new file mode 100644 index 0000000..5f594a4 --- /dev/null +++ b/test_mom/cmake/add_mpi_test.cmake @@ -0,0 +1,27 @@ + +function(add_mpi_test TEST_TARGET_NAME TEST_FILE DATA_DIR) + + set(prefix TIM) + set(optionalValues "") + set(singleValues MAX_PES) + set(multiValues "") + + include(CMakeParseArguments) + cmake_parse_arguments(${prefix} "${optionalValues}" "${singleValues}" "${multiValues}" ${ARGN}) + + if(DEFINED TIM_MAX_PES) + if (TIM_MAX_PES NOT MATCHES "^[1-9][0-9]*$") + message(FATAL_ERROR "MAX_PES expected a valid positive integer; recieved ${TIM_MAX_PES}") + endif() + else() + set(TIM_MAX_PES 4) + endif() + + add_executable(${TEST_TARGET_NAME} ${TEST_FILE}) + target_sources(${TEST_TARGET_NAME} PRIVATE $) + target_link_libraries(${TEST_TARGET_NAME} PRIVATE common) + + add_test(NAME MPI_${TEST_TARGET_NAME} + COMMAND ${MPIEXEC_EXECUTABLE} --tag-output ${MPIEXEC_NUMPROC_FLAG} ${TIM_MAX_PES} ./${TEST_TARGET_NAME} --data-dir=${CMAKE_CURRENT_SOURCE_DIR}/${DATA_DIR}) + set_tests_properties(MPI_${TEST_TARGET_NAME} PROPERTIES PROCESSORS ${TIM_MAX_PES}) +endfunction() diff --git a/test_mom/common/CMakeLists.txt b/test_mom/common/CMakeLists.txt new file mode 100644 index 0000000..dde066c --- /dev/null +++ b/test_mom/common/CMakeLists.txt @@ -0,0 +1,8 @@ +set(COMMON_SRC + amrex_assertions.cpp + captured_io.cpp) + +add_library(common OBJECT ${COMMON_SRC}) + +target_link_libraries(common PUBLIC GTest::gtest AMReX::amrex) +target_include_directories(common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test_mom/common/captured_io.cpp b/test_mom/common/captured_io.cpp index 617e4fc..871b43e 100644 --- a/test_mom/common/captured_io.cpp +++ b/test_mom/common/captured_io.cpp @@ -154,14 +154,21 @@ amrex::FArrayBox CapturedFile::fab_host(const std::string& name) const { std::to_string(nelem) + ", expected " + std::to_string(expected) + ")"); } - amrex::Box sbx(amrex::IntVect(0, 0, 0), - amrex::IntVect(shape[0] - 1, shape[1] - 1, shape[2] - 1)); + amrex::IntVect start(0, 0, 0); + if(entries_.contains(name + "%isd_global") && entries_.contains(name + "%jsd_global")) + { + int isd_global = this->integer(name + "%isd_global"); + int jsd_global = this->integer(name + "%jsd_global"); + start = amrex::IntVect(isd_global, jsd_global, 0); + } + amrex::IntVect end(start[0] + shape[0] - 1, start[1] + shape[1] -1, shape[2] - 1); + amrex::Box sbx(start, end); amrex::FArrayBox fab(sbx, 1, amrex::The_Pinned_Arena()); auto arr = fab.array(); // Fortran column-major in the file: i fastest, then j, then k. - for (int k = 0; k < shape[2]; ++k) - for (int j = 0; j < shape[1]; ++j) - for (int i = 0; i < shape[0]; ++i) + for (int k = start[2]; k < end[2]; ++k) + for (int j = start[1]; j < end[1]; ++j) + for (int i = start[0]; i < end[0]; ++i) arr(i, j, k) = read_be_f64(bin_, off); return fab; } diff --git a/test_mom/mom_continuity_ppm/CMakeLists.txt b/test_mom/mom_continuity_ppm/CMakeLists.txt new file mode 100644 index 0000000..3aafe70 --- /dev/null +++ b/test_mom/mom_continuity_ppm/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(test_mom_continuity_ppm test_mom_continuity_ppm.cpp) +target_sources(test_mom_continuity_ppm PRIVATE $) +target_link_libraries(test_mom_continuity_ppm PRIVATE common mom_continuity) +gtest_discover_tests(test_mom_continuity_ppm + EXTRA_ARGS --data-dir=${TEST_MOM_DATA_DIR} + # Discover at test-run time rather than build time. With the CUDA backend + # the binary calls amrex::Initialize() which aborts on hosts without a GPU + # (e.g. Derecho login nodes), so running it at POST_BUILD would break the + # build. + DISCOVERY_MODE PRE_TEST +) From 5beab61fcbc275dceab1a20eada6ded898354fbf Mon Sep 17 00:00:00 2001 From: Michael Waxmonsky Date: Wed, 24 Jun 2026 21:31:56 -0600 Subject: [PATCH 2/5] Whitespace and naming fixes. --- test_mom/boundary/test_boundary_exchange.cpp | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/test_mom/boundary/test_boundary_exchange.cpp b/test_mom/boundary/test_boundary_exchange.cpp index 2d4259b..be7b903 100644 --- a/test_mom/boundary/test_boundary_exchange.cpp +++ b/test_mom/boundary/test_boundary_exchange.cpp @@ -1,5 +1,4 @@ #include -#include #include @@ -13,7 +12,6 @@ #include "data_dir.hpp" using test_mom::expect_arrays_equal; -using test_mom::to_host_fab; TEST(BoundaryExchange, BoundaryMatchesAfterOneTimeStep) { int myRank = amrex::ParallelDescriptor::MyProc(); @@ -27,35 +25,36 @@ TEST(BoundaryExchange, BoundaryMatchesAfterOneTimeStep) { int niglobal = captured.integer("G%Domain%niglobal"); int njglobal = captured.integer("G%Domain%njglobal"); - amrex::BoxList boxList; + amrex::BoxList boxList; amrex::Vector processBoxList; - int iLocalGridSize = bathyTBefore.box().length(0) - (2*nihalo); - int jLocalGridSize = bathyTBefore.box().length(1) - (2*njhalo); + int iLocalDataGridSize = bathyTBefore.box().length(0) - (2*nihalo); + int jLocalDataGridSize = bathyTBefore.box().length(1) - (2*njhalo); // Assumes equally sized grids for(int i = 0; i < amrex::ParallelDescriptor::NProcs(); i++) { test_mom::CapturedFile rankc(test_mom::data_dir / ("MOM_fixed_initialization_" + std::format("{:04}", i))); + int iGridStartLoc = rankc.integer("G%bathyT_brefore%isd_global") + nihalo; int jGridStartLoc = rankc.integer("G%bathyT_brefore%jsd_global") + njhalo; amrex::IntVect lo(iGridStartLoc, jGridStartLoc, 0); - amrex::IntVect hi(lo[0] + iLocalGridSize - 1, lo[1] + jLocalGridSize - 1, 0); - amrex::Box b(lo, hi); - boxList.push_back(b); + amrex::IntVect hi(lo[0] + iLocalDataGridSize - 1, lo[1] + jLocalDataGridSize - 1, 0); + + boxList.emplace_back(amrex::Box(lo, hi)); processBoxList.push_back(i); } // Setup multifab - amrex::BoxArray boxes(boxList); + amrex::BoxArray boxes(boxList); amrex::DistributionMapping dm(processBoxList); - amrex::IntVect fourRowTwo2DGhostCells{nihalo, njhalo, 0}; - amrex::MultiFab mf(boxes, dm, /*ncomp=*/1, fourRowTwo2DGhostCells); + amrex::IntVect fourRowTwo2DGhostCells{nihalo, njhalo, 0}; + amrex::MultiFab mf(boxes, dm, /*ncomp=*/1, fourRowTwo2DGhostCells); - // Setup box + // Setup geometry amrex::Box globalComputationalDomain(amrex::IntVect( 0, 0, 0), amrex::IntVect(niglobal - 1, njglobal - 1, 0)); - amrex::RealBox realBox({0.0, 0.0, 0.0}, {1.0, 1.0, 1.0}); + amrex::RealBox realBox({0.0, 0.0, 0.0}, {1.0, 1.0, 1.0}); amrex::Geometry geom(globalComputationalDomain, &realBox); // Verify that the loops iterate only the expected number of times From 9cb6c35a00a78d03f3e0935161ce60b20de4d943 Mon Sep 17 00:00:00 2001 From: Michael Waxmonsky Date: Wed, 24 Jun 2026 21:54:05 -0600 Subject: [PATCH 3/5] Add MPI test option. --- test_mom/CMakeLists.txt | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/test_mom/CMakeLists.txt b/test_mom/CMakeLists.txt index 19a1cad..597b96e 100644 --- a/test_mom/CMakeLists.txt +++ b/test_mom/CMakeLists.txt @@ -27,6 +27,23 @@ if(AMReX_GPU_BACKEND STREQUAL "CUDA") enable_language(CUDA) endif() +# --- MPI based tests ------------------------------------------------------ +option(MPI_UNIT_TESTS "Build and run MPI based unit tests." OFF) + +# --- GTest ---------------------------------------------------------------- +option(TEST_MOM_FETCH_GTEST + "Download GoogleTest via FetchContent if find_package fails" ON) + +# --- Captured-data directory (used by --data-dir CLI flag) --------------- +set(TEST_MOM_DATA_DIR "" + CACHE PATH "Directory containing the captured Fortran I/O .bin/.meta files") +if(NOT TEST_MOM_DATA_DIR) + message(FATAL_ERROR + "TEST_MOM_DATA_DIR is not set. Pass\n" + " -DTEST_MOM_DATA_DIR=/path/to/captured/fixtures\n" + "on the cmake configure line.") +endif() + # --- AMReX ---------------------------------------------------------------- # Prefer an installed AMReX if available; otherwise build the in-tree source. set(AMREX_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../amrex" @@ -45,10 +62,6 @@ if(NOT AMReX_FOUND) ${CMAKE_CURRENT_BINARY_DIR}/_amrex) endif() -# --- GTest ---------------------------------------------------------------- -option(TEST_MOM_FETCH_GTEST - "Download GoogleTest via FetchContent if find_package fails" ON) - find_package(GTest QUIET) if(NOT GTest_FOUND) if(TEST_MOM_FETCH_GTEST) @@ -70,16 +83,6 @@ endif() enable_testing() include(GoogleTest) -# --- Captured-data directory (used by --data-dir CLI flag) --------------- -set(TEST_MOM_DATA_DIR "" - CACHE PATH "Directory containing the captured Fortran I/O .bin/.meta files") -if(NOT TEST_MOM_DATA_DIR) - message(FATAL_ERROR - "TEST_MOM_DATA_DIR is not set. Pass\n" - " -DTEST_MOM_DATA_DIR=/path/to/captured/fixtures\n" - "on the cmake configure line.") -endif() - # --- MOM C++ kernels library (target: mom_continuity) --------------------- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../mom/cpp ${CMAKE_CURRENT_BINARY_DIR}/mom_cpp) @@ -104,5 +107,8 @@ add_subdirectory(common) add_library(data_driven_shared_main OBJECT test_mom_main.cpp) target_link_libraries(data_driven_shared_main PUBLIC common) -add_subdirectory(mom_continuity_ppm) -add_subdirectory(boundary) +if(MPI_UNIT_TESTS) + add_subdirectory(boundary) +else() + add_subdirectory(mom_continuity_ppm) +endif() \ No newline at end of file From ba748d6c86d3296594f6bafccf5f1657945ab996 Mon Sep 17 00:00:00 2001 From: Michael Waxmonsky Date: Wed, 24 Jun 2026 21:55:26 -0600 Subject: [PATCH 4/5] Fixing whitespace. --- test_mom/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_mom/CMakeLists.txt b/test_mom/CMakeLists.txt index 597b96e..c9b23e6 100644 --- a/test_mom/CMakeLists.txt +++ b/test_mom/CMakeLists.txt @@ -111,4 +111,4 @@ if(MPI_UNIT_TESTS) add_subdirectory(boundary) else() add_subdirectory(mom_continuity_ppm) -endif() \ No newline at end of file +endif() From e7f76665a9694bf7fcf84afaa46d8388122e9098 Mon Sep 17 00:00:00 2001 From: Michael Waxmonsky Date: Wed, 24 Jun 2026 22:09:06 -0600 Subject: [PATCH 5/5] Fix incorrect list api. --- test_mom/boundary/test_boundary_exchange.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_mom/boundary/test_boundary_exchange.cpp b/test_mom/boundary/test_boundary_exchange.cpp index be7b903..86937fb 100644 --- a/test_mom/boundary/test_boundary_exchange.cpp +++ b/test_mom/boundary/test_boundary_exchange.cpp @@ -41,7 +41,7 @@ TEST(BoundaryExchange, BoundaryMatchesAfterOneTimeStep) { amrex::IntVect lo(iGridStartLoc, jGridStartLoc, 0); amrex::IntVect hi(lo[0] + iLocalDataGridSize - 1, lo[1] + jLocalDataGridSize - 1, 0); - boxList.emplace_back(amrex::Box(lo, hi)); + boxList.push_back(amrex::Box(lo, hi)); processBoxList.push_back(i); }