Skip to content

Commit fe5e605

Browse files
committed
Merge branch 'jiandewang-main-candidate-EMC-2021-01-04' into main
2 parents 0f664aa + ea5e245 commit fe5e605

9 files changed

Lines changed: 881 additions & 1081 deletions

config_src/nuopc_driver/mom_cap.F90

Lines changed: 323 additions & 713 deletions
Large diffs are not rendered by default.

config_src/nuopc_driver/mom_cap_methods.F90

Lines changed: 286 additions & 162 deletions
Large diffs are not rendered by default.

config_src/nuopc_driver/mom_cap_time.F90

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module MOM_cap_time
1616
use ESMF , only : ESMF_RC_ARG_BAD
1717
use ESMF , only : operator(<), operator(/=), operator(+), operator(-), operator(*) , operator(>=)
1818
use ESMF , only : operator(<=), operator(>), operator(==)
19+
use MOM_cap_methods , only : ChkErr
1920

2021
implicit none; private
2122

@@ -125,22 +126,13 @@ subroutine AlarmInit( clock, alarm, option, &
125126
endif
126127

127128
call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc)
128-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
129-
line=__LINE__, &
130-
file=__FILE__)) &
131-
return
129+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
132130

133131
call ESMF_TimeGet(CurrTime, yy=cyy, mm=cmm, dd=cdd, s=csec, rc=rc )
134-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
135-
line=__LINE__, &
136-
file=__FILE__)) &
137-
return
132+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
138133

139134
call ESMF_TimeGet(CurrTime, yy=nyy, mm=nmm, dd=ndd, s=nsec, rc=rc )
140-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
141-
line=__LINE__, &
142-
file=__FILE__)) &
143-
return
135+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
144136

145137
! initial guess of next alarm, this will be updated below
146138
if (present(RefTime)) then
@@ -151,25 +143,16 @@ subroutine AlarmInit( clock, alarm, option, &
151143

152144
! Determine calendar
153145
call ESMF_ClockGet(clock, calendar=cal, rc=rc)
154-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
155-
line=__LINE__, &
156-
file=__FILE__)) &
157-
return
146+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
158147

159148
! Determine inputs for call to create alarm
160149
selectcase (trim(option))
161150

162151
case (optNONE, optNever)
163152
call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc)
164-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
165-
line=__LINE__, &
166-
file=__FILE__)) &
167-
return
153+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
168154
call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc )
169-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
170-
line=__LINE__, &
171-
file=__FILE__)) &
172-
return
155+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
173156
update_nextalarm = .false.
174157

175158
case (optDate)
@@ -188,15 +171,9 @@ subroutine AlarmInit( clock, alarm, option, &
188171
return
189172
endif
190173
call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc)
191-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
192-
line=__LINE__, &
193-
file=__FILE__)) &
194-
return
174+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
195175
call TimeInit(NextAlarm, lymd, cal, tod=ltod, desc="optDate", rc=rc)
196-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
197-
line=__LINE__, &
198-
file=__FILE__)) &
199-
return
176+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
200177
update_nextalarm = .false.
201178

202179
case (optIfdays0)
@@ -208,104 +185,65 @@ subroutine AlarmInit( clock, alarm, option, &
208185
return
209186
endif
210187
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
211-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
212-
line=__LINE__, &
213-
file=__FILE__)) &
214-
return
188+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
215189
call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=opt_n, s=0, calendar=cal, rc=rc )
216-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
217-
line=__LINE__, &
218-
file=__FILE__)) &
219-
return
190+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
220191
update_nextalarm = .true.
221192

222193
case (optNSteps, optNStep)
223194
call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc)
224-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
225-
line=__LINE__, &
226-
file=__FILE__)) &
227-
return
195+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
228196
AlarmInterval = AlarmInterval * opt_n
229197
update_nextalarm = .true.
230198

