From 789b6dbc3b4e4ec54bb45f69644c5cd81ec21733 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 27 Jul 2022 16:30:14 +0200
Subject: [PATCH] Assume  "{shpc_dir}/{orientation}/Slice_{slice}"

Assume that a slice is in a directory
"{shpc_dir}/{orientation}/Slice_{slice}" where shpc_dir can be any
name, orientation is "Anticyclones" or "Cyclones" and slice is an
integer. Do not read or create any longer a file "orientation.txt" in
the slice directory. Add procedure `get_slice_dir`. Add dummy
arguments cyclone and slice to procedure `shpc_open`. Add dummy
argument slice to procedure `shpc_create`.
---
 Common/CMakeLists.txt                         |  25 +--
 Common/shpc_create.f90                        |  20 +-
 Common/shpc_open.f90                          |  22 +-
 Common/util_eddies.py                         |  22 +-
 Inst_eddies/Analysis/anim_eddy_contours.py    |   7 +-
 Inst_eddies/Analysis/eddy_dump.py             |   3 +-
 Inst_eddies/Analysis/plot_eddy_contours.py    |  21 +-
 Inst_eddies/Analysis/stat.py                  |  12 +-
 Inst_eddies/Analysis/tests.json               |  28 +--
 .../{ => Anticyclones/Slice_0}/extremum.dbf   | Bin
 .../{ => Anticyclones/Slice_0}/extremum.shp   | Bin
 .../{ => Anticyclones/Slice_0}/extremum.shx   | Bin
 .../Slice_0}/ishape_last.txt                  |   0
 .../Slice_0}/max_speed_contour.dbf            | Bin
 .../Slice_0}/max_speed_contour.shp            | Bin
 .../Slice_0}/max_speed_contour.shx            | Bin
 .../Slice_0}/outermost_contour.dbf            | Bin
 .../Slice_0}/outermost_contour.shp            | Bin
 .../Slice_0}/outermost_contour.shx            | Bin
 .../Input/SHPC_degenerate/orientation.txt     |   1 -
 Inst_eddies/Tests/long_tests.json             |  22 +-
 Inst_eddies/Tests/short_tests.json            |  63 ++++--
 Inst_eddies/Tests/test_get_1_outerm.f90       |   2 +-
 Inst_eddies/Tests/test_nearby_extr.f90        |   3 +-
 Inst_eddies/Tests/test_output.json            |  16 +-
 Inst_eddies/Tests/test_set_all_outerm.f90     |   7 +-
 Inst_eddies/Tests/test_set_max_speed.f90      |   7 +-
 Inst_eddies/Tests/test_write_eddy.f90         |   8 +-
 Inst_eddies/inst_eddies.f90                   |  23 +-
 Inst_eddies/inst_eddies.py.in                 |  39 ++--
 Inst_eddies/inst_eddies_Aviso.py              |   3 +-
 Overlap/Tests/Input/NSO_delta_in.txt          |   3 +-
 Overlap/Tests/long_tests.json                 |   8 +-
 Overlap/Tests/save_snapshot.f90               |   5 +-
 Overlap/Tests/short_tests.json                | 201 +++++++++---------
 Overlap/Tests/test_get_dispatch_snap.f90      |   3 +-
 Overlap/Tests/test_overlap.f90                |   5 +-
 Overlap/Tests/test_read_eddy.f90              |   6 +-
 Overlap/Tests/test_read_snapshot.f90          |  28 ++-
 Overlap/Tests/test_send_recv.f90              |   3 +-
 Overlap/eddy_graph.f90                        |  47 ++--
 Overlap/eddy_graph.sh.in                      |  14 +-
 Overlap/plot_components.py                    |  10 +-
 Overlap/report_graph.py                       |   4 +-
 Trajectories/cost_function.py                 |  12 +-
 Trajectories/tests.json                       |   5 +-
 46 files changed, 389 insertions(+), 319 deletions(-)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/extremum.dbf (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/extremum.shp (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/extremum.shx (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/ishape_last.txt (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/max_speed_contour.dbf (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/max_speed_contour.shp (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/max_speed_contour.shx (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/outermost_contour.dbf (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/outermost_contour.shp (100%)
 rename Inst_eddies/Tests/Input/SHPC_degenerate/{ => Anticyclones/Slice_0}/outermost_contour.shx (100%)
 delete mode 100644 Inst_eddies/Tests/Input/SHPC_degenerate/orientation.txt

diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt
index e1806545..f14f0dee 100644
--- a/Common/CMakeLists.txt
+++ b/Common/CMakeLists.txt
@@ -1,42 +1,43 @@
 add_subdirectory(Tests)
-target_sources(test_get_1_outerm PRIVATE derived_types.f90
+target_sources(test_get_1_outerm PRIVATE derived_types.f90 get_slice_dir.f90
   spher_polyline_area.f90 shpc_create.f90 write_eddy.f90 shpc_close.f90
   ccw_orient.f90)
-target_sources(test_set_all_outerm PRIVATE derived_types.f90
+target_sources(test_set_all_outerm PRIVATE derived_types.f90 get_slice_dir.f90
   spher_polyline_area.f90 shpc_create.f90 write_eddy.f90 shpc_close.f90
   ccw_orient.f90 write_snapshot.f90)
 target_sources(test_max_speed_contour_ssh PRIVATE derived_types.f90)
 target_sources(test_nearby_extr PRIVATE derived_types.f90 read_snapshot.f90
-  read_eddy.f90 read_field_indices.f90 shpc_open.f90 shpc_close.f90)
-target_sources(test_set_max_speed PRIVATE derived_types.f90
+  read_eddy.f90 read_field_indices.f90 shpc_open.f90 shpc_close.f90
+  get_slice_dir.f90)
+target_sources(test_set_max_speed PRIVATE derived_types.f90 get_slice_dir.f90
   spher_polyline_area.f90 shpc_open.f90 shpc_close.f90 read_field_indices.f90
   read_eddy.f90 shpc_create.f90 write_eddy.f90 ccw_orient.f90)
 target_sources(test_spher_polyline_area PRIVATE spher_polyline_area.f90)
 target_sources(inst_eddies PRIVATE write_eddy.f90 spher_polyline_area.f90
   derived_types.f90 shpc_create.f90 shpc_close.f90 shpc_open.f90
-  read_field_indices.f90 write_snapshot.f90 ccw_orient.f90)
+  get_slice_dir.f90 read_field_indices.f90 write_snapshot.f90 ccw_orient.f90)
 target_sources(test_write_eddy PRIVATE derived_types.f90 shpc_open.f90
-  shpc_close.f90 read_field_indices.f90 shpc_create.f90)
+  shpc_close.f90 read_field_indices.f90 shpc_create.f90 get_slice_dir.f90)
 
 if(MPI_Fortran_HAVE_F08_MODULE)
   target_sources(test_overlap PRIVATE derived_types.f90 read_snapshot.f90
     spher_polyline_area.f90 read_eddy.f90 read_field_indices.f90 write_eddy.f90
-    shpc_open.f90 shpc_close.f90)
+    shpc_open.f90 shpc_close.f90 get_slice_dir.f90)
   target_sources(test_read_snapshot PRIVATE derived_types.f90 shpc_create.f90
     read_snapshot.f90 write_eddy.f90 read_eddy.f90 read_field_indices.f90
-    shpc_open.f90 shpc_close.f90)
+    shpc_open.f90 shpc_close.f90 get_slice_dir.f90)
   target_sources(test_spher_polygon_area PRIVATE spher_polyline_area.f90)
   target_sources(test_weight PRIVATE derived_types.f90)
   target_sources(test_read_eddy PRIVATE derived_types.f90 shpc_create.f90
     read_eddy.f90 write_eddy.f90 read_field_indices.f90 shpc_open.f90
-    shpc_close.f90)
+    shpc_close.f90 get_slice_dir.f90)
   target_sources(test_send_recv PRIVATE read_field_indices.f90
     read_snapshot.f90 write_eddy.f90 shpc_create.f90 read_eddy.f90
-    derived_types.f90 shpc_open.f90 shpc_close.f90)
+    derived_types.f90 shpc_open.f90 shpc_close.f90 get_slice_dir.f90)
   target_sources(test_get_dispatch_snap PRIVATE read_field_indices.f90
     read_snapshot.f90 shpc_create.f90 write_eddy.f90 read_eddy.f90
-    derived_types.f90 shpc_open.f90 shpc_close.f90)
+    derived_types.f90 shpc_open.f90 shpc_close.f90 get_slice_dir.f90)
   target_sources(eddy_graph PRIVATE shpc_open.f90 shpc_close.f90
     read_field_indices.f90 read_snapshot.f90 spher_polyline_area.f90
-    read_eddy.f90 write_eddy.f90 derived_types.f90)
+    read_eddy.f90 write_eddy.f90 derived_types.f90 get_slice_dir.f90)
 endif()
diff --git a/Common/shpc_create.f90 b/Common/shpc_create.f90
index ae702247..47fe5451 100644
--- a/Common/shpc_create.f90
+++ b/Common/shpc_create.f90
@@ -4,7 +4,7 @@ module shpc_create_m
 
 contains
 
-  subroutine shpc_create(hshp, shpc_dir, cyclone)
+  subroutine shpc_create(hshp, shpc_dir, cyclone, slice)
 
     ! Libraries:
     use jumble, only: new_unit
@@ -12,17 +12,16 @@ contains
     use shapelib_03, only: shp_create_03, dbf_add_field_03
 
     use derived_types, only: shpc_slice_handler
+    use get_slice_dir_m, only: get_slice_dir
 
     TYPE(shpc_slice_handler), intent(out):: hshp
     character(len = *), intent(in):: shpc_dir
     logical, intent(in):: cyclone
-
-    ! Local:
-    integer unit
+    integer, intent(in):: slice
 
     !---------------------------------------------------------------------
 
-    hshp%dir = shpc_dir
+    hshp%dir = get_slice_dir(shpc_dir, cyclone, slice)
 
     ! extremum shapefile:
     call shp_create_03(hshp%dir // "/extremum", shpt_point, &
@@ -68,17 +67,6 @@ contains
     open(hshp%unit, file = hshp%dir // "/ishape_last.txt", status = "replace", &
          action = "write")
     hshp%cyclone = cyclone
-    call new_unit(unit)
-    open(unit, file  = hshp%dir // "/orientation.txt", status = "replace", &
-         action  = "write")
-
-    if (cyclone) then
-       write(unit, fmt = *) "cyclones"
-    else
-       write(unit, fmt = *) "anticyclones"
-    end if
-    
-    close(unit)
 
   end subroutine shpc_create
 
diff --git a/Common/shpc_open.f90 b/Common/shpc_open.f90
index 33883292..50677fee 100644
--- a/Common/shpc_open.f90
+++ b/Common/shpc_open.f90
@@ -4,27 +4,31 @@ module shpc_open_m
 
 contains
 
-  subroutine shpc_open(hshp, shpc_dir, pszaccess, iostat)
+  subroutine shpc_open(hshp, shpc_dir, cyclone, slice, pszaccess, iostat)
+
+    ! Opens a given slice of a given orientation in an SHPC.
 
     ! Libraries:
     USE jumble, only: new_unit
     use shapelib_03, only: shp_open_03
 
     use derived_types, only: shpc_slice_handler
+    use get_slice_dir_m, only: get_slice_dir
     use read_field_indices_m, only: read_field_indices
 
     TYPE(shpc_slice_handler), intent(out):: hshp
     character(len = *), intent(in):: shpc_dir
+    logical, intent(in):: cyclone
+    integer, intent(in):: slice
     character(len = *), intent(in):: pszaccess ! should be "rb" or "rb+"
     integer, optional, intent(out):: iostat
 
     ! Local:
-    integer unit, iostat_extr
-    character(len = 12) orientation
+    integer iostat_extr
 
     !--------------------------------------------------------------------
 
-    hshp%dir = shpc_dir
+    hshp%dir = get_slice_dir(shpc_dir, cyclone, slice)
     call shp_open_03(hshp%extremum, hshp%dir // "/extremum", pszaccess, &
          iostat_extr)
     if (present(iostat)) iostat = iostat_extr
@@ -35,12 +39,6 @@ contains
        call shp_open_03(hshp%max_speed, hshp%dir // "/max_speed_contour", &
             pszaccess)
        call read_field_indices(hshp)
-       call new_unit(unit)
-       open(unit, file = hshp%dir // "/orientation.txt", status = "old", &
-            action = "read", position = "rewind")
-       read(unit, fmt = *) orientation
-       close(unit)
-       hshp%cyclone = trim(adjustl(orientation)) == "cyclones"
        call new_unit(hshp%unit)
 
        if (pszaccess == "rb") then
@@ -50,10 +48,14 @@ contains
           open(hshp%unit, file = hshp%dir // "/ishape_last.txt", &
                status = "old", action = "readwrite", position = "append")
        end if
+
+       hshp%cyclone = cyclone
     else
        if (.not. present(iostat)) then
           print *, "shpc_open: failed"
           print *, "shpc_dir = ", shpc_dir
+          print *, "cyclone = ", cyclone
+          print *, "slice = ", slice
           print *, "pszaccess = ", pszaccess
           stop 1
        end if
diff --git a/Common/util_eddies.py b/Common/util_eddies.py
index 5f61ad9e..b3637cb1 100644
--- a/Common/util_eddies.py
+++ b/Common/util_eddies.py
@@ -26,7 +26,7 @@ def in_window(point, window):
 
     return longit <= urcrnrlon and llcrnrlat <= point[1] <= urcrnrlat
 
-def open_shpc(shpc_dir):
+def open_shpc(shpc_dir, orientation, slice = 0):
     if not path.isdir(shpc_dir):
         sys.exit(f"open_shpc: {shpc_dir} is not an existing directory")
 
@@ -34,14 +34,16 @@ def open_shpc(shpc_dir):
 
     for layer in ["extremum", "outermost_contour", "max_speed_contour",
                   "centroid"]:
+        my_shapefile = path.join(shpc_dir, orientation, f"Slice_{slice}", layer)
+
         try:
-            handler["readers"][layer] \
-                = shapefile.Reader(path.join(shpc_dir, layer))
+            handler["readers"][layer] = shapefile.Reader(my_shapefile)
         except shapefile.ShapefileException:
-            print(f"Shapefile {layer} not found in {shpc_dir}.")
+            print(f"{my_shapefile}.shp not found.")
 
     handler["d_init"] = handler["readers"]["extremum"].record(0).date
-    fname = path.join(shpc_dir, "ishape_last.txt")
+    fname = path.join(shpc_dir, orientation, f"Slice_{slice}",
+                      "ishape_last.txt")
 
     try:
         handler["ishape_last"] = np.loadtxt(fname, dtype = int, ndmin = 1)
@@ -49,13 +51,5 @@ def open_shpc(shpc_dir):
         print("Could not read", fname)
         handler["ishape_last"] = None
 
-    fname = path.join(shpc_dir, "orientation.txt")
-
-    try:
-        with open(fname) as f: line = f.readline()
-    except FileNotFoundError:
-        print("Could not read", fname)
-    else:
-        handler["cyclones"] = line.strip() == "cyclones"
-        
+    handler["cyclones"] = orientation == "Cyclones"
     return handler
diff --git a/Inst_eddies/Analysis/anim_eddy_contours.py b/Inst_eddies/Analysis/anim_eddy_contours.py
index eb7a8abe..43d831ad 100755
--- a/Inst_eddies/Analysis/anim_eddy_contours.py
+++ b/Inst_eddies/Analysis/anim_eddy_contours.py
@@ -76,8 +76,8 @@ if __name__ == "__main__":
 
     # Process arguments:
     parser = argparse.ArgumentParser()
-    parser.add_argument("shpc_dir", help = "directories containing the "
-                        "collections of shapefiles", nargs = "+")
+    parser.add_argument("shpc_dir", help = "directory containing the "
+                        "collection of shapefiles")
     parser.add_argument("-d", "--dates", type = int, nargs = 2,
                         metavar = ("d_min", "d_max"))
     parser.add_argument("-l", "--light", help = "lighter plot",
@@ -89,7 +89,8 @@ if __name__ == "__main__":
     args = parser.parse_args()
     #--
 
-    handlers = [util_eddies.open_shpc(shpc_dir) for shpc_dir in args.shpc_dir]
+    handlers = [util_eddies.open_shpc(args.shpc_dir, orientation)
+                for orientation in ["Anticyclones", "Cyclones"]]
 
     # Do some checks on first input SHPC:
 
diff --git a/Inst_eddies/Analysis/eddy_dump.py b/Inst_eddies/Analysis/eddy_dump.py
index 3e32309f..d51e62f4 100755
--- a/Inst_eddies/Analysis/eddy_dump.py
+++ b/Inst_eddies/Analysis/eddy_dump.py
@@ -16,12 +16,13 @@ import json
 
 parser = argparse.ArgumentParser()
 parser.add_argument("directory", help = "containing the three shapefiles")
+parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
 group = parser.add_mutually_exclusive_group()
 group.add_argument("-i", "--ishape", type = int)
 group.add_argument("-n", "--node", type = int)
 args = parser.parse_args()
 
-handler = util_eddies.open_shpc(args.directory)
+handler = util_eddies.open_shpc(args.directory, args.orientation)
 
 if args.ishape:
     ishape = args.ishape
diff --git a/Inst_eddies/Analysis/plot_eddy_contours.py b/Inst_eddies/Analysis/plot_eddy_contours.py
index 38514d03..01403839 100755
--- a/Inst_eddies/Analysis/plot_eddy_contours.py
+++ b/Inst_eddies/Analysis/plot_eddy_contours.py
@@ -158,14 +158,14 @@ if __name__ == "__main__":
                         action = "store_true")
     parser.add_argument("--dashed", action = "store_true",
                         help = "dashed linestyle, useful for a second snapshot")
-    parser.add_argument("shpc_dir", help = "directories containing the "
-                        "collections of shapefiles", nargs = "+")
+    parser.add_argument("shpc_dir", help = "directory containing the "
+                        "collection of shapefiles")
     parser.add_argument("--save", metavar = "format",
                         help = "Save file to specified format")
     args = parser.parse_args()
 
     if args.grid or args.window is None:
-        file = path.join(args.shpc_dir[0], "grid_nml.txt")
+        file = path.join(args.shpc_dir, "grid_nml.txt")
     
         try:
             grid_nml = f90nml.read(file)["grid_nml"]
@@ -214,30 +214,27 @@ if __name__ == "__main__":
 
     if args.window is None: plot_grid_bb(grid_nml, ax)
 
-    for shpc_dir in args.shpc_dir:
-        handler = util_eddies.open_shpc(shpc_dir)
-
-        if "cyclones" not in handler:
-            sys.exit(f"Missing orientation.txt in {shpc_dir}")
+    for orientation in ["Anticyclones", "Cyclones"]:
+        handler = util_eddies.open_shpc(args.shpc_dir, orientation)
 
         if handler["ishape_last"] is None:
-            print(f"{shpc_dir}: We will use all the shapes.")
+            print(f"{orientation}: We will use all the shapes.")
             handler["ishape_last"] = [len(handler["readers"]["extremum"]) - 1]
 
         if len(handler["ishape_last"]) == 1:
             if args.date is not None and args.date != handler["d_init"]:
-                sys.exit(f"{shpc_dir}: Bad value of date option")
+                sys.exit(f"{orientation}: Bad value of date option")
             d = handler["d_init"]
         else:
             if args.date is None:
-                print(f"{shpc_dir}: No date option, plotting first date:",
+                print(f"{orientation}: No date option, plotting first date:",
                       handler["d_init"])
                 d = handler["d_init"]
             else:
                 d = args.date
 
         ishape_list = select_ishapes(d, handler, args.window)
-        if len(ishape_list) == 0: print(f"{shpc_dir}: No eddy found")
+        if len(ishape_list) == 0: print(f"{orientation}: No eddy found")
         snapshot(ax, ishape_list, handler, dashed = args.dashed,
                  light = args.light)
         
diff --git a/Inst_eddies/Analysis/stat.py b/Inst_eddies/Analysis/stat.py
index d2d95ebf..5973f1f0 100755
--- a/Inst_eddies/Analysis/stat.py
+++ b/Inst_eddies/Analysis/stat.py
@@ -7,6 +7,7 @@ from os import path
 
 parser = argparse.ArgumentParser()
 parser.add_argument("directory", help = "containing the shapefiles")
+parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
 args = parser.parse_args()
 
 n_valid = 0
@@ -17,9 +18,10 @@ n_points = 0
 n_missing_speed = np.zeros(3, dtype = int)
 n_valid_speed = 0
 
-with shapefile.Reader(path.join(args.directory, "extremum")) as extremum, \
-     shapefile.Reader(path.join(args.directory, "outermost_contour")) \
-     as outermost_contour:
+with shapefile.Reader(path.join(args.directory, args.orientation, "Slice_0",
+                                "extremum")) as extremum, \
+     shapefile.Reader(path.join(args.directory, args.orientation, "Slice_0",
+                                "outermost_contour")) as outermost_contour:
     n_extr = len(extremum)
     
     for rec_extr, shape_rec_outer in zip(extremum.iterRecords(),
@@ -89,8 +91,8 @@ n_max_speed = 0
 n_points_valid = 0
 n_points = 0
 
-with shapefile.Reader(path.join(args.directory, "max_speed_contour")) \
-     as max_speed_contour:
+with shapefile.Reader(path.join(args.directory, args.orientation, "Slice_0",
+                                "max_speed_contour")) as max_speed_contour:
     for shape_rec in max_speed_contour:
         l = len(shape_rec.shape.points)
         n_points += l
diff --git a/Inst_eddies/Analysis/tests.json b/Inst_eddies/Analysis/tests.json
index 659f0a4f..be49b3eb 100644
--- a/Inst_eddies/Analysis/tests.json
+++ b/Inst_eddies/Analysis/tests.json
@@ -4,8 +4,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/plot_eddy_contours.py",
-	    "$tests_old_dir/Region_6/SHPC_anti",
-	    "$tests_old_dir/Region_6/SHPC_cyclo", "--save=png"
+	    "$tests_old_dir/Region_6/SHPC", "--save=png"
 	]
     },
     {
@@ -13,8 +12,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/anim_eddy_contours.py",
-	    "$tests_old_dir/Region_6/SHPC_anti",
-	    "$tests_old_dir/Region_6/SHPC_cyclo", "--light"
+	    "$tests_old_dir/Region_6/SHPC", "--light"
 	]
     },
     {
@@ -22,7 +20,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/eddy_dump.py",
-	    "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+	    "$tests_old_dir/Inst_eddies_loop/SHPC", "Cyclones"
 	],
 	"input": "20455, 3\n"
     },
@@ -31,9 +29,8 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/plot_eddy_contours.py",
-	    "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti",
-	    "$tests_old_dir/Extraction_eddies_region_4/SHPC_cyclo",
-	    "--grid", "--save=png"
+	    "$tests_old_dir/Extraction_eddies_region_4/SHPC", "--grid",
+	    "--save=png"
 	],
 	"description": "With grid option.",
 	"symlink": [["$src_dir/Inst_eddies/Tests/Input/h_region_4.nc", "h.nc"]]
@@ -43,7 +40,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/plot_eddy_contours.py",
-	    "$tests_old_dir/Extraction_eddies_region_5/SHPC_cyclo", "--window",
+	    "$tests_old_dir/Extraction_eddies_region_5/SHPC", "--window",
 	    "10", "-40", "15", "-35", "--save=png"
 	],
 	"description": "With window option."
@@ -62,9 +59,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/plot_eddy_contours.py",
-	    "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti",
-	    "$tests_old_dir/Extraction_eddies_region_4/SHPC_cyclo",
-	    "--save=png"
+	    "$tests_old_dir/Extraction_eddies_region_4/SHPC", "--save=png"
 	],
 	"description": "With two SHPC as command line arguments."
     },
@@ -79,12 +74,11 @@
     },
     {
 	"title": "Animation_2_SHPC",
-	"description": "With two input SHPC and no option light.",
+	"description": "With two orientations and no option light.",
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/anim_eddy_contours.py",
-	    "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo",
-	    "$tests_old_dir/Inst_eddies_loop/SHPC_anti"
+	    "$tests_old_dir/Inst_eddies_loop/SHPC"
 	]
     },
     {
@@ -92,7 +86,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/stat.py",
-	    "$tests_old_dir/Inst_eddies_py/SHPC_anti"
+	    "$tests_old_dir/Inst_eddies_py/SHPC", "Anticyclones"
 	]
     },
     {
@@ -100,7 +94,7 @@
 	"command":
 	[
 	    "$src_dir/Inst_eddies/Analysis/filter.py",
-	    "$PWD/Inst_eddies_4_anti",
+	    "$PWD/Inst_eddies_4/Anticyclones/Slice_0",
 	    "plouf"
 	],
 	"env": {"PYTHONPATH": "$src_dir/Inst_eddies/Tests/Input"}
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/extremum.dbf b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.dbf
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/extremum.dbf
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.dbf
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/extremum.shp b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.shp
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/extremum.shp
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.shp
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/extremum.shx b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.shx
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/extremum.shx
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/extremum.shx
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/ishape_last.txt b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/ishape_last.txt
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/ishape_last.txt
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/ishape_last.txt
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.dbf b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.dbf
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.dbf
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.dbf
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.shp b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.shp
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.shp
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.shp
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.shx b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.shx
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/max_speed_contour.shx
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/max_speed_contour.shx
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.dbf b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.dbf
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.dbf
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.dbf
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.shp b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.shp
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.shp
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.shp
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.shx b/Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.shx
similarity index 100%
rename from Inst_eddies/Tests/Input/SHPC_degenerate/outermost_contour.shx
rename to Inst_eddies/Tests/Input/SHPC_degenerate/Anticyclones/Slice_0/outermost_contour.shx
diff --git a/Inst_eddies/Tests/Input/SHPC_degenerate/orientation.txt b/Inst_eddies/Tests/Input/SHPC_degenerate/orientation.txt
deleted file mode 100644
index 0e187bc2..00000000
--- a/Inst_eddies/Tests/Input/SHPC_degenerate/orientation.txt
+++ /dev/null
@@ -1 +0,0 @@
-anticyclones
diff --git a/Inst_eddies/Tests/long_tests.json b/Inst_eddies/Tests/long_tests.json
index 172eb47e..b7ee1d83 100644
--- a/Inst_eddies/Tests/long_tests.json
+++ b/Inst_eddies/Tests/long_tests.json
@@ -2,7 +2,10 @@
     {
 	"commands":
 	[
-	    ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+	    [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
 	    "$build_dir/Inst_eddies/Tests/test_set_all_outerm"
 	],
 	"title": "Set_all_outerm",
@@ -16,7 +19,10 @@
     {
 	"commands":
 	[
-	    ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+	    [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
 	    "$build_dir/Inst_eddies/inst_eddies"
 	],
 	"title": "Extraction_eddies_region_3",
@@ -32,7 +38,10 @@
     {
 	"commands":
 	[
-	    ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+	    [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
 	    "$build_dir/Inst_eddies/inst_eddies"
 	],
 	"title": "Extraction_eddies_region_3_min",
@@ -49,7 +58,10 @@
     {
 	"commands":
 	[
-	    ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+	    [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
 	    "$build_dir/Inst_eddies/inst_eddies"
 	],
 	"title": "Extraction_eddies_region_5",
@@ -85,7 +97,7 @@
 	    "$large_input_dir/dt_global_allsat_phy_l4_20060102_20210726.nc",
 	    "-b", "5.875", "12.125", "-32.125", "-26.875"
         ],
-	"input": "20454\n"
+	"input": "20454\n0\n"
     },
     {
         "create_file": ["config_nml.txt", "&config_nml /\n"],
diff --git a/Inst_eddies/Tests/short_tests.json b/Inst_eddies/Tests/short_tests.json
index b9698263..05c1a565 100644
--- a/Inst_eddies/Tests/short_tests.json
+++ b/Inst_eddies/Tests/short_tests.json
@@ -19,7 +19,10 @@
             ]
         ],
         "commands":
-	[["mkdir", "SHPC"], "$build_dir/Inst_eddies/Tests/test_get_1_outerm"]
+	[
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
+	    "$build_dir/Inst_eddies/Tests/test_get_1_outerm"
+	]
     },
     {
         "description":
@@ -40,7 +43,10 @@
             "$src_dir/Inst_eddies/Tests/Input/Region_1/outside_points.csv"
         ],
         "commands":
-	[["mkdir", "SHPC"], "$build_dir/Inst_eddies/Tests/test_get_1_outerm"]
+	[
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
+	    "$build_dir/Inst_eddies/Tests/test_get_1_outerm"
+	]
     },
     {
         "description": "Negative value for extremum 2.",
@@ -63,7 +69,10 @@
             ]
         ],
         "commands":
-	[["mkdir", "SHPC"], "$build_dir/Inst_eddies/Tests/test_get_1_outerm"]
+	[
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
+	    "$build_dir/Inst_eddies/Tests/test_get_1_outerm"
+	]
     },
     {
         "description":
@@ -220,7 +229,7 @@
         "command":
 	[
 	    "$build_dir/Inst_eddies/Tests/test_mean_speed",
-	    "$PWD/Get_1_outerm/SHPC/outermost_contour"
+	    "$PWD/Get_1_outerm/SHPC/Cyclones/Slice_0/outermost_contour"
 	]
     },
     {
@@ -259,12 +268,13 @@
         "title": "Set_max_speed",
         "commands":
 	[
-	    ["mkdir", "SHPC"],
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
 	    [
 		"$build_dir/Inst_eddies/Tests/test_set_max_speed",
 		"$PWD/Get_1_outerm/SHPC"
 	    ]
-	]
+	],
+	"input": "t\n"
     },
     {
 	"create_file": ["config_nml.txt", "&config_nml /\n"],
@@ -283,12 +293,13 @@
         "title": "Set_max_speed_noise",
         "commands":
 	[
-	    ["mkdir", "SHPC"],
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
 	    [
 		"$build_dir/Inst_eddies/Tests/test_set_max_speed",
 		"$PWD/Get_1_outerm_noise_2_8/SHPC"
 	    ]
-	]
+	],
+	"input": "t\n"
     },
     {
 	"create_file": ["config_nml.txt", "&config_nml /\n"],
@@ -305,12 +316,13 @@
 	"description": "The SSH value of the extremum is exactly equal to the SSH value of the point next to the extremum, eastward. This points is selected as the point with maximum azimuthal speed. Then good_contour returns a null polyline.",
         "commands":
 	[
-	    ["mkdir", "SHPC"],
+	    ["mkdir", "-p", "SHPC/Anticyclones/Slice_0"],
 	    [
 		"$build_dir/Inst_eddies/Tests/test_set_max_speed",
 		"$src_dir/Inst_eddies/Tests/Input/SHPC_degenerate"
 	    ]
-	]
+	],
+	"input": "f\n"
     },
     {
         "create_file": ["config_nml.txt", "&config_nml min_amp = 0./\n"],
@@ -327,7 +339,10 @@
         ],
         "title": "Extraction_eddies_region_1",
         "commands": [
-            ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+            [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
             "$build_dir/Inst_eddies/inst_eddies"
         ]
     },
