Skip to content

Commit e9490c3

Browse files
authored
Merge pull request #422 from GEOS-ESM/feature/mathomp4/v12-fms-handling
v12: Updated FMS Handling
2 parents c92e335 + c3113c6 commit e9490c3

File tree

3 files changed

+73
-33
lines changed

3 files changed

+73
-33
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ workflows:
2323
checkout_fixture: true
2424
# V12 code uses a special branch for now.
2525
fixture_branch: feature/sdrabenh/gcm_v12
26+
develop_repos: "GEOSgcm_GridComp GEOSgcm_App GMAO_Shared FVdycoreCubed_GridComp fvdycore"
2627
# We comment out this as it will "undo" the fixture_branch
2728
#mepodevelop: true
2829
persist_workspace: true # Needs to be true to run fv3/gcm experiment, costs extra

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Changed
1919

20+
- Reworked FMS detection to better handle the different `FV_PRECISION` cases in `FindBaselibs.cmake`
2021
- Change f2py detection for the odd case where there might be multiple Python installations. For now, if the path to the Python executable does not match the path to the f2py executable, we issue a `WARNING`. We use a `WARNING` since some installations (e.g., Spack) will have the Python executable in a different location than the f2py executable.
2122
- Removed warning that Baselibs is not supported, to a STATUS message.
2223

external_libraries/FindBaselibs.cmake

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -277,42 +277,80 @@ if (Baselibs_FOUND)
277277
endif ()
278278

279279
# - fms_r4
280-
set (inc_fms_r4 ${BASEDIR}/FMS/include_r4)
281-
set (lib_fms_r4 ${BASEDIR}/FMS/lib/libfms_r4.a)
282-
add_library(FMS::fms_r4 STATIC IMPORTED)
283-
set_target_properties(FMS::fms_r4 PROPERTIES
284-
IMPORTED_LOCATION ${lib_fms_r4}
285-
INCLUDE_DIRECTORIES "${inc_fms_r4}"
286-
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r4}"
287-
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
288-
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
289-
)
290-
if (FMS_BUILT_WITH_YAML)
291-
target_link_libraries(FMS::fms_r4 INTERFACE ${LIBYAML_LIBRARIES})
292-
endif ()
293-
add_library(fms_r4 ALIAS FMS::fms_r4)
294-
set(FMS_R4_FOUND TRUE CACHE BOOL "fms_r4 Found" FORCE)
280+
if (FV_PRECISION STREQUAL R4 OR FV_PRECISION STREQUAL R4R8)
281+
# Use find_path and find_library to find the include and library
282+
find_path(FMS_INCLUDE_DIR_R4 NAMES fms.mod PATHS ${BASEDIR}/FMS/include_r4)
283+
find_library(FMS_LIBRARIES_R4 NAMES fms_r4 PATHS ${BASEDIR}/FMS/lib ${BASEDIR}/FMS/lib64)
284+
# We also need the path of where the library is for the INTERFACE_LINK_DIRECTORIES
285+
get_filename_component(FMS_LIBRARIES_DIR_R4 ${FMS_LIBRARIES_R4} DIRECTORY)
286+
add_library(FMS::fms_r4 STATIC IMPORTED)
287+
set_target_properties(FMS::fms_r4 PROPERTIES
288+
IMPORTED_LOCATION ${FMS_LIBRARIES_R4}
289+
INCLUDE_DIRECTORIES "${FMS_INCLUDE_DIR_R4}"
290+
INTERFACE_INCLUDE_DIRECTORIES "${FMS_INCLUDE_DIR_R4}"
291+
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
292+
INTERFACE_LINK_DIRECTORIES "${FMS_LIBRARIES_DIR_R4}"
293+
)
294+
if (FMS_BUILT_WITH_YAML)
295+
target_link_libraries(FMS::fms_r4 INTERFACE ${LIBYAML_LIBRARIES})
296+
endif ()
297+
# We will set FMS_R4_FOUND if both FMS_LIBRARIES_R4 and FMS_INCLUDE_DIR_R4 are found
298+
# and are valid files and directories respectively
299+
if (EXISTS ${FMS_LIBRARIES_R4} AND IS_DIRECTORY ${FMS_INCLUDE_DIR_R4})
300+
message(STATUS "Found FMS::fms_r4: ${FMS_LIBRARIES_R4}")
301+
message(STATUS "FMS::fms_r4 include directory: ${FMS_INCLUDE_DIR_R4}")
302+
set(FMS_R4_FOUND TRUE CACHE BOOL "fms_r4 Found" FORCE)
303+
else ()
304+
message(FATAL_ERROR "FMS::fms_r4 not found")
305+
endif()
306+
endif()
295307

