Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ww3 scotch #849

Merged
merged 42 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bb58f83
add scotch to dev
Oct 27, 2022
ba2f34f
add options for METIS and SCOTCH to GNU build
Nov 1, 2022
3655fac
add cmake capability to scotch
Nov 3, 2022
faa8d28
Merge remote-tracking branch 'upstream/develop' into ww3_scotch_dev
Nov 3, 2022
771e72f
few fixes
Nov 3, 2022
7135e29
update regtests
Nov 3, 2022
2c0d832
remove tmp link and comp
Nov 3, 2022
cc9bf72
fix typo
Nov 3, 2022
12baa6b
update regtests/bin/run_test
Nov 3, 2022
55f72e8
fix model/src/CMakeLists.txt
Nov 8, 2022
4014f78
add SCOTCH/METIS to bin/switch*pdlib*
Nov 9, 2022
4d1fba6
update cache_key for github action
Nov 9, 2022
604f04c
consolidate cmake/Find*.cmake files
Nov 10, 2022
0d2e4b3
some check
Nov 10, 2022
588fc54
more check
Nov 10, 2022
7fa9ebd
more checks
Nov 10, 2022
68ddc3a
another try
Nov 10, 2022
13cf941
another try2
Nov 10, 2022
65e8061
another try3
Nov 10, 2022
25fc80b
another try4
Nov 10, 2022
c65eadc
revert switch in model/bin/switch_ite_pdlib
Nov 14, 2022
1e9ab18
Update spack.yaml
aliabdolali Nov 17, 2022
da5716a
Update spack.yaml
aliabdolali Nov 17, 2022
28b1ff0
Merge remote-tracking branch 'upstream/develop' into ww3_scotch_dev
Nov 22, 2022
4a1b270
merge dev
Dec 14, 2022
ca072e4
Merge remote-tracking branch 'upstream/develop' into ww3_scotch_dev
Jan 12, 2023
b0e025a
Merge remote-tracking branch 'EMCWW3/develop' into new/scotchfix
JessicaMeixner-NOAA Feb 8, 2023
3007ca8
updates to cmake and ci
JessicaMeixner-NOAA Feb 8, 2023
158cc6d
sync dev
Feb 12, 2023
1401eda
rename COASTAL to STI on Hera
Feb 12, 2023
8184ada
Merge pull request #9 from JessicaMeixner-NOAA/new/scotchfix
aliabdolali Feb 12, 2023
1eb026f
merge upstream dev
Feb 16, 2023
3ac6cb9
matrix_cmake_ncep: add updated SCOTCH_PATH
MatthewMasarik-NOAA Feb 17, 2023
8cf103a
matrix_cmake_ncep: add updated SCOTCH_PATH for orion
MatthewMasarik-NOAA Feb 17, 2023
1211770
matrix_cmake_ncep: re-order module loads
MatthewMasarik-NOAA Feb 21, 2023
98509cb
matrix_cmake_ncep: re-order module loads for hera
MatthewMasarik-NOAA Feb 21, 2023
445a3df
matrix_cmake_ncep: gnu module use/loads
MatthewMasarik-NOAA Feb 21, 2023
9340d8f
matrix_cmake_ncep: re-order gnu mods
MatthewMasarik-NOAA Feb 21, 2023
a3c8bb8
re-re-order of module loads
MatthewMasarik-NOAA Feb 22, 2023
1ca5152
matrix_cmake_ncep: remove gnu module related
MatthewMasarik-NOAA Feb 23, 2023
67c91ff
Merge pull request #10 from MatthewMasarik-NOAA/ww3_scotch_dev
thesser1 Feb 28, 2023
d6b5427
merge upstream
Feb 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmake/FindPTSCOTCH.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
message(STATUS "Searching for PTSCOTCH library ...")

find_library(ptscotch_lib NAMES libptscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib)
find_path(ptscotch_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include)

add_library(PTSCOTCH::PTSCOTCH STATIC IMPORTED)

set_target_properties(PTSCOTCH::PTSCOTCH PROPERTIES
IMPORTED_LOCATION "${ptscotch_lib}"
INTERFACE_INCLUDE_DIRECTORIES "${ptscotch_inc}")

## Finalize find_package
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
${CMAKE_FIND_PACKAGE_NAME}
REQUIRED_VARS ptscotch_lib
ptscotch_inc)

message(STATUS "Found PTSCOTCH: ${ptscotch_lib}")
20 changes: 20 additions & 0 deletions cmake/FindPTSCOTCHerr.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
message(STATUS "Searching for PTSCOTCHerr library ...")

find_library(ptscotcherr_lib NAMES libptscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib)
find_path(ptscotcherr_inc ptscotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include)

add_library(PTSCOTCHerr::PTSCOTCHerr STATIC IMPORTED)

