From eb979ef415c5737d5150fe7efca62c6ebfe184eb Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Mon, 17 Jan 2022 23:33:20 +0100
Subject: [PATCH] Generalize `test_read_snapshot` to read any date

Use the first date of the SHPC as default date to read.
---
 Overlap/Tests/test_read_snapshot.f90 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Overlap/Tests/test_read_snapshot.f90 b/Overlap/Tests/test_read_snapshot.f90
index 22d06c3d..10810ff0 100644
--- a/Overlap/Tests/test_read_snapshot.f90
+++ b/Overlap/Tests/test_read_snapshot.f90
@@ -17,7 +17,7 @@ program test_read_snapshot
   character(len = :), allocatable:: shpc_dir
   type(snapshot) s
   TYPE(shpc) hshp
-  integer copy, unit
+  integer copy, unit, k
 
   real:: corner_deg(2) = [0.125, - 59.875]
   ! longitude and latitude of the corner of the whole grid in input
@@ -34,7 +34,7 @@ program test_read_snapshot
   ! We look for an overlapping eddy at dist_lim (in grid points) of
   ! the first extremum.
 
-  namelist /main_nml/ dist_lim
+  namelist /main_nml/ dist_lim, k
   namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
 
   !-------------------------------------------------------------------------
@@ -56,16 +56,17 @@ program test_read_snapshot
   copy = merge(dist_lim, 0, periodic)
 
   call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
+  k = hshp%d0
   write(unit = error_unit, nml = main_nml)
   write(unit = error_unit, fmt = *) "Enter namelist main_nml."
   read(unit = *, nml = main_nml)
   write(unit = *, nml = main_nml)
 
-  call read_snapshot(s, [hshp], nlon, nlat, k = hshp%d0, &
+  call read_snapshot(s, [hshp], nlon, nlat, k, &
        corner = corner_deg * deg_to_rad, step = step_deg * deg_to_rad, &
        copy = copy)
   CALL shpc_close(hshp)
 
-  call write_snapshot(s, corner_deg, step_deg, nlon, nlat, copy, hshp%d0)
+  call write_snapshot(s, corner_deg, step_deg, nlon, nlat, copy, k)
 
 end program test_read_snapshot
-- 
GitLab