231199
case (optNSeconds, optNSecond)
232200
call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc)
233-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
234-
line=__LINE__, &
235-
file=__FILE__)) &
236-
return
201+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
237202
AlarmInterval = AlarmInterval * opt_n
238203
update_nextalarm = .true.
239204

240205
case (optNMinutes, optNMinute)
241206
call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc)
242-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
243-
line=__LINE__, &
244-
file=__FILE__)) &
245-
return
207+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
246208
AlarmInterval = AlarmInterval * opt_n
247209
update_nextalarm = .true.
248210

249211
case (optNHours, optNHour)
250212
call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc)
251-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
252-
line=__LINE__, &
253-
file=__FILE__)) &
254-
return
213+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
255214
AlarmInterval = AlarmInterval * opt_n
256215
update_nextalarm = .true.
257216

258217
case (optNDays, optNDay)
259218
call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc)
260-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
261-
line=__LINE__, &
262-
file=__FILE__)) &
263-
return
219+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
264220
AlarmInterval = AlarmInterval * opt_n
265221
update_nextalarm = .true.
266222

267223
case (optNMonths, optNMonth)
268224
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
269-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
270-
line=__LINE__, &
271-
file=__FILE__)) &
272-
return
225+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
273226
AlarmInterval = AlarmInterval * opt_n
274227
update_nextalarm = .true.
275228

276229
case (optMonthly)
277230
call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc)
278-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
279-
line=__LINE__, &
280-
file=__FILE__)) &
281-
return
231+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
282232
call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=1, s=0, calendar=cal, rc=rc )
283-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
284-
line=__LINE__, &
285-
file=__FILE__)) &
286-
return
233+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
287234
update_nextalarm = .true.
288235

289236
case (optNYears, optNYear)
290237
call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc)
291-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
292-
line=__LINE__, &
293-
file=__FILE__)) &
294-
return
238+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
295239
AlarmInterval = AlarmInterval * opt_n
296240
update_nextalarm = .true.
297241

298242
case (optYearly)
299243
call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc)
300-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
301-
line=__LINE__, &
302-
file=__FILE__)) &
303-
return
244+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
304245
call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc )
305-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
306-
line=__LINE__, &
307-
file=__FILE__)) &
308-
return
246+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
309247
update_nextalarm = .true.
310248

311249
case default
@@ -332,10 +270,7 @@ subroutine AlarmInit( clock, alarm, option, &
332270
endif
333271

334272
alarm = ESMF_AlarmCreate( name=lalarmname, clock=clock, ringTime=NextAlarm, ringInterval=AlarmInterval, rc=rc)
335-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
336-
line=__LINE__, &
337-
file=__FILE__)) &
338-
return
273+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
339274

340275
end subroutine AlarmInit
341276

@@ -378,10 +313,7 @@ subroutine TimeInit( Time, ymd, cal, tod, desc, logunit, rc)
378313
call date2ymd (ymd,yr,mon,day)
379314

380315
call ESMF_TimeSet( Time, yy=yr, mm=mon, dd=day, s=ltod, calendar=cal, rc=rc )
381-
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
382-
line=__LINE__, &
383-
file=__FILE__)) &
384-
return
316+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
385317

386318
end subroutine TimeInit
387319

config_src/nuopc_driver/mom_ocean_model_nuopc.F90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ module MOM_ocean_model_nuopc
144144

145145
integer :: nstep = 0 !< The number of calls to update_ocean.
146146
logical :: use_ice_shelf !< If true, the ice shelf model is enabled.
147-
logical :: use_waves !< If true use wave coupling.
147+
logical,public :: use_waves !< If true use wave coupling.
148148

