Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8bf77373 authored by Christian Ethe's avatar Christian Ethe
Browse files

Minor improvments to create PISCES atmospheric deposition files for one or several childsgrid

parent 3633d417
No related branches found
No related tags found
1 merge request!23Resolve "PISCES external inputs for nesting"
...@@ -37,7 +37,7 @@ close(nc); ...@@ -37,7 +37,7 @@ close(nc);
Lp=L+1; Lp=L+1;
Mp=M+1; Mp=M+1;
nw = netcdf(dustname, 'clobber'); nw = netcdf(dustname, 'clobber');
%redef(nw); redef(nw);
% %
% Create dimensions % Create dimensions
% %
...@@ -70,7 +70,39 @@ nw{'dust'}.units = 'nmol Fe m-3'; ...@@ -70,7 +70,39 @@ nw{'dust'}.units = 'nmol Fe m-3';
nw{'dust'}.field = ncchar('Fe Dust Deposition, scalar, series'); nw{'dust'}.field = ncchar('Fe Dust Deposition, scalar, series');
nw{'dust'}.field = 'Fe Dust Deposition, scalar, series'; nw{'dust'}.field = 'Fe Dust Deposition, scalar, series';
%endef(nw); nw{'dustfer'} = ncdouble('dust_time', 'eta_rho', 'xi_rho');
nw{'dustfer'}.long_name = ncchar('Fe Dust Deposition');
nw{'dustfer'}.long_name = 'Fe Dust Deposition';
nw{'dustfer'}.units = ncchar('Kg m-2 s-1');
nw{'dustfer'}.units = 'Kg m-2 s-1';
nw{'dustfer'}.field = ncchar('dustfer, scalar, series');
nw{'dustfer'}.field = 'dustfer, scalar, series';
%
nw{'dustpo4'} = ncdouble('dust_time', 'eta_rho', 'xi_rho');
nw{'dustpo4'}.long_name = ncchar('PO4 Dust Deposition');
nw{'dustpo4'}.long_name = 'PO4 Dust Deposition';
nw{'dustpo4'}.units = ncchar('Kg m-2 s-1');
nw{'dustpo4'}.units = 'Kg m-2 s-1';
nw{'dustpo4'}.field = ncchar('dustpo4, scalar, series');
nw{'dustpo4'}.field = 'dustpo4, scalar, series';
%
nw{'dustsi'} = ncdouble('dust_time', 'eta_rho', 'xi_rho');
nw{'dustsi'}.long_name = ncchar('Si Dust Deposition');
nw{'dustsi'}.long_name = 'Si Dust Deposition';
nw{'dustsi'}.units = ncchar('Kg m-2 s-1');
nw{'dustsi'}.units = 'Kg m-2 s-1';
nw{'dustsi'}.field = ncchar('dustsi, scalar, series');
nw{'dustsi'}.field = 'dustsi, scalar, series';
%
nw{'solubility2'} = ncdouble('dust_time', 'eta_rho', 'xi_rho');
nw{'solubility2'}.long_name = ncchar('Fe solubility from Mahowald');
nw{'solubility2'}.long_name = 'Fe solubility from Mahowald';
nw{'solubility2'}.units = ncchar('%');
nw{'solubility2'}.units = '%';
nw{'solubility2'}.field = ncchar('solubility2, scalar, series');
nw{'solubility2'}.field = 'solubility2, scalar, series';
endef(nw);
% %
% Create global attributes % Create global attributes
......
function create_nestedndepo(ndeponame,parentname,grdname,title,ndepot,ndepoc)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Create an empty netcdf ndepo forcing file (for PISCES)
% ndeponame: name of the ndepo file
% grdname: name of the grid file
% title: title in the netcdf file
%
% Further Information:
% http://www.croco-ocean.org
%
% This file is part of CROCOTOOLS
%
% CROCOTOOLS is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% CROCOTOOLS is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston,
% MA 02111-1307 USA
%
% Copyright (c) 2004-2006 by Pierrick Penven
% e-mail:Pierrick.Penven@ird.fr
% Update : Gildas Cambon 13 Oct 2009
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nc=netcdf(grdname);
L=length(nc('xi_psi'));
M=length(nc('eta_psi'));
close(nc);
Lp=L+1;
Mp=M+1;
nw = netcdf(ndeponame, 'clobber');
redef(nw);
%
% Create dimensions
%
nw('xi_u') = L;
nw('eta_u') = Mp;
nw('xi_v') = Lp;
nw('eta_v') = M;
nw('xi_rho') = Lp;
nw('eta_rho') = Mp;
nw('xi_psi') = L;
nw('eta_psi') = M;
nw('ndepo_time') = length(ndepot);
%
% Create variables and attributes
%
nw{'ndepo_time'} = ncdouble('ndepo_time');
nw{'ndepo_time'}.long_name = ncchar('ndepo time');
nw{'ndepo_time'}.long_name = 'ndepo time';
nw{'ndepo_time'}.units = ncchar('days');
nw{'ndepo_time'}.units = 'days';
nw{'ndepo_time'}.cycle_length = ndepoc;
nw{'ndepo_time'}.field = ncchar('time, scalar, series');
nw{'ndepo_time'}.field = 'time, scalar, series';
%
nw{'ndepo'} = ncdouble('ndepo_time', 'eta_rho', 'xi_rho');
nw{'ndepo'}.long_name = ncchar('Nitrogen Deposition');
nw{'ndepo'}.long_name = 'Nitrogen Deposition';
nw{'ndepo'}.units = ncchar('KgN m-2 s-1');
nw{'ndepo'}.units = 'KgN m-2 s-1';
nw{'ndepo'}.field = ncchar('ndepo, scalar, series');
nw{'ndepo'}.field = 'ndepo, scalar, series';
%
nw{'noyndepo'} = ncdouble('ndepo_time', 'eta_rho', 'xi_rho');
nw{'noyndepo'}.long_name = ncchar('NOy Deposition');
nw{'noyndepo'}.long_name = 'NOy Deposition';
nw{'noyndepo'}.units = ncchar('KgN m-2 s-1');
nw{'noyndepo'}.units = 'KgN m-2 s-1';
nw{'noyndepo'}.field = ncchar('noyndepo, scalar, series');
nw{'noyndepo'}.field = 'noyndepo, scalar, series';
%
nw{'nhxndepo'} = ncdouble('ndepo_time', 'eta_rho', 'xi_rho');
nw{'nhxndepo'}.long_name = ncchar('NHx Deposition');
nw{'nhxndepo'}.long_name = 'NHx Deposition';
nw{'nhxndepo'}.units = ncchar('KgN m-2 s-1');
nw{'nhxndepo'}.units = 'KgN m-2 s-1';
nw{'nhxndepo'}.field = ncchar('nhxndepo, scalar, series');
nw{'nhxndepo'}.field = 'nhxndepo, scalar, series';
%
endef(nw);
%
% Create global attributes
%
nw.title = ncchar(title);
nw.title = title;
nw.date = ncchar(date);
nw.date = date;
nw.grd_file = ncchar(grdname);
nw.grd_file = grdname;
nw.parent_file = ncchar(parentname);
nw.parent_file = parentname;
%
% Write time variables
%
nw{'ndepo_time'}(:) = ndepot;
close(nw);
return
...@@ -57,7 +57,7 @@ elseif (nvar <= 41 & biol) ...@@ -57,7 +57,7 @@ elseif (nvar <= 41 & biol)
disp(['Compute Biogeochemical variables type NPZD : ']) disp(['Compute Biogeochemical variables type NPZD : '])
disp(['NChlPZD or N2ChlPZD2 ']) disp(['NChlPZD or N2ChlPZD2 '])
disp('==========================') disp('==========================')
elseif (46 <= nvar <=47 & biobus) elseif (46 <= nvar <=47 & bioebus)
timebiol={'no3_time';'o2_time';'chla_time';'sphyto_time';'lphyto_time';'szoo_time';'lzoo_time';'n2o_time'}; timebiol={'no3_time';'o2_time';'chla_time';'sphyto_time';'lphyto_time';'szoo_time';'lzoo_time';'n2o_time'};
cyclebiol={'no3_cyle';'o2_cycle';'chla_cycle';'sphyto_cycle';'lphyto_cycle';'szoo_cycle';'lzoo_cycle';'n2o_cycle'}; cyclebiol={'no3_cyle';'o2_cycle';'chla_cycle';'sphyto_cycle';'lphyto_cycle';'szoo_cycle';'lzoo_cycle';'n2o_cycle'};
namebiol={'NO3';'O2';'CHLA';'SPHYTO';'LPHYTO';'SZOO';'LZOO';'N2O'}; namebiol={'NO3';'O2';'CHLA';'SPHYTO';'LPHYTO';'SZOO';'LZOO';'N2O'};
......
...@@ -102,6 +102,10 @@ nc=netcdf(child_dust,'write'); ...@@ -102,6 +102,10 @@ nc=netcdf(child_dust,'write');
disp('dust...') disp('dust...')
for tindex=1:length(dustt) for tindex=1:length(dustt)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'dust',mask,tindex) interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'dust',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'dustfer',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'dustpo4',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'dustsi',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'solubility2',mask,tindex)
end end
result=close(np); result=close(np);
result=close(nc); result=close(nc);
......
function nested_ndepo(child_grd,parent_ndepo,child_ndepo)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% compute the ndepo file (PISCES biogeochemical model)
% of the embedded grid
%
% Further Information:
% http://www.croco-ocean.org
%
% This file is part of CROCOTOOLS
%
% CROCOTOOLS is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% CROCOTOOLS is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston,
% MA 02111-1307 USA
%
% Copyright (c) 2004-2006 by Pierrick Penven
% e-mail:Pierrick.Penven@ird.fr
% Update : Gildas Cambon: 13 Nov 2009
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
extrapmask=0;
%
% Title
%
title=['ndepo file for the embedded grid :',child_ndepo,...
' using parent ndepo file: ',parent_ndepo];
disp(' ')
disp(title)
%
% Read in the embedded grid
%
disp(' ')
disp(' Read in the embedded grid...')
nc=netcdf(child_grd);
parent_grd=nc.parent_grid(:);
imin=nc{'grd_pos'}(1);
imax=nc{'grd_pos'}(2);
jmin=nc{'grd_pos'}(3);
jmax=nc{'grd_pos'}(4);
refinecoeff=nc{'refine_coef'}(:);
result=close(nc);
nc=netcdf(parent_grd);
Lp=length(nc('xi_rho'));
Mp=length(nc('eta_rho'));
if extrapmask==1
mask=nc{'mask_rho'}(:);
else
mask=[];
end
result=close(nc);
%
% Read in the parent ndepo file
%
disp(' ')
disp(' Read in the parent ndepo file...')
nc = netcdf(parent_ndepo);
ndepot = nc{'ndepo_time'}(:);
ndepoc = nc{'ndepo_time'}.cycle_length(:);
result=close(nc);
%
% Create the ndepo file
%
disp(' ')
disp(' Create the ndepo file...')
create_nestedndepo(child_ndepo,parent_ndepo,child_grd,title,...
ndepot,ndepoc)
%
% parent indices
%
[igrd_r,jgrd_r]=meshgrid((1:1:Lp),(1:1:Mp));
[igrd_p,jgrd_p]=meshgrid((1:1:Lp-1),(1:1:Mp-1));
[igrd_u,jgrd_u]=meshgrid((1:1:Lp-1),(1:1:Mp));
[igrd_v,jgrd_v]=meshgrid((1:1:Lp),(1:1:Mp-1));
%
% the children indices
%
ipchild=(imin:1/refinecoeff:imax);
jpchild=(jmin:1/refinecoeff:jmax);
irchild=(imin+0.5-0.5/refinecoeff:1/refinecoeff:imax+0.5+0.5/refinecoeff);
jrchild=(jmin+0.5-0.5/refinecoeff:1/refinecoeff:jmax+0.5+0.5/refinecoeff);
[ichildgrd_p,jchildgrd_p]=meshgrid(ipchild,jpchild);
[ichildgrd_r,jchildgrd_r]=meshgrid(irchild,jrchild);
[ichildgrd_u,jchildgrd_u]=meshgrid(ipchild,jrchild);
[ichildgrd_v,jchildgrd_v]=meshgrid(irchild,jpchild);
%
% interpolations
%
disp(' ')
disp(' Do the interpolations...')
np=netcdf(parent_ndepo);
nc=netcdf(child_ndepo,'write');
disp('ndepo...')
for tindex=1:length(ndepot)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'ndepo',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'noyndepo',mask,tindex)
interpvar3d(np,nc,igrd_r,jgrd_r,ichildgrd_r,jchildgrd_r,'noyndepo',mask,tindex)
end
result=close(np);
result=close(nc);
disp(' ')
disp(' Done ')
%
% Make a plot
%
disp(' ')
disp(' Make a plot...')
figure(1)
plot_nestndepo(child_ndepo,'ndepo',[1 6],1)
function plot_nestndepo(child_ndepo,thefield,thetime,skip)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Test the embedded ndepo forcing file.
%
% Further Information:
% http://www.croco-ocean.org
%
% This file is part of CROCOTOOLS
%
% CROCOTOOLS is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% CROCOTOOLS is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston,
% MA 02111-1307 USA
%
% Copyright (c) 2004-2006 by Pierrick Penven
% e-mail:Pierrick.Penven@ird.fr
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
npts=[0 0 0 0];
i=0;
for time=thetime
i=i+1;
subplot(2,length(thetime),i)
nc=netcdf(child_ndepo);
parent_ndepo=nc.parent_file(:);
child_grd=nc.grd_file(:);
fieldc=nc{thefield}(time,:,:);
fieldname=nc{thefield}.long_name(:);
result=close(nc);
nc=netcdf(child_grd);
parent_grd=nc.parent_grid(:);
refinecoeff=nc{'refine_coef'}(:);
lonc=nc{'lon_rho'}(:);
latc=nc{'lat_rho'}(:);
mask=nc{'mask_rho'}(:);
result=close(nc);
mask(mask==0)=NaN;
pcolor(lonc,latc,mask.*fieldc)
shading flat
axis image
caxis([min(min(fieldc)) max(max(fieldc))])
colorbar
axis([min(min(lonc)) max(max(lonc)) min(min(latc)) max(max(latc))])
title(['\bf ',fieldname,' CHILD'])
subplot(2,length(thetime),i+length(thetime))
nc=netcdf(parent_ndepo);
field=nc{thefield}(time,:,:);
fieldname=nc{thefield}.long_name(:);
result=close(nc);
nc=netcdf(parent_grd);
lon=nc{'lon_rho'}(:);
lat=nc{'lat_rho'}(:);
mask=nc{'mask_rho'}(:);
result=close(nc);
mask(mask==0)=NaN;
pcolor(lon,lat,mask.*field)
shading flat
axis image
caxis([min(min(fieldc)) max(max(fieldc))])
colorbar
axis([min(min(lonc)) max(max(lonc)) min(min(latc)) max(max(latc))])
title(['\bf ',fieldname,' PARENT'])
end
return
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment