From 2fe699230c1f6653168588903b05b02439b8b02e Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 21 Aug 2019 17:36:24 +0200
Subject: [PATCH] Change order of procedure arguments

Move dummy arguments k and i of procedure `write_eddy` to the end of
dummy argument list: keyword association more likely for these.

Follow upgrade of `Shapelib_03`: move argument associated to dummy
argument hshp of `shp_open_03` to the beginning of argument list.
---
 Documentation_texfol/documentation.tex |  2 ++
 Tests/test_inside_4.f90                |  2 +-
 Tests/test_mean_speed.f90              |  2 +-
 Tests/test_nearby_extr.f90             |  2 +-
 Tests/test_read_eddy.f90               | 13 ++++++-------
 Tests/test_read_snapshot.f90           | 15 +++++++--------
 Tests/test_set_max_speed.f90           |  2 +-
 Tests/test_spher_polygon_area.f90      |  2 +-
 Tests/test_successive_overlap.f90      | 24 ++++++++++++------------
 extraction_eddies.f90                  |  4 ++--
 overlap.f90                            |  6 +++---
 set_all_outerm.f90                     |  4 ++--
 write_eddy.f90                         |  7 +++----
 13 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/Documentation_texfol/documentation.tex b/Documentation_texfol/documentation.tex
index b12d4a73..8a166c8b 100644
--- a/Documentation_texfol/documentation.tex
+++ b/Documentation_texfol/documentation.tex
@@ -533,6 +533,7 @@ Les procédures géométriques utilisées :
 \item polygon\_area\_2d (bibliothèque Geometry)
 \item polygon\_contains\_point (bibliothèque Geometry)
 \item find\_contours\_reg\_grid (bibliothèque Contour\_531)
+\item interpolate\_eddy
 \end{itemize}
 travaillent dans le plan
 et non sur la sphère. Ces procédures sont appelées par :
@@ -540,6 +541,7 @@ et non sur la sphère. Ces procédures sont appelées par :
 \item spher\_polyline\_area
 \item inside\_4
 \item good\_contour
+\item overlap
 \end{itemize}
 Dans le plan, par deux points passe un unique segment, et la donnée
 d'un triangle est équivalente à la donnée de l'ensemble de ses trois
diff --git a/Tests/test_inside_4.f90 b/Tests/test_inside_4.f90
index e5f776c7..9c7f617a 100644
--- a/Tests/test_inside_4.f90
+++ b/Tests/test_inside_4.f90
@@ -19,7 +19,7 @@ program test_inside_4
 
   call get_command_arg_dyn(1, filename)
   print *, "Reading from ", filename, "..."
-  call shp_open_03(filename, "rb", hshp)
+  call shp_open_03(hshp, filename, "rb")
   call shp_read_object_03(hshp, 0, psobject)
   CALL shpclose(hshp)
   
diff --git a/Tests/test_mean_speed.f90 b/Tests/test_mean_speed.f90
index 9a3672df..66817fce 100644
--- a/Tests/test_mean_speed.f90
+++ b/Tests/test_mean_speed.f90
@@ -54,7 +54,7 @@ program test_mean_speed
 
   call nf95_close(ncid)
 
-  call shp_open_03("contour", "rb", hshp)
+  call shp_open_03(hshp, "contour", "rb")
   call shp_read_object_03(hshp, 0, psobject)
   CALL shpclose(hshp)
 
diff --git a/Tests/test_nearby_extr.f90 b/Tests/test_nearby_extr.f90
index 1b8a8695..6be3e3db 100644
--- a/Tests/test_nearby_extr.f90
+++ b/Tests/test_nearby_extr.f90
@@ -33,7 +33,7 @@ program test_nearby_extr
   call nf95_gw_var(ncid, varid, extr_map)
   call nf95_close(ncid)
 
