Skip to content

Commit

Permalink
Adds source code to implement a mesh-based NUOPC cap (#641)
Browse files Browse the repository at this point in the history
in the dev/ufs-weather-model branch.
Co-authored-by: Mariana Vertenstein <mvertens@ucar.edu>
  • Loading branch information
DeniseWorthen authored May 31, 2022
1 parent b8ea5cd commit ec5077a
Show file tree
Hide file tree
Showing 26 changed files with 7,124 additions and 349 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
needs: setup
strategy:
matrix:
switch: [Ifremer1, NCEP_st2, NCEP_st4, ite_pdlib, NCEP_st4sbs, NCEP_glwu, OASACM, UKMO, MULTI_ESMF]
switch: [Ifremer1, NCEP_st2, NCEP_st4, ite_pdlib, NCEP_st4sbs, NCEP_glwu, OASACM, UKMO, MULTI_ESMF, NUOPC_MESH]
runs-on: ubuntu-20.04

steps:
Expand Down Expand Up @@ -95,7 +95,9 @@ jobs:
export OASISDIR=${GITHUB_WORKSPACE}/work_oasis3-mct
mkdir build && cd build
if [[ ${{ matrix.switch }} == "MULTI_ESMF" ]]; then
cmake .. -DMULTI_ESMF=ON -DSWITCH=multi_esmf
cmake .. -DUFS_CAP=MULTI_ESMF -DSWITCH=multi_esmf
elif [[ ${{ matrix.switch }} == "NUOPC_MESH" ]]; then
cmake .. -DUFS_CAP=NUOPC_MESH -DSWITCH=meshcap
else
cmake .. -DSWITCH=${{ matrix.switch }}
fi
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
needs: setup
strategy:
matrix:
switch: [Ifremer1, NCEP_st2, NCEP_st4, ite_pdlib, NCEP_st4sbs, NCEP_glwu, OASACM, UKMO, MULTI_ESMF]
switch: [Ifremer1, NCEP_st2, NCEP_st4, ite_pdlib, NCEP_st4sbs, NCEP_glwu, OASACM, UKMO, MULTI_ESMF, NUOPC_MESH]
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -120,7 +120,9 @@ jobs:
export OASISDIR=${GITHUB_WORKSPACE}/work_oasis3-mct
mkdir build && cd build
if [[ ${{ matrix.switch }} == "MULTI_ESMF" ]]; then
cmake .. -DMULTI_ESMF=ON -DSWITCH=multi_esmf
cmake .. -DUFS_CAP=MULTI_ESMF -DSWITCH=multi_esmf
elif [[ ${{ matrix.switch }} == "NUOPC_MESH" ]]; then
cmake .. -DUFS_CAP=NUOPC_MESH -DSWITCH=meshcap
else
cmake .. -DSWITCH=${{ matrix.switch }}
fi
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if(hasParent)
remove_definitions(-DDEBUG)
endif()

set(MULTI_ESMF OFF CACHE BOOL "Build ww3_multi_esmf library")
set(valid_caps "MULTI_ESMF" "NUOPC_MESH")

set(UFS_CAP "" CACHE STRING "Valid options are ${valid_caps}")
set(NETCDF ON CACHE BOOL "Build NetCDF programs (requires NetCDF)")
set(ENDIAN "BIG" CACHE STRING "Endianness of unformatted output files. Valid values are 'BIG', 'LITTLE', 'NATIVE'.")
set(EXCLUDE_FIND "" CACHE STRING "Don't try and search for these libraries (assumd to be handled by the compiler/wrapper)")
Expand All @@ -44,6 +46,12 @@ else()
endif()
endif()

if(UFS_CAP)
if(NOT UFS_CAP IN_LIST valid_caps)
message(FATAL_ERROR "Invalid UFS_CAP selection. Valids options are ${valid_caps}")
endif()
endif()

message(STATUS "Build with switch: ${switch_file}")
# Copy switch file to build dir
configure_file(${switch_file} ${CMAKE_BINARY_DIR}/switch COPYONLY)
Expand Down
112 changes: 60 additions & 52 deletions model/bin/build_utils.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e
# --------------------------------------------------------------------------- #
# build_utils.sh : Shell functions that can be used by multiple scripts #
# build_utils.sh : Shell functions that can be used by multiple scripts #
# for building the model #
# #
# programs used : w3_new Touches the correct files if compiler switches #
Expand All @@ -24,15 +24,15 @@
# Performs quality check on switches defined in variable $switch. Checks #
# to make sure that swtich choices are compatible and that only the valid #
# switches have been identified. Groups switched into different variables #
# by type #
# by type #
# --------------------------------------------------------------------------- #



check_switches()
{

# 1.a Step through categories
# 1.a Step through categories

for type in nco grib scrip scripnc \
shared mpp mpiexp thread GSE prop smcg \
Expand Down Expand Up @@ -291,7 +291,7 @@ check_switches()
ID='use pdlib'
TS='PDLIB'
OK='PDLIB' ;;
#sort:memck:
#sort:memck:
memck ) TY='upto1'
ID='check memory use'
TS='MEMCHECK'
Expand Down Expand Up @@ -436,7 +436,7 @@ check_switches()
esac
done

# 1.b Check switch compatibility
# 1.b Check switch compatibility

case $stress in
FLX0) str_st1='no' ; str_st2='no' ; str_st3='OK' ; str_st6='no' ;;
Expand Down Expand Up @@ -541,11 +541,11 @@ check_switches()
fi

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


} #end of check_switches
Expand All @@ -565,12 +565,12 @@ switch_files()
PR1) pr='w3profsmd w3pro1md' ;;
PR2) pr='w3profsmd w3pro2md' ;;
PR3) pr='w3profsmd w3pro3md' ;;
esac
esac