@@ -349,7 +364,10 @@
         ],
         "title": "Extraction_eddies_region_1_noise",
         "commands": [
-            ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+            [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
             "$build_dir/Inst_eddies/inst_eddies"
         ]
     },
@@ -362,7 +380,10 @@
         ],
         "title": "Extraction_eddies_region_2",
         "commands": [
-            ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+            [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
             "$build_dir/Inst_eddies/inst_eddies"
         ]
     },
@@ -377,7 +398,7 @@
 	    "$large_input_dir/dt_global_allsat_phy_l4_20060101_20210726.nc",
 	    "$large_input_dir/dt_global_allsat_phy_l4_20060102_20210726.nc"
 	],
-	"input": "20454\n"
+	"input": "20454\n0\n"
     },
     {
 	"description":
@@ -390,7 +411,7 @@
 	    "-38.875", "-34.125",
 	    "$large_input_dir/dt_global_allsat_phy_l4_20060101_20210726.nc"
 	],
-	"input": "20454\n"
+	"input": "20454\n0\n"
     },
     {
         "create_file": ["config_nml.txt", "&config_nml /\n"],
@@ -408,7 +429,7 @@
         "command":
 	[
             "$build_dir/Inst_eddies/Tests/test_nearby_extr",
-	    "$PWD/Inst_eddies_loop/SHPC_cyclo"
+	    "$PWD/Inst_eddies_loop/SHPC"
 	],
 	"description": "We are using Inst_eddies_loop, which is a previous test."
     },
