diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90
index 540fd12e4adfdb90f3ae0aa6b997ce263ba69bd8..6345df26aca9c85b261bf76e2278f68620156a69 100644
--- a/Overlap/eddy_graph.f90
+++ b/Overlap/eddy_graph.f90
@@ -34,6 +34,9 @@ program eddy_graph
   type(snapshot), allocatable:: flow(:) ! (max_delta + 1)
   character(len = 30) file
 
+  integer, allocatable:: n_dates_slice(:) ! (n_slices)
+  ! number of dates in each slice
+
   namelist /main_nml/ n_dates, i_slice
 
   !-------------------------------------------------------------------------
@@ -95,8 +98,9 @@ program eddy_graph
   end do
 
   if (rank == 0) then
-     if (n_dates == huge(0)) &
-          n_dates = sum([(size(ssm(i)%ishape_last), i = 1, n_slices)])
+     allocate(n_dates_slice(n_slices))
+     forall (i = 1:n_slices) n_dates_slice(i) = size(ssm(i)%ishape_last)
+     if (n_dates == huge(0)) n_dates = sum(n_dates_slice)
      print *, "n_dates = ", n_dates
      call assert(n_dates >= max_delta + 1, &
           "eddy_graph: n_dates should be >= max_delta + 1")