diff --git a/CMakeLists.txt b/CMakeLists.txt index 0af2ea9a7..d85272169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ if(CCPP) - add_definitions(-DCCPP) + add_definitions(-DCCPP) endif() add_subdirectory(cpl) @@ -7,14 +7,15 @@ add_subdirectory(gfsphysics) add_subdirectory(ipd) add_subdirectory(io) -# fv3core library - +############################################################################### +### fv3dycore +############################################################################### if(NOT CCPP) -set(FAST_PHYSICS_SRCS_F90 atmos_cubed_sphere/model/fv_cmp.F90) + set(FAST_PHYSICS_SRCS_F90 atmos_cubed_sphere/model/fv_cmp.F90) endif() add_library( - fv3core + fv3dycore atmos_cubed_sphere/model/a2b_edge.F90 atmos_cubed_sphere/model/multi_gases.F90 @@ -61,37 +62,46 @@ add_library( set_property(SOURCE atmos_cubed_sphere/model/nh_utils.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}") set_property(SOURCE atmos_cubed_sphere/model/fv_mapz.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "${FAST}") -target_link_libraries(fv3core PRIVATE fms) -target_link_libraries(fv3core PRIVATE gfsphysics) -target_link_libraries(fv3core PRIVATE ipd) +set_target_properties(fv3dycore PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(fv3dycore PUBLIC $) -target_include_directories(fv3core PRIVATE atmos_cubed_sphere ${ESMF_MOD}) +target_link_libraries(fv3dycore PRIVATE fms) +target_link_libraries(fv3dycore PRIVATE gfsphysics) +target_link_libraries(fv3dycore PRIVATE ipd) +target_link_libraries(fv3dycore PRIVATE esmf) -# end of fv3core +target_include_directories(fv3dycore PRIVATE atmos_cubed_sphere ${ESMF_MOD}) ############################################################################### ### ccpp ############################################################################### if(CCPP) - add_subdirectory(ccpp) - add_subdirectory(ccpp/driver) - add_dependencies(gfsphysics ccpp ccppphys) - add_dependencies(ccppdriver ccpp ccppphys) - add_dependencies(ccppphys ccpp) - - target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) - target_include_directories(fv3core PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/driver) -endif() + add_subdirectory(ccpp) + add_subdirectory(ccpp/driver) + + add_dependencies(gfsphysics ccpp ccppphys) + add_dependencies(ccppdriver ccpp ccppphys) + add_dependencies(ccppphys ccpp) -set_target_properties(fv3core PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(fv3core PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) + target_include_directories(fv3dycore PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) + target_include_directories(fv3dycore PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/driver) + target_link_libraries(ccppphys PRIVATE sp::sp_d) + target_link_libraries(ccppphys PRIVATE w3nco::w3nco_d) +endif() + +############################################################################### +### stochastic_physics +############################################################################### # When specifying an out-of-tree source a binary directory must be explicitly specified. #add_subdirectory(../stochastic_physics stochastic_physics) add_subdirectory(stochastic_physics) +############################################################################### +### fv3atm +############################################################################### add_library( - fv3cap + fv3atm atmos_model.F90 fv3_cap.F90 @@ -100,21 +110,45 @@ add_library( time_utils.F90 ) +set_target_properties(fv3atm PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(fv3atm PUBLIC $) + if(CCPP) -target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod) -add_dependencies(fv3cap ccppdriver ccppphys) + target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/ccpp/driver/mod) + set(CCPP_LIBRARIES ccppdriver ccppphys ccpp) + add_dependencies(fv3atm ccppdriver ccppphys ccpp) + target_link_libraries(fv3atm PUBLIC ccppdriver ccppphys ccpp) +endif() +target_include_directories(fv3atm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics) +target_compile_definitions(fv3atm PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR}) + +target_link_libraries(fv3atm PUBLIC fms) +target_link_libraries(fv3atm PUBLIC cpl) +target_link_libraries(fv3atm PUBLIC gfsphysics) +target_link_libraries(fv3atm PUBLIC ipd) +target_link_libraries(fv3atm PUBLIC io) +target_link_libraries(fv3atm PUBLIC fv3dycore) +target_link_libraries(fv3atm PUBLIC stochastic_physics) + +target_link_libraries(fv3atm PUBLIC + nemsio::nemsio w3emc::w3emc_d w3nco::w3nco_d sp::sp_d bacio::bacio_4) +if(INLINE_POST) + target_link_libraries(fv3atm PUBLIC nceppost::nceppost) endif() -target_include_directories(fv3cap PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/stochastic_physics) -target_compile_definitions(fv3cap PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR}) -target_include_directories(fv3cap PRIVATE ${ESMF_MOD}) - -target_link_libraries(fv3cap PRIVATE fms) -target_link_libraries(fv3cap PRIVATE fv3cpl) -target_link_libraries(fv3cap PRIVATE gfsphysics) -target_link_libraries(fv3cap PRIVATE ipd) -target_link_libraries(fv3cap PRIVATE io) -target_link_libraries(fv3cap PRIVATE fv3core) -target_link_libraries(fv3cap PRIVATE stochastic_physics) - -set_target_properties(fv3cap PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(fv3cap PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) + +target_link_libraries(fv3atm PUBLIC esmf) + +############################################################################### +### Install +############################################################################### +install( + TARGETS fv3atm fv3dycore io ipd gfsphysics ${CCPP_LIBRARIES} cpl stochastic_physics + EXPORT fv3atm-config + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX}) + +install(EXPORT fv3atm-config + DESTINATION lib/cmake +) + diff --git a/ccpp/driver/CMakeLists.txt b/ccpp/driver/CMakeLists.txt index 654eb972e..5960d92da 100644 --- a/ccpp/driver/CMakeLists.txt +++ b/ccpp/driver/CMakeLists.txt @@ -24,4 +24,4 @@ target_link_libraries(ccppdriver ccppphys) target_include_directories(ccppdriver PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) set_target_properties(ccppdriver PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(ccppdriver PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(ccppdriver PUBLIC $) diff --git a/cpl/CMakeLists.txt b/cpl/CMakeLists.txt index c810ed1b3..74271f917 100644 --- a/cpl/CMakeLists.txt +++ b/cpl/CMakeLists.txt @@ -1,12 +1,11 @@ add_library( - fv3cpl + cpl module_cplfields.F90 module_cap_cpl.F90 ) +target_link_libraries(cpl PRIVATE esmf) -target_include_directories(fv3cpl PRIVATE ${ESMF_MOD}) - -set_target_properties(fv3cpl PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(fv3cpl PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) +set_target_properties(cpl PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(cpl PUBLIC $) diff --git a/gfsphysics/CMakeLists.txt b/gfsphysics/CMakeLists.txt index 6b9d5ae8e..34faf6f4c 100644 --- a/gfsphysics/CMakeLists.txt +++ b/gfsphysics/CMakeLists.txt @@ -10,7 +10,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") string (REPLACE "-i4 -real-size 32" "-i4 -real-size 64 -no-prec-div -no-prec-sqrt" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") endif() elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8") endif() endif() @@ -202,6 +202,7 @@ if(CCPP) add_library(gfsphysics ${CCPP_SOURCES}) target_include_directories(gfsphysics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) target_include_directories(gfsphysics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/physics) + target_link_libraries(gfsphysics PRIVATE ccppphys ccpp) else() add_library(gfsphysics ${IPD_SOURCES}) endif() @@ -216,7 +217,7 @@ endif() set_property(SOURCE GFS_layer/GFS_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0") target_compile_definitions(gfsphysics PRIVATE -DNEMS_GSM) -target_include_directories(gfsphysics PRIVATE ${NETCDF_INC_DIR}) +target_link_libraries(gfsphysics PRIVATE NetCDF::NetCDF_Fortran) set_target_properties(gfsphysics PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(gfsphysics PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(gfsphysics PUBLIC $) diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt index 8ec8bcf00..1fc2ea77e 100644 --- a/io/CMakeLists.txt +++ b/io/CMakeLists.txt @@ -23,20 +23,21 @@ add_library( ${POST_SRC} ) -set_source_files_properties(post_gfs.F90 post_nems_routines.F90 - PROPERTIES - COMPILE_FLAGS "-I${POST_INC}") +target_link_libraries(io PRIVATE fms) +target_link_libraries(io PRIVATE gfsphysics) +target_link_libraries(io PRIVATE ipd) -target_link_libraries(io fms) -target_link_libraries(io gfsphysics) -target_link_libraries(io ipd) +if(INLINE_POST) + target_link_libraries(io PRIVATE nceppost::nceppost) +endif() if(CCPP) target_include_directories(io PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) target_include_directories(io PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/physics) endif() -target_include_directories(io PRIVATE ${ESMF_MOD}) -target_include_directories(io PRIVATE ${NEMSIO_INC}) + +target_link_libraries(io PRIVATE nemsio::nemsio) +target_link_libraries(io PRIVATE esmf) set_target_properties(io PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(io PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(io PUBLIC $) diff --git a/ipd/CMakeLists.txt b/ipd/CMakeLists.txt index 7c9e59b16..3009fbfa5 100644 --- a/ipd/CMakeLists.txt +++ b/ipd/CMakeLists.txt @@ -20,11 +20,12 @@ add_library( IPD_driver.F90 IPD_typedefs.F90 ) -target_link_libraries(ipd gfsphysics) +target_link_libraries(ipd PRIVATE gfsphysics) if(CCPP) target_include_directories(ipd PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) target_include_directories(ipd PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/physics) endif() + set_target_properties(ipd PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod) -target_include_directories(ipd PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/mod) +target_include_directories(ipd PUBLIC $) diff --git a/stochastic_physics/CMakeLists.txt b/stochastic_physics/CMakeLists.txt index a9ee27efa..4f4186464 100644 --- a/stochastic_physics/CMakeLists.txt +++ b/stochastic_physics/CMakeLists.txt @@ -56,6 +56,7 @@ if(CCPP) target_include_directories(stochastic_physics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/framework/src) target_include_directories(stochastic_physics PRIVATE ${CMAKE_BINARY_DIR}/FV3/ccpp/physics) endif() -target_link_libraries(stochastic_physics fms) -target_link_libraries(stochastic_physics gfsphysics) -target_link_libraries(stochastic_physics fv3core) +target_link_libraries(stochastic_physics PRIVATE fms) +target_link_libraries(stochastic_physics PRIVATE gfsphysics) +target_link_libraries(stochastic_physics PRIVATE fv3dycore) +target_link_libraries(stochastic_physics PRIVATE sp::sp_d)