-  call shp_open_03("extremum", pszaccess = "rb", hshp = hshp)
+  call shp_open_03(hshp, "extremum", pszaccess = "rb")
   call shp_get_info_03(hshp, n_entities)
   allocate(list_vis(n_entities))
 
diff --git a/Tests/test_read_eddy.f90 b/Tests/test_read_eddy.f90
index cb6a5f15..ba35ee5d 100644
--- a/Tests/test_read_eddy.f90
+++ b/Tests/test_read_eddy.f90
@@ -20,12 +20,11 @@ program test_read_eddy
 
   !-------------------------------------------------------------------------
 
-  call shp_open_03("Snapshot_old/extremum", pszaccess = "rb", &
-       hshp = hshp_extremum)
-  call shp_open_03("Snapshot_old/outermost_contour", pszaccess = "rb", &
-       hshp = hshp_outermost)
-  call shp_open_03("Snapshot_old/max_speed_contour", pszaccess = "rb", &
-       hshp = hshp_max_speed)
+  call shp_open_03(hshp_extremum, "Snapshot_old/extremum", pszaccess = "rb")
+  call shp_open_03(hshp_outermost, "Snapshot_old/outermost_contour", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_max_speed, "Snapshot_old/max_speed_contour", &
+       pszaccess = "rb")
   call read_field_indices(hshp_extremum, hshp_outermost, hshp_max_speed)
   call read_eddy(e, k, i, hshp_extremum, hshp_outermost, hshp_max_speed, &
        ishape = 0)
@@ -34,7 +33,7 @@ program test_read_eddy
   CALL shpclose(hshp_max_speed)
 
   call init_shapefiles(hshp_extremum, hshp_outermost, hshp_max_speed)
-  call write_eddy(e, k, i, hshp_extremum, hshp_outermost, hshp_max_speed)
+  call write_eddy(e, hshp_extremum, hshp_outermost, hshp_max_speed, k, i)
   CALL shpclose(hshp_extremum)
   print *, 'Created shapefile "extremum".'
   CALL shpclose(hshp_outermost)
diff --git a/Tests/test_read_snapshot.f90 b/Tests/test_read_snapshot.f90
index 0682f08b..719a2fad 100644
--- a/Tests/test_read_snapshot.f90
+++ b/Tests/test_read_snapshot.f90
@@ -49,12 +49,11 @@ program test_read_snapshot
   if (periodic) call assert(2 * dist_lim * step(1) < 180., &
        "test_read_snapshot dist_lim")
 
-  call shp_open_03("Snapshot_old/extremum", pszaccess = "rb", &
-       hshp = hshp_extremum)
-  call shp_open_03("Snapshot_old/outermost_contour", pszaccess = "rb", &
-       hshp = hshp_outermost)
-  call shp_open_03("Snapshot_old/max_speed_contour", pszaccess = "rb", &
-       hshp = hshp_max_speed)
+  call shp_open_03(hshp_extremum, "Snapshot_old/extremum", pszaccess = "rb")
+  call shp_open_03(hshp_outermost, "Snapshot_old/outermost_contour", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_max_speed, "Snapshot_old/max_speed_contour", &
+       pszaccess = "rb")
   call read_field_indices(hshp_extremum, hshp_outermost, hshp_max_speed)
   call read_snapshot(s, k, hshp_extremum, hshp_outermost, hshp_max_speed, &
        corner * deg_to_rad, step * deg_to_rad, nlon, nlat, periodic, dist_lim)
@@ -66,8 +65,8 @@ program test_read_snapshot
 
   ! Write snapshot:
   do i = 1, s%number_vis_extr
-     call write_eddy(s%list_vis(i), k, i, hshp_extremum, hshp_outermost, &
-          hshp_max_speed)
+     call write_eddy(s%list_vis(i), hshp_extremum, hshp_outermost, &
+          hshp_max_speed, k, i)
   end do
 
   print *, "Number of extrema:", s%number_vis_extr
