Implement CMake build system for TIM#16
Merged
Merged
Conversation
…ld-system-for-TIM
- Remove if(NOT build_type STREQUAL debug) guard on precision flags so -fdefault-real-8 is always applied to Fortran sources; without this, tim_chksum generic resolution fails at Debug build time because TIM compiles real as 4-byte while MOM6 always uses 8-byte. - TIMConfig.cmake.in: add FMS-style R4/R8 component validation loop, default to R8, emit per-target status lines matching fms-config.cmake. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, --ninja flag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
hctorres
requested review from
alperaltuntas,
johnmauff,
mnlevy1981 and
mwaxmonsky
May 12, 2026 07:21
hctorres
marked this pull request as draft
May 12, 2026 17:56
TIM's C++ object files and the AMReX static archive it depends on reference the C++ standard library (e.g. __cxa_call_terminate). When the consuming executable is driven by gfortran -- or by a g++ install whose CMAKE_CXX_IMPLICIT_LINK_LIBRARIES is empty (some spack-built compilers on NCAR Derecho) -- libstdc++ never reaches the link line and amrex symbols come up undefined. Declare the C++ runtime explicitly via per-compiler generator expressions so the dependency is honest and the link resolves regardless of how the consumer's driver was configured. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous commit attached the stdc++/c++ generator expression to
tim_r{4,8}, which placed -lstdc++ before libamrex_3d.a in the
consumer's link line. GNU ld with --as-needed (default on some Linux
distros incl. NCAR Derecho) then dropped libstdc++ before AMReX's
undefined __cxa_call_terminate refs were seen, so the link still
failed.
Relocate the runtime to the tim target (the actual C++ shim that
pulls in AMReX), positioned after AMReX::amrex. That guarantees
-lstdc++ lands after libamrex_3d.a in the consumer's link order,
which is what --as-needed needs to see.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ld-system-for-TIM
This workflow tested a standalone "libFMS via cmake" build inside a GFDL container that has no AMReX. The CMakeLists in this repo now requires AMReX, so the workflow has been failing on every push since TIM picked up that dependency. The real cmake build path is covered by turbo-stack's "Build MOM6 with TIM and FMS" job. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ld-system-for-TIM
Two consumer-facing bugs in the installed TIM cmake package: 1. TIMConfig.cmake.in included tim-targets.cmake BEFORE find_dependency(). The exported targets reference NetCDF::, MPI::, AMReX::amrex by name; cmake errors out at include() because those imported targets don't yet exist. Resolve transitive deps first, then include tim-targets.cmake. 2. TIM_FIND_COMPONENTS defaulted to R8 even when TIM was built with the cmake default (32BIT=ON, 64BIT=OFF, R8 not installed). find_package(TIM) then succeeded with no usable target. Default the requested component to one of the components actually built (R8 if 64BIT=ON, else R4). Plus targeted fixes uncovered during review: - Save/restore CMAKE_MODULE_PATH instead of REMOVE_ITEM (drops a pre-existing matching entry). - find_dependency(AMReX COMPONENTS FORTRAN) — consumers must get the same component TIM linked against. - Drop CXX from MPI components — Fortran-only consumers shouldn't fail on systems lacking C++ MPI bindings. - target_compile_features(tim PUBLIC cxx_std_20): tim_profile.hpp and tim_coms_infra_C_API.h ship in the public include interface, so the C++20 requirement must propagate. - Map IntelLLVM to libstdc++ (its Linux default) instead of libc++ in the runtime-link genex. - Rename installed file to TIMConfigVersion.cmake so versioned find_package(TIM <version>) works (cmake derives the version filename from the config stem).
This was referenced May 27, 2026
hctorres
marked this pull request as ready for review
May 27, 2026 05:50
johnmauff
requested changes
May 28, 2026
johnmauff
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the PR. Let me know if you have any questions regarding my comments.
…now defaults to 64 bit.
mwaxmonsky
approved these changes
Jun 3, 2026
mwaxmonsky
left a comment
Contributor
There was a problem hiding this comment.
Looks great @hctorres! Just had one question (that overlaps slightly with the MOM6 comments) but nothing that should hold up the PR.
alperaltuntas
approved these changes
Jun 4, 2026
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.
Summary
TIMConfig.cmake.insupporting FMS-stylefind_package(TIM COMPONENTS R4|R8)component selection.
tim_coms_infra,tim_profile) as a separatetimstatic library linked intotim_r4/tim_r8.TIM::tim_r4andTIM::tim_r8namespace alias targets; config files install tolib/cmake/tim/for standardTIM_DIRhint compatibility.64BIT=ON, else R4) sofind_package(TIM)with noexplicit
COMPONENTSsucceeds against any valid install.TIMConfig.cmakeresolves transitive deps (find_dependency(MPI|NetCDF|AMReX FORTRAN)) before includingtim-targets.cmake, so the imported targets it references are defined when needed.build.shwith--debug(clean rebuild),--ninja(opt-in; default Unix Makefiles), and--build-diroptions.build_cmake_gnu.ymlCI workflow (no longer accurate; CMake build is now exercised end-to-end viathe turbo-stack workflows).
Environment
For now you'll need MPI, NetCDF, and AMReX (with the FORTRAN component) available on
CMAKE_PREFIX_PATH. turbo-stack has a script to set this up for you on derecho.Test plan
find_package(TIM REQUIRED COMPONENTS R8)works from turbo-stack — verified by the turbo-stack workflows (BuildMOM6 with TIM and FMS, Build Inside NCAR HPC Development Containers) all currently green.