Skip to content

Commit

Permalink
Merge pull request #382 from mvertens/feature/theorywaves
Browse files Browse the repository at this point in the history
add new optional mapping of taux and tauy from ocean to wave
  • Loading branch information
jedwards4b committed May 17, 2023
2 parents f2cbf27 + 488b8d9 commit 09d1e08
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
8 changes: 8 additions & 0 deletions mediator/esmFldsExchange_cesm_mod.F90
Expand Up @@ -2986,6 +2986,14 @@ subroutine esmFldsExchange_cesm(gcomp, phase, rc)
end if
end if

! ---------------------------------------------------------------------
! to wav: zonal and meridional wind stress
! ---------------------------------------------------------------------
if (phase == 'advertise') then
call addfld_to(compwav , 'Fwxx_taux')
call addfld_to(compwav , 'Fwxx_tauy')
end if

!=====================================================================
! FIELDS TO RIVER (comprof)
!=====================================================================
Expand Down
15 changes: 15 additions & 0 deletions mediator/fd_cesm.yaml
Expand Up @@ -1176,6 +1176,21 @@
canonical_units: m2/s
description: wave elevation spectrum

#
#-----------------------------------
# section: wave import
#-----------------------------------
#
- standard_name: Fwxx_taux
alias: mean_zonal_moment_flx
canonical_units: N m-2
description: wave import - zonal surface stress
#
- standard_name: Fwxx_tauy
alias: mean_merid_moment_flx
canonical_units: N m-2
description: wave import - meridional surface stress

#-----------------------------------
# mediator fields
#-----------------------------------
Expand Down
40 changes: 37 additions & 3 deletions mediator/med_phases_aofluxes_mod.F90
Expand Up @@ -27,7 +27,7 @@ module med_phases_aofluxes_mod
use ESMF , only : ESMF_XGridGet, ESMF_MeshCreate, ESMF_MeshWrite, ESMF_KIND_R8
use med_kind_mod , only : CX=>SHR_KIND_CX, CS=>SHR_KIND_CS, CL=>SHR_KIND_CL, R8=>SHR_KIND_R8
use med_internalstate_mod , only : InternalState, maintask, logunit
use med_internalstate_mod , only : compatm, compocn, coupling_mode, aoflux_code, mapconsd, mapconsf, mapfcopy
use med_internalstate_mod , only : compatm, compocn, compwav, coupling_mode, aoflux_code, mapconsd, mapconsf, mapfcopy
use med_constants_mod , only : dbug_flag => med_constants_dbug_flag
use med_utils_mod , only : memcheck => med_memcheck
use med_utils_mod , only : chkerr => med_utils_chkerr
Expand Down Expand Up @@ -487,6 +487,7 @@ subroutine med_aofluxes_init_ogrid(gcomp, aoflux_in, aoflux_out, rc)
use esmFlds , only : med_fldlist_GetaofluxfldList
use esmFlds , only : med_fldList_type
use med_map_mod , only : med_map_packed_field_create
use med_methods_mod , only : FB_fldchk => med_methods_FB_FldChk

! Arguments
type(ESMF_GridComp) , intent(inout) :: gcomp
Expand Down Expand Up @@ -565,15 +566,13 @@ subroutine med_aofluxes_init_ogrid(gcomp, aoflux_in, aoflux_out, rc)
if (is_local%wrap%aoflux_grid == 'ogrid') then
if ( ESMF_FieldBundleIsCreated(is_local%wrap%FBMed_aoflux_o) .and. &
ESMF_FieldBundleIsCreated(is_local%wrap%FBMed_aoflux_a)) then

call med_map_packed_field_create(destcomp=compatm, &
flds_scalar_name=is_local%wrap%flds_scalar_name, &
fieldsSrc=fldListMed_aoflux, &
FBSrc=is_local%wrap%FBMed_aoflux_o, &
FBDst=is_local%wrap%FBMed_aoflux_a, &
packed_data=is_local%wrap%packed_data_aoflux_o2a(:), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

end if
end if

Expand Down Expand Up @@ -950,6 +949,9 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
use ESMF , only : ESMF_GridComp
use ESMF , only : ESMF_LogWrite, ESMF_LogMsg_Info, ESMF_SUCCESS
use med_map_mod , only : med_map_field_packed, med_map_rh_is_created
use med_map_mod , only : med_map_routehandles_init
use med_methods_mod, only : FB_fldchk => med_methods_FB_fldchk
use med_methods_mod, only : FB_diagnose => med_methods_FB_diagnose
#ifdef CESMCOUPLED
use shr_flux_mod , only : flux_atmocn
#else
Expand All @@ -972,6 +974,9 @@ subroutine med_aofluxes_update(gcomp, aoflux_in, aoflux_out, rc)
real(r8), parameter :: p0 = 100000.0_r8 ! reference pressure in Pa
real(r8), parameter :: rcp = 0.286_r8 ! gas constant of air / specific heat capacity at a constant pressure
real(r8), parameter :: rdair = 287.058_r8 ! dry air gas constant in J/K/kg
integer :: maptype
type(ESMF_Field) :: field_src
type(ESMF_Field) :: field_dst
character(*),parameter :: subName = '(med_aofluxes_update) '
!-----------------------------------------------------------------------

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

end if

! map taux and tauy from ocean to wave grid if stresses are needed on the wave grid
if ( FB_fldchk(is_local%wrap%FBExp(compwav), 'Fwxx_taux', rc=rc) .and. &
FB_fldchk(is_local%wrap%FBExp(compwav), 'Fwxx_tauy', rc=rc)) then
maptype = mapconsf
if (.not. med_map_RH_is_created(is_local%wrap%RH(compocn,compwav,:), maptype, rc=rc)) then
call med_map_routehandles_init( compocn, compwav, &
FBSrc=is_local%wrap%FBImp(compocn,compocn), &
FBDst=is_local%wrap%FBImp(compwav,compwav), &
mapindex=maptype, RouteHandle=is_local%wrap%RH, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
call ESMF_FieldBundleGet(is_local%wrap%FBMed_aoflux_o, 'Faox_taux', field=field_src, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compwav), 'Fwxx_taux', field=field_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegrid(field_src, field_dst, &
routehandle=is_local%wrap%RH(compocn, compwav, maptype), &
termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBMed_aoflux_o, 'Faox_tauy', field=field_src, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleGet(is_local%wrap%FBExp(compwav), 'Fwxx_tauy', field=field_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegrid(field_src, field_dst, &
routehandle=is_local%wrap%RH(compocn, compwav, maptype), &
termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

call t_stopf('MED:'//subname)

end subroutine med_aofluxes_update
Expand Down

0 comments on commit 09d1e08

Please sign in to comment.