case $p_switch in
UQ ) pr="$pr w3uqckmd" ;;
UNO) pr="$pr w3uno2md" ;;
esac
esac

smcm=$NULL
smco=$NULL
Expand Down Expand Up @@ -697,16 +697,16 @@ switch_files()
REF1) refcode='w3ref1md'
esac

pdlibcode=$NULL
pdlibyow=$NULL
pdlibcode=$NULL
pdlibyow=$NULL
case $pdlib in
PDLIB) pdlibcode='yowfunction pdlib_field_vec w3profsmd_pdlib'
pdlibyow='yowsidepool yowdatapool yowerr yownodepool yowelementpool yowexchangeModule yowrankModule yowpdlibmain yowpd' ;;
esac

memcode=$NULL
case $memck in
MEMCHECK) memcode='w3meminfo'
memcode=$NULL
case $memck in
MEMCHECK) memcode='w3meminfo'
esac

setupcode=$NULL
Expand Down Expand Up @@ -756,13 +756,13 @@ switch_files()


# --------------------------------------------------------------------------- #
# 3. Create list of files for a prog #
# 3. Create list of files for a prog #
# For a particular prog create files and filesl a list of files and a #
# list of files to be linked. The variable prog needs to be set and #
# the switch_files should be used first (which requires check_switches() #
# the switch_files should be used first (which requires check_switches() #
# --------------------------------------------------------------------------- #

