Skip to content

Commit

Permalink
Merge pull request #235 from mom-ocean/main
Browse files Browse the repository at this point in the history
Merge with mom-ocean
  • Loading branch information
alperaltuntas committed Mar 2, 2023
2 parents c142e4c + b57ff02 commit 9786710
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 80 deletions.
37 changes: 9 additions & 28 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -745,23 +745,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if (wave_method == "EFACTOR") then
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_lamult" , "will provide")
else if (wave_method == "SURFACE_BANDS") then
if (cesm_coupled) then
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_x", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_y", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
else ! below is the old approach of importing partitioned stokes drift components. after the planned ww3 nuopc
! cap unification, this else block should be removed in favor of the more flexible import approach above.
if (Ice_ocean_boundary%num_stk_bands > 3) then
call MOM_error(FATAL, "Number of Stokes Bands > 3, NUOPC cap not set up for this")
endif
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_1" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_1", "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_2" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_2", "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_3" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_3", "will provide")
endif
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_x", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_y", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
else
call MOM_error(FATAL, "Unsupported WAVE_METHOD encountered in NUOPC cap.")
endif
Expand Down Expand Up @@ -1700,16 +1687,10 @@ subroutine ModelAdvance(gcomp, rc)
close(writeunit)
endif
else ! not cesm_coupled
! write the final restart without a timestamp
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
write(restartname,'(A)')"MOM.res"
write(stoch_restartname,'(A)')"ocn_stoch.res.nc"
else
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2)') &
"MOM.res.", year, month, day, hour, minute, seconds
write(stoch_restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
endif
write(restartname,'(i4.4,2(i2.2),A,3(i2.2),A)') year, month, day,".", hour, minute, seconds, &
".MOM.res"
write(stoch_restartname,'(i4.4,2(i2.2),A,3(i2.2),A)') year, month, day,".", hour, minute, seconds, &
".ocn_stoch.res.nc"
call ESMF_LogWrite("MOM_cap: Writing restart : "//trim(restartname), ESMF_LOGMSG_INFO)

! write restart file(s)
Expand Down Expand Up @@ -1869,7 +1850,7 @@ subroutine ModelSetRunClock(gcomp, rc)
line=__LINE__, file=__FILE__, rcToReturn=rc)
return
endif
! not used in nems
! not used in ufs
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
52 changes: 1 addition & 51 deletions config_src/drivers/nuopc_cap/mom_cap_methods.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!> Contains import/export methods for both NEMS and CMEPS.
!> Contains import/export methods for CMEPS.
module MOM_cap_methods

use ESMF, only: ESMF_Clock, ESMF_ClockGet, ESMF_time, ESMF_TimeGet
Expand Down Expand Up @@ -87,8 +87,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
character(len=128) :: fldname
real(ESMF_KIND_R8), allocatable :: taux(:,:)
real(ESMF_KIND_R8), allocatable :: tauy(:,:)
real(ESMF_KIND_R8), allocatable :: stkx1(:,:),stkx2(:,:),stkx3(:,:)
real(ESMF_KIND_R8), allocatable :: stky1(:,:),stky2(:,:),stky3(:,:)
real(ESMF_KIND_R8), allocatable :: stkx(:,:,:)
real(ESMF_KIND_R8), allocatable :: stky(:,:,:)
character(len=*) , parameter :: subname = '(mom_import)'
Expand Down Expand Up @@ -329,8 +327,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
! Partitioned Stokes Drift Components
!----
if ( associated(ice_ocean_boundary%ustkb) ) then

if (cesm_coupled) then
nsc = Ice_ocean_boundary%num_stk_bands
allocate(stkx(isc:iec,jsc:jec,1:nsc))
allocate(stky(isc:iec,jsc:jec,1:nsc))
Expand Down Expand Up @@ -358,52 +354,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
enddo
enddo
deallocate(stkx,stky)

else ! below is the old approach of importing partitioned stokes drift components. after the planned ww3 nuopc
! cap unification, this else block should be removed in favor of the more flexible import approach above.
allocate(stkx1(isc:iec,jsc:jec))
allocate(stky1(isc:iec,jsc:jec))
allocate(stkx2(isc:iec,jsc:jec))
allocate(stky2(isc:iec,jsc:jec))
allocate(stkx3(isc:iec,jsc:jec))
allocate(stky3(isc:iec,jsc:jec))

call state_getimport(importState,'eastward_partitioned_stokes_drift_1' , isc, iec, jsc, jec, stkx1,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_1', isc, iec, jsc, jec, stky1,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'eastward_partitioned_stokes_drift_2' , isc, iec, jsc, jec, stkx2,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_2', isc, iec, jsc, jec, stky2,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'eastward_partitioned_stokes_drift_3' , isc, iec, jsc, jec, stkx3,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_3', isc, iec, jsc, jec, stky3,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! rotate from true zonal/meridional to local coordinates
do j = jsc, jec
jg = j + ocean_grid%jsc - jsc
do i = isc, iec
ig = i + ocean_grid%isc - isc
ice_ocean_boundary%ustkb(i,j,1) = ocean_grid%cos_rot(ig,jg)*stkx1(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky1(i,j)
ice_ocean_boundary%vstkb(i,j,1) = ocean_grid%cos_rot(ig,jg)*stky1(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx1(i,j)

ice_ocean_boundary%ustkb(i,j,2) = ocean_grid%cos_rot(ig,jg)*stkx2(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky2(i,j)
ice_ocean_boundary%vstkb(i,j,2) = ocean_grid%cos_rot(ig,jg)*stky2(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx2(i,j)

ice_ocean_boundary%ustkb(i,j,3) = ocean_grid%cos_rot(ig,jg)*stkx3(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky3(i,j)
ice_ocean_boundary%vstkb(i,j,3) = ocean_grid%cos_rot(ig,jg)*stky3(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx3(i,j)
enddo
enddo
deallocate(stkx1,stkx2,stkx3,stky1,stky2,stky3)
endif
endif

end subroutine mom_import
Expand Down
1 change: 0 additions & 1 deletion config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
endif
forces%accumulate_p_surf = .true. ! Multiple components may contribute to surface pressure.

! TODO: this does not seem correct for NEMS
#ifdef CESMCOUPLED
wind_stagger = AGRID
#else
Expand Down

0 comments on commit 9786710

Please sign in to comment.