set_target_properties(PTSCOTCHerr::PTSCOTCHerr PROPERTIES
IMPORTED_LOCATION "${ptscotcherr_lib}"
INTERFACE_INCLUDE_DIRECTORIES "${ptscotcherr_inc}")

## Finalize find_package
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
${CMAKE_FIND_PACKAGE_NAME}
REQUIRED_VARS ptscotcherr_lib
ptscotcherr_inc)

message(STATUS "Found PTSCOTCHerr: ${ptscotcherr_lib}")
20 changes: 20 additions & 0 deletions cmake/FindPTSCOTCHparmetis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
message(STATUS "Searching for PTSCOTCHparmetis library ...")
find_library(ptscotchparmetis_lib NAMES libptscotchparmetisv3.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib)
find_path(ptscotchparmetis_inc parmetis.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include)

add_library(PTSCOTCHparmetis::PTSCOTCHparmetis STATIC IMPORTED)

set_target_properties(PTSCOTCHparmetis::PTSCOTCHparmetis PROPERTIES
IMPORTED_LOCATION "${ptscotchparmetis_lib}"
INTERFACE_INCLUDE_DIRECTORIES "${ptscotchparmetis_inc}")

## Finalize find_package
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
${CMAKE_FIND_PACKAGE_NAME}
REQUIRED_VARS ptscotchparmetis_lib
ptscotchparmetis_inc)

message(STATUS "Found PTSCOTCHparmetis: ${ptscotchparmetis_lib}")

21 changes: 21 additions & 0 deletions cmake/FindSCOTCH.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
message(STATUS "Searching for SCOTCH library ...")

find_library(scotch_lib NAMES libscotch.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib)
find_path(scotch_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include)

add_library(SCOTCH::SCOTCH STATIC IMPORTED)

set_target_properties(SCOTCH::SCOTCH PROPERTIES
IMPORTED_LOCATION "${scotch_lib}"
INTERFACE_INCLUDE_DIRECTORIES "${scotch_inc}")

## Finalize find_package
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
${CMAKE_FIND_PACKAGE_NAME}
REQUIRED_VARS scotch_lib
scotch_inc)

message(STATUS "Found SCOTCH: ${scotch_lib}")

22 changes: 22 additions & 0 deletions cmake/FindSCOTCHerr.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
message(STATUS "Searching for SCOTCHerr library ...")

find_library(scotcherr_lib NAMES libscotcherr.a HINTS ENV SCOTCH_PATH PATH_SUFFIXES lib)
find_path(scotcherr_inc scotch.h HINTS ENV SCOTCH_PATH PATH_SUFFIXES include)

add_library(SCOTCHerr::SCOTCHerr STATIC IMPORTED)


set_target_properties(SCOTCHerr::SCOTCHerr PROPERTIES
IMPORTED_LOCATION "${scotcherr_lib}"
INTERFACE_INCLUDE_DIRECTORIES "${scotcherr_inc}")


## Finalize find_package
include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
${CMAKE_FIND_PACKAGE_NAME}
REQUIRED_VARS scotcherr_lib
scotcherr_inc)

message(STATUS "Found SCOTCHerr: ${scotcherr_lib}")
33 changes: 32 additions & 1 deletion model/bin/build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check_switches()
dstress s_ice s_is reflection \
wind windx wcor rwind curr currx mgwind mgprop mggse \
subsec tdyn dss0 pdif tide refrx ig rotag nnt mprf \
cou oasis agcm ogcm igcm trknc setup pdlib memck uost rstwind b4b
cou oasis agcm ogcm igcm trknc setup pdlib ddlib memck uost rstwind b4b
do

# 1.a.1 Group switches by category
Expand Down Expand Up @@ -291,6 +291,12 @@ check_switches()
ID='use pdlib'
TS='PDLIB'
OK='PDLIB' ;;

#sort:ddlib:
ddlib ) TY='upto1'
ID='domain decomposition library'
OK='METIS SCOTCH' ;;

#sort:memck:
memck ) TY='upto1'
ID='check memory use'
Expand Down Expand Up @@ -428,6 +434,7 @@ check_switches()
igcm ) igcm=$sw ;;
trknc ) trknc=$sw ;;
pdlib ) pdlib=$sw ;;
ddlib ) ddlib=$sw ;;
memck ) memck=$sw ;;
setup ) setup=$sw ;;
uost ) uost=$sw ;;
Expand Down Expand Up @@ -547,6 +554,30 @@ check_switches()
echo ' ' ; exit 17
fi

if [ "$pdlib" = 'PDLIB' ] && [ "$ddlib" != 'SCOTCH' ]
then
if [ "$ddlib" != 'METIS' ]
then
echo ' '
echo " *** For PDLIB, we need either SCOTCH or METIS, not both."
echo ' ' ; exit 18
fi
fi


if [ "$ddlib" = 'METIS' ] && [ "$pdlib" != 'PDLIB' ]
then
echo ' '
echo " *** For METIS, we need to have PDLIB as well."
echo ' ' ; exit 19
fi

if [ "$ddlib" = 'SCOTCH' ] && [ "$pdlib" != 'PDLIB' ]
then
echo ' '
echo " *** For SCOTCH, we need to have PDLIB as well."
echo ' ' ; exit 20
fi

} #end of check_switches

Expand Down
16 changes: 15 additions & 1 deletion model/bin/link.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@
libs="$libs `$NETCDF_CONFIG --flibs` `$NETCDF_CONFIG --libs`"
fi

# scotch library
if [ "$prog" = 'ww3_shel' ] || [ "$prog" = 'ww3_multi' ] || [ "$prog" = 'ww3_sbs1' ] ; then
if [ "$scotch_mod" = 'yes' ] ; then
if [ -z "$(env | grep SCOTCH_PATH)" ] ; then
echo ''
echo "[ERROR] SCOTCH_PATH is not defined"
exit 1
fi
echo "link with scotch"
libs="$libs $SCOTCH_PATH/lib/libptscotchparmetisv3.a $SCOTCH_PATH/lib/libptscotch.a $SCOTCH_PATH/lib/libptscotcherr.a $SCOTCH_PATH/lib/libscotch.a"
fi
fi


# parmetis library
if [ "$prog" = 'ww3_shel' ] || [ "$prog" = 'ww3_multi' ] || [ "$prog" = 'ww3_sbs1' ] ; then
if [ "$pdlib_mod" = 'yes' ] ; then
if [ "$metis_mod" = 'yes' ] ; then
if [ -z "$(env | grep METIS_PATH)" ] ; then
echo ''
echo "[ERROR] METIS_PATH is not defined"
Expand Down
2 changes: 2 additions & 0 deletions model/bin/w3_automake
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@
./sort_switch -s -r switch
sed -e 's/DIST/SHRD/g' \
-e 's/PDLIB //g' \
-e 's/METIS //g' \
-e 's/SCOTCH //g' \
-e 's/OMPG //g' \
-e 's/PDLIB //g' \
-e 's/OMPH //g' \
Expand Down
17 changes: 16 additions & 1 deletion model/bin/w3_make
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,28 @@ EOF
export oasis_mod

pdlib_mod=no
metis_mod=no
scotch_mod=no

esmfpdlib=''
if [ -n "`grep PDLIB $switch_file`" ]
then
export pdlib_mod='yes'
esmfpdlib="$METIS_PATH/lib/libparmetis.a $METIS_PATH/lib/libmetis.a"
if [ -n "`grep METIS $switch_file`" ]
then
export metis_mod='yes'
esmfpdlib="$METIS_PATH/lib/libparmetis.a $METIS_PATH/lib/libmetis.a"
fi
if [ -n "`grep SCOTCH $switch_file`" ]
then
export scotch_mod='yes'
esmfpdlib="$SCOTCH_PATH/lib/libptscotchparmetisv3.a $SCOTCH_PATH/lib/libptscotch.a \
$SCOTCH_PATH/lib/libptscotcherr.a $SCOTCH_PATH/lib/libscotch.a"
fi
fi
export pdlib_mod
export metis_mod
export scotch_mod

# NCEP GRIB
export ncep_grib_compile="no"
Expand Down
2 changes: 1 addition & 1 deletion model/ci/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Continuous Integration
WW3 uses Github Actions for continuous integration.

This directory contains a Spack environment file to build library dependencies such as NetCDF, ESMF, ParMETIS, and g2.
This directory contains a Spack environment file to build library dependencies such as NetCDF, ESMF, ParMETIS, SCOTCH and g2.
1 change: 1 addition & 0 deletions model/ci/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ spack:
specs:
- [email protected]~shared
- [email protected]~shared
- [email protected]~shared
- [email protected]~dap
- [email protected]
- [email protected]
Expand Down
15 changes: 15 additions & 0 deletions model/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,24 @@ endif()

# Handle PDLIB, SCRIP, SCRIPNC build files directly instead of through configuration file
if("PDLIB" IN_LIST switches)
if("SCOTCH" IN_LIST switches)
find_package(PTSCOTCHparmetis REQUIRED)
find_package(PTSCOTCH REQUIRED)
find_package(PTSCOTCHerr REQUIRED)
find_package(SCOTCHerr REQUIRED)
find_package(SCOTCH REQUIRED)
target_sources(ww3_lib PRIVATE ${pdlib_src})
target_link_libraries(PTSCOTCHparmetis::PTSCOTCHparmetis INTERFACE PTSCOTCHerr::PTSCOTCHerr SCOTCHerr::SCOTCHerr PTSCOTCH::PTSCOTCH SCOTCH::SCOTCH)
target_link_libraries(ww3_lib PUBLIC PTSCOTCHparmetis::PTSCOTCHparmetis SCOTCHerr::SCOTCHerr)
endif()
endif()

if("PDLIB" IN_LIST switches)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not have this in the same "if("PDLIB" IN_LIST switches)" if statement as above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if ("METIS" IN_LIST switches)
find_package(ParMETIS REQUIRED)
target_sources(ww3_lib PRIVATE ${pdlib_src})
target_link_libraries(ww3_lib PUBLIC ParMETIS::ParMETIS)
endif()
endif()

if("SCRIP" IN_LIST switches)
Expand Down
13 changes: 13 additions & 0 deletions model/src/PDLIB/yowpdlibmain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ subroutine runParmetis(MNP)
! parmetis need single precision
real(4), allocatable :: xyz(:), tpwgts(:), ubvec(:)
integer :: IP_glob, itmp
integer :: ref
logical :: lexist = .false.

! Node to domain mapping.
Expand Down Expand Up @@ -677,12 +678,24 @@ subroutine runParmetis(MNP)
endif

!if(debugParmetis) write(710+myrank,*) "Run ParMETIS now..."
#ifdef W3_SCOTCH
call SCOTCH_ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, &
vwgt, & !vwgt - ignore weights
adjwgt, & ! adjwgt - ignore weights
wgtflag, &
numflag,ndims,xyz,ncon,nparts,tpwgts,ubvec,options, &
edgecut,part, comm,ref)
#endif

#ifdef W3_METIS
call ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, &
vwgt, & !vwgt - ignore weights
adjwgt, & ! adjwgt - ignore weights
wgtflag, &
numflag,ndims,xyz,ncon,nparts,tpwgts,ubvec,options, &
edgecut,part, comm)
#endif


CALL REAL_MPI_BARRIER_PDLIB(comm, "runParmetis, step 9")

Expand Down
17 changes: 16 additions & 1 deletion model/src/cmake/switches.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,25 @@
"name": "pdlib",
"num_switches": "upto1",
"description": "use pdlib",
"valid-options": [
"valid-options":[
{
"name": "PDLIB",
"requires": ["MPI"]
}
]
},
{
"name": "ddlib",
"num_switches": "upto1",
"description": "domain decomposition library",
"valid-options": [
{
"name": "METIS",
"requires": ["PDLIB"]
},
{
"name": "SCOTCH",
"requires": ["PDLIB"]
}
]
},
Expand Down
1 change: 1 addition & 0 deletions regtests/bin/matrix.base
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,7 @@
if [ "$pdlib" = 'y' ]
then
echo "$rtst -s MPI -s PDLIB -w work_b -g b -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
echo "$rtst -s MPI -s PDLIB_METIS -w work_b_metis -g b -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
echo "$rtst -s MPI -s PDLIB -w work_mb -m grdset_b -f -p $mpi -n $np $ww3 ww3_tp2.21" >> matrix.body
fi
fi
Expand Down
5 changes: 4 additions & 1 deletion regtests/bin/matrix_cmake_ncep
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ EOF
modcomp='hpc-intel/18.0.5.274'
modmpi='hpc-impi/2018.0.4'
metispath='/scratch2/COASTAL/coastal/save/Ali.Abdolali/hpc-stack/parmetis-4.0.3'
scotchpath='/scratch2/COASTAL/coastal/save/Ali.Abdolali/hpc-stack/scotch/install'
modcmake='cmake/3.20.1'
elif [ $isorion ]
then
Expand All @@ -74,6 +75,7 @@ EOF
modcomp='hpc-intel/2018.4'
modmpi='hpc-impi/2018.4'
metispath='/work/noaa/marine/ali.abdolali/Source/hpc-stack/parmetis-4.0.3'
scotchpath='/work/noaa/marine/ali.abdolali/Source/hpc-stack/scotch/install'
modcmake='cmake/3.22.1'
else
batchq=
Expand Down Expand Up @@ -125,7 +127,7 @@ EOF
echo " cd $(dirname $main_dir)/regtests" >> matrix.head
echo ' ' >> matrix.head

# Netcdf and Parmetis modules & variables
# Netcdf, Parmetis and SCOTCH modules & variables
echo " module purge" >> matrix.head
echo " module load $modcmake" >> matrix.head
echo " module use $hpcstackpath" >> matrix.head
Expand All @@ -143,6 +145,7 @@ EOF
echo " module load $modesmf" >> matrix.head

echo " export METIS_PATH=${metispath}" >> matrix.head
echo " export SCOTCH_PATH=${scotchpath}" >> matrix.head
echo " export path_build_root=$(dirname $main_dir)/regtests/buildmatrix" >> matrix.head
echo ' [[ -d ${path_build_root} ]] && rm -rf ${path_build_root}' >> matrix.head
echo ' '
Expand Down
Loading