create_file_list()
create_file_list()
{
case $prog in
ww3_grid)
Expand All @@ -776,8 +776,8 @@ create_file_list()
then
aux="$aux scrip_constants scrip_grids scrip_iounitsmod"
aux="$aux scrip_remap_vars scrip_timers scrip_errormod scrip_interface"
aux="$aux scrip_kindsmod scrip_remap_conservative wmscrpmd"
fi
aux="$aux scrip_kindsmod scrip_remap_conservative wmscrpmd"
fi
if [ "$scripnc" = 'SCRIPNC' ]
then
aux="$aux scrip_netcdfmod scrip_remap_write scrip_remap_read"
Expand All @@ -803,7 +803,7 @@ create_file_list()
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $stx $nlx $btx $is wmmdatmd w3parall w3triamd $uostmd"
IO='w3iobcmd w3iogrmd w3dispmd w3gsrumd'
aux="constants w3servmd w3arrymd w3timemd w3cspcmd w3nmlbouncmd" ;;
ww3_prep)
ww3_prep)
core='w3fldsmd'
data="$memcode w3gdatmd w3adatmd w3idatmd w3odatmd w3wdatmd wmmdatmd"
prop=
Expand All @@ -817,22 +817,30 @@ create_file_list()
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3triamd $stx $flx $nlx $btx $is w3parall $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd w3tidemd w3nmlprncmd" ;;
ww3_prtide)
ww3_prtide)
core='w3fldsmd'
data="wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop="$pr $smcm"
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3triamd $stx $nlx $btx $is w3parall $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
ww3_shel)
core='w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd'
ww3_shel|ww3_shel_esmf)
if [ "$prog" = "ww3_shel" ]
then
core=''
else
core='wav_kind_mod wav_shr_mod wav_shel_inp wav_comp_nuopc wav_import_export w3iogoncdmd'
fi
core="$core w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd"
core="$core wminitmd wmwavemd wmfinlmd wmgridmd wmupdtmd wminiomd"
data="wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop="$pr $smcm"
sourcet="$pdlibcode $setupcode w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $ic"
sourcet="$sourcet $is $db $tr $bs $refcode $igcode w3parall $uostmd"
IO="w3iogrmd w3iogomd w3iopomd w3iotrmd w3iorsmd w3iobcmd $oasismd $agcmmd $ogcmmd $igcmmd"
IO="$IO w3iosfmd w3partmd"
IO="$IO w3iosfmd w3partmd wmiopomd"
aux="constants w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd"
aux="$aux wmunitmd w3nmlmultimd"
aux="$aux w3nmlshelmd $pdlibyow" ;;
ww3_multi|ww3_multi_esmf)
if [ "$prog" = "ww3_multi" ]
Expand All @@ -849,7 +857,7 @@ create_file_list()
IO='w3iogrmd w3iogomd w3iopomd wmiopomd'
IO="$IO w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants $tidecode w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux"
aux="$aux wmunitmd w3nmlmultimd"
aux="$aux wmunitmd w3nmlmultimd"
if [ "$scrip" = 'SCRIP' ]
then
aux="$aux scrip_constants scrip_grids scrip_iounitsmod"
Expand All @@ -860,22 +868,22 @@ create_file_list()
then
aux="$aux scrip_netcdfmod scrip_remap_write scrip_remap_read"
fi ;;
ww3_sbs1)
core='wminitmd wmwavemd wmfinlmd wmgridmd wmupdtmd wminiomd'
core="$core w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd"
data="w3parall wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop="$pr $smcm"
sourcet="$pdlibcode $pdlibyow w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $db $tr $bs $refcode $igcode $is $ic $uostmd"
IO='w3iogrmd w3iogomd w3iopomd wmiopomd'
IO="$IO w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux $tidecode"
aux="$aux wmunitmd w3nmlmultimd"
ww3_sbs1)
core='wminitmd wmwavemd wmfinlmd wmgridmd wmupdtmd wminiomd'
core="$core w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd"
data="w3parall wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop="$pr $smcm"
sourcet="$pdlibcode $pdlibyow w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $db $tr $bs $refcode $igcode $is $ic $uostmd"
IO='w3iogrmd w3iogomd w3iopomd wmiopomd'
IO="$IO w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux $tidecode"
aux="$aux wmunitmd w3nmlmultimd"
if [ "$scrip" = 'SCRIP' ]
then
aux="$aux scrip_constants scrip_grids scrip_iounitsmod"
aux="$aux scrip_remap_vars scrip_timers scrip_errormod scrip_interface"
aux="$aux scrip_kindsmod scrip_remap_conservative wmscrpmd"
fi
fi
if [ "$scripnc" = 'SCRIPNC' ]
then
aux="$aux scrip_netcdfmod scrip_remap_write scrip_remap_read"
Expand All @@ -896,7 +904,7 @@ create_file_list()
IO='w3iogrmd w3iogomd w3iorsmd w3iopomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3nmlounfmd $smco w3ounfmetamd w3metamd" ;;
ww3_outp)
ww3_outp)
core=
data="wmmdatmd w3parall w3triamd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
Expand All @@ -911,7 +919,7 @@ create_file_list()
IO='w3bullmd w3iogrmd w3iopomd w3partmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3nmlounpmd" ;;
ww3_trck)
ww3_trck)
core=
data="$memcode w3gdatmd w3odatmd"
prop=
Expand All @@ -925,22 +933,22 @@ create_file_list()
sourcet=
IO=
aux="constants w3servmd w3timemd w3gsrumd w3nmltrncmd" ;;
ww3_grib)
ww3_grib)
core=
data="w3parall wmmdatmd w3triamd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $stx $flx $nlx $btx $is $uostmd"
IO='w3iogrmd w3iogomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux" ;;
ww3_gspl)
ww3_gspl)
core='w3fldsmd'
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3parall w3triamd $stx $flx $nlx $btx $is $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
ww3_gint)
ww3_gint)
core=
data="w3parall wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
IO='w3iogrmd w3iogomd'
Expand All @@ -956,38 +964,38 @@ create_file_list()
IO='w3iogrmd w3iogomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux" ;;
gx_outp)
gx_outp)
core=
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3parall w3triamd $ln $flx $st $nlx $btx $tr $bs $is $ic $uostmd"
IO='w3iogrmd w3iopomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd" ;;
ww3_systrk)
ww3_systrk)
core='w3strkmd'
data="$memcode w3gdatmd w3adatmd w3idatmd w3odatmd w3wdatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3dispmd w3triamd $ln $stx $flx $nlx $btx $tr $bs $is $uostmd"
IO=
aux="constants w3servmd w3timemd w3arrymd w3gsrumd w3parall" ;;
libww3|libww3.so)
libww3|libww3.so)
core='w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd'
data='wmmdatmd w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd'
prop="$pr $smcm"
sourcet="w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $ic $is $db $tr $bs $refcode $igcode $uostmd"
IO='w3iogrmd w3iogomd w3iopomd w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd'
aux="constants w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd" ;;
ww3_uprstr)
core=
data='wmmdatmd w3triamd w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd'
prop=
ww3_uprstr)
core=
data='wmmdatmd w3triamd w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd'
prop=
sourcet="$memcode $pdlibcode $pdlibyow $flx $ln $st $nl $bt $ic $is $db $tr $bs $uostmd"
IO='w3iogrmd w3iogomd w3iorsmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3parall w3nmluprstrmd" ;;
IO='w3iogrmd w3iogomd w3iorsmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3parall w3nmluprstrmd" ;;
esac

# if esmf is included in program name or if
# if esmf is included in program name or if
# the target is compile and create archive
if [ -n "`echo $prog | grep esmf 2>/dev/null`" ]
then
Expand Down
Loading

0 comments on commit ec5077a

Please sign in to comment.