296308
# - fms_r8
297-
set (inc_fms_r8 ${BASEDIR}/FMS/include_r8)
298-
set (lib_fms_r8 ${BASEDIR}/FMS/lib/libfms_r8.a)
299-
add_library(FMS::fms_r8 STATIC IMPORTED)
300-
set_target_properties(FMS::fms_r8 PROPERTIES
301-
IMPORTED_LOCATION ${lib_fms_r8}
302-
INCLUDE_DIRECTORIES "${inc_fms_r8}"
303-
INTERFACE_INCLUDE_DIRECTORIES "${inc_fms_r8}"
304-
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
305-
INTERFACE_LINK_DIRECTORIES "${BASEDIR}/FMS/lib"
306-
)
307-
if (FMS_BUILT_WITH_YAML)
308-
target_link_libraries(FMS::fms_r8 INTERFACE ${LIBYAML_LIBRARIES})
309-
endif ()
310-
add_library(fms_r8 ALIAS FMS::fms_r8)
311-
set(FMS_R8_FOUND TRUE CACHE BOOL "fms_r8 Found" FORCE)
309+
if (FV_PRECISION STREQUAL R8 OR FV_PRECISION STREQUAL R4R8)
310+
# Use find_path and find_library to find the include and library
311+
find_path(FMS_INCLUDE_DIR_R8 NAMES fms.mod PATHS ${BASEDIR}/FMS/include_r8)
312+
find_library(FMS_LIBRARIES_R8 NAMES fms_r8 PATHS ${BASEDIR}/FMS/lib ${BASEDIR}/FMS/lib64)
313+
# We also need the path of where the library is for the INTERFACE_LINK_DIRECTORIES
314+
get_filename_component(FMS_LIBRARIES_DIR_R8 ${FMS_LIBRARIES_R8} DIRECTORY)
315+
add_library(FMS::fms_r8 STATIC IMPORTED)
316+
set_target_properties(FMS::fms_r8 PROPERTIES
317+
IMPORTED_LOCATION ${FMS_LIBRARIES_R8}
318+
INCLUDE_DIRECTORIES "${FMS_INCLUDE_DIR_R8}"
319+
INTERFACE_INCLUDE_DIRECTORIES "${FMS_INCLUDE_DIR_R8}"
320+
INTERFACE_LINK_LIBRARIES "NetCDF::NetCDF_Fortran;MPI::MPI_Fortran"
321+
INTERFACE_LINK_DIRECTORIES "${FMS_LIBRARIES_DIR_R8}"
322+
)
323+
if (FMS_BUILT_WITH_YAML)
324+
target_link_libraries(FMS::fms_r8 INTERFACE ${LIBYAML_LIBRARIES})
325+
endif ()
326+
# We will set FMS_R8_FOUND if both FMS_LIBRARIES_R8 and FMS_INCLUDE_DIR_R8 are found
327+
# and are valid files and directories respectively
328+
if (EXISTS ${FMS_LIBRARIES_R8} AND IS_DIRECTORY ${FMS_INCLUDE_DIR_R8})
329+
message(STATUS "Found FMS::fms_r8: ${FMS_LIBRARIES_R8}")
330+
message(STATUS "FMS::fms_r8 include directory: ${FMS_INCLUDE_DIR_R8}")
331+
set(FMS_R8_FOUND TRUE CACHE BOOL "fms_r8 Found" FORCE)
332+
else ()
333+
message(FATAL_ERROR "FMS::fms_r8 not found")
334+
endif()
335+
endif()
312336

313-
if (FMS_R4_FOUND AND FMS_R8_FOUND)
314-
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
315-
endif ()
337+
if (FV_PRECISION STREQUAL R4R8)
338+
# We will set FMS_FOUND if both fms_r4 and fms_r8 are found
339+
# and are valid files and directories respectively
340+
if (FMS_R4_FOUND AND FMS_R8_FOUND)
341+
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
342+
endif()
343+
elseif (FV_PRECISION STREQUAL R4)
344+
if (FMS_R4_FOUND)
345+
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
346+
endif()
347+
elseif (FV_PRECISION STREQUAL R8)
348+
if (FMS_R8_FOUND)
349+
set(FMS_FOUND TRUE CACHE BOOL "FMS Found" FORCE)
350+
endif()
351+
else()
352+
message(FATAL_ERROR "FMS Detection failed in odd way")
353+
endif()
316354

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

0 commit comments

Comments
 (0)