Skip to content

add initial cmake build#180

Open
rem1776 wants to merge 6 commits into
NOAA-GFDL:mainfrom
rem1776:cmake-null-model
Open

add initial cmake build#180
rem1776 wants to merge 6 commits into
NOAA-GFDL:mainfrom
rem1776:cmake-null-model

Conversation

@rem1776

@rem1776 rem1776 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

adds a cmakelists to build the coupler code and any components. I only used it for the null model, but tried to make things generic enough so that it can be easily used for other models.

This also includes a run test using ctest from the null model build script.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an initial CMake-based build for FMScoupler (and its component libraries) and wires up a basic end-to-end null-model run via CTest, with accompanying README documentation to describe the new build/test flow.

Changes:

  • Added a top-level CMakeLists.txt to build the coupler drivers (“full” and “simple”) and component libraries, with optional dependency fetching via FetchContent.
  • Added a new ctest-invoked null-model run script (t/test_run.sh) to exercise the built executables.
  • Updated README.md with a new section describing repository structure and CMake build/test usage.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 16 comments.

File Description
CMakeLists.txt Adds initial CMake build system, dependency fetching/symlinking, library/executable targets, and a CTest entry.
t/test_run.sh Adds an end-to-end runtime test script intended to be executed from CTest.
README.md Documents the new build system and provides example build/test commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CMakeLists.txt
Comment on lines +27 to +28
set(EXTERNAL_SOURCE_DIR ${CMAKE_SOURCE_DIR}/external)
file(MAKE_DIRECTORY ${EXTERNAL_SOURCE_DIR})
Comment thread CMakeLists.txt
Comment on lines +81 to +83
else()
add_subdirectory(${fms_path} ${CMAKE_CURRENT_BINARY_DIR}/fms_build)
endif()
Comment thread CMakeLists.txt
file(GLOB_RECURSE component_srcs ${EXTERNAL_SOURCE_DIR}/${component_name}/*.F90)
# TODO if/when cmake is added to component libraries, this should use add_subdirectory instead
add_library(${component_name} STATIC ${component_srcs})
target_include_directories(${component_name} PUBLIC ${EXTERNAL_SOURCE_DIR}/FMS)
Comment thread CMakeLists.txt
Comment on lines +103 to +105
SOURCE_DIR ${EXTERNAL_SOURCE_DIR}/${component_name}
GIT_TAG main
)
Comment thread CMakeLists.txt

# Build libraries for each external component
foreach(component_name IN LISTS COMPONENTS)
file(GLOB_RECURSE component_srcs ${EXTERNAL_SOURCE_DIR}/${component_name}/*.F90)
Comment thread t/test_run.sh
Comment on lines +14 to +16
tarFile=coupler_null_test_data_full_simple.tar.gz
curl -O ftp://ftp.gfdl.noaa.gov/perm/GFDL_pubrelease/test_data/${tarFile}
tar zxf ${tarFile}
Comment thread t/test_run.sh
curl -O ftp://ftp.gfdl.noaa.gov/perm/GFDL_pubrelease/test_data/${tarFile}
tar zxf ${tarFile}
# add an io layout to the full nml
sed -i '22i io_layout = 1, 1' input-full.nml
Comment thread README.md
Comment on lines +38 to +42
The "full" coupler has 5 direct dependencies: FMS[github.com/noaa-gfdl/fms], "ice_model_mod", "land_model_mod",
"atmos_model_mod", "ocean_model_mod". The "simple" coupler differs in that in does not require a ocean model, and
includes its own ice_model module, rather than using an external repository. "ice_param" is a dependency of the simple
ice_model, so is also included in the build. It is commonly used by GFDL ice models as well, so will be linked with
the ice component by default.
Comment thread README.md
Comment on lines +47 to +48
A cmake build is available to build the coupler and component libraries. It is currently only tested with the null model
and supports either locally cloned repositories or automagically cloning components during configuration.
Comment thread README.md

To build using local components, all source code must be cloned in a single directory:

```{shell}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants