Skip to content

Commit 6a5814a

Browse files
Updates for SCOTCH 7.0.7
1 parent 9939046 commit 6a5814a

File tree

3 files changed

+67
-12
lines changed

3 files changed

+67
-12
lines changed

cmake/FindSCOTCH.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,46 @@ find_package_handle_standard_args(
7777
REQUIRED_VARS ptscotchparmetis_lib
7878
ptscotchparmetis_inc)
7979

80+
81+
## Find version of scotch if possible
82+
if( EXISTS "${scotch_inc}/scotch.h" )
83+
84+
file(READ "${scotch_inc}/scotch.h" header_content)
85+
86+
# Extract the major version number using regex
87+
string(REGEX MATCH "SCOTCH_VERSION ([0-9]+)" VERSION_MAJOR_MATCH "${header_content}")
88+
if(VERSION_MAJOR_MATCH)
89+
set(SCOTCH_VERSION_MAJOR "${CMAKE_MATCH_1}")
90+
message(STATUS "SCOTCH_VERSION_MAJOR: ${SCOTCH_VERSION_MAJOR}")
91+
else()
92+
message(WARNING "Could not find SCOTCH_VERSION in scotch.h")
93+
endif()
94+
95+
# Extract the minor version number using regex
96+
string(REGEX MATCH "SCOTCH_RELEASE ([0-9]+)" VERSION_MINOR_MATCH "${header_content}")
97+
if(VERSION_MINOR_MATCH)
98+
set(SCOTCH_RELEASE "${CMAKE_MATCH_1}")
99+
message(STATUS "SCOTCH_RELEASE: ${SCOTCH_RELEASE}")
100+
else()
101+
message(WARNING "Could not find SCOTCH_RELEASE in scotch.h")
102+
endif()
103+
104+
# Extract the patch version number using regex
105+
string(REGEX MATCH "SCOTCH_PATCHLEVEL ([0-9]+)" VERSION_PATCH_MATCH "${header_content}")
106+
if(VERSION_PATCH_MATCH)
107+
set(SCOTCH_PATCHLEVEL "${CMAKE_MATCH_1}")
108+
message(STATUS "SCOTCH_PATCHLEVEL: ${SCOTCH_PATCHLEVEL}")
109+
else()
110+
message(WARNING "Could not find VERSION_PATCH in scotch.h")
111+
endif()
112+
set(SCOTCH_VERSION "${SCOTCH_VERSION_MAJOR}.${SCOTCH_RELEASE}.${SCOTCH_PATCHLEVEL}")
113+
endif()
114+
80115
message(STATUS "Found SCOTCH: ${scotch_lib}")
81116
message(STATUS "Found PTSCOTCH: ${ptscotch_lib}")
82117
message(STATUS "Found SCOTCHerr: ${scotcherr_lib}")
83118
message(STATUS "Found PTSCOTCHerr: ${ptscotcherr_lib}")
84119
message(STATUS "Found PTSCOTCHparmetis: ${ptscotchparmetis_lib}")
120+
message(STATUS "SCOTCH version: ${SCOTCH_VERSION}")
121+
122+

model/src/CMakeLists.txt

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
105105
set(compile_flags_debug -O0 -Rbcps -Ktrap=fp)
106106
endif()
107107

108-
target_compile_options(ww3_lib PUBLIC "$<$<COMPILE_LANGUAGE:Fortran>:${compile_flags}>")
109-
target_compile_options(ww3_lib PUBLIC "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:Fortran>>:${compile_flags_debug}>")
110-
target_compile_options(ww3_lib PUBLIC "$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:Fortran>>:${compile_flags_release}>")
111-
112108
# Executables to always build
113109
set(programs ww3_strt ww3_grid ww3_bound ww3_outf ww3_outp ww3_trck ww3_grib
114110
ww3_gint gx_outf gx_outp ww3_uprstr ww3_shel ww3_prep ww3_gspl ww3_multi ww3_systrk)
@@ -181,16 +177,23 @@ endif()
181177
# Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file
182178
if("PDLIB" IN_LIST switches)
183179
if("SCOTCH" IN_LIST switches)
184-
find_package(SCOTCH REQUIRED)
185-
target_sources(ww3_lib PRIVATE ${pdlib_src})
186-
target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis)
187-
elseif("METIS" IN_LIST switches)
188-
find_package(ParMETIS REQUIRED)
189-
target_sources(ww3_lib PRIVATE ${pdlib_src})
190-
target_link_libraries(ww3_lib PUBLIC ParMETIS::ParMETIS)
180+
find_package(SCOTCH REQUIRED)
181+
target_sources(ww3_lib PRIVATE ${pdlib_src})
182+
target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis)
183+
if(SCOTCH_VERSION VERSION_GREATER "7.0.6")
184+
list(APPEND compile_flags -DSCOTCH_707)
185+
list(APPEND compile_flags_release -DSCOTCH_707)
186+
list(APPEND compile_flags_debug -DSCOTCH_707)
187+
else()
188+
message(STATUS "SOCTCH version 7.06 or lower")
189+
endif()
190+
elseif("METIS" IN_LIST switches)
191+
find_package(ParMETIS REQUIRED)
192+
target_sources(ww3_lib PRIVATE ${pdlib_src})
193+
target_link_libraries(ww3_lib PUBLIC ParMETIS::ParMETIS)
191194
else()
192195
message(FATAL_ERROR "PDLIB requires METIS or SCOTCH library for domain decomposition")
193-
endif()
196+
endif()
194197
endif()
195198

196199
if("SCRIP" IN_LIST switches)
@@ -224,6 +227,10 @@ foreach(program ${programs})
224227
target_link_libraries(${program} PRIVATE ww3_lib)
225228
endforeach()
226229

230+
target_compile_options(ww3_lib PUBLIC "$<$<COMPILE_LANGUAGE:Fortran>:${compile_flags}>")
231+
target_compile_options(ww3_lib PUBLIC "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:Fortran>>:${compile_flags_debug}>")
232+
target_compile_options(ww3_lib PUBLIC "$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:Fortran>>:${compile_flags_release}>")
233+
227234
install(
228235
TARGETS ${programs} ww3_lib
229236
EXPORT WW3Exports

model/src/PDLIB/yowpdlibmain.F90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,23 @@ subroutine runParmetis(MNP)
629629

630630
!if(debugParmetis) write(710+myrank,*) "Run ParMETIS now..."
631631
#ifdef W3_SCOTCH
632+
#ifdef SCOTCH_707
633+
! Starting with SCOTCH 7.0.7 need ot explicitly call the SCOTCHF
634+
call SCOTCHFParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, &
635+
vwgt, & !vwgt - ignore weights
636+
adjwgt, & ! adjwgt - ignore weights
637+
wgtflag, &
638+
numflag,ndims,xyz,ncon,nparts,tpwgts,ubvec,options, &
639+
edgecut,part, comm,ref)
640+
#else
632641
call SCOTCH_ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, &
633642
vwgt, & !vwgt - ignore weights
634643
adjwgt, & ! adjwgt - ignore weights
635644
wgtflag, &
636645
numflag,ndims,xyz,ncon,nparts,tpwgts,ubvec,options, &
637646
edgecut,part, comm,ref)
638647
#endif
648+
#endif
639649

640650
#ifdef W3_METIS
641651
call ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, &

0 commit comments

Comments
 (0)