Skip to content

Conversation

@rem1776
Copy link
Contributor

@rem1776 rem1776 commented May 1, 2025

Description
This pr updates the cmake build in an effort to behave more similar to autotools, and makes the following changes:

  • Changes the default value for QUAD_PRECISION and OpenMP options (to off and on, respectively)

  • Renames the "Release" and "Debug" build type flags to "ReleaseUFS" and "DebugUFS"

  • Simplifies Release/Debug build types to just add optimization flags and debug info:
    Release -> -O3
    Debug -> -O0 -g

  • updates how mixed precision is handled. Previously a kind type had to be provided when cmake is run, but now if no kind is given it will just build one 8 byte real default version of the library (which includes support for 4 byte reals for most routines as well) and not include the kind size in the built library name. If the kind size is specified, it will behave as it has before for backwards compatibility.

  • Fixes an invalid llvm intel flag for the C compiler (Fixes Intel LLVM Debug Flags have incorrect flag (for icx 2025.1 at least) #1687)

  • Adds unit testing via ctest

  • Updates markdown files for testing and the cmake build instructions

How Has This Been Tested?
cmake + make test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

@rem1776 rem1776 marked this pull request as ready for review May 22, 2025 15:14
@rem1776
Copy link
Contributor Author

rem1776 commented May 22, 2025

@mathomp4 @aerorahul @dkokron Just wanted to make you aware of these updates and hear any thoughts. We're trying to move towards CMake as our "main" supported build system.

Copy link
Contributor

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

High-level review. Didn't run any tests myself, but CI tests all pass and not seeing any red flags either.

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!

@rem1776 rem1776 requested a review from vithikashah001 as a code owner June 4, 2025 16:54
@rem1776 rem1776 changed the title cmake build type and mixed precision updates + initial ctest updates update cmake build for testing, build types and mixed precision Aug 19, 2025
Copy link
Contributor

@uramirez8707 uramirez8707 left a comment

Choose a reason for hiding this comment

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

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?

@rem1776
Copy link
Contributor Author

rem1776 commented Aug 21, 2025

@uramirez8707 @vithikashah001 @bensonr This PR should be ready now, I just updated the compiler flags based off the meeting discussion.

Copy link
Contributor

@uramirez8707 uramirez8707 left a comment

Choose a reason for hiding this comment

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

This is looks good to me

@vithikashah001 vithikashah001 merged commit 4e18fb9 into NOAA-GFDL:main Aug 21, 2025
28 of 29 checks passed
-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

# GNU Fortan
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fconvert=big-endian -ffree-line-length-none -fno-range-check -fbacktrace")
# GNU Fortran
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fallow-argument-mismatch -ffree-line-length-none")

Choose a reason for hiding this comment

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

note here: -fallow-argument-mismatch was introduced in GNU 10.x ish so if anyone tries anything below that, the compilation will fail.

@ONLY)

# build any helper modules that are used by unit tests
list(APPEND TEST_MODS_SRC

Choose a reason for hiding this comment

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

I know this has been merged already, just keeping the convo from the other PR going with a question here: is there a particular reason why all the files get specified from the top level dir downwards instead of using include_subdirectory and inside each subdir adding the files into the TARGET created?

@JorgeG94
Copy link

btw this is great, thanks so much for doing this!

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.

Intel LLVM Debug Flags have incorrect flag (for icx 2025.1 at least)

5 participants