Skip to content

Commit

Permalink
Remove cmake/FindESMF.cmake and rename esmf target to ESMF::ESMF
Browse files Browse the repository at this point in the history
  • Loading branch information
DusanJovic-NOAA committed Aug 16, 2024
1 parent bfd347d commit c994cb0
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 151 deletions.
36 changes: 24 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[submodule "FV3"]
path = FV3
url = https://github.com/NOAA-EMC/fv3atm
branch = develop
#url = https://github.com/NOAA-EMC/fv3atm
#branch = develop
url = https://github.com/DusanJovic-NOAA/fv3atm
branch = remove_findesmf
[submodule "WW3"]
path = WW3
url = https://github.com/NOAA-EMC/WW3
branch = dev/ufs-weather-model
#url = https://github.com/NOAA-EMC/WW3
#branch = dev/ufs-weather-model
url = https://github.com/DusanJovic-NOAA/WW3
branch = remove_findesmf
[submodule "stochastic_physics"]
path = stochastic_physics
url = https://github.com/NOAA-PSL/stochastic_physics
Expand All @@ -18,8 +22,10 @@
branch = feature/remove_findesmf
[submodule "CMEPS"]
path = CMEPS-interface/CMEPS
url = https://github.com/NOAA-EMC/CMEPS
branch = emc/develop
#url = https://github.com/NOAA-EMC/CMEPS
#branch = emc/develop
url = https://github.com/DusanJovic-NOAA/CMEPS
branch = remove_findesmf
[submodule "HYCOM"]
path = HYCOM-interface/HYCOM
url = https://github.com/NOAA-EMC/HYCOM-src
Expand All @@ -34,17 +40,23 @@
branch = emc/develop
[submodule "CDEPS"]
path = CDEPS-interface/CDEPS
url = https://github.com/NOAA-EMC/CDEPS
branch = develop
#url = https://github.com/NOAA-EMC/CDEPS
#branch = develop
url = https://github.com/DusanJovic-NOAA/CDEPS
branch = remove_findesmf
[submodule "GOCART"]
path = GOCART
url = https://github.com/GEOS-ESM/GOCART
branch = develop
[submodule "AQM"]
path = AQM
url = https://github.com/NOAA-EMC/AQM
branch = develop
#url = https://github.com/NOAA-EMC/AQM
#branch = develop
url = https://github.com/DusanJovic-NOAA/AQM
branch = remove_findesmf
[submodule "NOAHMP"]
path = NOAHMP-interface/noahmp
url = https://github.com/NOAA-EMC/noahmp
branch = develop
#url = https://github.com/NOAA-EMC/noahmp
#branch = develop
url = https://github.com/DusanJovic-NOAA/noahmp
branch = remove_findesmf
2 changes: 1 addition & 1 deletion AQM
Submodule AQM updated 1 files
+5 −5 CMakeLists.txt
2 changes: 1 addition & 1 deletion CDEPS-interface/CDEPS
Submodule CDEPS updated 1 files
+0 −47 cmake/FindESMF.cmake
20 changes: 10 additions & 10 deletions CDEPS-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set_target_properties(share PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_
target_include_directories(share PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ufs/cdeps_share)
target_include_directories(share PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_compile_definitions(share PRIVATE ${CDEPS_SHARE_DEFS})
target_link_libraries(share PRIVATE esmf)
target_link_libraries(share PRIVATE ESMF::ESMF)

# CDEPS/streams
add_library(streams OBJECT ${cdeps_streams_files})
Expand All @@ -37,63 +37,63 @@ set_target_properties(streams PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURREN
target_include_directories(streams PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_compile_definitions(streams PUBLIC "DISABLE_FoX")
target_link_libraries(streams PRIVATE share)
target_link_libraries(streams PRIVATE esmf PIO::PIO_Fortran)
target_link_libraries(streams PRIVATE ESMF::ESMF PIO::PIO_Fortran)

# CDEPS/dshr
add_library(dshr OBJECT ${cdeps_dshr_files})
add_dependencies(dshr share streams)
set_target_properties(dshr PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dshr PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(dshr PRIVATE share streams)
target_link_libraries(dshr PRIVATE esmf PIO::PIO_Fortran)
target_link_libraries(dshr PRIVATE ESMF::ESMF PIO::PIO_Fortran)

# CDEPS/datm
add_library(datm OBJECT ${cdeps_datm_files})
add_dependencies(datm share streams dshr)
set_target_properties(datm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(datm PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(datm PRIVATE dshr share streams)
target_link_libraries(datm PRIVATE esmf PIO::PIO_Fortran)
target_link_libraries(datm PRIVATE ESMF::ESMF PIO::PIO_Fortran)

# CDEPS/dice
add_library(dice OBJECT ${cdeps_dice_files})
add_dependencies(dice share streams dshr)
set_target_properties(dice PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dice PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(dice PRIVATE dshr share streams)
target_link_libraries(dice PRIVATE esmf)
target_link_libraries(dice PRIVATE ESMF::ESMF)

# CDEPS/dlnd
add_library(dlnd OBJECT ${cdeps_dlnd_files})
add_dependencies(dlnd share streams dshr)
set_target_properties(dlnd PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dlnd PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(dlnd PRIVATE dshr share streams)
target_link_libraries(dlnd PRIVATE esmf)
target_link_libraries(dlnd PRIVATE ESMF::ESMF)

# CDEPS/docn
add_library(docn OBJECT ${cdeps_docn_files})
add_dependencies(docn share streams dshr)
set_target_properties(docn PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(docn PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(docn PRIVATE dshr share streams)
target_link_libraries(docn PRIVATE esmf PIO::PIO_Fortran)
target_link_libraries(docn PRIVATE ESMF::ESMF PIO::PIO_Fortran)

# CDEPS/drof
add_library(drof OBJECT ${cdeps_drof_files})
add_dependencies(drof share streams dshr)
set_target_properties(drof PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(drof PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(drof PRIVATE dshr share streams)
target_link_libraries(drof PRIVATE esmf)
target_link_libraries(drof PRIVATE ESMF::ESMF)

# CDEPS/dwav
add_library(dwav OBJECT ${cdeps_dwav_files})
add_dependencies(dwav share streams dshr)
set_target_properties(dwav PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(dwav PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
target_link_libraries(dwav PRIVATE dshr share streams)
target_link_libraries(dwav PRIVATE esmf)
target_link_libraries(dwav PRIVATE ESMF::ESMF)

# CDEPS
add_library(cdeps STATIC $<TARGET_OBJECTS:share>
Expand All @@ -108,7 +108,7 @@ add_library(cdeps STATIC $<TARGET_OBJECTS:share>
add_library(cdeps::cdeps ALIAS cdeps)
target_include_directories(cdeps PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(cdeps PUBLIC esmf PIO::PIO_Fortran)
target_link_libraries(cdeps PUBLIC ESMF::ESMF PIO::PIO_Fortran)
list(APPEND LIB_TARGETS cdeps)

###############################################################################
Expand Down
214 changes: 107 additions & 107 deletions CICE-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
### CICE Fortran compiler flags
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-none ")
if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
endif()
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -Wextra -fcheck=bounds -ffpe-trap=invalid,zero,overflow,underflow" )
set(CMAKE_Fortran_LINK_FLAGS "" )
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -FR -convert big_endian -assume byterecl -ftz -align array64byte")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fp-model precise")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -init=snan,arrays")
set(CMAKE_Fortran_LINK_FLAGS "")
else()
message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options")
endif()

### CICE C compiler flags
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_DEBUG "-O0")
set(CMAKE_C_LINK_FLAGS "")
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -traceback")
set( CMAKE_C_FLAGS_RELEASE "-O2 -fp-model precise")
set( CMAKE_C_FLAGS_DEBUG "-O0 -ftrapuv")
set( CMAKE_C_LINK_FLAGS "")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set( CMAKE_C_FLAGS_RELEASE "-O3" )
set( CMAKE_C_FLAGS_DEBUG "-O0" )
set( CMAKE_C_LINK_FLAGS "" )
else()
message(WARNING "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options")
endif()

# Configuration Options
set(CICE_IO "PIO" CACHE STRING "CICE OPTIONS: Choose IO options.")
set_property(CACHE CICE_IO PROPERTY STRINGS "NetCDF" "PIO" "Binary")

# Too many files to list, so include them via this file
include("cice_files.cmake")

# Collect source files for library
list(APPEND lib_src_files
${cice_shared_files}
${cice_shared_files_c}
${icepack_files}
${cice_mpi_comm_files}
${cice_nuopc_cmeps_driver_files}
${cice_cdeps_inline_files})

list(APPEND _cice_defs FORTRANUNDERSCORE
coupled)

# Select IO source files based on CICE_IO
if(CICE_IO MATCHES "NetCDF")
list(APPEND lib_src_files ${cice_netcdf_io_files})
list(APPEND _cice_defs USE_NETCDF)
elseif(CICE_IO MATCHES "PIO")
list(APPEND lib_src_files ${cice_pio2_io_files})
list(APPEND _cice_defs USE_NETCDF)
elseif(CICE_IO MATCHES "Binary")
list(APPEND lib_src_files ${cice_binary_io_files})
endif()

### Create target library and set PUBLIC interfaces on the library
add_library(cice STATIC ${lib_src_files})
set_target_properties(cice PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_compile_definitions(cice PUBLIC "${_cice_defs}")
target_include_directories(cice PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(cice PUBLIC esmf)
if(CICE_IO MATCHES "^(NetCDF|PIO)$")
target_link_libraries(cice PUBLIC NetCDF::NetCDF_Fortran)
if(CICE_IO MATCHES "PIO")
target_link_libraries(cice PUBLIC PIO::PIO_Fortran)
endif()
endif()
if(OpenMP_Fortran_FOUND)
target_link_libraries(cice PRIVATE OpenMP::OpenMP_Fortran)
endif()

# ice prescribed
add_dependencies(cice cdeps::cdeps)
target_compile_definitions(cice PUBLIC "DISABLE_FoX")
target_link_libraries(cice PUBLIC cdeps::cdeps)

###############################################################################
### Install
###############################################################################

install(
TARGETS cice
EXPORT cice-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT Library)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}/CICE)

install(EXPORT cice-config
DESTINATION lib/cmake)
### CICE Fortran compiler flags
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-none ")
if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
endif()
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -Wextra -fcheck=bounds -ffpe-trap=invalid,zero,overflow,underflow" )
set(CMAKE_Fortran_LINK_FLAGS "" )
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -FR -convert big_endian -assume byterecl -ftz -align array64byte")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -fp-model precise")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -init=snan,arrays")
set(CMAKE_Fortran_LINK_FLAGS "")
else()
message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options")
endif()

### CICE C compiler flags
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_DEBUG "-O0")
set(CMAKE_C_LINK_FLAGS "")
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -traceback")
set( CMAKE_C_FLAGS_RELEASE "-O2 -fp-model precise")
set( CMAKE_C_FLAGS_DEBUG "-O0 -ftrapuv")
set( CMAKE_C_LINK_FLAGS "")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set( CMAKE_C_FLAGS_RELEASE "-O3" )
set( CMAKE_C_FLAGS_DEBUG "-O0" )
set( CMAKE_C_LINK_FLAGS "" )
else()
message(WARNING "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options")
endif()

# Configuration Options
set(CICE_IO "PIO" CACHE STRING "CICE OPTIONS: Choose IO options.")
set_property(CACHE CICE_IO PROPERTY STRINGS "NetCDF" "PIO" "Binary")

# Too many files to list, so include them via this file
include("cice_files.cmake")

# Collect source files for library
list(APPEND lib_src_files
${cice_shared_files}
${cice_shared_files_c}
${icepack_files}
${cice_mpi_comm_files}
${cice_nuopc_cmeps_driver_files}
${cice_cdeps_inline_files})

list(APPEND _cice_defs FORTRANUNDERSCORE
coupled)

# Select IO source files based on CICE_IO
if(CICE_IO MATCHES "NetCDF")
list(APPEND lib_src_files ${cice_netcdf_io_files})
list(APPEND _cice_defs USE_NETCDF)
elseif(CICE_IO MATCHES "PIO")
list(APPEND lib_src_files ${cice_pio2_io_files})
list(APPEND _cice_defs USE_NETCDF)
elseif(CICE_IO MATCHES "Binary")
list(APPEND lib_src_files ${cice_binary_io_files})
endif()

### Create target library and set PUBLIC interfaces on the library
add_library(cice STATIC ${lib_src_files})
set_target_properties(cice PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_compile_definitions(cice PUBLIC "${_cice_defs}")
target_include_directories(cice PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_link_libraries(cice PUBLIC ESMF::ESMF)
if(CICE_IO MATCHES "^(NetCDF|PIO)$")
target_link_libraries(cice PUBLIC NetCDF::NetCDF_Fortran)
if(CICE_IO MATCHES "PIO")
target_link_libraries(cice PUBLIC PIO::PIO_Fortran)
endif()
endif()
if(OpenMP_Fortran_FOUND)
target_link_libraries(cice PRIVATE OpenMP::OpenMP_Fortran)
endif()

# ice prescribed
add_dependencies(cice cdeps::cdeps)
target_compile_definitions(cice PUBLIC "DISABLE_FoX")
target_link_libraries(cice PUBLIC cdeps::cdeps)

###############################################################################
### Install
###############################################################################

install(
TARGETS cice
EXPORT cice-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT Library)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}/CICE)

install(EXPORT cice-config
DESTINATION lib/cmake)
2 changes: 1 addition & 1 deletion CMEPS-interface/CMEPS
Submodule CMEPS updated 1 files
+0 −47 cmake/FindESMF.cmake
2 changes: 1 addition & 1 deletion CMEPS-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ set_target_properties(cmeps PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_
target_include_directories(cmeps PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
target_compile_definitions(cmeps PRIVATE ${CDEPS_SHARE_DEFS})
target_link_libraries(cmeps PUBLIC esmf
target_link_libraries(cmeps PUBLIC ESMF::ESMF
PIO::PIO_Fortran)
if(OpenMP_Fortran_FOUND)
target_link_libraries(cmeps PRIVATE OpenMP::OpenMP_Fortran)
Expand Down
Loading

0 comments on commit c994cb0

Please sign in to comment.