Skip to content

Commit 7295f7e

Browse files
committed
Update particles_run call to allow accurate particle advection using u, v or uh, vh
The drifters package is able to run in 2 different modes: one where the particles are advected using u and v, and one where they are advected using uh and vh. When u and v are used (i.e. the drifters are advected using the resolved velocities only, with no sub-grd component), the particles package needs the layer thickness that is consistent with these velocities, so particles_run needs to be called before any subgrid scale parameterizations are applied. This was not implemented correctly in my last PR, and is corrected here. The particles package also needs the correct timestep for particle advection. This is added here.
1 parent e6e0870 commit 7295f7e

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

config_src/external/drifters/MOM_particles.F90

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ subroutine particles_init(parts, Grid, Time, dt, u, v, h)
2828
end subroutine particles_init
2929

3030
!> The main driver the steps updates particles
31-
subroutine particles_run(parts, time, uo, vo, ho, tv, use_uh, stagger)
31+
subroutine particles_run(parts, time, uo, vo, ho, tv, dt_adv, use_uh)
3232
! Arguments
3333
type(particles), pointer :: parts !< Container for all types and memory
3434
type(time_type), intent(in) :: time !< Model time
@@ -40,8 +40,8 @@ subroutine particles_run(parts, time, uo, vo, ho, tv, use_uh, stagger)
4040
!! that are used to advect tracers [H L2 ~> m3 or kg]
4141
real, dimension(:,:,:), intent(in) :: ho !< Ocean layer thickness [H ~> m or kg m-2]
4242
type(thermo_var_ptrs), intent(in) :: tv !< structure containing pointers to available thermodynamic fields
43+
real, intent(in) :: dt_adv !< timestep for advecting particles [s]
4344
logical :: use_uh !< Flag for whether u and v are weighted by thickness
44-
integer, optional, intent(in) :: stagger !< Flag for whether velocities are staggered
4545

4646
end subroutine particles_run
4747

src/core/MOM.F90

+18-8
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,18 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
12791279

12801280
endif ! -------------------------------------------------- end SPLIT
12811281

1282+
if (CS%use_particles .and. CS%do_dynamics .and. (.not. CS%use_uh_particles)) then
1283+
if (CS%thickness_diffuse_first) call MOM_error(WARNING,"particles_run: "//&
1284+
"Thickness_diffuse_first is true and use_uh_particles is false. "//&
1285+
"This is usually a bad combination.")
1286+
!Run particles using unweighted velocity
1287+
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
1288+
CS%tv, dt, CS%use_uh_particles)
1289+
call particles_to_z_space(CS%particles, h)
1290+
endif
1291+
1292+
1293+
12821294
! Update the model's current to reflect wind-wave growth
12831295
if (Waves%Stokes_DDT .and. (.not.Waves%Passive_Stokes_DDT)) then
12841296
do J=jsq,jeq ; do i=is,ie
@@ -1364,23 +1376,21 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
13641376
endif
13651377
call disable_averaging(CS%diag)
13661378

1379+
! Advance the dynamics time by dt.
1380+
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt
1381+
13671382
if (CS%use_particles .and. CS%do_dynamics .and. CS%use_uh_particles) then
13681383
!Run particles using thickness-weighted velocity
13691384
call particles_run(CS%particles, Time_local, CS%uhtr, CS%vhtr, CS%h, &
1370-
CS%tv, CS%use_uh_particles)
1371-
elseif (CS%use_particles .and. CS%do_dynamics) then
1372-
!Run particles using unweighted velocity
1373-
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
1374-
CS%tv, CS%use_uh_particles)
1385+
CS%tv, CS%t_dyn_rel_adv, CS%use_uh_particles)
13751386
endif
13761387

1377-
1378-
! Advance the dynamics time by dt.
1379-
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt
13801388
CS%n_dyn_steps_in_adv = CS%n_dyn_steps_in_adv + 1
13811389
if (CS%alternate_first_direction) then
13821390
call set_first_direction(G, MODULO(G%first_direction+1,2))
13831391
CS%first_dir_restart = real(G%first_direction)
1392+
elseif (CS%use_particles .and. CS%do_dynamics .and. (.not.CS%use_uh_particles)) then
1393+
call particles_to_k_space(CS%particles, h)
13841394
endif
13851395
CS%t_dyn_rel_thermo = CS%t_dyn_rel_thermo + dt
13861396
if (abs(CS%t_dyn_rel_thermo) < 1e-6*dt) CS%t_dyn_rel_thermo = 0.0

0 commit comments

Comments
 (0)