From eb8ff9c7c48b933fc87eb25b1aacf6f419e45bf7 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Mon, 23 Jul 2018 14:00:12 +0200
Subject: [PATCH] Sort the extrema in the second pass of set_all_outerm.

---
 set_all_outerm.f | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/set_all_outerm.f b/set_all_outerm.f
index efad820f..1f4d43f7 100644
--- a/set_all_outerm.f
+++ b/set_all_outerm.f
@@ -112,6 +112,7 @@ contains
 
     do l = 1, s%number_vis_eddies
        i = sorted_extr(l)
+       
        if (flat_extr(i)) then
           s%list_vis(i)%out_cont = get_1_outerm(s%list_vis(i)%cyclone, &
                s%list_vis(i)%coord_extr, innermost_level(i), &
@@ -147,8 +148,10 @@ contains
          = any(s%extr_map(llc(1, i):urc(1, i), llc(2, i):urc(2, i)) < 0)
 
     s%list_vis%twice = flat_extr .and. s%list_vis%suff_amp .and. noise_around
-
-    do i = 1, s%number_vis_eddies
+    
+    do l = 1, s%number_vis_eddies
+       i = sorted_extr(l)
+       
        if (s%list_vis(i)%suff_amp .and. noise_around(i) &
             .or. .not. flat_extr(i)) then
           s%list_vis(i)%out_cont = get_1_outerm(s%list_vis(i)%cyclone, &
-- 
GitLab