From d1ac326b1b45c04f121dda77cc6e90cfbb030d29 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Fri, 23 Jul 2021 13:59:21 -0600 Subject: [PATCH 1/3] Add netCDF dependency, rename target to ccpp_physics --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5c756d15..67b53628e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ endif (NOT PROJECT) #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 3.0) -project(ccppphys +project(ccpp_physics VERSION 4.0.0 LANGUAGES C CXX Fortran) @@ -336,7 +336,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") endif () #------------------------------------------------------------------------------ -add_library(ccppphys STATIC ${SCHEMES} ${SCHEMES_SFX_OPT} ${CAPS}) +add_library(ccpp_physics STATIC ${SCHEMES} ${SCHEMES_SFX_OPT} ${CAPS}) # Generate list of Fortran modules from defined sources foreach(source_f90 ${CAPS}) get_filename_component(tmp_source_f90 ${source_f90} NAME) @@ -345,20 +345,22 @@ foreach(source_f90 ${CAPS}) list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) endforeach() -set_target_properties(ccppphys PROPERTIES VERSION ${PROJECT_VERSION} +target_link_libraries(ccpp_physics PUBLIC NetCDF::NetCDF_Fortran) + +set_target_properties(ccpp_physics PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) if (PROJECT STREQUAL "CCPP-FV3") # Define where to install the library - install(TARGETS ccppphys - EXPORT ccppphys-targets + install(TARGETS ccpp_physics + EXPORT ccpp_physics-targets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) # Export our configuration - install(EXPORT ccppphys-targets - FILE ccppphys-config.cmake + install(EXPORT ccpp_physics-targets + FILE ccpp_physics-config.cmake DESTINATION lib/cmake ) # Define where to install the C headers and Fortran modules From a9c7465d11e026334bd39d14c221554c4d2c3ef5 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Fri, 23 Jul 2021 14:51:47 -0600 Subject: [PATCH 2/3] More cleanup in CMakeLists.txt --- CMakeLists.txt | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67b53628e..8817bf9a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ endif (NOT PROJECT) cmake_minimum_required(VERSION 3.0) project(ccpp_physics - VERSION 4.0.0 - LANGUAGES C CXX Fortran) + VERSION 5.0.0 + LANGUAGES Fortran) # Use rpaths on MacOSX set(CMAKE_MACOSX_RPATH 1) @@ -31,25 +31,9 @@ set(AUTHORS "Grant Firl" "Dom Heinzeller" "Man Zhang" "Laurie Carson") if (OPENMP) include(detect_openmp) detect_openmp() - #set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - #set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") - message(STATUS "Enable OpenMP support for C/C++/Fortran compiler") + message(STATUS "Enable OpenMP support") else (OPENMP) - message (STATUS "Disable OpenMP support for C/C++/Fortran compiler") -endif() - -#------------------------------------------------------------------------------ -# The Fortran compiler/linker flag inserted by cmake to create shared libraries -# with the Intel compiler is deprecated (-i_dynamic), correct here. -# CMAKE_Fortran_COMPILER_ID = {"Intel", "PGI", "GNU", "Clang", "MSVC", ...} -if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Intel") - string(REPLACE "-i_dynamic" "-shared-intel" - CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS - "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS}") - string(REPLACE "-i_dynamic" "-shared-intel" - CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS - "${CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS}") + message (STATUS "Disable OpenMP support") endif() #------------------------------------------------------------------------------ @@ -321,20 +305,6 @@ else() message (FATAL_ERROR "This program has only been compiled with gfortran, pgf90 and ifort. If another compiler is needed, the appropriate flags must be added in ${GFS_PHYS_SRC}/CMakeLists.txt") endif() -# The auto-generated caps can contain calls to physics schemes in -# which some of the arguments (pointers, arrays) are not associated/allocated. -# This is on purpose to avoid allocating fields that are not used inside the -# scheme if, for example, certain conditions are not met. To avoid -# Fortran runtime errors, it is necessary to remove checks for pointers -# that are not associated and for array bounds from the caps ONLY. For the -# physics schemes, these checks can and should remain enabled. Overwriting -# the pointer check flags explicitly works for Intel and GNU, but not for PGI. -if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") - set_property(SOURCE ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " -fcheck=no-pointer,no-bounds ") -elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") - set_property(SOURCE ${CAPS} APPEND_STRING PROPERTY COMPILE_FLAGS " -check nopointers,nobounds ") -endif () - #------------------------------------------------------------------------------ add_library(ccpp_physics STATIC ${SCHEMES} ${SCHEMES_SFX_OPT} ${CAPS}) # Generate list of Fortran modules from defined sources @@ -345,11 +315,14 @@ foreach(source_f90 ${CAPS}) list(APPEND MODULES_F90 ${CMAKE_CURRENT_BINARY_DIR}/${module_f90}) endforeach() -target_link_libraries(ccpp_physics PUBLIC NetCDF::NetCDF_Fortran) - set_target_properties(ccpp_physics PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) +target_include_directories(ccpp_physics PUBLIC + $) + +target_link_libraries(ccpp_physics PUBLIC NetCDF::NetCDF_Fortran) + if (PROJECT STREQUAL "CCPP-FV3") # Define where to install the library install(TARGETS ccpp_physics From 18fb14eb79777a5edd95daa0c26730df96ba03cf Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 13 Sep 2021 07:31:13 -0600 Subject: [PATCH 3/3] Add missing dependency on w3nco::w3nco_d --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8817bf9a9..5252802ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,7 +321,7 @@ set_target_properties(ccpp_physics PROPERTIES VERSION ${PROJECT_VERSION} target_include_directories(ccpp_physics PUBLIC $) -target_link_libraries(ccpp_physics PUBLIC NetCDF::NetCDF_Fortran) +target_link_libraries(ccpp_physics PUBLIC w3nco::w3nco_d NetCDF::NetCDF_Fortran) if (PROJECT STREQUAL "CCPP-FV3") # Define where to install the library