diff --git a/Inst_eddies/inst_eddies.f90 b/Inst_eddies/inst_eddies.f90
index a576824459d337e0cbbd411222255956990b1858..a75976e16db3d69a3c9e8b6bd20c3f01a05b6949 100644
--- a/Inst_eddies/inst_eddies.f90
+++ b/Inst_eddies/inst_eddies.f90
@@ -142,10 +142,11 @@ program inst_eddies
 
   ! Done sorting
 
+  if (.not. periodic) nlon = size(ssh, 1)
+  nlat = size(ssh, 2)
+
   loop_extr: do l = 1, s%number_extr
      i = sorted_extr(l)
-     if (.not. periodic) nlon = size(ssh, 1)
-     nlat = size(ssh, 2)
 
      associate (e => s%list(i))
        ! Define the geographical window around each eddy extremum: