Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update particles_run call to allow accurate particle advection using … #785

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config_src/external/drifters/MOM_particles.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine particles_init(parts, Grid, Time, dt, u, v, h)
end subroutine particles_init

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

end subroutine particles_run

Expand Down
26 changes: 18 additions & 8 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,18 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &

endif ! -------------------------------------------------- end SPLIT

if (CS%use_particles .and. CS%do_dynamics .and. (.not. CS%use_uh_particles)) then
if (CS%thickness_diffuse_first) call MOM_error(WARNING,"particles_run: "//&
"Thickness_diffuse_first is true and use_uh_particles is false. "//&
"This is usually a bad combination.")
!Run particles using unweighted velocity
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
CS%tv, dt, CS%use_uh_particles)
call particles_to_z_space(CS%particles, h)
endif



! Update the model's current to reflect wind-wave growth
if (Waves%Stokes_DDT .and. (.not.Waves%Passive_Stokes_DDT)) then
do J=jsq,jeq ; do i=is,ie
Expand Down Expand Up @@ -1368,23 +1380,21 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
endif
call disable_averaging(CS%diag)

! Advance the dynamics time by dt.
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt

if (CS%use_particles .and. CS%do_dynamics .and. CS%use_uh_particles) then
!Run particles using thickness-weighted velocity
call particles_run(CS%particles, Time_local, CS%uhtr, CS%vhtr, CS%h, &
CS%tv, CS%use_uh_particles)
elseif (CS%use_particles .and. CS%do_dynamics) then
!Run particles using unweighted velocity
call particles_run(CS%particles, Time_local, CS%u, CS%v, CS%h, &
CS%tv, CS%use_uh_particles)
CS%tv, CS%t_dyn_rel_adv, CS%use_uh_particles)
endif


! Advance the dynamics time by dt.
CS%t_dyn_rel_adv = CS%t_dyn_rel_adv + dt
CS%n_dyn_steps_in_adv = CS%n_dyn_steps_in_adv + 1
if (CS%alternate_first_direction) then
call set_first_direction(G, MODULO(G%first_direction+1,2))
CS%first_dir_restart = real(G%first_direction)
elseif (CS%use_particles .and. CS%do_dynamics .and. (.not.CS%use_uh_particles)) then
call particles_to_k_space(CS%particles, h)
endif
CS%t_dyn_rel_thermo = CS%t_dyn_rel_thermo + dt
if (abs(CS%t_dyn_rel_thermo) < 1e-6*dt) CS%t_dyn_rel_thermo = 0.0
Expand Down
Loading