From 041c9fd6928afc0e8da3e8248fd60aad08d6b51e Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ipsl.fr>
Date: Tue, 4 Mar 2025 18:48:58 +0100
Subject: [PATCH] Promote `dimid_lon` and `dimid_lat`

To arguments of `read_grid_inst_eddies`. Because we are going to need
them to check the order of dimensions in SSH variable.
---
 Inst_eddies/Tests/test_local_extrema.f90 | 4 ++--
 Inst_eddies/input_ssh.f90                | 4 ++--
 Inst_eddies/read_grid_inst_eddies.f90    | 6 ++++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Inst_eddies/Tests/test_local_extrema.f90 b/Inst_eddies/Tests/test_local_extrema.f90
index 26a86fd6..c7d5740f 100644
--- a/Inst_eddies/Tests/test_local_extrema.f90
+++ b/Inst_eddies/Tests/test_local_extrema.f90
@@ -18,7 +18,7 @@ program test_local_extrema
 
   implicit none
 
-  integer ncid, varid
+  integer ncid, varid, dimid_lon, dimid_lat
   integer i, unit
   character(len = :), allocatable:: filename
 
@@ -44,7 +44,7 @@ program test_local_extrema
   print *, "Reading from ", filename, "..."
   call nf95_open(filename, nf95_nowrite, ncid)
   call config(leave_trace = .false.)
-  call read_grid_inst_eddies(ncid, leave_trace = .false.)
+  call read_grid_inst_eddies(dimid_lon, dimid_lat, ncid, leave_trace = .false.)
   copy = merge(1, 0, periodic)
   allocate(ssh(1 - copy:nlon + copy, nlat), &
        extr_map(1 - copy:nlon + copy, nlat))
diff --git a/Inst_eddies/input_ssh.f90 b/Inst_eddies/input_ssh.f90
index 3b8c4629..efb729fd 100644
--- a/Inst_eddies/input_ssh.f90
+++ b/Inst_eddies/input_ssh.f90
@@ -30,7 +30,7 @@ contains
 
     ! Local:
 
-    integer ncid
+    integer ncid, dimid_lon, dimid_lat
 
     integer:: nc_time = 1
     ! Index, 1-based, in the NetCDF time coordinate, if any, of the
@@ -46,7 +46,7 @@ contains
     print *, "input_ssh: Enter input_ssh_nml:"
     read(unit = *, nml = input_ssh_nml)
     call nf95_open(ssh_fname, nf95_nowrite, ncid)
-    call read_grid_inst_eddies(ncid, leave_trace)
+    call read_grid_inst_eddies(dimid_lon, dimid_lat, ncid, leave_trace)
     allocate(ssh(1 - copy_max_radius:nlon + copy_max_radius, nlat), &
          u(1 - copy_max_radius:nlon + copy_max_radius, nlat), &
          v(1 - copy_max_radius:nlon + copy_max_radius, nlat))
diff --git a/Inst_eddies/read_grid_inst_eddies.f90 b/Inst_eddies/read_grid_inst_eddies.f90
index f7a3bf1d..02bac45c 100644
--- a/Inst_eddies/read_grid_inst_eddies.f90
+++ b/Inst_eddies/read_grid_inst_eddies.f90
@@ -42,7 +42,8 @@ module read_grid_inst_eddies_m
 
 contains
 
-  subroutine read_grid_inst_eddies(ncid, leave_trace)
+  subroutine read_grid_inst_eddies(dimid_lon, dimid_lat, ncid, &
+       leave_trace)
 
     ! Libraries:
     use jumble, only: deg_to_rad, new_unit, assert, ediff1d
@@ -51,6 +52,7 @@ contains
 
     use config_m, only: max_radius
 
+    integer, intent(out):: dimid_lon, dimid_lat ! dimids in SSH file
     integer, intent(in):: ncid
     logical, intent(in):: leave_trace
 
@@ -69,7 +71,7 @@ contains
          uniform_lon_lat, stag_u, stag_v
     namelist /read_grid_inst_eddies_nml/ periodic, uniform_lon_lat, stag_u, &
          stag_v
-    integer dimid_lon, dimid_lat, varid_lon, varid_lat, unit
+    integer varid_lon, varid_lat, unit
     real lon_max, lat_max ! longitude and latitude, in degrees
 
     !----------------------------------------------------------------------
-- 
GitLab