From 0badcf0190e295d13f07b539e1c52e55e713bced Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 24 Apr 2024 18:57:50 +0200
Subject: [PATCH] Bug fix: require continuity of dates across slices

The algorithm of `eddy_graph` assumes that the set of dates it
processes is evenly spaced.
---
 Overlap/eddy_graph.f90   | 3 +++
 Overlap/eddy_graph.sh.in | 4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90
index 6345df26..60b4747b 100644
--- a/Overlap/eddy_graph.f90
+++ b/Overlap/eddy_graph.f90
@@ -100,6 +100,9 @@ program eddy_graph
   if (rank == 0) then
      allocate(n_dates_slice(n_slices))
      forall (i = 1:n_slices) n_dates_slice(i) = size(ssm(i)%ishape_last)
+     call assert(ediff1d(ssm%d0) == n_dates_slice, "eddy_graph: the first " &
+          // "date index of each slice should be one more than the last date " &
+          // "of the previous slice")
      if (n_dates == huge(0)) n_dates = sum(n_dates_slice)
      print *, "n_dates = ", n_dates
      call assert(n_dates >= max_delta + 1, &
diff --git a/Overlap/eddy_graph.sh.in b/Overlap/eddy_graph.sh.in
index f74a93d1..e2cf74ec 100644
--- a/Overlap/eddy_graph.sh.in
+++ b/Overlap/eddy_graph.sh.in
@@ -1,9 +1,7 @@
 #!/bin/bash
 
 # This script creates the edge list for a given orientation of
-# eddies. The script takes an SHPC as argument. We assume (and do not
-# check) that the first date index in a slice of the SHPC is greater
-# than the last date index in the previous slice.
+# eddies. The script takes an SHPC as argument.
 
 if (($# <= 1))
 then
-- 
GitLab