Skip to content

Commit

Permalink
Refactor Loki/GPU build options
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Mar 21, 2024
1 parent 3bb8903 commit 7e2c64c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ecbuild_find_package( NAME loki )
ecwam_find_python_mods()
ecbuild_add_option( FEATURE GEN_DERIV_TYPES
DEFAULT ON
DESCRIPTION "Generate derived-type data structures using fypp pre-processor"
DESCRIPTION "Generate derived-type data structures using fypp pre-processor and yaml config"
CONDITION FYPP_FOUND AND PYYAML_FOUND )

### Set third party libraries
Expand All @@ -90,28 +90,27 @@ if( HAVE_OMP )
set( OpenMP_Fortran_LIBRARIES OpenMP::OpenMP_Fortran )
endif()

### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE WAM_LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
CONDITION loki_FOUND )

# Determine Loki transformation type
if( NOT DEFINED LOKI_MODE )
set( LOKI_MODE "scc-stack" CACHE STRING "Transformation mode for Loki source transformations" )
endif()

# Workaround for the fact that CMake only sets language components to FOUND,
# so OpenACC_FOUND must be set manually
find_package( OpenACC )
if( OpenACC_Fortran_FOUND AND OpenACC_C_FOUND )
set( OpenACC_FOUND ON )
endif()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT ON
DESCRIPTION "OpenACC" DEFAULT OFF
REQUIRED_PACKAGES "OpenACC"
CONDITION CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" )

### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE WAM_LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
CONDITION HAVE_LOKI )

### Apply Loki source-to-source transformations to the ecWam physics with GPU offload
ecbuild_add_option( FEATURE WAM_LOKI_GPU
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics with GPU offload"
CONDITION HAVE_ACC AND field_api_FOUND AND HAVE_LOKI )
CONDITION HAVE_WAM_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" AND HAVE_GEN_DERIV_TYPES )

### Sources

Expand Down
4 changes: 2 additions & 2 deletions src/ecwam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ list( APPEND ecwam_srcs
z0wave.F90
)

if(HAVE_WAM_LOKI AND NOT ${LOKI_DEBUG})
if(HAVE_WAM_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack")
list(APPEND ecwam_srcs wamintgr_loki_gpu.F90)
list(REMOVE_ITEM ecwam_srcs wamintgr.F90)
endif()
Expand Down Expand Up @@ -495,7 +495,7 @@ if( HAVE_WAM_LOKI )
set( LOKI_FRONTEND "fp" CACHE STRING "Frontend parser for Loki source transformations" )
set( SCC_ARGS "")

if( ${LOKI_DEBUG} )
if( LOKI_MODE MATCHES "idem|idem-stack" )
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki.config )
else()
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki_gpu.config )
Expand Down

0 comments on commit 7e2c64c

Please sign in to comment.