@@ -422,7 +443,10 @@
         "title": "Set_all_outerm_periodic",
         "commands":
 	[
-	    ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+	    [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
 	    "$build_dir/Inst_eddies/Tests/test_set_all_outerm"
         ],
 	"symlink":
@@ -454,7 +478,10 @@
         ],
         "title": "Extraction_eddies_periodic",
         "commands": [
-            ["mkdir", "SHPC_cyclo", "SHPC_anti"],
+            [
+		"mkdir", "-p", "SHPC/Cyclones/Slice_0",
+		"SHPC/Anticyclones/Slice_0"
+	    ],
             "$build_dir/Inst_eddies/inst_eddies"
         ]
     }
diff --git a/Inst_eddies/Tests/test_get_1_outerm.f90 b/Inst_eddies/Tests/test_get_1_outerm.f90
index 1516dfa6..57b00e46 100644
--- a/Inst_eddies/Tests/test_get_1_outerm.f90
+++ b/Inst_eddies/Tests/test_get_1_outerm.f90
@@ -95,7 +95,7 @@ program test_get_1_outerm
      e%max_speed = missing_speed
      e%radius4 = - 1
      e%valid = .true.
-     call shpc_create(hshp, shpc_dir = "SHPC", cyclone = cyclone)
+     call shpc_create(hshp, shpc_dir = "SHPC", cyclone = cyclone, slice = 0)
      call write_eddy(e, hshp, date, i = 1)
      write(hshp%unit, fmt = *) 0
      CALL shpc_close(hshp)
diff --git a/Inst_eddies/Tests/test_nearby_extr.f90 b/Inst_eddies/Tests/test_nearby_extr.f90
index 1cd0fdb4..39a8d6f3 100644
--- a/Inst_eddies/Tests/test_nearby_extr.f90
+++ b/Inst_eddies/Tests/test_nearby_extr.f90
@@ -44,7 +44,8 @@ program test_nearby_extr
   read(unit, nml = grid_nml)
   close(unit)
 
-  call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
+  call shpc_open(hshp, trim(shpc_dir), cyclone = .true., slice = 0, &
+       pszaccess = "rb")
   call dbf_read_attribute_03(ssm%d0, hshp%extremum, hshp%extr_date, ishape = 0)
   call read_opcol(ssm%ishape_last, hshp%unit, my_lbound = ssm%d0)
   call read_snapshot(s, [hshp], [ssm], nlon, nlat, k = ssm%d0, &
diff --git a/Inst_eddies/Tests/test_output.json b/Inst_eddies/Tests/test_output.json
index 57bc29e7..8409b3f2 100644
--- a/Inst_eddies/Tests/test_output.json
+++ b/Inst_eddies/Tests/test_output.json
@@ -4,7 +4,7 @@
 	"description": "Append to medium-sized SHPC, mixing output to the three shapefiles.",
 	"input": "&main_nml /\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/n_dates_14/SHPC_cyclo"],
+	"copy":	[["$PWD/n_dates_14", "SHPC"]],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
 
@@ -14,7 +14,7 @@
 	"description": "Append to small SHPC, mixing output to the three shapefiles.",
 	"input": "&main_nml /\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/n_dates_1/SHPC_cyclo"],
+	"copy":	[["$PWD/n_dates_1", "SHPC"]],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
     },
@@ -23,7 +23,7 @@
 	"description": "Append to medium-sized SHPC, separating output to the three shapefiles.",
 	"input": "&main_nml mixed = f/\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/n_dates_14/SHPC_cyclo"],
+	"copy":	[["$PWD/n_dates_14", "SHPC"]],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
     },
@@ -32,7 +32,7 @@
 	"description": "Append to small SHPC, separating output to the three shapefiles.",
 	"input": "&main_nml mixed = f/\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/n_dates_1/SHPC_cyclo"],
+	"copy":	[["$PWD/n_dates_1", "SHPC"]],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
     },
@@ -42,7 +42,7 @@
 	"input": "&main_nml /\n",
 	"commands" :
 	[
-	    ["mkdir", "SHPC_cyclo"],
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
 	    ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"]
 	],
 	"stdout": "test_write_eddy_stdout.txt",
@@ -54,7 +54,7 @@
 	"input": "&main_nml mixed = f/\n",
 	"commands" :
 	[
-	    ["mkdir", "SHPC_cyclo"],
+	    ["mkdir", "-p", "SHPC/Cyclones/Slice_0"],
 	    ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"]
 	],
 	"stdout": "test_write_eddy_stdout.txt",
@@ -65,7 +65,7 @@
 	"description": "Append to big SHPC, mixing output to the three shapefiles.",
 	"input": "&main_nml /\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/Inst_eddies_9/SHPC_cyclo"],
+	"copy":	["$PWD/Inst_eddies_9/SHPC"],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
     },
@@ -74,7 +74,7 @@
 	"description": "Append to big SHPC, separating output to the three shapefiles.",
 	"input": "&main_nml mixed = f/\n",
 	"command" : ["time", "$build_dir/Inst_eddies/Tests/test_write_eddy"],
-	"copy":	["$PWD/Inst_eddies_9/SHPC_cyclo"],
+	"copy":	["$PWD/Inst_eddies_9/SHPC"],
 	"stdout": "test_write_eddy_stdout.txt",
 	"exclude_cmp": ["test_write_eddy_stderr.txt"]
     }
diff --git a/Inst_eddies/Tests/test_set_all_outerm.f90 b/Inst_eddies/Tests/test_set_all_outerm.f90
index 92b3d966..59cd0f84 100644
--- a/Inst_eddies/Tests/test_set_all_outerm.f90
+++ b/Inst_eddies/Tests/test_set_all_outerm.f90
@@ -51,12 +51,11 @@ program test_set_all_outerm
   print *, "test_set_all_outerm: s%number_extr = ", s%number_extr
   print *, "test_set_all_outerm: Average number of points per outermost ", &
        "contour: ", sum(s%list%out_cont%n_points) / real(s%number_extr)
-  call shpc_create(hshp_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.)
-  call shpc_create(hshp_anti, shpc_dir = "SHPC_anti", cyclone = .false.)
+  call shpc_create(hshp_cyclo, shpc_dir = "SHPC", cyclone = .true., slice = 0)
+  call shpc_create(hshp_anti, shpc_dir = "SHPC", cyclone = .false., slice = 0)
   call write_snapshot(s, hshp_cyclo, hshp_anti, date = 1)
   CALL shpc_close(hshp_cyclo)
   CALL shpc_close(hshp_anti)
-  print *, 'test_set_all_outerm: Created shapefile collections in ', &
-       'SHPC_cyclo and SHPC_anti.'
+  print *, 'test_set_all_outerm: Created shapefile collection in SHPC.'
 
 end program test_set_all_outerm
diff --git a/Inst_eddies/Tests/test_set_max_speed.f90 b/Inst_eddies/Tests/test_set_max_speed.f90
index 716fd982..9ca45508 100644
--- a/Inst_eddies/Tests/test_set_max_speed.f90
+++ b/Inst_eddies/Tests/test_set_max_speed.f90
@@ -15,6 +15,7 @@ program test_set_max_speed
 
   implicit none
 
+  logical cyclone
   logical periodic ! grid is periodic in longitude
   integer nlon, nlat, unit, n, l, d, i
   real, allocatable:: ssh(:, :) ! (nlon, nlat) sea-surface height, in m
@@ -35,11 +36,13 @@ program test_set_max_speed
   !----------------------------------------------------------------
 
   call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
+  print *, "cyclone = ? "
+  read *, cyclone
   call config(exist = .true.)
   call input_ssh(corner, step, nlon, nlat, periodic, ssh, u, v, corner_deg, &
        step_deg)
   print *, "test_set_max_speed: Reading from shapefiles..."
-  call shpc_open(hshp, shpc_dir, pszaccess = "rb")
+  call shpc_open(hshp, shpc_dir, cyclone, slice = 0, pszaccess = "rb")
   call read_eddy(e, d, i, hshp, ishape = 0)
   CALL shpc_close(hshp)
 
@@ -63,7 +66,7 @@ program test_set_max_speed
   step = 0.25  * deg_to_rad
   call set_max_speed(e, nint((e%coord_extr - corner) / step) + 1, &
        outside_points, ssh, u, v, corner, step)
-  call shpc_create(hshp, shpc_dir = "SHPC", cyclone = e%cyclone)
+  call shpc_create(hshp, shpc_dir = "SHPC", cyclone = cyclone, slice = 0)
   call write_eddy(e, hshp, d, i)
   CALL shpc_close(hshp)
   print *, 'test_set_max_speed: Created "SHPC".'
diff --git a/Inst_eddies/Tests/test_write_eddy.f90 b/Inst_eddies/Tests/test_write_eddy.f90
index 33f636cb..bf9814cd 100644
--- a/Inst_eddies/Tests/test_write_eddy.f90
+++ b/Inst_eddies/Tests/test_write_eddy.f90
@@ -22,10 +22,10 @@ program test_write_eddy
 
   !--------------------------------------------------------------
 
-  call shpc_open(hshpc, shpc_dir = "SHPC_cyclo", pszaccess = "rb+", &
-       iostat = iostat)
-  if (iostat /= 0) call shpc_create(hshpc, shpc_dir = "SHPC_cyclo", &
-       cyclone = .true.)
+  call shpc_open(hshpc, shpc_dir = "SHPC", cyclone = .true., slice = 0, &
+       pszaccess = "rb+", iostat = iostat)
+  if (iostat /= 0) call shpc_create(hshpc, shpc_dir = "SHPC", &
+       cyclone = .true., slice = 0)
   print *, "Enter namelist main_nml."
   read(unit = *, nml = main_nml)
 
diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90
index 7544abb6..93d99d9b 100644
--- a/Inst_eddies/inst_eddies.f90
+++ b/Inst_eddies/inst_eddies.f90
@@ -60,8 +60,8 @@ program inst_eddies
 
   logical exist
   real t0, t1 ! CPU times, in s
-  integer:: date = 0
-  namelist /dates_nml/ date
+  integer:: date = 0, slice = 0
+  namelist /dates_nml/ date, slice
 
   !--------------------------------------------------------------
 
@@ -86,14 +86,17 @@ program inst_eddies
        step_deg)
 
   ! Open or create now so we test the existence of directories:
-  call shpc_open(hshpc_cyclo, shpc_dir = "SHPC_cyclo", pszaccess = "rb+", &
-       iostat = iostat)
+  call shpc_open(hshpc_cyclo, shpc_dir = "SHPC", cyclone = .true., &
+       slice = slice, pszaccess = "rb+", iostat = iostat)
 
   if (iostat == 0) then
-     call shpc_open(hshpc_anti, shpc_dir = "SHPC_anti", pszaccess = "rb+")
+     call shpc_open(hshpc_anti, shpc_dir = "SHPC", cyclone = .false., &
+          slice = slice, pszaccess = "rb+")
   else
-     call shpc_create(hshpc_cyclo, shpc_dir = "SHPC_cyclo", cyclone = .true.)
-     call shpc_create(hshpc_anti, shpc_dir = "SHPC_anti", cyclone = .false.)
+     call shpc_create(hshpc_cyclo, shpc_dir = "SHPC", cyclone = .true., &
+          slice = slice)
+     call shpc_create(hshpc_anti, shpc_dir = "SHPC", cyclone = .false., &
+          slice = slice)
   end if
 
   call cpu_time(t1)
@@ -152,11 +155,9 @@ program inst_eddies
   CALL shpc_close(hshpc_anti)
 
   if (iostat == 0) then
-     print *, 'inst_eddies: Appended to shapefile collections in SHPC_cyclo ', &
-          'and SHPC_anti.'
+     print *, 'inst_eddies: Appended to shapefiles in one slice of SHPC.'
   else
-     print *, 'inst_eddies: Created shapefile collections in SHPC_cyclo and ', &
-          'SHPC_anti.'
+     print *, 'inst_eddies: Created shapefiles in one slice of SHPC.'
   end if
 
   call cpu_time(t1)
diff --git a/Inst_eddies/inst_eddies.py.in b/Inst_eddies/inst_eddies.py.in
index 0383e1c2..e1fc49a5 100644
--- a/Inst_eddies/inst_eddies.py.in
+++ b/Inst_eddies/inst_eddies.py.in
@@ -1,9 +1,10 @@
 #!/usr/bin/env python3
 
-"""This script creates the directories SHPC_cyclo and SHPC_anti,
-containing time slices of instantaneous eddies, and the file
-perf_report.csv. If SHPC_cyclo, SHPC_anti or perf_report.csv already
-exist then they are replaced.
+"""This script creates the directories SHPC/Cyclones/Slice_{my_slice}
+and SHPC/Anticyclones/Slice_{my_slice}, containing a time slice of
+instantaneous eddies, and the file perf_report.csv. If
+SHPC/{orientation}/Slice_{my_slice} or perf_report.csv already exist
+then they are replaced.
 
 """
 
@@ -16,9 +17,10 @@ import sys
 import time
 import csv
 
-def loop_inst_eddies(files, bbox, d):
+def loop_inst_eddies(files, bbox, d, my_slice):
     """files is a sequence of file paths. bbox is a tuple of four real
