Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v12: Updated FMS Handling #422

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ workflows:
checkout_fixture: true
# V12 code uses a special branch for now.
fixture_branch: feature/sdrabenh/gcm_v12
develop_repos: "GEOSgcm_GridComp GEOSgcm_App GMAO_Shared FVdycoreCubed_GridComp fvdycore"
# We comment out this as it will "undo" the fixture_branch
#mepodevelop: true
persist_workspace: true # Needs to be true to run fv3/gcm experiment, costs extra
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

[4.11.0] - 2025-01-03
## [4.12.0] - 2025-01-30

### Changed

- Reworked FMS detection to better handle the different `FV_PRECISION` cases in `FindBaselibs.cmake`

## [4.11.0] - 2025-01-03

### Changed

Expand Down
102 changes: 68 additions & 34 deletions external_libraries/FindBaselibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -281,43 +281,77 @@ if (Baselibs_FOUND)
message(STATUS "LIBYAML_LIBRARIES: ${LIBYAML_LIBRARIES}")
endif ()

# - fms_r4
set (inc_fms_r4 ${BASEDIR}/FMS/include_r4)
set (lib_fms_r4 ${BASEDIR}/FMS/lib/libfms_r4.a)
add_library(FMS::fms_r4 STATIC IMPORTED)
set_target_properties(FMS::fms_r4 PROPERTIES
IMPORTED_LOCATION ${lib_fms_r4}
INCLUDE_DIRECTORIES "${inc_fms_r4}"
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r4}"
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
)
if (FMS_BUILT_WITH_YAML)
target_link_libraries(FMS::fms_r4 INTERFACE ${LIBYAML_LIBRARIES})
endif ()
add_library(fms_r4 ALIAS FMS::fms_r4)
set(FMS_R4_FOUND TRUE CACHE BOOL "fms_r4 Found" FORCE)
if (FV_PRECISION STREQUAL R4 OR FV_PRECISION STREQUAL R4R8)
# - fms_r4
set (inc_fms_r4 ${BASEDIR}/FMS/include_r4)
set (lib_fms_r4 ${BASEDIR}/FMS/lib/libfms_r4.a)
add_library(FMS::fms_r4 STATIC IMPORTED)
set_target_properties(FMS::fms_r4 PROPERTIES
IMPORTED_LOCATION ${lib_fms_r4}
INCLUDE_DIRECTORIES "${inc_fms_r4}"
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r4}"
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
)
if (FMS_BUILT_WITH_YAML)
target_link_libraries(FMS::fms_r4 INTERFACE ${LIBYAML_LIBRARIES})
endif ()
#add_library(fms_r4 ALIAS FMS::fms_r4)
# We will set FMS_R4_FOUND if both lib_fms_r4 and inc_fms_r4 are found
# and are valid files and directories respectively
if (EXISTS ${lib_fms_r4} AND IS_DIRECTORY ${inc_fms_r4})
message(STATUS "Found FMS::fms_r4: ${lib_fms_r4}")
message(STATUS "FMS::fms_r4 include directory: ${inc_fms_r4}")
set(FMS_R4_FOUND TRUE CACHE BOOL "fms_r8 Found" FORCE)
else ()
message(FATAL_ERROR "FMS::fms_r8 not found")
endif()
endif()

# - fms_r8
set (inc_fms_r8 ${BASEDIR}/FMS/include_r8)
set (lib_fms_r8 ${BASEDIR}/FMS/lib/libfms_r8.a)
add_library(FMS::fms_r8 STATIC IMPORTED)
set_target_properties(FMS::fms_r8 PROPERTIES
IMPORTED_LOCATION ${lib_fms_r8}
INCLUDE_DIRECTORIES "${inc_fms_r8}"
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r8}"
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
)
if (FMS_BUILT_WITH_YAML)
target_link_libraries(FMS::fms_r8 INTERFACE ${LIBYAML_LIBRARIES})
endif ()
add_library(fms_r8 ALIAS FMS::fms_r8)
set(FMS_R8_FOUND TRUE CACHE BOOL "fms_r8 Found" FORCE)
if (FV_PRECISION STREQUAL R8 OR FV_PRECISION STREQUAL R4R8)
set (inc_fms_r8 ${BASEDIR}/FMS/include_r8)
set (lib_fms_r8 ${BASEDIR}/FMS/lib/libfms_r8.a)
add_library(FMS::fms_r8 STATIC IMPORTED)
set_target_properties(FMS::fms_r8 PROPERTIES
IMPORTED_LOCATION ${lib_fms_r8}
INCLUDE_DIRECTORIES "${inc_fms_r8}"
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r8}"
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
)
if (FMS_BUILT_WITH_YAML)
target_link_libraries(FMS::fms_r8 INTERFACE ${LIBYAML_LIBRARIES})
endif ()
#add_library(fms_r8 ALIAS FMS::fms_r8)
# We will set FMS_R8_FOUND if both lib_fms_r8 and inc_fms_r8 are found
# and are valid files and directories respectively
if (EXISTS ${lib_fms_r8} AND IS_DIRECTORY ${inc_fms_r8})
message(STATUS "Found FMS::fms_r8: ${lib_fms_r8}")
message(STATUS "FMS::fms_r8 include directory: ${inc_fms_r8}")
set(FMS_R8_FOUND TRUE CACHE BOOL "fms_r8 Found" FORCE)
else ()
message(FATAL_ERROR "FMS::fms_r8 not found")
endif()
endif()

if (FMS_R4_FOUND AND FMS_R8_FOUND)
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
endif ()
if (FV_PRECISION STREQUAL R4R8)
# We will set FMS_FOUND if both fms_r4 and fms_r8 are found
# and are valid files and directories respectively
if (FMS_R4_FOUND AND FMS_R8_FOUND)
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
endif()
elseif (FV_PRECISION STREQUAL R4)
if (FMS_R4_FOUND)
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
endif()
elseif (FV_PRECISION STREQUAL R8)
if (FMS_R8_FOUND)
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
endif()
else()
message(FATAL_ERROR "FMS Detection failed in odd way")
endif()

if (FMS_FOUND)
set (FMS_DIR ${BASEDIR}/FMS CACHE PATH "Path to FMS" FORCE)
Expand Down