Implement CMake build system for MOM6#25
Open
hctorres wants to merge 10 commits into
Open
Conversation
- Fix LANGUAGES: remove unused C/CXX from project() declaration - Add TURBO_INFRA and TURBO_MEMORY_MODE validation in MOM6Options.cmake - Add if(NOT TARGET) guards so MOM6 can be built without turbo-stack: finds FMS2 or TIM via find_package, finds MPI/NetCDF directly - Add cmake/MARBLTargets.cmake with MARBL source list; used by the standalone path when MARBL::marbl is not provided by a parent build - Add comment blocks explaining subdirectory vs standalone build modes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove double-nesting bug: after find_package(TIM), TIM_DIR is already set to the directory containing TIMConfig.cmake, so appending /lib/cmake/tim created an invalid path. - Change find_package(TIM REQUIRED) to find_package(TIM REQUIRED COMPONENTS R8) so CMake errors at configure time if TIM was built without 64BIT=ON. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…E_DIR guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e-build-system-for-MOM6
…mes. The recent dev/turbo merge added MOM_ANN.F90, MOM_diag_buffers.F90, and Recon1d_PLM_WLS.F90; deleted FMS_coupler_util.F90, generic_tracer.F90, and generic_tracer_utils.F90 (their functionality is folded into the new MOM_generic_tracer.F90); and renamed MOM_load_love_numbers.F90 to MOM_load_Love_numbers.F90 (case-only). The cmake lists weren't updated in lockstep because dev/turbo's autotools build doesn't enumerate sources by name. Reconcile here so the cmake build works again. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two HIGH findings from the pre-PR review: 1. CMAKE_MODULE_PATH was appended AFTER find_package(FMS|TIM) — useless, because FMSConfig.cmake / TIMConfig.cmake call find_dependency(NetCDF) during the find_package, before the append runs. On NetCDF installs without a CMake config file (e.g. NCAR Derecho's spack module), that transitive resolution requires FindNetCDF.cmake on the module path. Pre-discover the bundled FindNetCDF.cmake from the backend's install prefix (FMS_ROOT / TIM_ROOT env or var, or via CMAKE_PREFIX_PATH) and prepend it to CMAKE_MODULE_PATH *before* find_package, so the transitive NetCDF lookup succeeds. 2. pkg/CVMix-src and pkg/GSW-Fortran are git submodules. If a downstream clone forgot `git submodule update --init`, the cmake build silently reached target_sources() with missing files and failed with a cryptic "file not found" error. Add an explicit existence check on a known source file in each submodule, with a FATAL_ERROR pointing the user at the right git command.
This was referenced May 27, 2026
johnmauff
reviewed
May 28, 2026
| @@ -0,0 +1,121 @@ | |||
| # ── Why multiple framework libraries? ───────────────────────────────────────── | |||
There was a problem hiding this comment.
@hctorres, if I am adding a new file to the src/framework directory. How do I figure out which tier to add my file? Is there an easy way to figure this out?
Author
There was a problem hiding this comment.
Today it would be a manual process. You could grep the new file's use statements, map each used module to the tier it's defined in. In the future we might want to put each layer in its own directory to make what is used where more obvious but that would break the old build system if we did it now.
There was a problem hiding this comment.
@hctorres, if you could add comments in the CMakeLists.txt file about using AI to identify which tier a new file should go into that would be great.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of issue-192 cross-repo CMake build system effort
This PR is one of four coordinated changes:
dev/turbomaindev/turbomainRecommended merge order: FMS → TIM → MOM6 → turbo-stack. turbo-stack consumes this via
add_subdirectory(${MOM6_SOURCE_DIR} mom6_build).Summary
cmake/MOM6Options.cmakeis the canonical definition ofTURBO_INFRA(FMS2 | TIM) andTURBO_MEMORY_MODE; turbo-stack includes this file so both repos stay in sync on option names and defaults.cmake/MARBLTargets.cmakecreates theMARBL::marbltarget from source viaMARBL_SOURCE_DIR.CMakeLists.txtsupports both standalone (cmake -S MOM6 -B build) and subdirectory (add_subdirectory) builds viaif(NOT TARGET TURBO::infra_r8)guards for both the infra and MARBL targets.FindNetCDF.cmakeis pre discovered from the backend's install prefix (FMS_ROOT/TIM_ROOTenv or var, or viaCMAKE_PREFIX_PATH) beforefind_package(FMS|TIM), so the transitivefind_dependency(NetCDF)works on systems without aNetCDFConfig.cmake(e.g. NCAR Derecho's NetCDF module).MOM6::framework_base→MOM6::infra→MOM6::framework→MOM6::grid→MOM6::io→MOM6::ocean, plusMOM6::CVMix,MOM6::GSW, andMOM6::marbl. Transitive include propagation correct via PUBLIC scope.pkg/CVMix-srcandpkg/GSW-Fortransubmodules so an uninitialized clone fails with a clearFATAL_ERRORpointing at the right git command, instead of a cryptic "file not found" deep in the build.Environment
turbo-stack has a script to set up the environment for you on derecho.
Test plan