diff --git a/Tests/test_set_max_speed.f90 b/Tests/test_set_max_speed.f90
index cb06b309..5f2b1f6b 100644
--- a/Tests/test_set_max_speed.f90
+++ b/Tests/test_set_max_speed.f90
@@ -80,7 +80,7 @@ program test_set_max_speed
   call nf95_close(ncid)
 
   print *, "Reading from shapefile test_get_1_outerm..."
-  call shp_open_03("test_get_1_outerm", "rb", hshp)
+  call shp_open_03(hshp, "test_get_1_outerm", "rb")
   call shp_read_object_03(hshp, 0, psobject)
   call dbfreadattribute(hshp, 0, 0, outermost_contour_ssh)
   CALL shpclose(hshp)
diff --git a/Tests/test_spher_polygon_area.f90 b/Tests/test_spher_polygon_area.f90
index 061353f3..c5b7735c 100644
--- a/Tests/test_spher_polygon_area.f90
+++ b/Tests/test_spher_polygon_area.f90
@@ -21,7 +21,7 @@ program test_spher_polygon_area
   !---------------------------------------------------------------------
 
   call get_command_arg_dyn(1, filename, "Required argument: shapefile")
-  call shp_open_03(filename, "rb", hshp)
+  call shp_open_03(hshp, filename, "rb")
   call shp_get_info_03(hshp, nentities)
   allocate(p(0:nentities - 1))
   
diff --git a/Tests/test_successive_overlap.f90 b/Tests/test_successive_overlap.f90
index 87a89323..ebadb106 100644
--- a/Tests/test_successive_overlap.f90
+++ b/Tests/test_successive_overlap.f90
@@ -61,12 +61,12 @@ program test_successive_overlap
   corner = corner_deg * deg_to_rad
   step = step_deg * deg_to_rad
 
-  call shp_open_03(trim(snapshot_1) // "/extremum", pszaccess = "rb", &
-       hshp = hshp_extremum)
-  call shp_open_03(trim(snapshot_1) // "/outermost_contour", pszaccess = "rb", &
-       hshp = hshp_outermost)
-  call shp_open_03(trim(snapshot_1) // "/max_speed_contour", pszaccess = "rb", &
-       hshp = hshp_max_speed)
+  call shp_open_03(hshp_extremum, trim(snapshot_1) // "/extremum", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_outermost, trim(snapshot_1) // "/outermost_contour", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_max_speed, trim(snapshot_1) // "/max_speed_contour", &
+       pszaccess = "rb")
   call read_field_indices(hshp_extremum, hshp_outermost, hshp_max_speed)
   call read_snapshot(flow(1), k, hshp_extremum, hshp_outermost, &
        hshp_max_speed, corner, step, nlon, nlat, periodic, dist_lim)
@@ -75,12 +75,12 @@ program test_successive_overlap
   CALL shpclose(hshp_max_speed)
   print *, snapshot_1, ", k = ", k
 
-  call shp_open_03(trim(snapshot_2) // "/extremum", pszaccess = "rb", &
-       hshp = hshp_extremum)
-  call shp_open_03(trim(snapshot_2) // "/outermost_contour", pszaccess = "rb", &
-       hshp = hshp_outermost)
-  call shp_open_03(trim(snapshot_2) // "/max_speed_contour", pszaccess = "rb", &
-       hshp = hshp_max_speed)
+  call shp_open_03(hshp_extremum, trim(snapshot_2) // "/extremum", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_outermost, trim(snapshot_2) // "/outermost_contour", &
+       pszaccess = "rb")
+  call shp_open_03(hshp_max_speed, trim(snapshot_2) // "/max_speed_contour", &
+       pszaccess = "rb")
   ! We assume that the field indices are the same than in snapshot_1.
   call read_snapshot(flow(2), k, hshp_extremum, hshp_outermost, &
        hshp_max_speed, corner, step, nlon, nlat, periodic, dist_lim)
