From 1affbf1dc1210444a45ecadb7b8eed0348bd22c7 Mon Sep 17 00:00:00 2001 From: Rich Fiorella Date: Tue, 24 Dec 2024 07:43:57 -0700 Subject: [PATCH] Reduce hardcoded cmake logic linking ATS Many of the cmake steps to link ATS were hardcoded in cime_config. Much of this has been removed now that these have been moved to find_package(*) in components/cime/build_model.cmake. --- .../machines/cmake_macros/universal.cmake | 32 ++++--------------- .../machines/cmake_macros/userdefined.cmake | 27 ++-------------- components/cmake/build_model.cmake | 4 +-- 3 files changed, 11 insertions(+), 52 deletions(-) diff --git a/cime_config/machines/cmake_macros/universal.cmake b/cime_config/machines/cmake_macros/universal.cmake index 3580a0acca8..18e34c96f7c 100644 --- a/cime_config/machines/cmake_macros/universal.cmake +++ b/cime_config/machines/cmake_macros/universal.cmake @@ -27,33 +27,13 @@ set(CMAKE_CXX_FLAGS_RELEASE "") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "") set(CMAKE_Fortran_FORMAT_FREE_FLAG "") -# ATS libraries, previously in userdefined.cmake, but which excluded in cime now. +# RPF/WIP - much of the hardcoded cmake for linking ATS libraries +# has been moved to components/cmake/build_model.cmake, but a few things remain. set(AMANZI_TPLS_DIR "$ENV{AMANZI_TPLS_DIR}") set(ATS_DIR "$ENV{ATS_DIR}") if (COMP_NAME STREQUAL elm) - if (NOT ${AMANZI_TPLS_DIR} STREQUAL "") - - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/trilinos-15-1-0/include") - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/SEACAS/include ") - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/petsc-3.20/include -I${AMANZI_TPLS_DIR}/pflotran/src ") - if (NOT ${ATS_DIR} STREQUAL "") - string(APPEND CPPDEFS " -DUSE_ATS_LIB ") - string(APPEND CMAKE_Fortran_FLAGS " -I${ATS_DIR}/include ") - endif() - endif() -endif() -if (COMP_NAME STREQUAL cpl) - string(APPEND CMAKE_EXE_LINKER_FLAGS " -lstdc++") - if (NOT ${AMANZI_TPLS_DIR} STREQUAL "") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/lib") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/trilinos-15-1-0/lib") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/SEACAS/lib ") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/petsc-3.20/lib -L${AMANZI_TPLS_DIR}/pflotran/src ") - if (NOT ${ATS_DIR} STREQUAL "") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${ATS_DIR}/lib -lerror_handling -latk -lfunctions -lgeometry -lgeochemutil -lgeochemsolvers -lgeochembase -lgeochemrxns -lgeochemistry -lmesh -lmesh_simple -lmesh_mstk -lmesh_extracted -lmesh_logical -lmesh_factory -ldbg -lwhetstone -ldata_structures -lmesh_functions -loutput -lstate -lsolvers -ltime_integration -loperators -lpks -lchemistry_pk -ltransport -lshallow_water -lats_operators -lats_eos -lats_surf_subsurf -lats_generic_evals -lats_column_integrator -lats_pks -lats_energy_relations -lats_energy -lats_flow_relations -lats_flow -lats_transport -lats_deform -lats_surface_balance -lats_bgc -lats_mpc_relations -lats_mpc -lats_executable -lelm_ats") - endif() + if (NOT ${ATS_DIR} STREQUAL "") + string(APPEND CPPDEFS " -DUSE_ATS_LIB ") + string(APPEND CMAKE_Fortran_FLAGS " -I${ATS_DIR}/include ") endif() -endif() - - -string(APPEND CPPDEFS " -DCPL_BYPASS") +endif() \ No newline at end of file diff --git a/cime_config/machines/cmake_macros/userdefined.cmake b/cime_config/machines/cmake_macros/userdefined.cmake index 42a32d4d437..8c3ef66b4b3 100644 --- a/cime_config/machines/cmake_macros/userdefined.cmake +++ b/cime_config/machines/cmake_macros/userdefined.cmake @@ -1,32 +1,11 @@ string(APPEND CONFIG_ARGS " ") string(APPEND CPPDEFS " ") -# cime/CIME/case_setup.py Now doesn't include userdefined.cmake anymore -# so the following won't work. Move it to universal.cmake temporarily. - set(AMANZI_TPLS_DIR "$ENV{AMANZI_TPLS_DIR}") set(ATS_DIR "$ENV{ATS_DIR}") if (COMP_NAME STREQUAL elm) - if (NOT ${AMANZI_TPLS_DIR} STREQUAL "") - - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/trilinos-15-1-0/include") - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/SEACAS/include ") - string(APPEND CMAKE_Fortran_FLAGS " -I${AMANZI_TPLS_DIR}/petsc-3.20/include -I${AMANZI_TPLS_DIR}/pflotran/src ") - if (NOT ${ATS_DIR} STREQUAL "") - string(APPEND CPPDEFS " -DUSE_ATS_LIB ") - string(APPEND CMAKE_Fortran_FLAGS " -I${ATS_DIR}/include ") - endif() - endif() -endif() -if (COMP_NAME STREQUAL cpl) - string(APPEND CMAKE_EXE_LINKER_FLAGS " -lstdc++") - if (NOT ${AMANZI_TPLS_DIR} STREQUAL "") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/lib") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/trilinos-15-1-0/lib") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/SEACAS/lib ") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${AMANZI_TPLS_DIR}/petsc-3.20/lib -L${AMANZI_TPLS_DIR}/pflotran/src ") - if (NOT ${ATS_DIR} STREQUAL "") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -L${ATS_DIR}/lib -lerror_handling -latk -lfunctions -lgeometry -lgeochemutil -lgeochemsolvers -lgeochembase -lgeochemrxns -lgeochemistry -lmesh -lmesh_simple -lmesh_mstk -lmesh_extracted -lmesh_logical -lmesh_factory -ldbg -lwhetstone -ldata_structures -lmesh_functions -loutput -lstate -lsolvers -ltime_integration -loperators -lpks -lchemistry_pk -ltransport -lshallow_water -lats_operators -lats_eos -lats_surf_subsurf -lats_generic_evals -lats_column_integrator -lats_pks -lats_energy_relations -lats_energy -lats_flow_relations -lats_flow -lats_transport -lats_deform -lats_surface_balance -lats_bgc -lats_mpc_relations -lats_mpc -lats_executable -lelm_ats") - endif() + if (NOT ${ATS_DIR} STREQUAL "") + string(APPEND CPPDEFS " -DUSE_ATS_LIB ") + string(APPEND CMAKE_Fortran_FLAGS " -I${ATS_DIR}/include ") endif() endif() diff --git a/components/cmake/build_model.cmake b/components/cmake/build_model.cmake index 3642c27ac8c..9b536089d94 100644 --- a/components/cmake/build_model.cmake +++ b/components/cmake/build_model.cmake @@ -264,8 +264,8 @@ macro(build_model COMP_CLASS COMP_NAME) set(ATS_DIR "$ENV{ATS_DIR}") if (NOT ATS_DIR STREQUAL "") set(Amanzi_DIR "${ATS_DIR}/lib") - #find_package(HDF5 REQUIRED) - #find_package(NETCDF REQUIRED) + find_package(HDF5 REQUIRED) + find_package(NETCDF REQUIRED) find_package(Amanzi REQUIRED) target_link_libraries(${TARGET_NAME} amanzi_elm_ats) endif()