From aae5b9bc57a039117db03b62abd2d01c9bbb4422 Mon Sep 17 00:00:00 2001
From: Renaud Person <renaud.person@ird.fr>
Date: Thu, 12 Dec 2024 17:41:55 +0100
Subject: [PATCH] Merge branch...

---
 Preprocessing_tools/Bio/make_dust.m  | 20 +++++------
 Preprocessing_tools/Bio/make_ndepo.m | 50 ++++++++++++++--------------
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/Preprocessing_tools/Bio/make_dust.m b/Preprocessing_tools/Bio/make_dust.m
index a58d9016..bfcf43b8 100644
--- a/Preprocessing_tools/Bio/make_dust.m
+++ b/Preprocessing_tools/Bio/make_dust.m
@@ -152,16 +152,16 @@ nc=netcdf(bioname,'write');
 %
 for tindex=1:length(time)
   time=nc{'dust_time'}(tindex);
-  nc{'dust'}(tindex,:,:)=ext_data(dust_file,'dust',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'dustfer'}(tindex,:,:)=ext_data(dust_file,'dustfer',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'dustpo4'}(tindex,:,:)=ext_data(dust_file,'dustpo4',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'dustsi'}(tindex,:,:)=ext_data(dust_file,'dustsi',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'solubility2'}(tindex,:,:)=ext_data(dust_file,'solubility2',tindex,...
-             lon,lat,time,Roa,1);
+  nc{'dust'}(tindex,:,:)=max(0.,ext_data(dust_file,'dust',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'dustfer'}(tindex,:,:)=max(0.,ext_data(dust_file,'dustfer',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'dustpo4'}(tindex,:,:)=max(0.,ext_data(dust_file,'dustpo4',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'dustsi'}(tindex,:,:)=max(0.,ext_data(dust_file,'dustsi',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'solubility2'}(tindex,:,:)=max(0.,ext_data(dust_file,'solubility2',tindex,...
+             lon,lat,time,Roa,1));
 end
 close(nc)
 if (makeplot)
diff --git a/Preprocessing_tools/Bio/make_ndepo.m b/Preprocessing_tools/Bio/make_ndepo.m
index 3ad96fe7..1c2c35bb 100644
--- a/Preprocessing_tools/Bio/make_ndepo.m
+++ b/Preprocessing_tools/Bio/make_ndepo.m
@@ -76,26 +76,26 @@ nc('eta_u') = Mp;
 nc('eta_v') = M;
 nc('eta_rho') = Mp;
 %
-nc('ndep_time') = length(time);
-nc{'ndep_time'} = ncdouble('ndep_time') ;
-nc{'ndep'} = ncdouble('ndep_time','eta_rho','xi_rho') ;
-nc{'noyndepo'} = ncdouble('ndep_time','eta_rho','xi_rho') ;
-nc{'nhxndepo'} = ncdouble('ndep_time','eta_rho','xi_rho') ;
-%
-nc{'ndep_time'}.long_name = ncchar('time for nitrogen deposition');
-nc{'ndep_time'}.long_name = 'time for nitrogen deposition';
-nc{'ndep_time'}.units = ncchar('day');
-nc{'ndep_time'}.units = 'day';
+nc('ndepo_time') = length(time);
+nc{'ndepo_time'} = ncdouble('ndepo_time') ;
+nc{'ndepo'} = ncdouble('ndepo_time','eta_rho','xi_rho') ;
+nc{'noyndepo'} = ncdouble('ndepo_time','eta_rho','xi_rho') ;
+nc{'nhxndepo'} = ncdouble('ndepo_time','eta_rho','xi_rho') ;
+%
+nc{'ndepo_time'}.long_name = ncchar('time for nitrogen deposition');
+nc{'ndepo_time'}.long_name = 'time for nitrogen deposition';
+nc{'ndepo_time'}.units = ncchar('day');
+nc{'ndepo_time'}.units = 'day';
 if cycle~=0
-  nc{'ndep_time'}.cycle_length = cycle;
+  nc{'ndepo_time'}.cycle_length = cycle;
 end
 %
-nc{'ndep'}.long_name = ncchar('Nitrogen Deposition');
-nc{'ndep'}.long_name = 'Nitrogen Deposition';
-nc{'ndep'}.units = ncchar('KgN m-2 s-1');
-nc{'ndep'}.units = 'KgN m-2 s-1';
-nc{'ndep'}.fields = ncchar('ndep, scalar, series');
-nc{'ndep'}.fields = 'ndep, scalar, series';
+nc{'ndepo'}.long_name = ncchar('Nitrogen Deposition');
+nc{'ndepo'}.long_name = 'Nitrogen Deposition';
+nc{'ndepo'}.units = ncchar('KgN m-2 s-1');
+nc{'ndepo'}.units = 'KgN m-2 s-1';
+nc{'ndepo'}.fields = ncchar('ndepo, scalar, series');
+nc{'ndepo'}.fields = 'ndepo, scalar, series';
 %
 nc{'noyndepo'}.long_name = ncchar('NOy Deposition');
 nc{'noyndepo'}.long_name = 'NOy Deposition';
@@ -124,7 +124,7 @@ nc.type = ncchar('CROCO biology forcing file');
 nc.type = 'CROCO biology forcing file';
 
 % Write time variable
-nc{'ndep_time'}(:)=time.*30; % if time in month in the dataset !!!
+nc{'ndepo_time'}(:)=time.*30; % if time in month in the dataset !!!
 
 close(nc)
 
@@ -132,13 +132,13 @@ nc=netcdf(bioname,'write');
 %
 % Loop on time
 for tindex=1:length(time)
-  time=nc{'ndep_time'}(tindex);
-  nc{'ndep'}(tindex,:,:)=ext_data(ndep_file,'ndep',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'noyndepo'}(tindex,:,:)=ext_data(ndep_file,'noyndepo',tindex,...
-             lon,lat,time,Roa,1);
-  nc{'nhxndepo'}(tindex,:,:)=ext_data(ndep_file,'nhxndepo',tindex,...
-             lon,lat,time,Roa,1);
+  time=nc{'ndepo_time'}(tindex);
+  nc{'ndepo'}(tindex,:,:)=max(0.,ext_data(ndep_file,'ndep',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'noyndepo'}(tindex,:,:)=max(0.,ext_data(ndep_file,'noyndepo',tindex,...
+             lon,lat,time,Roa,1));
+  nc{'nhxndepo'}(tindex,:,:)=max(0.,ext_data(ndep_file,'nhxndepo',tindex,...
+             lon,lat,time,Roa,1));
 end
 %
 close(nc)
-- 
GitLab