149149
logical :: icebergs_alter_ocean !< If true, the icebergs can change ocean the
150150
!! ocean dynamics and forcing fluxes.
@@ -204,7 +204,7 @@ module MOM_ocean_model_nuopc
204204
type(marine_ice_CS), pointer :: &
205205
marine_ice_CSp => NULL() !< A pointer to the control structure for the
206206
!! marine ice effects module.
207-
type(wave_parameters_cs), pointer :: &
207+
type(wave_parameters_cs), pointer, public :: &
208208
Waves !< A structure containing pointers to the surface wave fields
209209
type(surface_forcing_CS), pointer :: &
210210
forcing_CSp => NULL() !< A pointer to the MOM forcing control structure
@@ -388,6 +388,9 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
388388
"If true, enables surface wave modules.", default=.false.)
389389
if (OS%use_waves) then
390390
call MOM_wave_interface_init(OS%Time, OS%grid, OS%GV, OS%US, param_file, OS%Waves, OS%diag)
391+
call get_param(param_file,mdl,"SURFBAND_WAVENUMBERS",OS%Waves%WaveNum_Cen, &
392+
"Central wavenumbers for surface Stokes drift bands.",units='rad/m', &
393+
default=0.12566)
391394
else
392395
call MOM_wave_interface_init_lite(param_file)
393396
endif
@@ -572,7 +575,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, &
572575
call set_net_mass_forcing(OS%fluxes, OS%forces, OS%grid, OS%US)
573576

574577
if (OS%use_waves) then
575-
call Update_Surface_Waves(OS%grid, OS%GV, OS%US, OS%time, ocean_coupling_time_step, OS%waves)
578+
call Update_Surface_Waves(OS%grid, OS%GV, OS%US, OS%time, ocean_coupling_time_step, OS%waves, OS%forces)
576579
endif
577580

578581
if (OS%nstep==0) then
@@ -733,7 +736,7 @@ subroutine ocean_model_end(Ocean_sfc, Ocean_state, Time, write_restart)
733736
type(time_type), intent(in) :: Time !< The model time, used for writing restarts.
734737
logical, intent(in) :: write_restart !< true => write restart file
735738

736-
call ocean_model_save_restart(Ocean_state, Time)
739+
if(write_restart)call ocean_model_save_restart(Ocean_state, Time)
737740
call diag_mediator_end(Time, Ocean_state%diag, end_diag_manager=.true.)
738741
call MOM_end(Ocean_state%MOM_CSp)
739742
if (Ocean_state%use_ice_shelf) call ice_shelf_end(Ocean_state%Ice_shelf_CSp)

config_src/nuopc_driver/mom_surface_forcing_nuopc.F90

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ module MOM_surface_forcing_nuopc
183183
!! ice-shelves, expressed as a coefficient
184184
!! for divergence damping, as determined
185185
!! outside of the ocean model in [m3/s]
186+
real, pointer, dimension(:,:) :: ustk0 => NULL() !< Surface Stokes drift, zonal [m/s]
187+
real, pointer, dimension(:,:) :: vstk0 => NULL() !< Surface Stokes drift, meridional [m/s]
188+
real, pointer, dimension(:) :: stk_wavenumbers => NULL() !< The central wave number of Stokes bands [rad/m]
189+
real, pointer, dimension(:,:,:) :: ustkb => NULL() !< Stokes Drift spectrum, zonal [m/s]
190+
!! Horizontal - u points
191+
!! 3rd dimension - wavenumber
192+
real, pointer, dimension(:,:,:) :: vstkb => NULL() !< Stokes Drift spectrum, meridional [m/s]
193+
!! Horizontal - v points
194+
!! 3rd dimension - wavenumber
195+
integer :: num_stk_bands !< Number of Stokes drift bands passed through the coupler
186196
integer :: xtype !< The type of the exchange - REGRID, REDIST or DIRECT
187197
type(coupler_2d_bc_type) :: fluxes !< A structure that may contain an array of
188198
!! named fields used for passive tracer fluxes.
@@ -428,7 +438,10 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
428438
call MOM_error(FATAL, "liquid runoff is being added via data_override but "// &
429439
"there is no associated runoff in the IOB")
430440
return
431-
end if
441+
endif
442+
if (associated(IOB%lrunoff)) then
443+
if(CS%liquid_runoff_from_data)call data_override('OCN', 'runoff', IOB%lrunoff, Time)
444+
endif
432445