-    numbers. d is a date index (integer value) for the first date.
+    numbers. d is a date index (integer value) for the first
+    date. my_slice is the slice index (integer value) in the SHPC.
 
     """
 
@@ -34,9 +36,10 @@ def loop_inst_eddies(files, bbox, d):
 
     nco_instance = nco.Nco()
 
-    for orient in ["cyclo", "anti"]:
-        if os.access(f"SHPC_{orient}", os.F_OK): shutil.rmtree(f"SHPC_{orient}")
-        os.mkdir(f"SHPC_{orient}")
+    for orient in ["Cyclones", "Anticyclones"]:
+        my_dir = f"SHPC/{orient}/Slice_{my_slice}"
+        if os.access(my_dir, os.F_OK): shutil.rmtree(my_dir)
+        os.makedirs(my_dir)
 
     perf_report = open("perf_report.csv", "w", newline = '')
     writer = csv.writer(perf_report, lineterminator = "\n")
@@ -68,7 +71,7 @@ def loop_inst_eddies(files, bbox, d):
             elapsed_NCO = time.perf_counter() - my_pc
             my_pc = time.perf_counter()
             subprocess.run(inst_eddies_exe, check = True, input = "&dates_nml "
-                           f"date = {d}/\n", text = True)
+                           f"date = {d}, slice = {my_slice}/\n", text = True)
             elapsed_Fortran = time.perf_counter() - my_pc
             os.remove("h.nc")
             os.remove("uv.nc")
@@ -76,10 +79,11 @@ def loop_inst_eddies(files, bbox, d):
         else:
             print("inst_eddies.loop_inst_eddies: Missing file:", nc_file)
 
-            for orient in ["cyclo", "anti"]:
-                with open(f"SHPC_{orient}/ishape_last.txt", "a") \
-                     as ishape_last, \
-                     shapefile.Reader(f"SHPC_{orient}/extremum") as shpr:
+            for orient in ["Cyclones", "Anticyclones"]:
+                with open(f"SHPC/{orient}/Slice_{my_slice}/ishape_last.txt",
+                          "a") as ishape_last, \
+                    shapefile.Reader(f"SHPC/{orient}/Slice_{my_slice}/"
+                                     "extremum") as shpr:
                     n_shapes = len(shpr)
                     ishape_last.write(str(n_shapes - 1) + "\n")
 
@@ -89,6 +93,9 @@ def loop_inst_eddies(files, bbox, d):
     os.remove("unpacked.nc")
     if bbox: os.remove("cropped.nc")
 
+    if my_slice == 0 and not os.access("SHPC/n_slices.txt", os.F_OK):
+        with open("SHPC/n_slices.txt", "w") as f: f.write("1\n")
+
 if __name__ == "__main__":
     import argparse
     
@@ -101,4 +108,6 @@ if __name__ == "__main__":
     args = argparser.parse_args()
     d = input("Enter first date index (integer value): ")
     d = int(d)
-    loop_inst_eddies(args.file, args.bbox, d)
+    my_slice = input("Enter slice index (integer value): ")
+    my_slice = int(my_slice)
+    loop_inst_eddies(args.file, args.bbox, d, my_slice)
diff --git a/Inst_eddies/inst_eddies_Aviso.py b/Inst_eddies/inst_eddies_Aviso.py
index 9e8eac4d..5d16e81d 100644
--- a/Inst_eddies/inst_eddies_Aviso.py
+++ b/Inst_eddies/inst_eddies_Aviso.py
@@ -58,4 +58,5 @@ else:
 # We choose to use d as the first date index. We could choose anything.
 inst_eddies.loop_inst_eddies(filename_generator(args.first_file, first_date,
                                                 last_date, args.template,
-                                                dirname), args.bbox, d)
+                                                dirname), args.bbox, d,
+                             my_slice = 0)
diff --git a/Overlap/Tests/Input/NSO_delta_in.txt b/Overlap/Tests/Input/NSO_delta_in.txt
index 3a6620d9..aa4f7b8f 100644
--- a/Overlap/Tests/Input/NSO_delta_in.txt
+++ b/Overlap/Tests/Input/NSO_delta_in.txt
@@ -1,3 +1,4 @@
- &MAIN_NML MAX_DELTA       = 2, k_test_1 = 20454, k_test_2 = 20455 /
+ &MAIN_NML MAX_DELTA       = 2, k_test_1 = 20454, k_test_2 = 20455,
+ cyclone = f /
 ,,,,,,1
 ,,,,,,1
diff --git a/Overlap/Tests/long_tests.json b/Overlap/Tests/long_tests.json
index 5ec654e7..70994c36 100644
--- a/Overlap/Tests/long_tests.json
+++ b/Overlap/Tests/long_tests.json
@@ -1,13 +1,13 @@
 [
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f/\n",
         "title": "EGg",
 	"env": {"mpiexec": "$mpiexec"},
         "command":
-	["$build_dir/Overlap/eddy_graph.sh", "1", "$PWD/Inst_eddies_5_anti"]
+	["$build_dir/Overlap/eddy_graph.sh", "1", "$PWD/Inst_eddies_5"]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f/\n",
         "title": "EGg_1993",
 	"env": {"mpiexec": "$mpiexec"},
 	"description":
@@ -15,7 +15,7 @@
         "command":
 	[
 	    "$build_dir/Overlap/eddy_graph.sh", "1",
-	    "$large_input_dir/SHPC_anti_1993"
+	    "$large_input_dir/SHPC_1993"
 	]
     }
 ]
diff --git a/Overlap/Tests/save_snapshot.f90 b/Overlap/Tests/save_snapshot.f90
index e3d206b6..82afc60a 100644
--- a/Overlap/Tests/save_snapshot.f90
+++ b/Overlap/Tests/save_snapshot.f90
@@ -35,7 +35,8 @@ contains
 
     !-----------------------------------------------------------------
 
-    call shpc_create(hshp, shpc_dir = "SHPC", cyclone = s%list(1)%cyclone)
+    call shpc_create(hshp, shpc_dir = "SHPC", cyclone = s%list(1)%cyclone, &
+         slice = 0)
 
     ! Write snapshot:
     do i = 1, s%number_extr
@@ -43,7 +44,7 @@ contains
     end do
 
     CALL shpc_close(hshp)
-    print *, 'Created shapefiles in SHPC.'
+    print *, 'Created a slice in SHPC.'
     print *, "Number of extrema:", s%number_extr
     print *, "s%ind_extr:"
 
diff --git a/Overlap/Tests/short_tests.json b/Overlap/Tests/short_tests.json
index a4654ca5..0960aa01 100644
--- a/Overlap/Tests/short_tests.json
+++ b/Overlap/Tests/short_tests.json
@@ -22,10 +22,10 @@
         "title": "Read_eddy",
         "commands":
 	[
-            ["mkdir", "SHPC"],
+            ["mkdir", "-p", "SHPC/Anticyclones/Slice_0"],
             [
 		"$build_dir/Overlap/Tests/test_read_eddy",
-		"$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+		"$tests_old_dir/Extraction_eddies_region_4/SHPC"
 	    ]
         ],
 	"input": "&main_nml /\n"
@@ -35,33 +35,33 @@
         "title": "Read_snapshot",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$build_dir/Overlap/Tests/test_read_snapshot",
-                "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+                "$tests_old_dir/Extraction_eddies_region_4/SHPC"
             ]
         ]
     },
     {
-        "input": "&MAIN_NML k_test_1 = 20455, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML k_test_1 = 20455, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description": "Overlap of a snapshot with itself.",
         "title": "Successive_overlap",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+          "$tests_old_dir/Extraction_eddies_region_4/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML k_test_1 = 20455, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML k_test_1 = 20455, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description": "Same as Successive_overlap, but with larger domain: region 5 instead of region 4.",
         "title": "Successive_overlap_region_5_one_date",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$PWD/Inst_eddies_4_anti"
+          "$PWD/Inst_eddies_4"
         ]
     },
     {
@@ -71,91 +71,91 @@
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$tests_old_dir/Extraction_eddies_periodic/SHPC_cyclo"
+          "$tests_old_dir/Extraction_eddies_periodic/SHPC"
         ]
     },
     {
-	"input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+	"input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description": "Overlap of different snapshots.",
         "title": "Successive_overlap_different_snapshots",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+          "$tests_old_dir/Extraction_eddies_region_4/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description":
 	"Overlap of different snapshots. Same as Successive_overlap_different_snapshots, but with a larger region. The identifying numbers of the connected eddies are not the same for all edges.",
         "title": "Successive_overlap_region_2",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+          "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description": "Same as Successive_overlap_region_2, but with a larger region. We get some merging and splitting.",
         "title": "Successive_overlap_region_5",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$PWD/Inst_eddies_4_anti"
+          "$PWD/Inst_eddies_4"
         ]
     },
     {
-        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description": "Global grid, normal 0.25° resolution.",
         "title": "Successive_overlap_global",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$PWD/Inst_eddies_5_anti"
+          "$PWD/Inst_eddies_5"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20454 /\n/\n/\n",
+        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20454, cyclone = f /\n/\n/\n",
         "description": "Overlap of a snapshot with itself. Same as Successive_overlap, except for max_delta.",
         "title": "Non_successive_overlap",
         "command":
         [
           "$build_dir/Overlap/Tests/test_overlap",
-          "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+          "$tests_old_dir/Extraction_eddies_region_4/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description":
 	"Overlap of different snapshots. Same as Successive_overlap_different_snapshots, except for max_delta.",
         "title": "NSO_different_snapshots",
         "command":
             [
                 "$build_dir/Overlap/Tests/test_overlap",
-                "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+                "$tests_old_dir/Extraction_eddies_region_4/SHPC"
             ]
     },
     {
-        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455, cyclone = f /\n/\n/\n",
         "description":
 	"Same as Successive_overlap_region_5, except for max_delta.",
         "title": "NSO_region_5",
         "command":
             [
                 "$build_dir/Overlap/Tests/test_overlap",
-                "$PWD/Inst_eddies_4_anti"
+                "$PWD/Inst_eddies_4"
             ]
     },
     {
-        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455 /\n/\n/\n",
+        "input": "&MAIN_NML max_delta = 3, k_test_1 = 20454, k_test_2 = 20455, cyclone = f/\n/\n/\n",
         "description":
 	"Same as Successive_overlap_global, except for max_delta.",
         "title": "NSO_global",
         "command":
             [
                 "$build_dir/Overlap/Tests/test_overlap",
-                "$PWD/Inst_eddies_5_anti"
+                "$PWD/Inst_eddies_5"
             ]
     },
     {
@@ -165,7 +165,7 @@
         "command":
             [
                 "$build_dir/Overlap/Tests/test_overlap",
-                "$tests_old_dir/Region_6/SHPC_anti"
+                "$tests_old_dir/Region_6/SHPC"
             ]
     },
     {
@@ -175,15 +175,15 @@
         "stdout": "test_send_recv_stdout.txt",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$mpiexec",
                 "-n",
                 "2",
                 "$build_dir/Overlap/Tests/test_send_recv",
-                "$tests_old_dir/Extraction_eddies_region_4/SHPC_anti"
+                "$tests_old_dir/Extraction_eddies_region_4/SHPC"
             ]
         ]
     },
@@ -194,15 +194,15 @@
         "stdout": "test_get_dispatch_snap_stdout.txt",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$mpiexec",
                 "-n",
                 "1",
                 "$build_dir/Overlap/Tests/test_get_dispatch_snap",
-                "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+                "$tests_old_dir/Inst_eddies_loop/SHPC"
             ]
         ]
     },
@@ -213,15 +213,15 @@
         "stdout": "test_get_dispatch_snap_stdout.txt",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$mpiexec",
                 "-n",
                 "2",
                 "$build_dir/Overlap/Tests/test_get_dispatch_snap",
-                "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+                "$tests_old_dir/Inst_eddies_loop/SHPC"
             ]
         ]
     },
@@ -232,7 +232,7 @@
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+            "$tests_old_dir/Inst_eddies_loop/SHPC"
         ]
     },
     {
@@ -243,7 +243,7 @@
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "2",
-            "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+            "$tests_old_dir/Inst_eddies_loop/SHPC"
         ]
     },
     {
@@ -254,183 +254,183 @@
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Inst_eddies_loop/SHPC_cyclo"
+            "$tests_old_dir/Inst_eddies_loop/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 4/\n",
+        "input": "&MAIN_NML n_dates = 4, cyclone = f/\n",
         "description": "Eddy_graph with a larger region.",
         "title": "Eddy_graph_region_2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 4/\n",
+        "input": "&MAIN_NML n_dates = 4, cyclone = f/\n",
         "description": "Same as Eddy_graph_region_2 but with 2 processes.",
         "title": "Eddy_graph_region_2_2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "2",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 4, max_delta = 2/\n",
+        "input": "&MAIN_NML n_dates = 4, max_delta = 2, cyclone = f/\n",
         "description": "Same as Eddy_graph_region_2 but with max_delta = 2.",
         "title": "Eddy_graph_r2md2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 4, max_delta = 3/\n",
+        "input": "&MAIN_NML n_dates = 4, max_delta = 3, cyclone = f/\n",
         "description": "Same as Eddy_graph_region_2 but with max_delta = 3.",
         "title": "Eddy_graph_r2md3",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 5, max_delta = 3/\n",
+        "input": "&MAIN_NML n_dates = 5, max_delta = 3, cyclone = f/\n",
         "description": "Same as Eddy_graph_r2md3 but with n_dates = 5.",
         "title": "Eddy_graph_r2nd5md3",
  	"env": {"mpiexec": "$mpiexec"},
 	"command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 5, max_delta = 4/\n",
+        "input": "&MAIN_NML n_dates = 5, max_delta = 4, cyclone = f/\n",
         "description": "Same as Eddy_graph_r2nd5md3 but with max_delta = 4.",
         "title": "EGr2nd5md4",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 6, max_delta = 4/\n",
+        "input": "&MAIN_NML n_dates = 6, max_delta = 4, cyclone = f/\n",
         "description": "Same as EGr2nd5md4 but with n_dates = 6.",
         "title": "EGr2nd6md4",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 6/\n",
+        "input": "&MAIN_NML n_dates = 6, cyclone = f/\n",
         "description": "Same as EGr2nd6md4 but with max_delta = 1.",
         "title": "EGr2nd6md1",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 6/\n",
+        "input": "&MAIN_NML n_dates = 6, cyclone = f/\n",
         "description": "Same as EGr2nd6md1 but with 2 processes.",
         "title": "EGr2nd6md1np2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "2",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML n_dates = 6/\n",
+        "input": "&MAIN_NML n_dates = 6, cyclone = f/\n",
         "description": "Same as EGr2nd6md1 but with 3 processes.",
         "title": "EGr2nd6md1np3",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "3",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML /\n",
+        "input": "&MAIN_NML cyclone = f /\n",
         "description": "Same as EGr2nd6md1 but with all the 15 dates.",
         "title": "EGr2nd15md1",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 2 /\n",
+        "input": "&MAIN_NML max_delta = 2, cyclone = f /\n",
         "description": "Same as EGr2nd15md1 but with max_delta = 2.",
         "title": "EGr2nd15md2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 3 /\n",
+        "input": "&MAIN_NML max_delta = 3, cyclone = f /\n",
         "description": "Same as EGr2nd15md1 but with max_delta = 3.",
         "title": "EGr2nd15md3",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f /\n",
         "description": "Same as EGr2nd15md1 but with max_delta = 4.",
         "title": "EGr2nd15md4",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f /\n",
         "description": "Same as EGr2nd15md4 but with 2 processes.",
         "title": "EGr2nd15md4np2",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "2",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f /\n",
         "description": "Same as EGr2nd15md4 but with 3 processes.",
         "title": "EGr2nd15md4np3",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "3",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
@@ -441,29 +441,29 @@
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "3",
-            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_cyclo"
+            "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f /\n",
         "description": "Same as EGr2nd15md4 but with a larger region.",
         "title": "EGr5np1",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "1",
-            "$PWD/Inst_eddies_4_anti"
+            "$PWD/Inst_eddies_4"
         ]
     },
     {
-        "input": "&MAIN_NML max_delta = 4 /\n",
+        "input": "&MAIN_NML max_delta = 4, cyclone = f /\n",
         "description": "Same as EGr5np1 but with 3 processes.",
         "title": "EGr5np3",
 	"env": {"mpiexec": "$mpiexec"},
         "command": [
             "$build_dir/Overlap/eddy_graph.sh",
             "3",
-            "$PWD/Inst_eddies_4_anti"
+            "$PWD/Inst_eddies_4"
         ]
     },
     {
@@ -488,8 +488,8 @@
 	[
 	    "$src_dir/Overlap/plot_components.py",
 	    "$PWD/EGr2nd15md4np3/edgelist.csv",
-	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti",
-	    "--save=png"
+	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC",
+	    "Anticyclones", "--save=png"
 	]
     },
     {
@@ -504,10 +504,10 @@
         "title": "Read_eddy_missing_speed",
         "commands":
 	[
-            ["mkdir", "SHPC"],
+            ["mkdir", "-p", "SHPC/Anticyclones/Slice_0"],
             [
 		"$build_dir/Overlap/Tests/test_read_eddy",
-		"$PWD/Inst_eddies_4_anti"
+		"$PWD/Inst_eddies_4"
 	    ]
         ],
 	"input": "&main_nml ishape = 330 /\n"
@@ -515,15 +515,15 @@
     {
         "input": "&main_nml /\n",
         "title": "Read_snapshot_15",
-	"description": "Read a snapshot from an SHPC on a very small region with a sufficient number of dates: 15. $tests_old_dir/Extraction_eddies_region_4/SHPC_anti used by the test Read_snapshot has only 2 dates.",
+	"description": "Read a snapshot from an SHPC on a very small region with a sufficient number of dates: 15. $tests_old_dir/Extraction_eddies_region_4/SHPC used by the test Read_snapshot has only 2 dates.",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$build_dir/Overlap/Tests/test_read_snapshot",
-                "$PWD/Inst_eddies_10_anti"
+                "$PWD/Inst_eddies_10"
             ]
         ]
     },
@@ -533,28 +533,27 @@
 	"description": "Like Read_snapshot_15, but we read a date other than the first date.",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$build_dir/Overlap/Tests/test_read_snapshot",
-                "$PWD/Inst_eddies_10_anti"
+                "$PWD/Inst_eddies_10"
             ]
         ]
     },
     {
         "input": "&main_nml k = 20461/\n",
         "title": "Read_snapshot_several",
-	"description": "Like Read_snapshot_middle, but we read from several SHPC. The 3 SHPC are just the result from splitting Inst_eddies_10_anti.",
+	"description": "Like Read_snapshot_middle, but we read from several slices. The 3 slices are just the result from splitting Inst_eddies_10.",
         "commands": [
             [
-                "mkdir",
-                "SHPC"
+                "mkdir", "-p", "SHPC/Anticyclones/Slice_0",
+		"SHPC/Cyclones/Slice_0"
             ],
             [
                 "$build_dir/Overlap/Tests/test_read_snapshot",
-                "$PWD/Inst_eddies_10_anti_1", "$PWD/Inst_eddies_10_anti_2",
-		"$PWD/Inst_eddies_10_anti_3"
+                "$PWD/Inst_eddies_10_splitted"
             ]
         ]
     },
@@ -566,21 +565,21 @@
 	"command":
 	[
             "$build_dir/Overlap/eddy_graph.sh", "1",
-	    "$PWD/Inst_eddies_10_anti"
+	    "$PWD/Inst_eddies_10"
 	],
-	"input": "&MAIN_NML MAX_DELTA=4 /\n"
+	"input": "&MAIN_NML MAX_DELTA=4, cyclone = f /\n"
     },
     {
 	"title": "EG_15_3_SHPC",
 	"description":
-	"As EG_15_region_4 but with 3 input SHPC which are just the result of splitting Inst_eddies_10_anti.",
+	"As EG_15_region_4 but with 3 slices which are just the result of splitting Inst_eddies_10.",
 	"env": {"mpiexec": "$mpiexec"},
 	"command":
 	[
             "$build_dir/Overlap/eddy_graph.sh", "1",
-	    "$PWD/Inst_eddies_10_anti_[1-3]"
+	    "$PWD/Inst_eddies_10_splitted"
 	],
-	"input": "&MAIN_NML MAX_DELTA=4 /\n"
+	"input": "&MAIN_NML MAX_DELTA=4, cyclone = f /\n"
     },
     {
 	"title": "Plot_components_date",
@@ -589,8 +588,8 @@
 	[
 	    "$src_dir/Overlap/plot_components.py",
 	    "$PWD/EGr2nd15md4np3/edgelist.csv",
-	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti",
-	    "--save=png", "--node=347852", "--label_date=20461"
+	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC",
+	    "Anticyclones", "--save=png", "--node=347852", "--label_date=20461"
 	]
     },
     {
@@ -600,8 +599,8 @@
 	"command":
 	[
 	    "$build_dir/Overlap/eddy_graph.sh", "1",
-	    "$tests_old_dir/Greece/SHPC_anti"
+	    "$tests_old_dir/Greece/SHPC"
 	],
-        "input": "&MAIN_NML max_delta = 4/\n"
+        "input": "&MAIN_NML max_delta = 4, cyclone = f/\n"
     }
 ]
diff --git a/Overlap/Tests/test_get_dispatch_snap.f90 b/Overlap/Tests/test_get_dispatch_snap.f90
index 0c5d8d2c..eac81030 100644
--- a/Overlap/Tests/test_get_dispatch_snap.f90
+++ b/Overlap/Tests/test_get_dispatch_snap.f90
@@ -73,7 +73,8 @@ program test_get_dispatch_snap
      copy = merge(dist_lim, 0, periodic)
   end if
 
-  call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
+  call shpc_open(hshp, trim(shpc_dir), cyclone = .true., slice = 0, &
+       pszaccess = "rb")
   call dbf_read_attribute_03(ssm%d0, hshp%extremum, hshp%extr_date, ishape = 0)
   call read_opcol(ssm%ishape_last, hshp%unit, my_lbound = ssm%d0)
 
diff --git a/Overlap/Tests/test_overlap.f90 b/Overlap/Tests/test_overlap.f90
index 7fef4fbd..4bb562a1 100644
--- a/Overlap/Tests/test_overlap.f90
+++ b/Overlap/Tests/test_overlap.f90
@@ -33,13 +33,14 @@ program test_overlap
   logical periodic ! grid is periodic in longitude
   integer:: nlon = - 1, nlat = - 1, max_delta = 1
   integer e_overestim ! over-estimation of the number of eddies at each date
+  logical:: cyclone = .true.
 
   integer:: dist_lim = 12
   ! We look for an overlapping eddy at dist_lim (in grid points) of
   ! the first extremum.
 
   namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
-  namelist /main_nml/ dist_lim, max_delta, k_test_1, k_test_2
+  namelist /main_nml/ dist_lim, max_delta, k_test_1, k_test_2, cyclone
 
   !-------------------------------------------------------------------------
 
@@ -65,7 +66,7 @@ program test_overlap
   corner = corner_deg * deg_to_rad
   step = step_deg * deg_to_rad
   allocate(flow(max_delta + 1))
-  call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
+  call shpc_open(hshp, trim(shpc_dir), cyclone, slice = 0, pszaccess = "rb")
   call dbf_read_attribute_03(ssm%d0, hshp%extremum, hshp%extr_date, ishape = 0)
   call read_opcol(ssm%ishape_last, hshp%unit, my_lbound = ssm%d0)
   n_dates = size(ssm%ishape_last)
diff --git a/Overlap/Tests/test_read_eddy.f90 b/Overlap/Tests/test_read_eddy.f90
index 071aa8f7..41040f4d 100644
--- a/Overlap/Tests/test_read_eddy.f90
+++ b/Overlap/Tests/test_read_eddy.f90
@@ -24,9 +24,11 @@ program test_read_eddy
   call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
   print *, "Enter namelist main_nml."
   read(unit = *, nml = main_nml)
-  call shpc_open(hshp_in, shpc_dir, pszaccess = "rb")
+  call shpc_open(hshp_in, shpc_dir, cyclone = .false., slice = 0, &
+       pszaccess = "rb")
   call read_eddy(e, k, eddy_i, hshp_in, ishape)
-  call shpc_create(hshp_out, shpc_dir = "SHPC", cyclone = hshp_in%cyclone)
+  call shpc_create(hshp_out, shpc_dir = "SHPC", cyclone = hshp_in%cyclone, &
+       slice = 0)
   CALL shpc_close(hshp_in)
   call write_eddy(e, hshp_out, k, eddy_i)
   CALL shpc_close(hshp_out)
diff --git a/Overlap/Tests/test_read_snapshot.f90 b/Overlap/Tests/test_read_snapshot.f90
index b9a8118d..a0c56637 100644
--- a/Overlap/Tests/test_read_snapshot.f90
+++ b/Overlap/Tests/test_read_snapshot.f90
@@ -19,7 +19,7 @@ program test_read_snapshot
   type(snapshot) s
   TYPE(shpc_slice_handler), allocatable:: hshp(:) ! (n_slices)
   type(shpc_slice_meta), allocatable:: ssm(:) ! (n_slices)
-  integer copy, unit, k, i
+  integer copy, unit, k, i, iostat
   integer n_slices ! number of input SHPC directories
 
   real:: corner_deg(2) = [0.125, - 59.875]
@@ -42,21 +42,35 @@ program test_read_snapshot
 
   !-------------------------------------------------------------------------
 
-  n_slices = COMMAND_ARGUMENT_COUNT()
-  call assert(n_slices /= 0, &
-       "Required arguments: SHPC-directory [SHPC-directory] ...")
+  call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
+
+  call new_unit(unit)
+
+  ! n_slices:
+
+  open(unit, file = shpc_dir // "/n_slices.txt", status = "old", &
+       action = "read", position = "rewind", iostat = iostat)
+
+  if (iostat == 0) then
+     read(unit, fmt = *) n_slices
+     close(unit)
+  else
+     print *, "test_read_snapshot: Could not open ", shpc_dir, "/n_slices.txt"
+     print *, "test_read_snapshot: Assuming there is only one slice..."
+     n_slices = 1
+  end if
+
   allocate(hshp(n_slices), ssm(n_slices))
 
   do i = 1, n_slices
-     call get_command_arg_dyn(i, shpc_dir)
-     call shpc_open(hshp(i), trim(shpc_dir), pszaccess = "rb")
+     call shpc_open(hshp(i), trim(shpc_dir), cyclone = .false., slice = i - 1, &
+          pszaccess = "rb")
      call dbf_read_attribute_03(ssm(i)%d0, hshp(i)%extremum, &
           hshp(i)%extr_date, ishape = 0)
      call read_opcol(ssm(i)%ishape_last, hshp(i)%unit, my_lbound = ssm(i)%d0)
   end do
 
   ! Assuming grid_nml.txt is the same in all input SHPC:
-  call new_unit(unit)
   open(unit, file = hshp(1)%dir // "/grid_nml.txt", status = "old", &
        action = "read", position  = "rewind")
   read(unit, nml = grid_nml)
diff --git a/Overlap/Tests/test_send_recv.f90 b/Overlap/Tests/test_send_recv.f90
index cee0e7cd..1ea1f174 100644
--- a/Overlap/Tests/test_send_recv.f90
+++ b/Overlap/Tests/test_send_recv.f90
@@ -82,7 +82,8 @@ program test_send_recv
      copy = merge(dist_lim, 0, periodic)
   end if
 
-  call shpc_open(hshp, trim(shpc_dir), pszaccess = "rb")
+  call shpc_open(hshp, trim(shpc_dir), cyclone = .false., slice = 0, &
+       pszaccess = "rb")
   call dbf_read_attribute_03(ssm%d0, hshp%extremum, hshp%extr_date, ishape = 0)
   call read_opcol(ssm%ishape_last, hshp%unit, my_lbound = ssm%d0)
 
diff --git a/Overlap/eddy_graph.f90 b/Overlap/eddy_graph.f90
index 8abc52ef..e840ed4c 100644
--- a/Overlap/eddy_graph.f90
+++ b/Overlap/eddy_graph.f90
@@ -20,7 +20,7 @@ program eddy_graph
 
   implicit none
 
-  integer rank, n_proc, copy, delta, i, j
+  integer rank, n_proc, copy, delta, i, j, iostat
   integer:: n_dates = huge(0) ! number of dates to read
   integer k ! date index
   integer k_begin, k_end, k_end_main_loop
@@ -50,15 +50,16 @@ program eddy_graph
 
   logical periodic ! grid is periodic in longitude
   integer unit_isolated, unit
-  integer n_slices ! number of input SHPC directories
+  integer n_slices ! number of slices in the input SHPC
   integer e_overestim ! over-estimation of the number of eddies at each date
   TYPE(shpc_slice_handler), allocatable:: hshpc(:) ! (n_slices)
   type(shpc_slice_meta), allocatable:: ssm(:) ! (n_slices)
   type(snapshot), allocatable:: flow(:) ! (max_delta + 1)
   character(len = 30) file
+  logical:: cyclone = .true.
 
   namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
-  namelist /main_nml/ max_delta, dist_lim, n_dates
+  namelist /main_nml/ max_delta, dist_lim, n_dates, cyclone
 
   !-------------------------------------------------------------------------
 
@@ -67,19 +68,40 @@ program eddy_graph
   call mpi_init
   call MPI_Comm_rank(MPI_Comm_world, rank)
   call MPI_Comm_size(MPI_Comm_world, n_proc)
+  call get_command_arg_dyn(1, shpc_dir, "Required argument: SHPC-directory")
 
   if (rank == 0) then
-     n_slices = COMMAND_ARGUMENT_COUNT()
-     call assert(n_slices /= 0, &
-          "Required arguments: SHPC-directory [SHPC-directory] ...")
+     ! n_slices:
+
+     open(unit, file = shpc_dir // "/n_slices.txt", status = "old", &
+          action = "read", position = "rewind", iostat = iostat)
+
+     if (iostat == 0) then
+        read(unit, fmt = *) n_slices
+        close(unit)
+     else
+        print *, "eddy_graph: Could not open ", shpc_dir, "/n_slices.txt"
+        print *, "eddy_graph: Assuming there is only one slice..."
+        n_slices = 1
+     end if
+
+     ! main_nml:
+     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 assert(max_delta >= 1, "eddy_graph max_delta")
+     call assert(n_dates == huge(0) .or. n_slices == 1, "If we have several " &
+          // "slices then we read all the dates from them")
   end if
 
   call ezmpi_bcast(n_slices, root = 0)
+  call ezmpi_bcast(cyclone, root = 0)
   allocate(hshpc(n_slices), ssm(n_slices))
 
   do i = 1, n_slices
-     call get_command_arg_dyn(i, shpc_dir)
-     call shpc_open(hshpc(i), trim(shpc_dir), pszaccess = "rb")
+     call shpc_open(hshpc(i), trim(shpc_dir), cyclone = cyclone, &
+          slice = i - 1, pszaccess = "rb")
      call dbf_read_attribute_03(ssm(i)%d0, hshpc(i)%extremum, &
           hshpc(i)%extr_date, ishape = 0)
      call read_opcol(ssm(i)%ishape_last, hshpc(i)%unit, my_lbound = ssm(i)%d0)
@@ -93,15 +115,6 @@ program eddy_graph
      read(unit, nml = grid_nml)
      close(unit)
 
-     ! main_nml:
-     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 assert(max_delta >= 1, "eddy_graph max_delta")
-     call assert(n_dates == huge(0) .or. n_slices == 1, "If we have several " &
-          // "slices then we read all the dates from them")
-
      ! As we are requiring the grid spacing to be uniform, the value of
      ! "periodic" may be deduced from the values of step_deg(1) and nlon:
      periodic = nint(360. / step_deg(1)) == nlon
diff --git a/Overlap/eddy_graph.sh.in b/Overlap/eddy_graph.sh.in
index 2089129f..f74a93d1 100644
--- a/Overlap/eddy_graph.sh.in
+++ b/Overlap/eddy_graph.sh.in
@@ -1,27 +1,25 @@
 #!/bin/bash
 
 # This script creates the edge list for a given orientation of
-# eddies. The script takes a list of SHPC as arguments. We assume (and
-# do not check) that the first date index in an SHPC is greater than
-# the last date index in the previous SHPC.
+# 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.
 
 if (($# <= 1))
 then
-    echo "Usage: eddy_graph.sh N_PROC SHPC-directory [SHPC-directory] ..."
+    echo "Usage: eddy_graph.sh N_PROC SHPC-directory"
     exit 1
 fi
 
 set -e
 ##set -x
-n_proc=$1
-shift
 echo "mpiexec: $mpiexec"
-${mpiexec:-mpiexec} -n $n_proc @CMAKE_CURRENT_BINARY_DIR@/eddy_graph $*
+${mpiexec:-mpiexec} -n $1 @CMAKE_CURRENT_BINARY_DIR@/eddy_graph $2
 
 rm -f isolated_nodes.txt edgelist_unsorted.csv
 rank=0
 
-while ((rank < $n_proc))
+while ((rank < $1))
 do
     cat edgelist_$rank.csv >>edgelist_unsorted.csv
     cat isolated_nodes_$rank.txt >>isolated_nodes.txt
diff --git a/Overlap/plot_components.py b/Overlap/plot_components.py
index 39b32e65..31520b08 100755
--- a/Overlap/plot_components.py
+++ b/Overlap/plot_components.py
@@ -108,6 +108,7 @@ if __name__ == "__main__":
     parser.add_argument("edgelist", help = "path to input CSV file")
     parser.add_argument("shpc_dir", help = "directory containing SHPC, with "
                         "visible eddies at all dates")
+    parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
     group = parser.add_mutually_exclusive_group()
     group.add_argument("-l", "--label_type",
                         choices = ["root", "leaf", "split", "merge", "all",
@@ -146,7 +147,8 @@ if __name__ == "__main__":
             print("Reading edge list and SHPC...")
             t0 = time.perf_counter()
             
-        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir)
+        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
+                                         args.orientation)
 
         if args.time:
             t1 = time.perf_counter()
@@ -172,7 +174,8 @@ if __name__ == "__main__":
             print("Reading edge list in current directory...")
             t0 = time.perf_counter()
             
-        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir)
+        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
+                                         args.orientation)
 
         if args.time:
             t1 = time.perf_counter()
@@ -195,7 +198,8 @@ if __name__ == "__main__":
             print("Reading edge lists in current directory...")
             t0 = time.perf_counter()
             
-        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir)
+        G = report_graph.read_eddy_graph(args.edgelist, args.shpc_dir,
+                                         args.orientation)
 
         if args.time:
             t1 = time.perf_counter()
diff --git a/Overlap/report_graph.py b/Overlap/report_graph.py
index 1990f49f..9bf67a8d 100755
--- a/Overlap/report_graph.py
+++ b/Overlap/report_graph.py
@@ -27,7 +27,7 @@ def date_eddy_to_node(date, eddy_index, e_overestim):
     """
     return date * e_overestim + eddy_index
 
