Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2cfa047
add an example mechanism to validate compsets and valid applications.
aerorahul Mar 12, 2021
d9a1548
missed cmeps
aerorahul Mar 12, 2021
c992195
more apps and unsupported too
aerorahul Mar 12, 2021
55885da
typo and missing CMEPS in DATM app
aerorahul Mar 12, 2021
6b9caba
forgot WW3 default option
aerorahul Mar 12, 2021
3f78119
WAVEWATCH needs to be all-caps
aerorahul Mar 12, 2021
9431974
remove unwanted options
aerorahul Mar 12, 2021
389fbd2
add an example mechanism to validate compsets and valid applications.
aerorahul Mar 12, 2021
554d9c7
missed cmeps
aerorahul Mar 12, 2021
5c705ee
more apps and unsupported too
aerorahul Mar 12, 2021
4c57c80
typo and missing CMEPS in DATM app
aerorahul Mar 12, 2021
00bd4f9
forgot WW3 default option
aerorahul Mar 12, 2021
39856d1
WAVEWATCH needs to be all-caps
aerorahul Mar 12, 2021
dd30668
remove unwanted options
aerorahul Mar 12, 2021
5c4072f
Merge branch 'feature/compsets' of https://github.com/NOAA-EMC/ufs-we…
aerorahul Mar 18, 2021
9f8a694
updates to test scripts and confs
aerorahul Mar 18, 2021
469f74a
edit more conf files
aerorahul Mar 18, 2021
bf062f3
use a unique application name and add user option -DAPP=<APP>
aerorahul Mar 20, 2021
81aaf0a
remove file added by error
aerorahul Mar 20, 2021
7fc0a36
missed echoing STOCH_PHYS. tidying
aerorahul Mar 20, 2021
3e46f5b
Stoch updates (#372)
pjpegion Mar 21, 2021
a724643
Merge branch 'develop' into feature/compsets
aerorahul Mar 22, 2021
40d988d
QUAD_PRECISION is ON in FMS by default and is not used anywhere else.
aerorahul Mar 22, 2021
277cefb
address comments from @dusanjovic-noaa. Missing table columns
aerorahul Mar 22, 2021
3624511
remove FMS installation block from top-level CMakeLists.txt
aerorahul Mar 22, 2021
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
251 changes: 131 additions & 120 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,26 @@ set(INLINE_POST OFF CACHE BOOL "Enable inline post")
set(MULTI_GASES OFF CACHE BOOL "Enable MULTI_GASES")
set(OPENMP ON CACHE BOOL "Enable OpenMP threading")
set(PARALLEL_NETCDF OFF CACHE BOOL "Enable parallel NetCDF")
set(QUAD_PRECISION ON CACHE BOOL "Enable QUAD_PRECISION (for certain grid metric terms in dycore)")
set(REPRO OFF CACHE BOOL "Enable REPRO mode")
set(WW3 OFF CACHE BOOL "Enable WW3")
set(S2S OFF CACHE BOOL "Enable S2S")
set(JEDI_DRIVER OFF CACHE BOOL "Enable JEDI as top level driver")
set(DATM OFF CACHE BOOL "Enable Data Atmosphere")

# Component Options
set(FMS OFF CACHE BOOL "Enable FMS")
set(FV3 OFF CACHE BOOL "Enable FV3")
set(MOM6 OFF CACHE BOOL "Enable MOM6")
set(CICE6 OFF CACHE BOOL "Enable CICE6")
set(WW3 OFF CACHE BOOL "Enable WW3")
set(STOCH_PHYS OFF CACHE BOOL "Enable Stochastic Physics")
set(NEMSdatm OFF CACHE BOOL "Enable NEMSdatm")
set(CMEPS OFF CACHE BOOL "Enable CMEPS")
set(CDEPS OFF CACHE BOOL "Enable CDEPS")

# Valid applications and choices
list(APPEND VALID_APPS ATM ATMW S2S S2SW DATM DATM_NEMS)
set(APP NONE CACHE BOOL "Application Name")
if(NOT (APP IN_LIST VALID_APPS))
message(FATAL_ERROR "${APP} is not a valid application.\nValid Applications are: ${VALID_APPS}")
endif()

###############################################################################
### Set CMAKE_BUILD_TYPE for DEBUG mode
Expand Down Expand Up @@ -65,7 +79,6 @@ if(CMAKE_Platform)
endif()

message("")
message("32BIT ............ ${32BIT}")
message("AVX2 ............. ${AVX2}")
message("SIMDMULTIARCH ... ${SIMDMULTIARCH}")
message("DEBUG ............ ${DEBUG}")
Expand All @@ -74,11 +87,26 @@ message("INLINE_POST ...... ${INLINE_POST}")
message("MULTI_GASES ...... ${MULTI_GASES}")
message("OPENMP ........... ${OPENMP}")
message("PARALLEL_NETCDF .. ${PARALLEL_NETCDF}")
message("QUAD_PRECISION ... ${QUAD_PRECISION}")
message("REPRO ............ ${REPRO}")
message("")

# Configure selected application specific components
include(cmake/configure_apps.cmake)

# Components
message("")
message("FMS .............. ${FMS}")
message("FV3 .............. ${FV3}")
message("MOM6 ............. ${MOM6}")
message("CICE6 ............ ${CICE6}")
message("WW3 .............. ${WW3}")
message("S2S .............. ${S2S}")
message("DATM ............. ${DATM}")
message("STOCH_PHYS ....... ${STOCH_PHYS}")
message("NEMSdatm ......... ${NEMSdatm}")
message("CDEPS ............ ${CDEPS}")
message("CMEPS ............ ${CMEPS}")

# Options that applications reset
message("32BIT ............ ${32BIT}")
message("")

get_filename_component (C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
Expand All @@ -105,7 +133,7 @@ if(OPENMP)
endif()
find_package(NetCDF REQUIRED C Fortran)
find_package(ESMF MODULE REQUIRED)
if(S2S)
if(CMEPS)
find_package(PIO REQUIRED COMPONENTS C Fortran STATIC)
endif()

Expand All @@ -125,82 +153,40 @@ target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4)
find_package(Python 3 REQUIRED COMPONENTS Interpreter)
message("Found Python: ${Python_EXECUTABLE}")

###############################################################################
### Checks
###############################################################################
if(DATM AND NOT S2S)
message(FATAL_ERROR "DATM=ON and S2S=OFF are incompatible, ABORT!")
endif()

if(S2S AND 32BIT)
message(FATAL_ERROR "S2S=ON and 32BIT=ON are incompatible, ABORT!")
endif()

###############################################################################
### FMS
###############################################################################
include(fms_files.cmake)
add_library(fms ${fms_src_files} ${fms_headers})

list(APPEND _fms_defs_public use_libMPI
use_netCDF
GFS_PHYS
INTERNAL_FILE_NML)
if(QUAD_PRECISION)
list(APPEND _fms_defs_public ENABLE_QUAD_PRECISION)
endif()

# check gettid
include(CheckFunctionExists)
check_function_exists(gettid HAVE_GETTID)
if(HAVE_GETTID)
list(APPEND _fms_defs_public HAVE_GETTID)
endif()
if(FMS)
set(GFS_PHYS ON CACHE BOOL "Enable GFS Physics")
if(NOT 32BIT)
set(64BIT ON CACHE BOOL "Enable 64-bit")
endif()

target_compile_definitions(fms PUBLIC "${_fms_defs_public}")
add_subdirectory(FMS)

if(32BIT)
list(APPEND _fms_defs_private OVERLOAD_R4
OVERLOAD_R8)
endif()

target_compile_definitions(fms PRIVATE "${_fms_defs_private}")

target_include_directories(fms PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/FMS/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/FMS/fms>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/FMS/fms2_io/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/FMS/mod>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/FMS/mpp/include>)
target_include_directories(fms INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/mod>)
target_link_libraries(fms PUBLIC MPI::MPI_Fortran
NetCDF::NetCDF_Fortran)
if(OpenMP_Fortran_FOUND)
target_link_libraries(fms PRIVATE OpenMP::OpenMP_Fortran)
endif()
set_target_properties(fms PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/FMS)
set_target_properties(fms PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/FMS/mod)
set_target_properties(fms PROPERTIES PUBLIC_HEADER "${fms_headers}" )
if(32BIT)
add_library(fms ALIAS fms_r4)
else()
add_library(fms ALIAS fms_r8)
endif()
endif(FMS)

###############################################################################
### stochastic_physics
###############################################################################
if(NOT DATM)
if(STOCH_PHYS)
add_subdirectory(stochastic_physics)
endif()

###############################################################################
### FV3 or Data Atmosphere
### Atmosphere Components [FV3, MPAS?]
###############################################################################
if(DATM)
add_subdirectory(DATM)
else()
if(FV3)
add_subdirectory(FV3)
endif()

###############################################################################
### WW3
### Wave components [WW3]
###############################################################################
if(WW3)
if(CMAKE_Platform)
Expand All @@ -225,18 +211,39 @@ if(WW3)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/WW3/model/esmf
COMMAND ${CMAKE_BUILD_TOOL} WW3_PARCOMPN=4 WW3_COMP=${WW3_COMP} ww3_nemslibonly > ${CMAKE_CURRENT_BINARY_DIR}/ww3_make.log 2>&1)

