Skip to content

Commit 5fd0c52

Browse files
authored
Merge pull request #30 from fmalatino/cmake
CMake installation method
2 parents ea76360 + 5d49f84 commit 5fd0c52

File tree

13 files changed

+602
-6
lines changed

13 files changed

+602
-6
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build libcFMS test with CMake
2+
3+
on: [push, pull_request]
4+
5+
# cancel running jobs if theres a newer push
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
11+
jobs:
12+
cmake_install:
13+
runs-on: ubuntu-latest
14+
container:
15+
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0
16+
env:
17+
PKG_CONFIG_PATH: "/opt/views/view/lib64/pkgconfig:/opt/views/view/lib/pkgconfig:/opt/views/view/share/pkgconfig"
18+
steps:
19+
- name: checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
submodules: 'recursive'
23+
- name: Generate makefiles with CMake
24+
run: |
25+
cmake -B build -DCFMS_TESTS=on -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view
26+
- name: Build library and tests
27+
run: make -C build
28+
- name: Run tests
29+
run: cd build && ctest --output-on-failure
30+

CMakeLists.txt

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#***********************************************************************
2+
#* Apache License 2.0
3+
#*
4+
#* This file is part of the GFDL Flexible Modeling System (FMS).
5+
#*
6+
#* Licensed under the Apache License, Version 2.0 (the "License");
7+
#* you may not use this file except in compliance with the License.
8+
#* You may obtain a copy of the License at
9+
#*
10+
#* http://www.apache.org/licenses/LICENSE-2.0
11+
#*
12+
#* FMS is distributed in the hope that it will be useful, but WITHOUT
13+
#* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied;
14+
#* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
#* PARTICULAR PURPOSE. See the License for the specific language
16+
#* governing permissions and limitations under the License.
17+
#***********************************************************************
18+
19+
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
20+
21+
# Build options
22+
option(PORTABLE_KINDS "Enable compiler defition -DPORTABLE_KINDS" ON)
23+
option(WITH_YAML "Enable compiler definition -Duse_yaml" ON)
24+
option(CFMS_TESTS "Enable compiling of test scripts" OFF)
25+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
26+
27+
include(FetchContent)
28+
29+
#Define the cmake project
30+
project(cFMS
31+
VERSION 2026.01.0
32+
DESCRIPTION "C Access to GFDL FMS Library"
33+
HOMEPAGE_URL "https://github.com/NOAA-GFDL/cFMS"
34+
LANGUAGES C Fortran)
35+
36+
if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|IntelLLVM)$")
37+
message(
38+
WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID)}"
39+
)
40+
endif()
41+
42+
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|IntelLLVM)$")
43+
message(
44+
WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}"
45+
)
46+
endif()
47+
48+
# Find dependencies
49+
50+
FetchContent_Declare(
51+
FMS
52+
GIT_REPOSITORY https://github.com/NOAA-GFDL/FMS.git
53+
GIT_TAG 043ab2f6037af92997aa72a467430e95c03652ae
54+
)
55+
FetchContent_MakeAvailable(FMS)
56+
57+
list(APPEND cfms_src_files
58+
c_constants/c_constants.F90
59+
c_data_override/c_data_override.F90
60+
c_diag_manager/c_diag_manager.F90
61+
c_fms/c_fms.F90
62+
c_fms_utils/c_fms_utils.F90
63+
c_grid_utils/c_grid_utils.F90
64+
c_horiz_interp/c_horiz_interp.F90
65+
)
66+
67+
list(APPEND cfms_header_files
68+
c_constants/c_constants.h
69+
c_data_override/c_data_override.h
70+
c_diag_manager/c_diag_manager.h
71+
c_fms/c_fms.h
72+
c_grid_utils/c_grid_utils.h
73+
c_horiz_interp/c_horiz_interp.h
74+
)
75+
76+
add_library(cFMS SHARED
77+
${cfms_src_files}
78+
)
79+
80+
target_link_libraries(cFMS PUBLIC
81+
FMS::fms
82+
${LIBYAML_LIBRARIES}
83+
)
84+
85+
target_include_directories(cFMS PRIVATE
86+
c_data_override/include
87+
c_diag_manager/include
88+
c_fms/include
89+
c_fms_utils/include
90+
c_horiz_interp/include
91+
${CMAKE_CURRENT_SOURCE_DIR}/FMS/include
92+
)
93+
94+
install(TARGETS cFMS
95+
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}
96+
)
97+
install(FILES ${cfms_header_files}
98+
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
99+
100+
# Tests
101+
if(CFMS_TESTS)
102+
enable_testing()
103+
add_subdirectory(test_cfms)
104+
endif()
105+
106+
107+

FMS

Submodule FMS updated 262 files

c_fms/c_fms.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ subroutine cFMS_declare_pelist(npes, pelist, name, commID) bind(C, name="cFMS_de
222222
integer, intent(in) :: npes
223223
integer, intent(in) :: pelist(npes)
224224
character(c_char), intent(in), optional :: name(NAME_LENGTH)
225-
integer, intent(out), optional :: commID
225+
integer, intent(out) :: commID
226226

227227
character(len=NAME_LENGTH) :: name_f=" " !mpp default
228228

@@ -252,7 +252,7 @@ subroutine cFMS_get_current_pelist(npes, pelist, name, commID) bind(C, name="cFM
252252
integer, intent(in) :: npes
253253
integer, intent(out) :: pelist(npes)
254254
character(c_char), intent(out), optional :: name(NAME_LENGTH)
255-
integer, intent(out), optional :: commID
255+
integer, intent(out) :: commID
256256

257257
character(len=NAME_LENGTH) :: name_f=" " !mpp default
258258

0 commit comments

Comments
 (0)