433446
! obtain fluxes from IOB; note the staggering of indices
434447
i0 = is - isc_bnd ; j0 = js - jsc_bnd
@@ -445,7 +458,6 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
445458

446459
! liquid runoff flux
447460
if (associated(IOB%lrunoff)) then
448-
if(CS%liquid_runoff_from_data)call data_override('OCN', 'runoff', IOB%lrunoff, Time)
449461
fluxes%lrunoff(i,j) = kg_m2_s_conversion * IOB%lrunoff(i-i0,j-j0) * G%mask2dT(i,j)
450462
endif
451463

@@ -624,7 +636,7 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
624636
real :: mass_eff !< effective mass of sea ice for rigidity [R Z ~> kg m-2]
625637

626638
integer :: wind_stagger !< AGRID, BGRID_NE, or CGRID_NE (integers from MOM_domains)
627-
integer :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq, i0, j0
639+
integer :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq, i0, j0, istk
628640
integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isr, ier, jsr, jer
629641
integer :: isc_bnd, iec_bnd, jsc_bnd, jec_bnd
630642

@@ -663,6 +675,7 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
663675
if ( (associated(IOB%area_berg) .and. (.not. associated(forces%area_berg))) .or. &
664676
(associated(IOB%mass_berg) .and. (.not. associated(forces%mass_berg))) ) &
665677
call allocate_mech_forcing(G, forces, iceberg=.true.)
678+
666679
if (associated(IOB%ice_rigidity)) then
667680
rigidity_at_h(:,:) = 0.0
668681
call safe_alloc_ptr(forces%rigidity_ice_u,IsdB,IedB,jsd,jed)
@@ -673,6 +686,9 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
673686
if (associated(forces%rigidity_ice_u)) forces%rigidity_ice_u(:,:) = 0.0
674687
if (associated(forces%rigidity_ice_v)) forces%rigidity_ice_v(:,:) = 0.0
675688

689+
if ( associated(IOB%ustkb) ) &
690+
call allocate_mech_forcing(G, forces, waves=.true., num_stk_bands=IOB%num_stk_bands)
691+
676692
! applied surface pressure from atmosphere and cryosphere
677693
if (CS%use_limited_P_SSH) then
678694
forces%p_surf_SSH => forces%p_surf
@@ -830,6 +846,24 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
830846

831847
endif ! endif for wind related fields
832848

849+
! wave to ocean coupling
850+
if ( associated(IOB%ustkb) ) then
851+
852+
forces%stk_wavenumbers(:) = IOB%stk_wavenumbers
853+
do j=js,je; do i=is,ie
854+
forces%ustk0(i,j) = IOB%ustk0(i-I0,j-J0) ! How to be careful here that the domains are right?
855+
forces%vstk0(i,j) = IOB%vstk0(i-I0,j-J0)
856+
enddo ; enddo
857+
call pass_vector(forces%ustk0,forces%vstk0, G%domain )
858+
do istk = 1,IOB%num_stk_bands
859+
do j=js,je; do i=is,ie
860+
forces%ustkb(i,j,istk) = IOB%ustkb(i-I0,j-J0,istk)
861+
forces%vstkb(i,j,istk) = IOB%vstkb(i-I0,j-J0,istk)
862+
enddo; enddo
863+
call pass_vector(forces%ustkb(:,:,istk),forces%vstkb(:,:,istk), G%domain )
864+
enddo
865+
endif
866+
833867
! sea ice related dynamic fields
834868
if (associated(IOB%ice_rigidity)) then
835869
call pass_var(rigidity_at_h, G%Domain, halo=1)

0 commit comments

Comments
 (0)