set(WW3_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/WW3/model/obj/libww3_multi_esmf.a)
set(WW3_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/WW3/model/obj/libww3_multi_esmf.a)
endif()

###############################################################################
### S2S Components [CMEPS, MOM6, CICE]
### Ocean Components [MOM6, CICE]
###############################################################################
if(S2S)
add_subdirectory(CMEPS-interface)
if(MOM6)
add_subdirectory(MOM6-interface)
endif()

if(CICE6)
add_subdirectory(CICE-interface)
endif()

###############################################################################
### Mediator Components [CMEPS]
###############################################################################
if(CMEPS)
add_subdirectory(CMEPS-interface)
endif()

###############################################################################
### Data Components [NEMSdatm, CDEPS]
###############################################################################
if(NEMSdatm)
add_subdirectory(DATM)
endif()

if(CDEPS)
message("ADD CDEPS-interface directory")
# add_subdirectory(CDEPS-interface)
endif()

###############################################################################
### UFS Library [NEMS]
###############################################################################
Expand All @@ -263,23 +270,39 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/NEMS/src/ESMFConvenienceMacros.h
COPYONLY)

add_library(ufs ${_nems_srcs})
target_include_directories(ufs PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/NEMS/src)
set_target_properties(ufs PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(ufs INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)

list(APPEND _ufs_defs_private ESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR}
FRONT_FMS)
add_dependencies(ufs fms)
list(APPEND _ufs_defs_private ESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})

