Skip to content

Commit

Permalink
Merge pull request ESCOMP#240 from alperaltuntas/ww3dev_ocn_coupling
Browse files Browse the repository at this point in the history
Mapping and Pole method changes for WW3DEV->MOM6 coupling
- Adds the new ww3->ocn export fields for SURFBANDS wave coupling method, i.e., the partitioned stokes drift components in x and y directions.
- Changes wav online mapping to bilnr_nstod. This only affects the new ww3dev code since the legacy ww3 code doesn't use online mapping.
- Sets the polemethod to NONE for all of the wave import/export fields and updates the mask for wav->ocn mapping. This is needed because the wave grid has triangles along the tripolar stitch, which triggers an ESMF error when POLEMETHOD_ALLAVG is used. This change also only affects the new ww3dev code since the legacy ww3 code doesn't use online mapping.
Contributors other than yourself, if any: None
CMEPS Issues Fixed: None
Are changes expected to change answers? bfb
Any User Interface Changes (namelist or namelist defaults changes)? No
Testing performed if application target is CESM:(either UFS-S2S or CESM testing is required):
All passing: (including baseline test)
SMS_Vnuopc.f09_g17.B1850.cheyenne_intel
SMS_Vnuopc.T62_g17.G1850ECO.cheyenne_intel
ERS_Vnuopc.TL319_g17.GIAF_JRA.cheyenne_gnu
ERS_Vnuopc.TL319_t061.GMOM_JRA_WD.cheyenne_gnu
SMS_Vnuopc.TL319_t061.GMOM_JRA.cheyenne_intel
ERS_Vnuopc.TL319_t061_wt061.GMOM_JRA_WD.cheyenne_gnu
Hashes used for testing: cesm2_3_beta06
  • Loading branch information
mvertens authored Oct 18, 2021
2 parents 2a8ce4e + c24b358 commit abc117d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
36 changes: 31 additions & 5 deletions mediator/esmFldsExchange_cesm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
use esmflds , only : compmed, compatm, complnd, compocn
use esmflds , only : compice, comprof, compwav, ncomps
use esmflds , only : compglc, num_icesheets, ocn2glc_coupling ! compglc is an array of integers
use esmflds , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d
use esmflds , only : mapbilnr, mapconsf, mapconsd, mappatch, mappatch_uv3d, mapbilnr_nstod
use esmflds , only : mapfcopy, mapnstod, mapnstod_consd, mapnstod_consf
use esmflds , only : map_glc2ocn_ice, map_glc2ocn_liq, map_rof2ocn_ice, map_rof2ocn_liq
use esmflds , only : fldListTo, fldListFr, fldListMed_aoflux, fldListMed_ocnalb
Expand Down Expand Up @@ -2228,7 +2228,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_lamult', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_lamult', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_lamult', compocn, mapbilnr, 'one', wav2ocn_smap)
call addmap(fldListFr(compwav)%flds, 'Sw_lamult', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_lamult', mrg_from=compwav, mrg_fld='Sw_lamult', mrg_type='copy')
end if
end if
Expand All @@ -2241,7 +2241,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_ustokes', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_ustokes', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_ustokes', compocn, mapbilnr, 'one', wav2ocn_smap)
call addmap(fldListFr(compwav)%flds, 'Sw_ustokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_ustokes', mrg_from=compwav, mrg_fld='Sw_ustokes', mrg_type='copy')
end if
end if
Expand All @@ -2254,7 +2254,7 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_vstokes', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_vstokes', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_vstokes', compocn, mapbilnr, 'one', wav2ocn_smap)
call addmap(fldListFr(compwav)%flds, 'Sw_vstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_vstokes', mrg_from=compwav, mrg_fld='Sw_vstokes', mrg_type='copy')
end if
end if
Expand All @@ -2267,10 +2267,36 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_hstokes', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_hstokes', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_hstokes', compocn, mapbilnr, 'one', wav2ocn_smap)
call addmap(fldListFr(compwav)%flds, 'Sw_hstokes', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_hstokes', mrg_from=compwav, mrg_fld='Sw_hstokes', mrg_type='copy')
end if
end if
!-----------------------------
! to ocn: Partitioned stokes drift components in x-direction
!-----------------------------
if (phase == 'advertise') then
call addfld(fldListFr(compwav)%flds, 'Sw_pstokes_x')
call addfld(fldListTo(compocn)%flds, 'Sw_pstokes_x')
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_pstokes_x', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_pstokes_x', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_pstokes_x', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_pstokes_x', mrg_from=compwav, mrg_fld='Sw_pstokes_x', mrg_type='copy')
end if
end if
!-----------------------------
! to ocn: Stokes drift depth from wave
!-----------------------------
if (phase == 'advertise') then
call addfld(fldListFr(compwav)%flds, 'Sw_pstokes_y')
call addfld(fldListTo(compocn)%flds, 'Sw_pstokes_y')
else
if ( fldchk(is_local%wrap%FBExp(compocn) , 'Sw_pstokes_y', rc=rc) .and. &
fldchk(is_local%wrap%FBImp(compwav, compwav), 'Sw_pstokes_y', rc=rc)) then
call addmap(fldListFr(compwav)%flds, 'Sw_pstokes_y', compocn, mapbilnr_nstod, 'one', wav2ocn_smap)
call addmrg(fldListTo(compocn)%flds, 'Sw_pstokes_y', mrg_from=compwav, mrg_fld='Sw_pstokes_y', mrg_type='copy')
end if
end if

!=====================================================================
! FIELDS TO ICE (compice)
Expand Down
7 changes: 7 additions & 0 deletions mediator/fd_cesm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,13 @@
canonical_units: m/s
description: ocean import - Stokes drift v component
#
- standard_name: Sw_pstokes_x
canonical_units: m/s
description: Eastward partitioned stokes drift components
#
- standard_name: Sw_pstokes_y
canonical_units: m/s
description: Northward partitioned stokes drift components
#-----------------------------------
# mediator fields
#-----------------------------------
Expand Down
12 changes: 10 additions & 2 deletions mediator/med_map_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ end subroutine med_map_routehandles_initfrom_fieldbundle
subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex, routehandles, mapfile, rc)

