Skip to content

Commit b973fb3

Browse files
authored
Merge branch 'bartgol/homme/timing-lib-mods' (PR #7727)
Avoid building CIME's tpl timing library when building homme inside eamxx. [BFB]
2 parents a73affb + 44619d6 commit b973fb3

File tree

16 files changed

+45
-13446
lines changed

16 files changed

+45
-13446
lines changed

components/eamxx/cmake/tpls/Scorpio.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ macro (CreateScorpioTargets)
2929
# that, so we need another way. Including the src tree folder works.
3030
target_include_directories(pioc INTERFACE ${SCREAM_BASE_DIR}/../../externals/scorpio/src/clib)
3131

32+
add_library (gptl INTERFACE)
33+
target_link_libraries(gptl INTERFACE spio)
34+
target_include_directories(gptl INTERFACE ${INSTALL_SHAREDPATH}/include)
35+
3236
else ()
3337
# Not a CIME build. We'll add scorpio as a subdir
3438

@@ -48,10 +52,12 @@ macro (CreateScorpioTargets)
4852
list(APPEND C_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/externals/scorpio/src/clib")
4953
set (SCORPIO_C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" CACHE INTERNAL "SCORPIO C include dirs")
5054

51-
# Add GPTL from SCORPIO
55+
# Add include dirs to the GPTL target that SCORPIO builds (scorpio sets them as PRIVATE properties, unfortunately)
5256
if (NOT GPTL_PATH)
5357
set (GPTL_PATH ${E3SM_EXTERNALS_DIR}/scorpio/src/gptl CACHE INTERNAL "Path to GPTL library")
5458
endif ()
59+
target_include_directories(gptl PUBLIC $<BUILD_INTERFACE:${GPTL_PATH}>)
60+
target_include_directories(gptl PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/externals/scorpio/src/gptl>)
5561

5662
EkatDisableAllWarning(pioc)
5763
EkatDisableAllWarning(piof)

components/eamxx/src/share/util/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,7 @@ target_link_libraries (eamxx_utils PUBLIC
1515
ekat::Logging
1616
ekat::Pack)
1717

18-
# We need to link gptl, used by eamxx_timing.cpp, but it is a bit problematic.
19-
# In standalone builds, it is built by scorpio, but its target properties are PRIVATE
20-
# In CIME builds, it is attached to the spio target (which we link to our interface
21-
# targets pioc/piof).
22-
# Hence, in CIME builds, just link against pioc (sharedlib are already built anyways),
23-
# while in standalone builds, link against gptl itself
24-
if (SCREAM_CIME_BUILD)
25-
target_link_libraries (eamxx_utils PUBLIC pioc)
26-
target_include_directories(eamxx_utils PUBLIC ${INSTALL_SHAREDPATH}/include)
27-
else ()
28-
target_link_libraries (eamxx_utils PUBLIC gptl)
29-
target_include_directories(eamxx_utils PUBLIC ${GPTL_PATH})
30-
endif()
18+
target_link_libraries (eamxx_utils PUBLIC gptl)
3119

3220
if (NOT SCREAM_LIB_ONLY)
3321
add_subdirectory(tests)

components/homme/CMakeLists.txt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,28 @@ IF (DEFINED SUNDIALS_DIR)
365365
INCLUDE_DIRECTORIES(${SUNDIALS_DIR}/fortran)
366366
ENDIF ()
367367

368-
###########################################
369-
# Definitions for timing library
370-
###########################################
371-
# This is required in timing to set HAVE_MPI
372-
ADD_DEFINITIONS(-DSPMD)
373-
OPTION(ENABLE_NANOTIMERS "Use nano timers in timing library" FALSE)
374-
OPTION(USE_BIT64 "Set BIT64 (for 64 bit arch) in timing library when ENABLE_NANOTIME" FALSE)
375-
IF (${ENABLE_NANOTIMERS})
376-
ADD_DEFINITIONS(-DHAVE_NANOTIME)
377-
IF (${USE_BIT64})
378-
ADD_DEFINITIONS(-DBIT64)
368+
if (HOMME_STANDALONE OR NOT TARGET gptl)
369+
###########################################
370+
# Definitions for timing library
371+
###########################################
372+
# This is required in timing to set HAVE_MPI
373+
ADD_DEFINITIONS(-DSPMD)
374+
OPTION(ENABLE_NANOTIMERS "Use nano timers in timing library" FALSE)
375+
OPTION(USE_BIT64 "Set BIT64 (for 64 bit arch) in timing library when ENABLE_NANOTIME" FALSE)
376+
IF (${ENABLE_NANOTIMERS})
377+
ADD_DEFINITIONS(-DHAVE_NANOTIME)
378+
IF (${USE_BIT64})
379+
ADD_DEFINITIONS(-DBIT64)
380+
ENDIF ()
379381
ENDIF ()
380-
ENDIF ()
381-
ADD_SUBDIRECTORY(utils/cime/CIME/non_py/src/timing)
382+
ADD_SUBDIRECTORY(utils/cime/CIME/non_py/src/timing)
383+
target_include_directories (timing PUBLIC utils/cime/CIME/non_py/src/timing)
384+
target_include_directories (timing PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/utils/cime/CIME/non_py/src/timing)
385+
else ()
386+
# EAMxx already takes care of making the gptl target available, so just make the timing tgt point to that
387+
add_library(timing INTERFACE)
388+
target_link_libraries (timing INTERFACE gptl)
389+
endif()
382390

383391

384392
# CMAKE_CURRENT_SOURCE_DIR == homme
@@ -409,16 +417,15 @@ if (HOMME_BUILD_SCORPIO)
409417
message("-- PnetCDF_C_PATH = ${PnetCDF_C_PATH}")
410418
message("** Configuring SCORPIO")
411419
# pio needs cime/externals/genf90/genf90.pl
420+
SET(GENF90_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/cime/CIME/non_py/externals/genf90)
412421
if (HOMME_USE_SCORPIO)
413422
# Need to use scorpio's older genf90 for now
414-
SET(GENF90_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/utils/externals/scorpio/src/genf90)
415423
SET(PIO_ENABLE_TOOLS OFF CACHE BOOL "Disabling Scorpio tool build")
416424
ADD_SUBDIRECTORY(utils/externals/scorpio)
417425
SET(PIO_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/utils/externals/scorpio/src/flib")
418426
else ()
419427
# The default I/O library used in "Scorpio classic"
420428
ADD_SUBDIRECTORY(utils/externals/scorpio_classic)
421-
SET(GENF90_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/cime/CIME/non_py/externals/genf90)
422429
SET(PIO_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/utils/externals/scorpio/pio")
423430
endif ()
424431
INCLUDE_DIRECTORIES(${PIO_INCLUDE_DIRS})

components/homme/src/preqx/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ SET(SRC_SHARE_DIR ${HOMME_SOURCE_DIR}/src/share)
1212
SET(TRILINOS_ZOLTAN_DIR ${HOMME_SOURCE_DIR}/src/zoltan)
1313
SET(TEST_SRC_DIR ${HOMME_SOURCE_DIR}/src/test_src)
1414

15-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/cime/CIME/non_py/src/timing)
16-
1715
# Make INCLUDE_DIRS global so the tests can access it
18-
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS} ${UTILS_TIMING_DIR})
16+
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS})
1917

