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

Update MOM6 cap for 2-way ocean-wave coupling for HAFS #143

Open
wants to merge 8 commits into
base: dev/emc
Choose a base branch
from
16 changes: 13 additions & 3 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ module MOM_cap_mod
logical :: grid_attach_area = .false.
logical :: use_coldstart = .true.
logical :: use_mommesh = .true.
logical :: set_missing_stks_to_zero = .false.
logical :: restart_eor = .false.
character(len=128) :: scalar_field_name = ''
integer :: scalar_field_count = 0
Expand Down Expand Up @@ -366,6 +367,14 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
write(logmsg,*) use_coldstart
call ESMF_LogWrite('MOM_cap:use_coldstart = '//trim(logmsg), ESMF_LOGMSG_INFO)

set_missing_stks_to_zero = .false.
call NUOPC_CompAttributeGet(gcomp, name="set_missing_stks_to_zero", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) set_missing_stks_to_zero=(trim(value)=="true")
write(logmsg,*) set_missing_stks_to_zero
call ESMF_LogWrite('MOM_cap:set_missing_stks_to_zero = '//trim(logmsg), ESMF_LOGMSG_INFO)

use_mommesh = .true.
call NUOPC_CompAttributeGet(gcomp, name="use_mommesh", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
Expand Down Expand Up @@ -1758,8 +1767,11 @@ subroutine ModelAdvance(gcomp, rc)
!---------------
! Import data
!---------------
call NUOPC_CompAttributeGet(gcomp, name='case_name', value=casename, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc=rc)
call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, &
casename, set_missing_stks_to_zero, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!---------------
Expand Down Expand Up @@ -1831,8 +1843,6 @@ subroutine ModelAdvance(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (cesm_coupled) then
call NUOPC_CompAttributeGet(gcomp, name='case_name', value=casename, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_GridCompGet(gcomp, vm=vm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_VMGet(vm, localPet=localPet, rc=rc)
Expand Down
39 changes: 29 additions & 10 deletions config_src/drivers/nuopc_cap/mom_cap_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ end subroutine mom_set_geomtype
!> This function has a few purposes:
!! (1) it imports surface fluxes using data from the mediator; and
!! (2) it can apply restoring in SST and SSS.
subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc)
type(ocean_public_type) , intent(in) :: ocean_public !< Ocean surface state
type(ocean_grid_type) , intent(in) :: ocean_grid !< Ocean model grid
type(ESMF_State) , intent(inout) :: importState !< incoming data from mediator
type(ice_ocean_boundary_type) , intent(inout) :: ice_ocean_boundary !< Ocean boundary forcing
integer , intent(inout) :: rc !< Return code
!! (3) it can convert imported stokes drift components to zero if they are missing.
subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, casename, &
set_missing_stks_to_zero, rc)
type(ocean_public_type) , intent(in) :: ocean_public !< Ocean surface state
type(ocean_grid_type) , intent(in) :: ocean_grid !< Ocean model grid
character(ESMF_MAXSTR) , intent(in) :: casename !< Case name for the experiment
logical , intent(in) :: set_missing_stks_to_zero !< If true, set
!! missing stokes drift to zero
type(ESMF_State) , intent(inout) :: importState !< incoming data from mediator
type(ice_ocean_boundary_type) , intent(inout) :: ice_ocean_boundary !< Ocean boundary forcing
integer , intent(inout) :: rc !< Return code

! Local Variables
integer :: i, j, ib, ig, jg, n
Expand Down Expand Up @@ -350,12 +355,26 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
do i = isc, iec
ig = i + ocean_grid%isc - isc
!rotate
do ib = 1, nsc
ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) &
if( (trim(casename) == "ufs.hafs") .and. set_missing_stks_to_zero ) then
do ib = 1, nsc
if( (abs(stkx(i,j,ib)-9.99E20_ESMF_KIND_R8) <= 0.01_ESMF_KIND_R8) ) then
ice_ocean_boundary%ustkb(i,j,ib) = 0.0
ice_ocean_boundary%vstkb(i,j,ib) = 0.0
else
ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) &
- ocean_grid%sin_rot(ig,jg)*stky(i,j,ib)
ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) &
+ ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib)
end if
end do
else
do ib = 1, nsc
ice_ocean_boundary%ustkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stkx(i,j,ib) &
- ocean_grid%sin_rot(ig,jg)*stky(i,j,ib)
ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) &
ice_ocean_boundary%vstkb(i,j,ib) = ocean_grid%cos_rot(ig,jg)*stky(i,j,ib) &
+ ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib)
enddo
enddo
end if
! apply masks
ice_ocean_boundary%ustkb(i,j,:) = ice_ocean_boundary%ustkb(i,j,:) * ocean_grid%mask2dT(ig,jg)
ice_ocean_boundary%vstkb(i,j,:) = ice_ocean_boundary%vstkb(i,j,:) * ocean_grid%mask2dT(ig,jg)
Expand Down