From ea297e7e20e3bcb004a0346de850cc3ad87c9843 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ipsl.fr>
Date: Tue, 10 Sep 2024 11:23:35 +0200
Subject: [PATCH] Write periodic to `grid_nml.txt`

So that the program `eddy_graph` can read it, instead of deducing it
from the longitude coordinate.
---
 Inst_eddies/input_ssh.f90 |  2 +-
 Overlap/read_grid.F90     | 10 ++--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/Inst_eddies/input_ssh.f90 b/Inst_eddies/input_ssh.f90
index bf4a75fc..a98d8950 100644
--- a/Inst_eddies/input_ssh.f90
+++ b/Inst_eddies/input_ssh.f90
@@ -48,7 +48,7 @@ contains
     real:: step_deg(2) = huge(0.) ! longitude and latitude steps, in degrees
     real lon_max, lat_max ! longitude and latitude, in degrees
     integer copy
-    namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
+    namelist /grid_nml/ corner_deg, step_deg, nlon, nlat, periodic
 
     !----------------------------------------------------------------------
 
diff --git a/Overlap/read_grid.F90 b/Overlap/read_grid.F90
index 6b06c7a6..d3c45429 100644
--- a/Overlap/read_grid.F90
+++ b/Overlap/read_grid.F90
@@ -6,7 +6,7 @@ module read_grid_m
   ! size of ssh array in input NetCDF file, assuming no repeated point
   ! if the grid is global
 
-  logical, protected:: periodic ! grid is periodic in longitude
+  logical, protected:: periodic = .false. ! grid is periodic in longitude
 
   real, protected:: corner(2)
   ! longitude and latitude of the corner of the whole grid in input
@@ -38,7 +38,7 @@ contains
     real:: step_deg(2) = [huge(0.), huge(0.)]
     ! longitude and latitude steps, in degrees
 
-    namelist /grid_nml/ corner_deg, step_deg, nlon, nlat
+    namelist /grid_nml/ corner_deg, step_deg, nlon, nlat, periodic
 
     !-----------------------------------------------------------------
 
@@ -48,12 +48,6 @@ contains
             action = "read", position = "rewind")
        read(unit, nml = grid_nml)
        close(unit)
-
-       ! 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
-       print *, "periodic = ", periodic
-
        corner = corner_deg * deg_to_rad
        step = step_deg * deg_to_rad
     end if
-- 
GitLab