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

Update CMakeLists.txt files to use imported targets #172

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bcd44ff
Update FV3 submodule
DusanJovic-NOAA May 13, 2020
2f08ca3
Add new cmake target (ufs-weather-model-lib)
DusanJovic-NOAA May 13, 2020
5bb3d98
Use cmake imported targets on hera.intel
DusanJovic-NOAA May 20, 2020
8a22c67
hera.intel cmake configure file cleanup
DusanJovic-NOAA May 21, 2020
658a2c1
linux.intel cmake configure file cleanup
DusanJovic-NOAA May 21, 2020
aae890c
linux.gnu cmake configure file cleanup`
DusanJovic-NOAA May 21, 2020
c01d619
orion.intel cmake configure file cleanup
DusanJovic-NOAA May 21, 2020
31c109a
wcoss_dell_p3 cmake configure file cleanup
DusanJovic-NOAA May 22, 2020
3d20218
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target
DusanJovic-NOAA Jun 10, 2020
23a0f67
Fix FMS include directory in CMakeLists.txt
DusanJovic-NOAA Jun 11, 2020
4e46c3c
Update nceplibs dependency in top-level CMakeLists.txt
DusanJovic-NOAA Jun 11, 2020
b25cb37
Change w3emc_d to w3emc::w3emc_d. Build ww3_nemslibonly
DusanJovic-NOAA Jun 12, 2020
9da6f05
Remove w3nco dependency
DusanJovic-NOAA Jun 12, 2020
78236ad
Set NETCDF_DIR in tests/compile_cmake.sh
DusanJovic-NOAA Jun 13, 2020
2f8c548
Fix cmake -DSUITES flag. It should be -DCCPP_SUITES
DusanJovic-NOAA Jun 15, 2020
f1398b3
Do not find and depened on Japser, PNG and ZLIB.
DusanJovic-NOAA Jun 15, 2020
47fc948
Update FV3 (use crtm target in io/CMakeLists.txt)
DusanJovic-NOAA Jun 16, 2020
2db4260
Update FV3 (use nceppost target in io/CMakeLists.txt)
DusanJovic-NOAA Jun 17, 2020
de8fb3d
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target
DusanJovic-NOAA Jun 17, 2020
8413bf0
Do not find and link libraries which are not direct dependencies
DusanJovic-NOAA Jun 18, 2020
28193c4
Merge branch 'develop' into ufs_cmake_target
DusanJovic-NOAA Jun 22, 2020
ecf73d4
Add fms_files.cmake
DusanJovic-NOAA Jun 26, 2020
88d5b3d
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target
DusanJovic-NOAA Jul 2, 2020
d10d25b
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target
DusanJovic-NOAA Jul 9, 2020
913bbc8
Update nceplib modules on Hera
DusanJovic-NOAA Jul 13, 2020
dbc6eaa
Update nceplib modules on Orion
DusanJovic-NOAA Jul 13, 2020
4e97d8f
Update nceplib modules on WCOSS Dell
DusanJovic-NOAA Jul 15, 2020
d6f1903
Update nceplib modules on WCOSS Cray
DusanJovic-NOAA Jul 15, 2020
cd5d7f9
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target
DusanJovic-NOAA Jul 16, 2020
d500e69
Add PARALLEL_NETCDF cmake option
DusanJovic-NOAA Jul 16, 2020
00765e7
Remove wcoss_phase1 and wcoss_phase2 modulefiles
DusanJovic-NOAA Jul 17, 2020
f9d9bf1
Remove wcoss_phase1 and wcoss_phase1 configure files
DusanJovic-NOAA Jul 17, 2020
bdab4e4
FFT files were removed from FMS. Cleanup.
DusanJovic-NOAA Jul 17, 2020
cbbff43
Remove *.appBuilder compsets and log.
DusanJovic-NOAA Jul 17, 2020
12d99e9
Remove outdated doc directory
DusanJovic-NOAA Jul 17, 2020
233531d
Put ww3_make.log file in PROJECT_BINARY_DIR
DusanJovic-NOAA Jul 17, 2020
eb4b4ff
Update crtm modules
DusanJovic-NOAA Jul 17, 2020
9755eda
Move module loading to the beginning of compile_cmake.sh
DusanJovic-NOAA Jul 17, 2020
f7e2d08
Update hera.gnu modules and configure_hera.gnu.cmake
DusanJovic-NOAA Jul 17, 2020
4a5a23b
Add CCPP (default ON) and WW3 (default OFF) cmake options
DusanJovic-NOAA Jul 17, 2020
44c4f87
Add bacio as explicit dependency (in case INLINE_POST is OFF)
DusanJovic-NOAA Jul 18, 2020
11c1faa
Restructure top-level CMakeLists.txt (use fv3atm target from FV3)
DusanJovic-NOAA Jul 19, 2020
f17627b
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target_test
DusanJovic-NOAA Jul 21, 2020
4b8c550
Merge remote-tracking branch 'origin/develop' into ufs_cmake_target_test
DusanJovic-NOAA Jul 23, 2020
634bafa
Remove unused build scripts.
DusanJovic-NOAA Jul 24, 2020
9914083
Update baseline date tag. Regtest log file on Hera (intel)
DusanJovic-NOAA Jul 24, 2020
e70d37f
Regtest log file on WCOSS Dell
DusanJovic-NOAA Jul 24, 2020
41d8b5c
Regtest log file on Hera (gnu)
DusanJovic-NOAA Jul 24, 2020
1d318f9
Regtest log file on WCOSS Cray
DusanJovic-NOAA Jul 24, 2020
f10d144
Define default build options in the top-level CMakeLists.txt
DusanJovic-NOAA Jul 25, 2020
7281ce7
Regtest log file on Orion (Intel)
DusanJovic-NOAA Jul 27, 2020
d9dcd78
Update FV3 submodule
DusanJovic-NOAA Jul 28, 2020
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
10 changes: 0 additions & 10 deletions CCPP.appBuilder

This file was deleted.

10 changes: 0 additions & 10 deletions CCPP_repro.appBuilder

This file was deleted.

281 changes: 139 additions & 142 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.15)

foreach(env_var IN ITEMS
CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER
CMAKE_Platform)
if ( NOT DEFINED ENV{${env_var}})
foreach(env_var IN ITEMS CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_Fortran_COMPILER)
if(NOT DEFINED ENV{${env_var}})
message(FATAL_ERROR "${env_var} is not defined")
endif()
endforeach()
Expand All @@ -18,10 +16,68 @@ project(ufs-weather-model
LANGUAGES C CXX Fortran)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(MPI REQUIRED)
find_package(ESMF REQUIRED)

include(${PROJECT_SOURCE_DIR}/cmake/configure_${CMAKE_Platform}.cmake)
set(32BIT OFF CACHE BOOL "Enable 32BIT (single precision arithmetic in dycore)")
set(AVX2 ON CACHE BOOL "Enable AVX2 instruction set")
set(CCPP ON CACHE BOOL "Enable CCPP")
set(DEBUG OFF CACHE BOOL "Enable DEBUG mode")
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")

if(CMAKE_Platform)
message("")
if(EXISTS ${PROJECT_SOURCE_DIR}/cmake/configure_${CMAKE_Platform}.cmake)
message("Setting configuration for ${CMAKE_Platform}")
include(${PROJECT_SOURCE_DIR}/cmake/configure_${CMAKE_Platform}.cmake)
else()
message("Platform '${CMAKE_Platform}' configuration file does not exist")
endif()
endif()

message("")
message("32BIT ............ ${32BIT}")
message("AVX2 ............. ${AVX2}")
message("CCPP ............. ${CCPP}")
message("DEBUG ............ ${DEBUG}")
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("WW3 .............. ${WW3}")
message("")

get_filename_component (C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
get_filename_component (CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
message("C compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} (${C_COMPILER_NAME})")
message("CXX compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} (${CXX_COMPILER_NAME})")
message("Fortran compiler: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION} (${Fortran_COMPILER_NAME})")
message("")

include(cmake/${CMAKE_Fortran_COMPILER_ID}.cmake)
message("")

find_package(NetCDF REQUIRED C Fortran)
find_package(MPI REQUIRED)
find_package(ESMF MODULE REQUIRED)

find_package(bacio REQUIRED)
find_package(nemsio REQUIRED)
find_package(sp REQUIRED)
find_package(w3emc REQUIRED)
find_package(w3nco REQUIRED)
if(INLINE_POST)
find_package(nceppost REQUIRED)
endif()
# See https://github.com/NOAA-EMC/NCEPLIBS-nemsio/pull/22
target_link_libraries(nemsio::nemsio INTERFACE w3emc::w3emc_d bacio::bacio_4)

add_definitions(-Duse_libMPI)
add_definitions(-Duse_netCDF)
Expand All @@ -36,7 +92,7 @@ add_definitions(-DUSE_COND)
add_definitions(-DNEW_TAUCTMAX)
add_definitions(-DINTERNAL_FILE_NML)

if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0.0)
if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0.0)
message(FATAL_ERROR "GNU Compiler >= 9 is required")
endif()

Expand Down Expand Up @@ -95,103 +151,16 @@ endif()
###############################################################################
### FMS
###############################################################################
add_library(
fms

FMS/amip_interp/amip_interp.F90
FMS/astronomy/astronomy.F90
FMS/axis_utils/axis_utils.F90
FMS/axis_utils/axis_utils2.F90
FMS/block_control/block_control.F90
FMS/column_diagnostics/column_diagnostics.F90
FMS/constants/constants.F90
FMS/coupler/atmos_ocean_fluxes.F90
FMS/coupler/coupler_types.F90
FMS/coupler/ensemble_manager.F90
FMS/data_override/data_override.F90
FMS/diag_integral/diag_integral.F90
FMS/diag_manager/diag_axis.F90
FMS/diag_manager/diag_data.F90
FMS/diag_manager/diag_grid.F90
FMS/diag_manager/diag_manager.F90
FMS/diag_manager/diag_output.F90
FMS/diag_manager/diag_table.F90
FMS/diag_manager/diag_util.F90
FMS/drifters/cloud_interpolator.F90
FMS/drifters/drifters.F90
FMS/drifters/drifters_comm.F90
FMS/drifters/drifters_core.F90
FMS/drifters/drifters_input.F90
FMS/drifters/drifters_io.F90
FMS/drifters/quicksort.F90
FMS/exchange/stock_constants.F90
FMS/exchange/xgrid.F90
FMS/field_manager/field_manager.F90
FMS/field_manager/fm_util.F90
FMS/fms/fms.F90
FMS/fms/fms_io.F90
FMS/fms2_io/blackboxio.F90
FMS/fms2_io/fms2_io.F90
FMS/fms2_io/fms_io_utils.F90
FMS/fms2_io/fms_netcdf_domain_io.F90
FMS/fms2_io/fms_netcdf_unstructured_domain_io.F90
FMS/fms2_io/netcdf_io.F90
FMS/horiz_interp/horiz_interp.F90
FMS/horiz_interp/horiz_interp_bicubic.F90
FMS/horiz_interp/horiz_interp_bilinear.F90
FMS/horiz_interp/horiz_interp_conserve.F90
FMS/horiz_interp/horiz_interp_spherical.F90
FMS/horiz_interp/horiz_interp_type.F90
FMS/interpolator/interpolator.F90
FMS/memutils/memutils.F90
FMS/monin_obukhov/monin_obukhov.F90
FMS/monin_obukhov/monin_obukhov_kernel.F90
FMS/mosaic/gradient.F90
FMS/mosaic/grid.F90
FMS/mosaic/mosaic.F90
FMS/mosaic/mosaic2.F90
FMS/mpp/mpp.F90
FMS/mpp/mpp_data.F90
FMS/mpp/mpp_domains.F90
FMS/mpp/mpp_efp.F90
FMS/mpp/mpp_io.F90
FMS/mpp/mpp_memutils.F90
FMS/mpp/mpp_parameter.F90
FMS/mpp/mpp_pset.F90
FMS/mpp/mpp_utilities.F90
FMS/platform/platform.F90
FMS/random_numbers/MersenneTwister.F90
FMS/random_numbers/random_numbers.F90
FMS/sat_vapor_pres/sat_vapor_pres.F90
FMS/sat_vapor_pres/sat_vapor_pres_k.F90
FMS/time_interp/time_interp.F90
FMS/time_interp/time_interp_external.F90
FMS/time_interp/time_interp_external2.F90
FMS/time_manager/get_cal_time.F90
FMS/time_manager/time_manager.F90
FMS/topography/gaussian_topog.F90
FMS/topography/topography.F90
FMS/tracer_manager/tracer_manager.F90
FMS/tridiagonal/tridiagonal.F90

FMS/mosaic/create_xgrid.c
FMS/mosaic/gradient_c2l.c
FMS/mosaic/interp.c
FMS/mosaic/mosaic_util.c
FMS/mosaic/read_mosaic.c
FMS/mpp/mpp_memuse.c
FMS/mpp/nsclock.c
FMS/mpp/threadloc.c
)
# stupid cmake can not figure out dependency of fft.F90 on fft99.F90 because 'use fft99_mod' is inside ifdefs
set_property(SOURCE FMS/fft/fft.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-DSGICRAY=0 -DNAGFFT=0")

target_include_directories(fms PUBLIC ${PROJECT_SOURCE_DIR}/FMS/include FMS/include FMS/fms FMS/fms2_io/include FMS/mpp/include)
target_include_directories(fms PRIVATE ${NETCDF_INC_DIR})

include(fms_files.cmake)
add_library(fms ${fms_src_files})
target_include_directories(fms PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/FMS/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/FMS/fms>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/FMS/fms2_io/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/FMS/mpp/include>)
target_link_libraries(fms PRIVATE NetCDF::NetCDF_Fortran)
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)
target_include_directories(fms PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/FMS/mod)
target_include_directories(fms PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/FMS/mod>)

###############################################################################
### FV3
Expand All @@ -210,34 +179,24 @@ if(WW3)
set(WW3_COMP "orion")
endif()
message("Build WW3:")
message(" run: ${CMAKE_BUILD_TOOL} WW3_PARCOMPN=4 WW3_COMP=${WW3_COMP} ww3_nems")
message(" run: ${CMAKE_BUILD_TOOL} WW3_PARCOMPN=4 WW3_COMP=${WW3_COMP} ww3_nemslibonly")
message(" in: ${PROJECT_SOURCE_DIR}/WW3/model/esmf")
message("")

add_custom_target(ww3_nems
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/WW3/model/esmf
COMMAND ${CMAKE_BUILD_TOOL} WW3_PARCOMPN=4 WW3_COMP=${WW3_COMP} ww3_nems > make.log 2>&1
COMMAND ${CMAKE_BUILD_TOOL} WW3_PARCOMPN=4 WW3_COMP=${WW3_COMP} ww3_nemslibonly > ${PROJECT_BINARY_DIR}/ww3_make.log 2>&1
)

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

###############################################################################
### NEMS
### NEMS (ufs-weather-model-lib)
###############################################################################
configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFVersionDefine_ESMF_NUOPC.h
${PROJECT_BINARY_DIR}/NEMS/src/ESMFVersionDefine.h
COPYONLY)
# until we remove "../ESMFVersionDefine.h" from ENS_Cpl/ENS_CplComp_ESMFMod_STUB.F90
configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFVersionDefine_ESMF_NUOPC.h
${PROJECT_BINARY_DIR}/NEMS/ESMFVersionDefine.h
COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFConvenienceMacros.h
${PROJECT_BINARY_DIR}/NEMS/src/ESMFConvenienceMacros.h
COPYONLY)

add_executable(
NEMS.exe
add_library(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made into libnems consisting solely of the NEMS source code?

ufs-weather-model-lib is a collection of libnems, fv3atm, ww3_nems
It will simplify the logic under hear as everything is target_link_libraries or target_compile_definitions to ufs-weather-model-lib.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to rename ufs-weather-model-lib to nems? I can do that. But I'm not sure I know how to make ufs-weather-model-lib a collection of nems, fv3atm, and optionally ww3_nems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.
you can create ufs-weather-model-lib from nems, fv3atm etc. same way you created fv3atm from fv3cpl, gfsphys, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But fv3atm, in addition to depending on fv3cpl, gfsphysics also contains code (atmos_model.F90, fv3_cap.F90, ...). How do I create library without code and then add other libraries as dependencies. I guess I do not understand what you mean by 'collection'? I do not know how to "create ufs-weather-model-lib from nems, fv3atm". I can only add nems and fv3atm as dependencies to ufs-weather-model-lib.

ufs-weather-model-lib

NEMS/src/MAIN_NEMS.F90
NEMS/src/module_NEMS_UTILS.F90
NEMS/src/module_MEDIATOR_methods.F90
NEMS/src/module_MEDIATOR.F90
Expand All @@ -250,41 +209,79 @@ add_executable(
NEMS/src/nems_c_rusage.c
NEMS/src/ENS_Cpl/ENS_CplComp_ESMFMod_STUB.F90
)
add_dependencies(ufs-weather-model-lib fv3atm)
target_link_libraries(ufs-weather-model-lib PRIVATE esmf)

target_compile_definitions(NEMS.exe PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
target_compile_definitions(NEMS.exe PRIVATE -DFRONT_FMS)
target_compile_definitions(NEMS.exe PRIVATE -DFRONT_FV3=fv3gfs_cap_mod)
target_compile_definitions(ufs-weather-model-lib PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
target_compile_definitions(ufs-weather-model-lib PRIVATE -DFRONT_FMS)
target_compile_definitions(ufs-weather-model-lib PRIVATE -DFRONT_FV3=fv3gfs_cap_mod)

target_include_directories(ufs-weather-model-lib PRIVATE ${PROJECT_BINARY_DIR}/NEMS/src)
target_include_directories(ufs-weather-model-lib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/FV3/mod)
target_include_directories(ufs-weather-model-lib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/FMS/mod)

if(WW3)
target_compile_definitions(ufs-weather-model-lib PRIVATE -DFRONT_WW3=WMESMFMD)
target_include_directories(ufs-weather-model-lib PRIVATE ${PROJECT_SOURCE_DIR}/WW3/model/mod)
set_target_properties(ufs-weather-model-lib PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_SOURCE_DIR}/WW3/model/mod)
add_dependencies(ufs-weather-model-lib ww3_nems)
endif()

set_target_properties(ufs-weather-model-lib PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/mod)
target_include_directories(ufs-weather-model-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/FV3/mod>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/mod>)

configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFVersionDefine_ESMF_NUOPC.h
${PROJECT_BINARY_DIR}/NEMS/src/ESMFVersionDefine.h
COPYONLY)
# until we remove "../ESMFVersionDefine.h" from ENS_Cpl/ENS_CplComp_ESMFMod_STUB.F90
configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFVersionDefine_ESMF_NUOPC.h
${PROJECT_BINARY_DIR}/NEMS/ESMFVersionDefine.h
COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/NEMS/src/ESMFConvenienceMacros.h
${PROJECT_BINARY_DIR}/NEMS/src/ESMFConvenienceMacros.h
COPYONLY)

target_include_directories(NEMS.exe PRIVATE ${ESMF_MOD} )
target_link_libraries(ufs-weather-model-lib PUBLIC fv3atm)

###############################################################################
### UFS executable
###############################################################################
add_executable(NEMS.exe
NEMS/src/MAIN_NEMS.F90
)
add_dependencies(NEMS.exe ufs-weather-model-lib)

target_compile_definitions(NEMS.exe PRIVATE -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Wouldn't it inherit from ufs-weather-model-lib?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed at this moment, because ESMF_VERSION_MAJOR is added as PRIVATE definition to ufs-weather-model-lib. We can add it as PUBLIC but then all users of ufs-weather-model-lib (ie. JEDI) will get it. Do we want that? I thought it makes more sense to keep it private. In any case this will all be replaced pretty soon.

target_include_directories(NEMS.exe PRIVATE ${PROJECT_BINARY_DIR}/NEMS/src)

set_target_properties(NEMS.exe PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/NEMS/mod)
set_target_properties(NEMS.exe PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/mod)

if(WW3)
target_compile_definitions(NEMS.exe PRIVATE -DFRONT_WW3=WMESMFMD)
set_target_properties(NEMS.exe PROPERTIES Fortran_MODULE_DIRECTORY ${PROJECT_SOURCE_DIR}/WW3/model/mod)
set(WW3_LIBS ${PROJECT_SOURCE_DIR}/WW3/model/obj/libww3_multi_esmf.a)
add_dependencies(NEMS.exe ww3_nems)
endif()

if(CCPP)
set(CCPP_LIBRARIES ccppdriver ccppphys ccpp)
else()
set(IPD_LIBRARIES ipd)
endif()

target_link_libraries(NEMS.exe
fv3cap
fv3core
io
${IPD_LIBRARIES}
gfsphysics
${CCPP_LIBRARIES}
fv3cpl
stochastic_physics
fms
ufs-weather-model-lib
${WW3_LIBS}
${NCEP_LIBS} ${ESMF_LIBS} ${NETCDF_LIBS} ${MKL_LIB})
esmf NetCDF::NetCDF_Fortran ${MKL_LIB})

###############################################################################
### Install
###############################################################################
install(
TARGETS ufs-weather-model-lib fms
EXPORT ufs-weather-model-lib-config
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod DESTINATION ${CMAKE_INSTALL_PREFIX})

install(EXPORT ufs-weather-model-lib-config
DESTINATION lib/cmake
)

###############################################################################
### done
Expand Down
Loading