From 0977b2fb5442dee1f24e698f4acdabbcbaebb74f Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ipsl.fr>
Date: Thu, 4 Jul 2024 18:24:27 +0200
Subject: [PATCH] Pass `corner_proj` to `get_1_outerm`

Instead of corner.
---
 Inst_eddies/Tests/test_get_1_outerm.f90 | 3 ++-
 Inst_eddies/get_1_outerm.f90            | 8 +++-----
 Inst_eddies/set_contours.f90            | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/Inst_eddies/Tests/test_get_1_outerm.f90 b/Inst_eddies/Tests/test_get_1_outerm.f90
index 049d3a38..9057bc37 100644
--- a/Inst_eddies/Tests/test_get_1_outerm.f90
+++ b/Inst_eddies/Tests/test_get_1_outerm.f90
@@ -94,7 +94,8 @@ program test_get_1_outerm
   e%extr%coord_proj = ind_targ_extr
   e%extr%coord = corner + (ind_targ_extr - 1) * step
   call get_1_outerm(e%out_cont, cont_list, cont_list_proj, n_cont, cyclone, &
-       real(ind_targ_extr), innermost_level, outside_points, ssh, corner, step)
+       real(ind_targ_extr), innermost_level, outside_points, ssh, &
+       corner_proj = [1., 1.], step = step)
 
   if (e%out_cont%closed) then
      e%extr%ssh = ssh(ind_targ_extr(1), ind_targ_extr(2))
diff --git a/Inst_eddies/get_1_outerm.f90 b/Inst_eddies/get_1_outerm.f90
index ce73601d..f3a74399 100644
--- a/Inst_eddies/get_1_outerm.f90
+++ b/Inst_eddies/get_1_outerm.f90
@@ -6,7 +6,7 @@ contains
 
   subroutine get_1_outerm(out_cont, cont_list, cont_list_proj, n_cont, &
        cyclone, extr_coord_proj, innermost_level_2, outside_points, ssh, &
-       corner, step)
+       corner_proj, step)
 
     ! This procedure gets one outermost good contour with sufficient
     ! area, if it can find one. If the procedure cannot find an
@@ -96,8 +96,8 @@ contains
 
     real, intent(in):: ssh(:, :) ! in m
 
-    real, intent(in):: corner(:) ! (2)
-    ! Longitude and latitude corresponding to ssh(1,1), in rad. A
+    real, intent(in):: corner_proj(:) ! (2)
+    ! Coordinates in projection space corresponding to ssh(1,1). A
     ! priori, this is not the corner of the grid of the NetCDF file.
 
     real, intent(in):: step(:) ! (2)
@@ -109,12 +109,10 @@ contains
     logical mask(size(ssh, 1), size(ssh, 2))
     integer n_max_cont ! >= 3
     integer i
-    real corner_proj(2)
     real outside_points_proj(2, size(outside_points, 2))
 
     !-----------------------------------------------------------------
 
-    corner_proj = (corner - corner_whole) / step + 1.
     outside_points_proj = convert_to_ind(outside_points, corner_whole, step)
     n_max_cont = size(cont_list_proj)
     n_cont = 0
diff --git a/Inst_eddies/set_contours.f90 b/Inst_eddies/set_contours.f90
index ec392569..bab8c704 100644
--- a/Inst_eddies/set_contours.f90
+++ b/Inst_eddies/set_contours.f90
@@ -96,7 +96,7 @@ contains
 
     call get_1_outerm(out_cont, cont_list, cont_list_proj, n_cont, cyclone, &
          real(extr%coord_proj), innermost_level_2, outside_points, ssh, &
-         corner, step)
+         (corner - corner_whole) / step + 1., step)
 
     ! Done with outermost contour, now let us take care of the
     ! max-speed contour.
-- 
GitLab