diff --git a/extraction_eddies.f90 b/extraction_eddies.f90
index e7ef1363..caa1d95d 100644
--- a/extraction_eddies.f90
+++ b/extraction_eddies.f90
@@ -188,8 +188,8 @@ program extraction_eddies
 
   ! Write snapshot:
   do i = 1, s%number_vis_extr
-     call write_eddy(s%list_vis(i), k, i, hshp_extremum, hshp_outermost, &
-          hshp_max_speed)
+     call write_eddy(s%list_vis(i), hshp_extremum, hshp_outermost, &
+          hshp_max_speed, k, i)
   end do
 
   print *, "Number of extrema:", s%number_vis_extr
diff --git a/overlap.f90 b/overlap.f90
index a552007b..efbd1c59 100644
--- a/overlap.f90
+++ b/overlap.f90
@@ -122,9 +122,9 @@ contains
                       k_interp = k - j + j_interp
                       call write_eddy(interpolate_eddy( &
                            flow(j - delta)%list_vis(i1), flow(j)%list_vis(i2), &
-                           k - delta, k, k_interp), k_interp, &
-                           flow(j_interp)%number_eddies, hshp_extremum, &
-                           hshp_outermost, hshp_max_speed)
+                           k - delta, k, k_interp), hshp_extremum, &
+                           hshp_outermost, hshp_max_speed, k_interp, &
+                           flow(j_interp)%number_eddies)
                       write(unit_edgelist, fmt = *) k_interp - 1, i_pred, &
                            k_interp, flow(j_interp)%number_eddies, w
                       i_pred = flow(j_interp)%number_eddies
diff --git a/set_all_outerm.f90 b/set_all_outerm.f90
index dcff1273..f26082f7 100644
--- a/set_all_outerm.f90
+++ b/set_all_outerm.f90
@@ -89,9 +89,9 @@ contains
          innermost_level, cyclone, ssh(1 - copy:nlon + copy, :), periodic, &
          my_lbound = [1 - copy, 1])
     ! Assertion: \forall k, s%ind_extr(1, k) \in \{2 - copy, \dots,
-    ! nlon + copy - 1\} et s%ind_extr(2, k) \in \{2, \dots, nlat - 1\}
+    ! nlon + copy - 1\} and s%ind_extr(2, k) \in \{2, \dots, nlat - 1\}
     
-    ! Assertion: \forall k, s%ind_extr(1, k) \in \{1, \dots, nlon\} et
+    ! Assertion: \forall k, s%ind_extr(1, k) \in \{1, \dots, nlon\} and
     ! s%ind_extr(2, k) \in \{2, \dots, nlat - 1\}
 
     if (periodic) then
diff --git a/write_eddy.f90 b/write_eddy.f90
index d7ee5393..8ea0dd4e 100644
--- a/write_eddy.f90
+++ b/write_eddy.f90
@@ -4,7 +4,7 @@ module write_eddy_m
 
 contains
 
-  subroutine write_eddy(e, k, i, hshp_extremum, hshp_outermost, hshp_max_speed)
+  subroutine write_eddy(e, hshp_extremum, hshp_outermost, hshp_max_speed, k, i)
 
     use, intrinsic:: ieee_arithmetic, only: ieee_is_nan
 
@@ -24,15 +24,14 @@ contains
          ifield_max_speed_eddy_index 
 
     type(eddy), intent(in):: e
-    integer, intent(in):: k ! date index
-    integer, intent(in):: i ! eddy index
-
     TYPE(shpfileobject), intent(in):: hshp_extremum ! shapefile extremum
 
     TYPE(shpfileobject), intent(in):: hshp_outermost
     ! shapefile outermost_contour
 
     TYPE(shpfileobject), intent(in):: hshp_max_speed ! shapefile x_speed_contour
+    integer, intent(in):: k ! date index
+    integer, intent(in):: i ! eddy index
 
     ! Local:
     integer ishape
-- 
GitLab