From fcfb13f55ec7e37ff08c6c67988678d0c087cd92 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ipsl.fr> Date: Thu, 4 Jul 2024 08:52:30 +0200 Subject: [PATCH] Pass `corner_proj` to `mean_speed` Pass `corner_proj` instead of corner to `mean_speed`, avoiding a repeated computation. --- Inst_eddies/Tests/test_mean_speed.f90 | 4 ++-- Inst_eddies/mean_speed.f90 | 18 +++++++----------- Inst_eddies/set_max_speed.f90 | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Inst_eddies/Tests/test_mean_speed.f90 b/Inst_eddies/Tests/test_mean_speed.f90 index 274aaa57..c16869ee 100644 --- a/Inst_eddies/Tests/test_mean_speed.f90 +++ b/Inst_eddies/Tests/test_mean_speed.f90 @@ -72,7 +72,7 @@ program test_mean_speed end if print *, "mean azimuthal speed = ", mean_speed(u, v, p%part(1), & - convert_to_ind(p%part(1)%points, corner, step), center, corner, step), & - "m s-1" + convert_to_ind(p%part(1)%points, corner, step), center, & + corner_proj = [1., 1.]), "m s-1" end program test_mean_speed diff --git a/Inst_eddies/mean_speed.f90 b/Inst_eddies/mean_speed.f90 index c8ed7b3d..fc7952e8 100644 --- a/Inst_eddies/mean_speed.f90 +++ b/Inst_eddies/mean_speed.f90 @@ -4,7 +4,7 @@ module mean_speed_m contains - real function mean_speed(u, v, p, points_xy, center, corner, step) + real function mean_speed(u, v, p, points_xy, center, corner_proj) ! Interpolates the wind at each point of the input polyline and ! computes the mean azimuthal speed at interpolation points. We @@ -20,8 +20,6 @@ contains use numer_rec_95, only: bilinear_interp2_reg use jumble, only: rad_to_deg - use input_ssh_m, only: corner_whole => corner - real, intent(in):: u(:, :), v(:, :) ! velocity type(polyline), intent(in):: p @@ -35,10 +33,9 @@ contains ! Longitude and latitude, in rad. Azimuthal speed is computed with ! respect to this point. - real, intent(in):: corner(:) ! (2) - ! longitude and latitude corresponding to u(1,1) and v(1, 1), in rad - - real, intent(in):: step(:) ! (2) ! longitude and latitude steps, in rad + real, intent(in):: corner_proj(:) ! (2) + ! coordinates in projection space of the point corresponding to + ! u(1,1) and v(1, 1) ! Local: @@ -56,16 +53,15 @@ contains write(error_unit, fmt = *) & "mean_speed: requires non-null, closed contour" write(error_unit, fmt = *) "center (in °) = ", center * rad_to_deg - write(error_unit, fmt = *) "corner (in °) = ", corner * rad_to_deg - write(error_unit, fmt = *) "step (in °) = ", step * rad_to_deg + write(error_unit, fmt = *) "corner_proj = ", corner_proj write(error_unit, fmt = *) "p%n_points = ", p%n_points write(error_unit, fmt = *) "Aborting." stop 1 end if ni = p%n_points - 1 - call bilinear_interp2_reg((corner - corner_whole) / step + 1., [1., 1.], & - u, v, points_xy(:, :ni), ui, vi) + call bilinear_interp2_reg(corner_proj, [1., 1.], u, v, points_xy(:, :ni), & + ui, vi) do j = 1, ni x = cos(center(2)) * (p%points(1, j) - center(1)) diff --git a/Inst_eddies/set_max_speed.f90 b/Inst_eddies/set_max_speed.f90 index 63dfa573..2d2fde77 100644 --- a/Inst_eddies/set_max_speed.f90 +++ b/Inst_eddies/set_max_speed.f90 @@ -110,7 +110,7 @@ contains do i = 1, n_cont if (cont_list(i)%closed) then speed(i) = mean_speed(u, v, cont_list(i), cont_list_proj(i)%points, & - extr_coord, corner, step) + extr_coord, corner_proj) else ! It is possible that good_contour returned a null polyline ! if there is a missing value of SSH inside the outermost -- GitLab