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

Cleanup CCPP cmake build #383

Merged
merged 7 commits into from
Sep 15, 2021
12 changes: 8 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
branch = dev/emc
[submodule "ccpp/framework"]
path = ccpp/framework
url = https://github.com/NCAR/ccpp-framework
branch = main
#url = https://github.com/NCAR/ccpp-framework
#branch = main
url = https://github.com/climbfuji/ccpp-framework
branch = ccpp_cmake_cleanup
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/NCAR/ccpp-physics
branch = main
#url = https://github.com/NCAR/ccpp-physics
#branch = main
url = https://github.com/climbfuji/ccpp-physics
branch = ccpp_cmake_cleanup
24 changes: 10 additions & 14 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ project(CCPP-FV3
LANGUAGES C CXX Fortran)
set(PROJECT "CCPP-FV3")

# Attempt to add link library "NetCDF::NetCDF_Fortran" to target "ccppphys"
# which is not built in this directory.
cmake_policy(SET CMP0079 NEW)

#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down Expand Up @@ -96,10 +92,14 @@ endif()
add_subdirectory(framework)

add_subdirectory(physics)
add_dependencies(ccppphys ccpp)
target_link_libraries(ccppphys PUBLIC w3nco::w3nco_d NetCDF::NetCDF_Fortran)
# This should not be necessary once framework and physics targets define BUILD_INTERFACE
target_include_directories(ccppphys PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/framework/src)
# DH*
add_dependencies(ccpp_physics ccpp_framework)
#
#add_dependencies(ccppphys ccpp)
#target_link_libraries(ccppphys PUBLIC w3nco::w3nco_d NetCDF::NetCDF_Fortran)
## This should not be necessary once framework and physics targets define BUILD_INTERFACE
#target_include_directories(ccppphys PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/framework/src)
# *DH
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove this if it's not necessary anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just saw a TODO comment in the PR description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I still need to add w3nco::w3nco_d somewhere in ccpp-physics's CMakeLists.txt, because the compile jobs are now failing with

/scratch1/NCEPDEV/nems/emc.nemspara/autort/pr/731093042/20210910021510/ufs-weather-model/FV3/ccpp/physics/physics/sfcsub.F:8551: undefined reference to `w3kind_'
/scratch1/NCEPDEV/nems/emc.nemspara/autort/pr/731093042/20210910021510/ufs-weather-model/FV3/ccpp/physics/physics/sfcsub.F:8554: undefined reference to `w3movdat_'
/scratch1/NCEPDEV/nems/emc.nemspara/autort/pr/731093042/20210910021510/ufs-weather-model/FV3/ccpp/physics/physics/sfcsub.F:8599: undefined reference to `getgbh_'
...

@DusanJovic-NOAA Am I correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, add it either in ccpp_physics, in which case you'll need to 'find' w3nco package there, if you want to have ccpp physics compilable outside UFS. Or just uncomment 'target_link_library' here to define dependency of ccpp_physics target on w3nco.


#------------------------------------------------------------------------------
# Build fv3ccpp
Expand All @@ -124,16 +124,12 @@ add_library(
set_property(SOURCE driver/GFS_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0")


target_link_libraries(fv3ccpp PUBLIC ccpp)
target_link_libraries(fv3ccpp PUBLIC ccppphys)
target_link_libraries(fv3ccpp PUBLIC ccpp_framework)
target_link_libraries(fv3ccpp PUBLIC ccpp_physics)

if(OPENMP)
target_link_libraries(fv3ccpp PUBLIC OpenMP::OpenMP_Fortran)
endif()

# This should not be necessary once framework and physics targets define BUILD_INTERFACE
target_include_directories(fv3ccpp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/framework/src
${CMAKE_CURRENT_BINARY_DIR}/physics)

set_target_properties(fv3ccpp PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(fv3ccpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
2 changes: 1 addition & 1 deletion ccpp/framework
Submodule framework updated 2 files
+6 −30 CMakeLists.txt
+11 −11 src/CMakeLists.txt
2 changes: 1 addition & 1 deletion ccpp/physics
Submodule physics updated 1 files
+16 −41 CMakeLists.txt