Skip to content

Commit

Permalink
Updated mom_cap.F90 and mom_cap_methods.F90 to use a new parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
binli2337 committed Feb 14, 2025
1 parent e8d23ad commit b82878b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
11 changes: 10 additions & 1 deletion 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 @@ -1761,7 +1770,7 @@ subroutine ModelAdvance(gcomp, rc)
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, casename, 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
39 changes: 24 additions & 15 deletions config_src/drivers/nuopc_cap/mom_cap_methods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ 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, casename, 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
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
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, optional , 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 All @@ -90,7 +91,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
real(ESMF_KIND_R8), allocatable :: stkx(:,:,:)
real(ESMF_KIND_R8), allocatable :: stky(:,:,:)
character(len=*) , parameter :: subname = '(mom_import)'
real(ESMF_KIND_R8), parameter :: fillValue = 9.99e20_ESMF_KIND_R8

rc = ESMF_SUCCESS

Expand Down Expand Up @@ -352,17 +352,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
if( (trim(casename) == "ufs.hafs") .and. (abs(stkx(i,j,ib)-fillValue) <= 0.01) ) then
ice_ocean_boundary%ustkb(i,j,ib) = 0.0
ice_ocean_boundary%vstkb(i,j,ib) = 0.0
else
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) &
+ ocean_grid%sin_rot(ig,jg)*stkx(i,j,ib)
endif
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

0 comments on commit b82878b

Please sign in to comment.