-def read_eddy_graph(edgelist, shpc_dir = None):
+def read_eddy_graph(edgelist, shpc_dir = None, orientation = "Cyclones"):
     if os.access(edgelist, os.R_OK):
         G = nx.read_edgelist(edgelist, create_using = nx.DiGraph,
                              nodetype = int)
@@ -37,7 +37,7 @@ def read_eddy_graph(edgelist, shpc_dir = None):
 
         if shpc_dir is not None:
             # Read and set attributes of eddies:
-            handler = util_eddies.open_shpc(shpc_dir)
+            handler = util_eddies.open_shpc(shpc_dir, orientation)
             set_attribute(G, handler)
     else:
         print(edgelist, "not readable")
diff --git a/Trajectories/cost_function.py b/Trajectories/cost_function.py
index 83dc3fb5..f0886911 100755
--- a/Trajectories/cost_function.py
+++ b/Trajectories/cost_function.py
@@ -25,6 +25,7 @@ import report_graph
 import util_eddies
 import bisect
 import argparse
+from os import path
 
 Omega = 2 * math.pi / 86164.
 
@@ -91,7 +92,8 @@ def node_to_prop(node_list, e_overestim, array_d_init, handlers):
 t0 = time.perf_counter()
 timings = open("timings.txt", "w")
 parser = argparse.ArgumentParser()
