From 4af22a9d3bf2b79df68d930eafb592e9f9470460 Mon Sep 17 00:00:00 2001
From: Gildas Cambon <gildas.cambon@ird.fr>
Date: Wed, 19 Mar 2025 15:06:27 +0100
Subject: [PATCH] Still some last bug fix: - for cycle in make_bry_WKB_ERA5.m -
 in make_OGCM_mercator.m, to handle overlaps with monthly mercator data
 starting at the first days of the month (...)

---
 Aforc_ERA5/make_bry_wkb_ERA5.m  | 2 +-
 Oforc_OGCM/make_OGCM_mercator.m | 7 ++++++-
 crocotools_param.m              | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Aforc_ERA5/make_bry_wkb_ERA5.m b/Aforc_ERA5/make_bry_wkb_ERA5.m
index c29d3b30..7d4097fe 100644
--- a/Aforc_ERA5/make_bry_wkb_ERA5.m
+++ b/Aforc_ERA5/make_bry_wkb_ERA5.m
@@ -122,7 +122,7 @@ for Y=Ymin:Ymax
   close(nc)
 
   wkb_time=time;
-  wkb_cycle=wkb_time(end);
+  wkb_cycle=0;
 %
 % Create the boundary file
 %
diff --git a/Oforc_OGCM/make_OGCM_mercator.m b/Oforc_OGCM/make_OGCM_mercator.m
index 91cd9269..f7243368 100644
--- a/Oforc_OGCM/make_OGCM_mercator.m
+++ b/Oforc_OGCM/make_OGCM_mercator.m
@@ -228,7 +228,12 @@ if makeclim==1 | makebry==1
             OGCM_time=nc{'time'}(:);
             ntimes=length(OGCM_time);
             if ntimes==1
-                dt=30; % monthly files
+                dt = eomday(Y, M); % monthly files
+                %disp(['Number of days of the given month: ',num2str(dt)]);
+                if strcmp(OGCM, 'mercator')
+                    dt = eomday(Y, M) + 1 ;  % add +1 days to avoid problems 
+                                             % with mercator starting at first days month   
+                end
                 itolap_a=1; itolap_p=1;
                 itolap_tot=itolap_a + itolap_p;
                 disp(['Reduced overlap for monthly files'])
diff --git a/crocotools_param.m b/crocotools_param.m
index 8b310ce1..e1a593e8 100644
--- a/crocotools_param.m
+++ b/crocotools_param.m
@@ -490,6 +490,9 @@ end
 rmdepth     = 2;
 %
 % Overlap parameters : nb of records around each sequence
+% => for SODA put itolap_a = itolap_p = 1
+% => for mercator daily put itolap_a = itolap_p = 2 
+%         (due to date of the month first day of month)
 %
 itolap_a    = 1;   % before
 itolap_p    = 1;   % after
-- 
GitLab