Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c6c7eef
changes to compile all unit tests via cmake and add in cmake test-lib…
Apr 17, 2025
b985446
add mpp unit test scripts
Apr 22, 2025
10d3f5d
mixed precision updates and fixes to use test-lib for both build systems
Apr 29, 2025
2c7869a
Merge branch 'main' of github.com:noaa-gfdl/fms into cmake-updates
May 1, 2025
10ac33b
update debug flags
May 1, 2025
436d708
revert changes to mosaic2 helper module
May 8, 2025
64d120a
Merge branch 'NOAA-GFDL:main' into cmake-updates
rem1776 May 15, 2025
a3ae512
remove real size flag
rem1776 May 15, 2025
c088182
fix test_fms directory/executable overlap by adding build directory t…
rem1776 May 15, 2025
a377d46
take out the lame executable test
rem1776 May 15, 2025
db7f16e
add labels and fix for mpp ascii read test
May 19, 2025
e9e04c3
Merge branch 'cmake-updates' of github.com:rem1776/FMS into cmake-upd…
May 19, 2025
1772c6b
fix for mpp ascii test, remove unused test-lib.sh.in
May 19, 2025
502d97b
unify precision macro names
May 28, 2025
810f343
fixed the DO tests
May 28, 2025
94bea35
Data override test fix
Jun 3, 2025
c68092e
Apply suggestions from code review
rem1776 Jun 4, 2025
ca15c94
Merge branch 'main' into cmake-updates
rem1776 Jun 5, 2025
1eeeddc
remove 64bit flag
rem1776 Jun 9, 2025
a209999
CPPFLAGS fix for test_axis r4 and r8
Jun 17, 2025
3bd3248
Merge remote-tracking branch 'vs/singlemacro' into cmake-updates
Jul 3, 2025
f12f78b
Merge branch 'main' into cmake-updates
rem1776 Jul 10, 2025
b957dd3
Merge branch 'main' of github.com:noaa-gfdl/fms into cmake-updates
Aug 5, 2025
d83abe7
list test src explicitly and fix any lingering precision issues
Aug 6, 2025
7e325c1
update flags to match mkmf templates and multiple test fixes
Aug 19, 2025
5d2a8d4
Merge branch 'cmake-updates' of github.com:rem1776/fms into cmake-upd…
Aug 20, 2025
8050e20
changes for autotools and add a missed new helper file for mosaic
Aug 20, 2025
cecc9e4
fix C flags for yaml builds
Aug 20, 2025
0badd96
clean up env variables in test scripts for parser build option
Aug 20, 2025
99d181b
fix conditional for field manager
Aug 20, 2025
4b63446
fixes for tridiagonal and column diagnostic tests
Aug 20, 2025
12ccd0b
add new output file location to cleanfiles for coupler tests
Aug 20, 2025
a12970d
missed some output files
Aug 21, 2025
06d81cc
revert change to default off for quad precision to line up with autot…
Aug 21, 2025
8a69d09
simplify build type options and compiler flags
Aug 21, 2025
b034f50
missed the fortran max line length flag for GNU
Aug 21, 2025
b904727
linter
Aug 21, 2025
842ddc5
Merge remote-tracking branch 'upstream/main' into cmake-updates
Aug 21, 2025
f7e21b2
rename skip variable used in added diag manager test
Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions .github/workflows/github_cmake_gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,17 @@ jobs:
container:
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0
env:
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }} -D64BIT=on"
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }}"
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Generate makefiles with CMake
run: cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view
- name: Build the library
run: make
- name: Link with basic executable
run: |
echo "program test" > test.F90
echo " use fms_mod" >> test.F90
echo " call fms_init" >> test.F90
echo " call fms_end" >> test.F90
echo "end program" >> test.F90
mpifort -L/opt/view/lib -fopenmp `nf-config --flibs` -Iinclude_r4 -Iinclude_r8 test.F90 libfms_r4.a libfms_r8.a -o test.x
touch input.nml
- name: Run executable
run: ./test.x
mkdir build
cd build
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view ..
Copy link
Contributor

Choose a reason for hiding this comment

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

Using spack containers, nice!

- name: Build the library
run: make -C build

build_arm:
runs-on: ubuntu-24.04-arm
Expand All @@ -48,22 +40,14 @@ jobs:
container:
image: ghcr.io/noaa-gfdl/fms/fms-ci-rocky-gnu:13.2.0-arm
env:
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }} -D64BIT=on"
CMAKE_FLAGS: "${{ matrix.build-type }} ${{ matrix.omp-flags }} ${{ matrix.libyaml-flag }}"
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Generate makefiles with CMake
run: cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view
- name: Build the library
run: make
- name: Link with basic executable
run: |
echo "program test" > test.F90
echo " use fms_mod" >> test.F90
echo " call fms_init" >> test.F90
echo " call fms_end" >> test.F90
echo "end program" >> test.F90
mpifort -L/opt/view/lib -fopenmp `nf-config --flibs` -Iinclude_r4 -Iinclude_r8 test.F90 libfms_r4.a libfms_r8.a -o test.x
touch input.nml
- name: Run executable
run: ./test.x
mkdir build
cd build
cmake $CMAKE_FLAGS -DNetCDF_ROOT=/opt/view -DLIBYAML_ROOT=/opt/view ..
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this running the tests?

