Skip to content

Commit 09d1e08

Browse files
authored
Merge pull request #382 from mvertens/feature/theorywaves
add new optional mapping of taux and tauy from ocean to wave
2 parents f2cbf27 + 488b8d9 commit 09d1e08

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

mediator/esmFldsExchange_cesm_mod.F90

+8
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,14 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
29862986
end if
29872987
end if
29882988

2989+
! ---------------------------------------------------------------------
2990+
! to wav: zonal and meridional wind stress
2991+
! ---------------------------------------------------------------------
2992+
if (phase == 'advertise') then
2993+
call addfld_to(compwav , 'Fwxx_taux')
2994+
call addfld_to(compwav , 'Fwxx_tauy')
2995+
end if
2996+
29892997
!=====================================================================
29902998
! FIELDS TO RIVER (comprof)
29912999
!=====================================================================

mediator/fd_cesm.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,21 @@
11761176
canonical_units: m2/s
11771177
description: wave elevation spectrum
11781178

1179+
#
1180+
#-----------------------------------
1181+
# section: wave import
1182+
#-----------------------------------
1183+
#
1184+
- standard_name: Fwxx_taux
1185+
alias: mean_zonal_moment_flx
1186+
canonical_units: N m-2
1187+
description: wave import - zonal surface stress
1188+
#
1189+
- standard_name: Fwxx_tauy
1190+
alias: mean_merid_moment_flx
1191+
canonical_units: N m-2
1192+
description: wave import - meridional surface stress
1193+
11791194
#-----------------------------------
11801195
# mediator fields
11811196
#-----------------------------------

mediator/med_phases_aofluxes_mod.F90

+37-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module med_phases_aofluxes_mod
2727
use ESMF , only : ESMF_XGridGet, ESMF_MeshCreate, ESMF_MeshWrite, ESMF_KIND_R8
2828
use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8
2929
use med_internalstate_mod , only : InternalState, maintask, logunit
30-
use med_internalstate_mod , only : compatm, compocn, coupling_mode, aoflux_code, mapconsd, mapconsf, mapfcopy
30+
use med_internalstate_mod , only : compatm, compocn, compwav, coupling_mode, aoflux_code, mapconsd, mapconsf, mapfcopy
3131
use med_constants_mod , only : dbug_flag => med_constants_dbug_flag
3232
use med_utils_mod , only : memcheck => med_memcheck
3333
use med_utils_mod , only : chkerr => med_utils_chkerr
@@ -487,6 +487,7 @@ subroutine med_aofluxes_init_ogrid(gcomp, aoflux_in, aoflux_out, rc)
487487
use esmFlds , only : med_fldlist_GetaofluxfldList
488488
use esmFlds , only : med_fldList_type
489489
use med_map_mod , only : med_map_packed_field_create
490+
use med_methods_mod , only : FB_fldchk => med_methods_FB_FldChk
490491

491492
! Arguments
492493
type(ESMF_GridComp) , intent(inout) :: gcomp
@@ -565,15 +566,13 @@ subroutine med_aofluxes_init_ogrid(gcomp, aoflux_in, aoflux_out, rc)
565566
if (is_local%wrap%aoflux_grid == 'ogrid') then
566567
if ( ESMF_FieldBundleIsCreated(is_local%wrap%FBMed_aoflux_o) .and. &
567568
ESMF_FieldBundleIsCreated(is_local%wrap%FBMed_aoflux_a)) then
568-
569569
call med_map_packed_field_create(destcomp=compatm, &
570570
flds_scalar_name=is_local%wrap%flds_scalar_name, &
571571
fieldsSrc=fldListMed_aoflux, &
572572
FBSrc=is_local%wrap%FBMed_aoflux_o, &
573573
FBDst=is_local%wrap%FBMed_aoflux_a, &
574574
packed_data=is_local%wrap%packed_data_aoflux_o2a(:), rc=rc)
575575
if (ChkErr(rc,__LINE__,u_FILE_u)) return
576-
577576
end if
578577
end if
579578

@@ -950,6 +949,9 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
950949
use ESMF , only : ESMF_GridComp
951950
use ESMF , only : ESMF_LogWrite, ESMF_LogMsg_Info, ESMF_SUCCESS
952951
use med_map_mod , only : med_map_field_packed, med_map_rh_is_created
952+
use med_map_mod , only : med_map_routehandles_init
953+
use med_methods_mod, only : FB_fldchk => med_methods_FB_fldchk
954+
use med_methods_mod, only : FB_diagnose => med_methods_FB_diagnose
953955
#ifdef CESMCOUPLED
954956
use shr_flux_mod , only : flux_atmocn
955957
#else
@@ -972,6 +974,9 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
972974
real(r8), parameter :: p0 = 100000.0_r8 ! reference pressure in Pa
973975
real(r8), parameter :: rcp = 0.286_r8 ! gas constant of air / specific heat capacity at a constant pressure
974976
real(r8), parameter :: rdair = 287.058_r8 ! dry air gas constant in J/K/kg
977+
integer :: maptype
978+
type(ESMF_Field) :: field_src
979+
type(ESMF_Field) :: field_dst
975980
character(*),parameter :: subName = '(med_aofluxes_update) '
976981
!-----------------------------------------------------------------------
977982

@@ -1117,6 +1122,35 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
11171122

11181123
end if
11191124

1125+
! map taux and tauy from ocean to wave grid if stresses are needed on the wave grid
1126+
if ( FB_fldchk(is_local%wrap%FBExp(compwav), 'Fwxx_taux', rc=rc) .and. &
1127+
FB_fldchk(is_local%wrap%FBExp(compwav), 'Fwxx_tauy', rc=rc)) then
1128+
maptype = mapconsf
1129+
if (.not. med_map_RH_is_created(is_local%wrap%RH(compocn,compwav,:), maptype, rc=rc)) then
1130+
call med_map_routehandles_init( compocn, compwav, &
1131+
FBSrc=is_local%wrap%FBImp(compocn,compocn), &
1132+
FBDst=is_local%wrap%FBImp(compwav,compwav), &
1133+
mapindex=maptype, RouteHandle=is_local%wrap%RH, rc=rc)
1134+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
1135+
end if
1136+
call ESMF_FieldBundleGet(is_local%wrap%FBMed_aoflux_o, 'Faox_taux', field=field_src, rc=rc)
1137+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1138+
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compwav), 'Fwxx_taux', field=field_dst, rc=rc)
1139+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1140+
call ESMF_FieldRegrid(field_src, field_dst, &
1141+
routehandle=is_local%wrap%RH(compocn, compwav, maptype), &
1142+
termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc)
1143+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1144+
call ESMF_FieldBundleGet(is_local%wrap%FBMed_aoflux_o, 'Faox_tauy', field=field_src, rc=rc)
1145+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1146+
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compwav), 'Fwxx_tauy', field=field_dst, rc=rc)
1147+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1148+
call ESMF_FieldRegrid(field_src, field_dst, &
1149+
routehandle=is_local%wrap%RH(compocn, compwav, maptype), &
1150+
termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc)
1151+
if (chkerr(rc,__LINE__,u_FILE_u)) return
1152+
end if
1153+
11201154
call t_stopf('MED:'//subname)
11211155

11221156
end subroutine med_aofluxes_update

0 commit comments

Comments
 (0)