use ESMF , only : ESMF_RouteHandle, ESMF_RouteHandlePrint, ESMF_Field, ESMF_MAXSTR
use ESMF , only : ESMF_PoleMethod_Flag, ESMF_POLEMETHOD_ALLAVG
use ESMF , only : ESMF_PoleMethod_Flag, ESMF_POLEMETHOD_ALLAVG, ESMF_POLEMETHOD_NONE
use ESMF , only : ESMF_FieldSMMStore, ESMF_FieldRedistStore, ESMF_FieldRegridStore
use ESMF , only : ESMF_RouteHandleIsCreated, ESMF_RouteHandleCreate
use ESMF , only : ESMF_REGRIDMETHOD_BILINEAR, ESMF_REGRIDMETHOD_PATCH
Expand Down Expand Up @@ -368,7 +368,7 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex,
integer :: ns
integer(I4), pointer :: dof(:)
integer :: srcTermProcessing_Value = 0
type(ESMF_PoleMethod_Flag), parameter :: polemethod=ESMF_POLEMETHOD_ALLAVG
type(ESMF_PoleMethod_Flag) :: polemethod
character(len=*), parameter :: subname=' (module_med_map: med_map_routehandles_initfrom_field) '
!---------------------------------------------

Expand All @@ -386,11 +386,19 @@ subroutine med_map_routehandles_initfrom_field(n1, n2, fldsrc, flddst, mapindex,
dststatusfield = ESMF_FieldCreate(dstmesh, ESMF_TYPEKIND_I4, meshloc=ESMF_MESHLOC_ELEMENT, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

polemethod=ESMF_POLEMETHOD_ALLAVG
if (trim(coupling_mode) == 'cesm') then
dstMaskValue = ispval_mask
srcMaskValue = ispval_mask
if (n1 == compocn .or. n1 == compice) srcMaskValue = 0
if (n2 == compocn .or. n2 == compice) dstMaskValue = 0
if (n1 == compwav .and. n2 == compocn) then
srcMaskValue = 0
dstMaskValue = ispval_mask
endif
if (n1 == compwav .or. n2 == compwav) then
polemethod = ESMF_POLEMETHOD_NONE ! todo: remove this when ESMF tripolar mapping fix is in place.
endif
else if (coupling_mode(1:4) == 'nems') then
if (n1 == compatm .and. (n2 == compocn .or. n2 == compice)) then
srcMaskValue = 1
Expand Down

0 comments on commit abc117d

Please sign in to comment.