-parser.add_argument("SHPC_dir", nargs='+')
+parser.add_argument("SHPC_dir")
+parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
 parser.add_argument("--graphml", action = "store_true",
                     help = "save to graphml format")
 args = parser.parse_args()
@@ -134,10 +136,10 @@ g.vp['first_av_ros'] = g.new_vp('float')
 g.vp['last_av_rad'] = g.new_vp('float')
 g.vp['last_av_ros'] = g.new_vp('float')
 g.ep['cost_function'] = g.new_ep('float')
-
-# Set up the list of SHPC:
-
-handlers = [util_eddies.open_shpc(shpc_dir) for shpc_dir in args.SHPC_dir]
+fname = path.join(args.SHPC_dir, "n_slices.txt")
+with open(fname) as f: n_slices = int(f.read())
+handlers = [util_eddies.open_shpc(args.SHPC_dir, args.orientation, slice = i)
+            for i in range(n_slices)]
 
 array_d_init = [handler["d_init"] for handler in handlers]
 # (create the list once and for all)
diff --git a/Trajectories/tests.json b/Trajectories/tests.json
index ece315aa..e1315d08 100644
--- a/Trajectories/tests.json
+++ b/Trajectories/tests.json
@@ -12,7 +12,8 @@
 	"command":
 	[
 	    "$src_dir/Trajectories/cost_function.py", "--graphml",
-	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC_anti"
+	    "$tests_old_dir/Extraction_eddies_region_2_noise/SHPC",
+	    "Anticyclones"
 	],
 	"env": {"PYTHONPATH": "$src_dir/Overlap:$src_dir/Common"},
 	"symlink":
@@ -39,7 +40,7 @@
 	"command":
 	[
 	    "$src_dir/Trajectories/cost_function.py", "--graphml",
-	    "$tests_old_dir/Greece/SHPC_anti"
+	    "$tests_old_dir/Greece/SHPC", "Anticyclones"
 	],
 	"env": {"PYTHONPATH": "$src_dir/Overlap:$src_dir/Common"},
 	"symlink":
-- 
GitLab