Skip to content

Commit

Permalink
Merge branch 'jgfouca/cmake_petsc' into master (PR #5959)
Browse files Browse the repository at this point in the history
Cleanup petsc cmake stuff

Also remove a lot of unused stuff.

[BFB]

* jgfouca/cmake_petsc:
  Cleanup petsc cmake stuff
  • Loading branch information
jgfouca committed Sep 27, 2023
2 parents f2dc02e + 67b20d1 commit 614d911
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 86 deletions.
8 changes: 7 additions & 1 deletion components/cmake/build_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,13 @@ function(build_model COMP_CLASS COMP_NAME)
target_link_libraries(${TARGET_NAME} PRIVATE samxx)
endif()
if (USE_RRTMGPXX)
target_link_libraries(${TARGET_NAME} PRIVATE rrtmgp rrtmgp_interface)
target_link_libraries(${TARGET_NAME} PRIVATE rrtmgp rrtmgp_interface)
endif()
endif()
if (COMP_NAME STREQUAL "elm")
if (USE_PETSC)
target_link_libraries(${TARGET_NAME} PRIVATE "${PETSC_LIBRARIES}")
target_include_directories(${TARGET_NAME} PRIVATE "${PETSC_INCLUDES}")
endif()
endif()
if (USE_KOKKOS)
Expand Down
78 changes: 1 addition & 77 deletions components/cmake/common_setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ set(CPPDEFS "${CPPDEFS} ${USER_CPPDEFS} -D${OS}")
# SLIBS comes from Macros, so this append must come after Macros are included

if (DEBUG)
# e3sm still has components that cannot build with -DDEBUG
if (CIME_MODEL STREQUAL "cesm")
set(CPPDEFS "${CPPDEFS} -DDEBUG")
endif()
else()
set(CPPDEFS "${CPPDEFS} -DNDEBUG")
endif()

Expand Down Expand Up @@ -183,43 +178,6 @@ else()
endif()
endif()

# Set PETSc info if it is being used
if (USE_PETSC)
if (PETSC_PATH)
if (NOT INC_PETSC)
set(INC_PETSC ${PETSC_PATH}/include)
endif()
if (NOT LIB_PETSC)
set(LIB_PETSC ${PETSC_PATH}/lib)
endif()
else()
message(FATAL_ERROR "PETSC_PATH must be defined when USE_PETSC is TRUE")
endif()

# Get the "PETSC_LIB" list an env var
set(PETSC_DIR ${PETSC_PATH})
find_package(PETSc)
set(PETSC_LIB ${PETSC_LIBRARIES})
endif()

# JGF: No one seems to be using this
# if (USE_MOAB)
# if (MOAB_PATH)
# set(CPPDEFS "${CPPDEFS} -DHAVE_MOAB")
# if (NOT INC_MOAB)
# set(INC_MOAB ${MOAB_PATH}/include)
# endif()
# if (NOT LIB_MOAB)
# set(LIB_MOAB ${MOAB_PATH}/lib)
# endif()
# else()
# message(FATAL_ERROR "MOAB_PATH must be defined when USE_MOAB is TRUE")
# endif()

# # # get the "IMESH_LIBS" list as an env var
# #include $(LIB_MOAB)/iMesh-Defs.inc
# endif()

# Set HAVE_SLASHPROC on LINUX systems which are not bluegene or Darwin (OSx)
string(FIND "${CPPDEFS}" "-DLINUX" HAS_DLINUX)
string(FIND "${CPPDEFS}" "DBG" HAS_DBG)
Expand All @@ -241,30 +199,6 @@ if (LIB_PNETCDF)
set(SLIBS "${SLIBS} -L${LIB_PNETCDF} -lpnetcdf")
endif()

# Set esmf.mk location with ESMF_LIBDIR having precedent over ESMFMKFILE
set(CIME_ESMFMKFILE "undefined_ESMFMKFILE")
if (ESMFMKFILE)
set(CIME_ESMFMKFILE ${ESMFMKFILE})
endif()
if (ESMF_LIBDIR)
set(CIME_ESMFMKFILE ${ESMF_LIBDIR}/esmf.mk)
endif()

# For compiling and linking with external ESMF.
# If linking to external ESMF library then include esmf.mk
# ESMF_F90COMPILEPATHS
# ESMF_F90LINKPATHS
# ESMF_F90LINKRPATHS
# ESMF_F90ESMFLINKLIBS
if (USE_ESMF_LIB)
# include(${CIME_ESMFMKFILE}) # JGF SKIPPING FOR NOW
# Will need something like 'make -f esmf.mk -p 2> /dev/null | grep ESMF_F90COMPILEPATHS'
#set(CPPDEFS "${CPPDEFS} -DESMF_VERSION_MAJOR=${ESMF_VERSION_MAJOR} -DESMF_VERSION_MINOR=${ESMF_VERSION_MINOR}")
#set(FFLAGS "${FFLAGS} ${ESMF_F90COMPILEPATHS}")
#set(SLIBS "${SLIBS} ${ESMF_F90LINKPATHS} ${ESMF_F90LINKRPATHS} ${ESMF_F90ESMFLINKLIBS}")
message(FATAL_ERROR "ESMF not supported in CMake yet")
endif()

#===============================================================================
# User-specified INCLDIR
#===============================================================================
Expand Down Expand Up @@ -307,7 +241,7 @@ else()
list(APPEND INCLDIR "${INC_NETCDF_C}" "${INC_NETCDF_FORTRAN}")
endif()

foreach(ITEM MOD_NETCDF INC_MPI INC_PNETCDF INC_PETSC) # INC_MOAB)
foreach(ITEM MOD_NETCDF INC_MPI INC_PNETCDF)
if (${ITEM})
list(APPEND INCLDIR "${${ITEM}}")
endif()
Expand Down Expand Up @@ -376,16 +310,6 @@ if (LIB_MPI)
endif()
endif()

# Add PETSc libraries
if (USE_PETSC)
set(SLIBS "${SLIBS} ${PETSC_LIB}")
endif()

# Add MOAB libraries. These are defined in the MOAB_LINK_LIBS env var that was included above
# if (USE_MOAB)
# set(SLIBS "${SLIBS} ${IMESH_LIBS}")
# endif()

# Add libraries and flags that we need on the link line when C++ code is included
if (USE_CXX)
if (CXX_LIBS)
Expand Down
3 changes: 3 additions & 0 deletions components/cmake/find_dep_packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ if (USE_ALBANY)
find_package(Albany REQUIRED)
endif()

if (USE_PETSC)
find_package(PETSc REQUIRED)
endif()
11 changes: 3 additions & 8 deletions components/mpas-ocean/src/ocean.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ if (LAPACK_FOUND AND BLAS_FOUND)
endif()

if (USE_PETSC)
find_package(PETSc)
if (PETSC_FOUND)
list(APPEND CPPDEFS "-DUSE_PETSC")
list(APPEND INCLUDES "${PETSC_INCLUDES}")
list(APPEND LIBRARIES "${PETSC_LIBRARIES}")
else()
message(FATAL_ERROR "USE_PETSC is ON but find_package could not find petsc")
endif()
list(APPEND CPPDEFS "-DUSE_PETSC")
list(APPEND INCLUDES "${PETSC_INCLUDES}")
list(APPEND LIBRARIES "${PETSC_LIBRARIES}")
endif()

# driver (files live in E3SM)
Expand Down

0 comments on commit 614d911

Please sign in to comment.