Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Updated CMAKE files to better handle coarrays and preprocessor variables
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Mar 21, 2023
1 parent 00d2ff5 commit a03a27e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)

# Set some options the user may choose
# Uncomment the below if you want the user to choose a parallelization library
OPTION(USE_CAF "Use Coarray Fortran for parallelization" ON)
OPTION(USE_COARRAY "Use Coarray Fortran for parallelization" OFF)
OPTION(USE_OPENMP "Use OpenMP for parallelization" ON)

IF (USE_COARRAY)
ADD_DEFINITIONS(-DCOARRAY)
ENDIF()

# Locate and set parallelization libraries. There are some CMake peculiarities
# taken care of here, such as the fact that the FindOpenMP routine doesn't know
Expand Down
34 changes: 24 additions & 10 deletions cmake/Modules/FindCoarray_Fortran.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,31 @@

INCLUDE (${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)

STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT)
IF(BT STREQUAL "DEBUG")
SET (Coarray_Fortran_FLAG_CANDIDATES
#Intel
"-coarray=single"
#Intel windows
"/Qcoarray:single"
#Gnu
"-fcoarray=single"
#Empty, if compiler automatically accepts coarray
" "
)
ELSE()
SET (Coarray_Fortran_FLAG_CANDIDATES
#Intel
"-coarray=distributed"
#Intel windows
"/Qcoarray:distributed"
#Gnu
"-fcoarray=lib -lcaf_mpi"
#Empty, if compiler automatically accepts coarray
" "
)
ENDIF()

SET (Coarray_Fortran_FLAG_CANDIDATES
#Intel
"-coarray=distributed"
#Intel windows
"/Qcoarray:distributed"
#Gnu
"-fcoarray=lib -lcaf_mpi"
#Empty, if compiler automatically accepts coarray
" "
)

IF (DEFINED Coarray_Fortran_FLAGS)
SET (Coarray_Fortran_FLAG_CANDIDATES)
Expand Down
9 changes: 4 additions & 5 deletions cmake/Modules/SetParallelizationLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@ IF (USE_OPENMP)
ENDIF (NOT OpenMP_Fortran_FLAGS)
ENDIF (USE_OPENMP)

IF (USE_CAF)
# Find MPI
IF (USE_COARRAY)
IF (NOT Coarray_Fortran_FLAGS)
FIND_PACKAGE (Coarray_Fortran)
IF (NOT Coarray_Fortran_FLAGS)
MESSAGE (FATAL_ERROR "Fortran compiler does not support Coarrays")
ENDIF (NOT Coarray_Fortran_FLAGS)
ENDIF (NOT Coarray_Fortran_FLAGS)
ENDIF (USE_CAF)
ENDIF (USE_COARRAY)

IF (NOT USE_OPENMP AND NOT USE_CAF)
IF (NOT USE_OPENMP AND NOT USE_COARRAY)
# Turn off both OpenMP and CAF
SET (OMP_NUM_PROCS 0 CACHE
STRING "Number of processors OpenMP may use" FORCE)
UNSET (OpenMP_Fortran_FLAGS CACHE)
UNSET (Coarray_Fortran_FLAGS CACHE)
UNSET (GOMP_Fortran_LINK_FLAGS CACHE)
ENDIF (NOT USE_OPENMP AND NOT USE_CAF)
ENDIF (NOT USE_OPENMP AND NOT USE_COARRAY)

0 comments on commit a03a27e

Please sign in to comment.