- name: Build the library
run: make -C build
58 changes: 38 additions & 20 deletions CMAKE_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
\page cmake Building with CMake
# Instructions for building FMS with cmake

## 1. Environment Variables
## 1. Configuring the build

### For GNU compilers on Linux with the bash shell:
### Environment Variables

#### For GNU compilers on Linux with the bash shell:
```
export FC=mpifort
export CC=mpicc
```

### For Intel Compilers on Linux with the bash shell:

#### For Intel Compilers on Linux with the bash shell:
```
export FC=mpiifort
export CC=mpiicc
```
MPI compiler wrappers may be named different on your system, so its best to ensure the compiler commands work prior to being set.

### NetCDF is provided via the `nc-config` command:
#### NetCDF is provided via the `nc-config` command:
```
export NetCDF_ROOT=`nc-config --prefix`
```

### If building with yaml parser (-DWITH_YAML)
#### If building with yaml parser (-DWITH_YAML)
```
export LIBYAML_ROOT=<your libyaml install directory>
```

### Setting custom flags with the bash shell
To override the default compiler flags:
### Running CMake
It's best to create a build directory inside of the FMS folder to avoid building on top of the source code.
Once that is done, CMake can be ran to generate the necessary build files:
```
export FCFLAGS="<fortran flags>"
export CFLAGS="<c flags>"
mkdir build && cd build
cmake [-DWITH_YAML=on] ..
```
In addition, the flag below must be included with the cmake command:

### Setting a Build Type
CMake uses "build types" to set compiler flags. By default (.ie no -DCMAKE_BUILD_TYPE="Type" argument when cmake is run), it will use the "Release" build type which corresponds the the prod/opt flags used by the GFDL mkmf templates.

Similarly "Repro" and "Debug" also correspond to whatever options would be set by theircorresponding mkmf template files.

To reproduce the old behavior for the cmake build (2025.03 and prior), the "ReleaseUFS" and "DebugUFS" will use the same flags as before.

Please open an issue in the FMS repository if you have any issues or would like to request any changes to the current build type options.

### Setting custom flags
To override the default compiler flags, you can set them via CMake arguments:
```
cmake <any other options> -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_BUILD_TYPE="NoFlags" -DCMAKE_C_FLAGS="<c flags>" -DCMAKE_Fortran_FLAGS="<fortran flags>"
```
By using the "NoFlags" build type, only necessary compilation flags will be added besides what is set via the cmake arguments.

## 2. Build and install FMS with CMake
`<prefix>` is the full install directory for FMS provided by user
Expand All @@ -45,20 +58,25 @@ cmake <any other options> -DCMAKE_BUILD_TYPE=Debug ..
cd FMS
mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=<prefix> ..
make -j4
make -j
make install
```

### User configurable options:
By default, FMS is built without `OpenMP`, in `single precision (r4)` and delivered in static library files.
By default, FMS is built with `OpenMP` enabled and delivered in static library files.

FMS has mixed precision real support for most interfaces. By default, one library will be created,
`libfms`, that is compiled with r8 defaults but also contains overloaded r4 routines.

The 64BIT and 32BIT precision options will build distinct libraries when enabled with the given default
real size, libfms_r4 or libfms_r8.
real size, libfms_r4 or libfms_r8. These option are provided for backwards compatibility, but are no longer
supported by our development team, since mixed precision can now be used with a single library.
Unit tests currently only work when no precision option is specified.

The following build options are available:
```
-DOPENMP "Build FMS with OpenMP support" DEFAULT: OFF
-D32BIT "Build 32-bit (r4) FMS library" DEFAULT: ON
-DOPENMP "Build FMS with OpenMP support" DEFAULT: ON
-D32BIT "Build 32-bit (r4) FMS library" DEFAULT: OFF

Choose a reason for hiding this comment

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

enabling -D64BIT=ON made my cmake configuration fail because the tests were trying to find FMS::fms and it was not built. I can patch this in my PR #1743 to just either not build the tests or fail

-D64BIT "Build 64-bit (r8) FMS library" DEFAULT: OFF
-DFPIC "Build with position independent code" DEFAULT: OFF
-DSHARED_LIBS "Build shared/dynamic libraries" DEFAULT: OFF
Expand All @@ -74,10 +92,10 @@ The following build options are available:

## 3. Installation structure

When the above command finishes, the `<prefix>` will have an `include_r4` and a `lib` directory. The `lib ` directory will have these files:
When the above command finishes, the `<prefix>` will have an `include` and a `lib` directory. The `lib ` directory will have these files:

```
libfms_r4.a
libfms.a
cmake/fms/fms-targets.cmake
cmake/fms/fms-targets-release.cmake
cmake/fms/fms-config.cmake
Expand Down
Loading
Loading