From e2efd2d9af5ab3840403e8cbe54061839601a997 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Tue, 19 Nov 2024 20:01:40 +0100
Subject: [PATCH] Read the initial date from `date_range.txt`

Rather than from the shapefiles. Following commit 63b99b5. Moreover,
the DBF file may be empty, as in the test
`Successive_overlap_periodic`, and then the call to
`dbf_read_attribute_03` would crash.
---
 Overlap/Tests/test_overlap.f90 | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90
index a93b8c4d..56278080 100644
--- a/Overlap/Tests/test_overlap.f90
+++ b/Overlap/Tests/test_overlap.f90
@@ -2,7 +2,6 @@ program test_overlap
 
   ! Libraries:
   use jumble, only: get_command_arg_dyn, read_opcol, new_unit, ediff1d, assert
-  use shapelib_03, only: dbf_read_attribute_03
 
   use config_graph_m, only: config_graph, copy, max_delta, cyclone
   use derived_types, only: snapshot, ori_slice_handler, shpc_slice_meta
@@ -15,7 +14,7 @@ program test_overlap
 
   implicit none
 
-  character(len = :), allocatable:: shpc_dir
+  character(len = :), allocatable:: shpc_dir, slice_dir
   integer:: k_test_1 = 0, k_test_2 = 1, i_slice = 0
   integer unit, i, n_dates
   type(snapshot), allocatable:: flow(:) ! (max_delta + 1)
@@ -39,13 +38,18 @@ program test_overlap
 
   call ori_slice_open(hshp, trim(shpc_dir), cyclone, i_slice, &
        with_proj = .not. uniform_lon_lat, pszaccess = "rb")
-  call dbf_read_attribute_03(ssm%d0, hshp%extremum, hshp%extr_date, ishape = 0)
+  allocate(character(len(shpc_dir) + 12):: slice_dir)
+  write(slice_dir, fmt = '(a, "/Slice_", i0)') shpc_dir, i_slice
+  call new_unit(unit)
+  open(unit, file = trim(slice_dir) // "/date_range.txt", &
+       STATUS = "old", action = "read", position = "rewind")
+  read(unit, fmt = *) ssm%d0
+  close(unit)
   call read_opcol(ssm%ishape_last, hshp%unit, my_lbound = ssm%d0)
   n_dates = size(ssm%ishape_last)
   call assert(ssm%d0 <= [k_test_1, k_test_2] .and. [k_test_1, k_test_2] &
        < ssm%d0 + n_dates, "test_overlap k_test_1, k_test_2")
   e_overestim = maxval([ssm%ishape_last(ssm%d0) + 1, ediff1d(ssm%ishape_last)])
-  call new_unit(unit)
   open(unit, file = "e_overestim.txt", status = "replace", action = "write")
   write(unit, fmt = *) e_overestim
   close(unit)
-- 
GitLab