if(DATM)
target_link_libraries(ufs PUBLIC esmf)

if(JEDI_DRIVER)
list(APPEND _ufs_defs_private JEDI_DRIVER=ON)
endif()

if(FMS)
list(APPEND _ufs_defs_private FRONT_FMS)
add_dependencies(ufs fms)
endif()

if(NEMSdatm)
list(APPEND _ufs_defs_private FRONT_DATM=datm)
add_dependencies(ufs datatm)
else()
target_link_libraries(ufs PUBLIC datatm)
endif()

if(FV3)
list(APPEND _ufs_defs_private FRONT_FV3=fv3gfs_cap_mod)
add_dependencies(ufs fv3atm)
target_link_libraries(ufs PUBLIC fv3atm)
endif()
if(JEDI_DRIVER)
list(APPEND _ufs_defs_private JEDI_DRIVER=ON)

if(STOCH_PHYS)
target_link_libraries(ufs PUBLIC stochastic_physics)
endif()
set_target_properties(ufs PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(ufs PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/NEMS/src)

if(WW3)
list(APPEND _ufs_defs_private FRONT_WW3=WMESMFMD)
Expand All @@ -288,26 +311,26 @@ if(WW3)
target_link_libraries(ufs PUBLIC ${WW3_LIBS})
endif()

target_include_directories(ufs INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<INSTALL_INTERFACE:mod>)
if(MOM6)
list(APPEND _ufs_defs_private FRONT_MOM6=mom_cap_mod)
add_dependencies(ufs mom6)
target_link_libraries(ufs PUBLIC mom6)
endif()

target_link_libraries(ufs PUBLIC esmf)
if(CICE6)
list(APPEND _ufs_defs_private FRONT_CICE6=ice_comp_nuopc)
add_dependencies(ufs cice)
target_link_libraries(ufs PUBLIC cice)
endif()

if(DATM)
target_link_libraries(ufs PUBLIC datatm)
else()
target_link_libraries(ufs PUBLIC fv3atm)
if(CMEPS)
list(APPEND _ufs_defs_private CMEPS FRONT_CMEPS=MED)
add_dependencies(ufs cmeps)
target_link_libraries(ufs PUBLIC cmeps)
endif()

if(S2S)
list(APPEND _ufs_defs_private FRONT_MOM6=mom_cap_mod
FRONT_CICE6=ice_comp_nuopc
CMEPS
FRONT_CMEPS=MED)
add_dependencies(ufs mom6 cice cmeps)
target_link_libraries(ufs PUBLIC mom6
cice
cmeps)
if(CDEPS)
message("Do CDEPS things here")
endif()

target_compile_definitions(ufs PRIVATE "${_ufs_defs_private}")
Expand All @@ -319,7 +342,8 @@ add_executable(ufs_model NEMS/src/MAIN_NEMS.F90)

list(APPEND _ufs_model_defs_private ESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})

set_target_properties(ufs_model PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
set_target_properties(ufs_model PROPERTIES Fortran_MODULE_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/mod)

target_include_directories(ufs_model PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/NEMS/src)

Expand All @@ -331,40 +355,27 @@ endif()

target_compile_definitions(ufs_model PRIVATE "${_ufs_model_defs_private}")

if(DATM)
if(NEMSdatm)
target_link_libraries(ufs_model PUBLIC ufs w3nco::w3nco_d)
endif()

target_link_libraries(ufs_model PRIVATE ufs
esmf
NetCDF::NetCDF_Fortran
${MKL_LIB})
NetCDF::NetCDF_Fortran)

###############################################################################
### Install
###############################################################################
install(
TARGETS fms
EXPORT fms-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include )

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

install(EXPORT fms-config
DESTINATION lib/cmake
)
install(
TARGETS ufs
EXPORT ufs-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(TARGETS ufs
EXPORT ufs-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(EXPORT ufs-config
DESTINATION lib/cmake)

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

install(EXPORT ufs-config
DESTINATION lib/cmake
)
###############################################################################
### Done
###############################################################################
2 changes: 1 addition & 1 deletion FMS
Submodule FMS updated 2 files
+3 −1 CHANGELOG.md
+5 −5 CMakeLists.txt
2 changes: 1 addition & 1 deletion FV3
Submodule FV3 updated from dbaff1 to 07b00a
Loading