2018
# Find F90 files in target directory
2119
FILE(GLOB TARGET_F90 ${TARGET_DIR}/*.F90 ${SRC_SHARE_DIR}/*.F90 ${SRC_DIR}/preqx/share/*.F90 ${TEST_SRC_DIR}/*.F90)

components/homme/src/preqx_acc/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ SET(TARGET_DIR ${HOMME_SOURCE_DIR}/src/preqx_acc)
1313
SET(SRC_DIR ${HOMME_SOURCE_DIR}/src)
1414
SET(SRC_SHARE_DIR ${HOMME_SOURCE_DIR}/src/share)
1515
SET(TEST_SRC_DIR ${HOMME_SOURCE_DIR}/src/test_src)
16-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/cime/CIME/non_py/src/timing)
1716

1817
# Make INCLUDE_DIRS global so the tests can access it
19-
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS}
20-
${UTILS_TIMING_DIR} )
18+
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS})
2119

2220
SET(TARGET_DIR ${HOMME_SOURCE_DIR}/src/preqx_acc)
2321
FILE(GLOB TARGET_F90 ${TARGET_DIR}/*.F90 ${SRC_SHARE_DIR}/*.F90 ${SRC_DIR}/preqx/share/*.F90 ${TEST_SRC_DIR}/*.F90)

components/homme/src/preqx_kokkos/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ MACRO(PREQX_KOKKOS_SETUP)
1414
SET(TRILINOS_ZOLTAN_DIR ${HOMME_SOURCE_DIR}/src/zoltan)
1515
SET(TEST_SRC_DIR ${HOMME_SOURCE_DIR}/src/test_src)
1616

17-
SET(UTILS_TIMING_SRC_DIR ${HOMME_SOURCE_DIR}/utils/cime/CIME/non_py/src/timing)
18-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/cime/CIME/non_py/src/timing)
19-
2017
# Make INCLUDE_DIRS global so the tests can access it
2118
SET (EXEC_LIB_INCLUDE_DIRS
2219
${TARGET_DIR}/cxx
23-
${UTILS_TIMING_DIR}
24-
${UTILS_TIMING_SRC_DIR}
2520
${PREQX_SHARE_DIR}
2621
${SRC_SHARE_DIR}/cxx
2722
${HOMME_BINARY_DIR}/src/share/cxx

components/homme/src/prim/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ LINK_DIRECTORIES ( ${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS})
99
SET(SRC_DIR ${HOMME_SOURCE_DIR}/src)
1010
SET(SRC_SHARE_DIR ${HOMME_SOURCE_DIR}/src/share)
1111
SET(PHYSICS_DIR ${HOMME_SOURCE_DIR}/physics)
12-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/timing)
1312
SET(UTILS_TRILINOS_DIR ${HOMME_SOURCE_DIR}/utils/trilinos)
1413

1514
# Make INCLUDE_DIRS global so the tests can access it
16-
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS}
17-
${UTILS_TIMING_DIR} )
15+
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS})
1816

1917
FILE(GLOB SB81_SRC_F90 ${SRC_DIR}/preqx/share/*.F90)
2018

components/homme/src/share/namelist_mod.F90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ subroutine readnl(par)
217217
integer :: se_nsplit
218218
integer :: interp_nlat, interp_nlon, interp_gridtype
219219
integer :: i, ii
220-
#if !defined(CAM) && !defined(SCREAM) && !defined(HOMME_WITHOUT_PIOLIBRARY)
221-
integer :: j, interp_type
220+
#if !defined(CAM) && !defined(SCREAM)
221+
#if !defined(HOMME_WITHOUT_PIOLIBRARY)
222+
integer :: j
223+
#endif
224+
integer :: interp_type
222225
#endif
223226
integer :: ierr
224227
character(len=80) :: errstr, arg

components/homme/src/sweqx/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ macro(sweqx_setup)
77
SET(TARGET_DIR ${HOMME_SOURCE_DIR}/src/sweqx)
88
SET(SRC_BASE ${HOMME_SOURCE_DIR}/src)
99
SET(SRC_SHARE ${HOMME_SOURCE_DIR}/src/share)
10-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/cime/CIME/non_py/src/timing)
1110

1211
# Find F90 files in target directory
1312
FILE(GLOB TARGET_F90 ${TARGET_DIR}/*.F90)
1413

1514
# Make INCLUDE_DIRS global so the tests can access it
16-
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS} ${UTILS_TIMING_DIR} )
15+
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS})
1716

1817
SET(SWEQX_SRCS
1918
${TARGET_F90}

components/homme/src/swim/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ LINK_DIRECTORIES ( ${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS} )
99
SET(SRC_DIR ${HOMME_SOURCE_DIR}/src)
1010
SET(SRC_SHARE_DIR ${HOMME_SOURCE_DIR}/src/share)
1111
SET(UTILS_TRILINOS_DIR ${HOMME_SOURCE_DIR}/utils/trilinos)
12-
SET(UTILS_TIMING_DIR ${HOMME_BINARY_DIR}/utils/timing)
1312

14-
15-
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS}
16-
${UTILS_TIMING_DIR} )
17-
13+
SET (EXEC_INCLUDE_DIRS ${PIO_INCLUDE_DIRS})
1814

1915
# Make SRCS global so the tests can access it
2016
SET(SWIM_SRCS ${SRC_SHARE_DIR}/kinds.F90

0 commit comments

Comments
 (0)