source: Roms_tools/Preprocessing_tools/add_phyto.m @ 2

Last change on this file since 2 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 2.5 KB
Line 
1function add_phyto(climfile);
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%
4%  function add_phyto(climfile);
5%
6%  Add phytoplancton (mMol N m-3)  in a ROMS climatology file.
7%  take the chlorophyll (mg C) from the climatology file and
8%  multiply by the ratio chlorophyll / phytoplancton derived
9%  from previous simulations.
10%
11%  phyto = 0.5 * chla
12%
13%  input:
14%   
15%    climfile      : roms climatology file to process (netcdf)
16%
17%  Further Information: 
18%  http://www.brest.ird.fr/Roms_tools/
19
20%  This file is part of ROMSTOOLS
21%
22%  ROMSTOOLS is free software; you can redistribute it and/or modify
23%  it under the terms of the GNU General Public License as published
24%  by the Free Software Foundation; either version 2 of the License,
25%  or (at your option) any later version.
26%
27%  ROMSTOOLS is distributed in the hope that it will be useful, but
28%  WITHOUT ANY WARRANTY; without even the implied warranty of
29%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30%  GNU General Public License for more details.
31%
32%  You should have received a copy of the GNU General Public License
33%  along with this program; if not, write to the Free Software
34%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
35%  MA  02111-1307  USA
36%
37%  Copyright (c) 2001-2006 by Pierrick Penven
38%  e-mail:Pierrick.Penven@ird.fr 
39%
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41%
42theta=0.5;
43%
44disp('Add_phyto: creating variable and attribute')
45%
46% open the clim file 
47%
48nc=netcdf(climfile,'write');
49time= nc{'chla_time'}(:);
50cycle= nc{'chla_time'}.cycle_length(:);
51tlen=length(time);
52redef(nc);
53nc('phyto_time') = tlen;
54nc{'phyto_time'} = ncdouble('phyto_time') ;
55nc{'PHYTO'} = ncdouble('phyto_time','s_rho','eta_rho','xi_rho') ;
56%
57nc{'phyto_time'}.long_name = ncchar('time for phytoplankton');
58nc{'phyto_time'}.long_name = 'time for phytoplankton';
59nc{'phyto_time'}.units = ncchar('day');
60nc{'phyto_time'}.units = 'day';
61if cycle~=0
62  nc{'phyto_time'}.cycle_length = cycle;
63end
64%
65nc{'PHYTO'}.long_name = ncchar('Phytoplankton');
66nc{'PHYTO'}.long_name = 'Phytoplankton';
67nc{'PHYTO'}.units = ncchar('mMol N m-3');
68nc{'PHYTO'}.units = 'mMol N m-3';
69nc{'PHYTO'}.fields = ncchar('PHYTO, scalar, series');
70nc{'PHYTO'}.fields = 'PHYTO, scalar, series';
71%
72endef(nc);
73%
74% record the time
75%
76nc{'phyto_time'}(:)=time;
77%
78% loop on time
79%
80for l=1:tlen
81  disp(['time index: ',num2str(l),' of total: ',num2str(tlen)])
82  nc{'PHYTO'}(l,:,:,:)=theta*squeeze(nc{'CHLA'}(l,:,:,:));
83end
84close(nc);
85return
Note: See TracBrowser for help on using the repository browser.