Skip to content

Commit ced28a3

Browse files
cspencerjonesHallberg-NOAA
authored andcommitted
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 400c982 commit ced28a3

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
@@ -1283,6 +1283,18 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
12831283

12841284
endif ! -------------------------------------------------- end SPLIT
12851285

1286+
if (CS%use_particles .and. CS%do_dynamics .and. (.not. CS%use_uh_particles)) then
1287+
if (CS%thickness_diffuse_first) call MOM_error(WARNING,"particles_run: "//&
1288+
"Thickness_diffuse_first is true and use_uh_particles is false. "//&
1289+
"This is usually a bad combination.")
1290+
!Run particles using unweighted velocity
1291+
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
1292+
CS%tv, dt, CS%use_uh_particles)
1293+
call particles_to_z_space(CS%particles, h)
1294+
endif
1295+
1296+
1297+
12861298
! Update the model's current to reflect wind-wave growth
12871299
if (Waves%Stokes_DDT .and. (.not.Waves%Passive_Stokes_DDT)) then
12881300
do J=jsq,jeq ; do i=is,ie
@@ -1368,23 +1380,21 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
13681380
endif
13691381
call disable_averaging(CS%diag)
13701382

1383+
! Advance the dynamics time by dt.
1384+
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt
1385+
13711386
if (CS%use_particles .and. CS%do_dynamics .and. CS%use_uh_particles) then
13721387
!Run particles using thickness-weighted velocity
13731388
call particles_run(CS%particles, Time_local, CS%uhtr, CS%vhtr, CS%h, &
1374-
CS%tv, CS%use_uh_particles)
1375-
elseif (CS%use_particles .and. CS%do_dynamics) then
1376-
!Run particles using unweighted velocity
1377-
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
1378-
CS%tv, CS%use_uh_particles)
1389+
CS%tv, CS%t_dyn_rel_adv, CS%use_uh_particles)
13791390
endif
13801391

1381-
1382-
! Advance the dynamics time by dt.
1383-
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt
13841392
CS%n_dyn_steps_in_adv = CS%n_dyn_steps_in_adv + 1
13851393
if (CS%alternate_first_direction) then
13861394
call set_first_direction(G, MODULO(G%first_direction+1,2))
13871395
CS%first_dir_restart = real(G%first_direction)
1396+
elseif (CS%use_particles .and. CS%do_dynamics .and. (.not.CS%use_uh_particles)) then
1397+
call particles_to_k_space(CS%particles, h)
13881398
endif
13891399
CS%t_dyn_rel_thermo = CS%t_dyn_rel_thermo + dt
13901400
if (abs(CS%t_dyn_rel_thermo) < 1e-6*dt) CS%t_dyn_rel_thermo = 0.0

0 commit comments

Comments
 (0)