1 | function 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 | % |
---|
42 | theta=0.5; |
---|
43 | % |
---|
44 | disp('Add_phyto: creating variable and attribute') |
---|
45 | % |
---|
46 | % open the clim file |
---|
47 | % |
---|
48 | nc=netcdf(climfile,'write'); |
---|
49 | time= nc{'chla_time'}(:); |
---|
50 | cycle= nc{'chla_time'}.cycle_length(:); |
---|
51 | tlen=length(time); |
---|
52 | redef(nc); |
---|
53 | nc('phyto_time') = tlen; |
---|
54 | nc{'phyto_time'} = ncdouble('phyto_time') ; |
---|
55 | nc{'PHYTO'} = ncdouble('phyto_time','s_rho','eta_rho','xi_rho') ; |
---|
56 | % |
---|
57 | nc{'phyto_time'}.long_name = ncchar('time for phytoplankton'); |
---|
58 | nc{'phyto_time'}.long_name = 'time for phytoplankton'; |
---|
59 | nc{'phyto_time'}.units = ncchar('day'); |
---|
60 | nc{'phyto_time'}.units = 'day'; |
---|
61 | if cycle~=0 |
---|
62 | nc{'phyto_time'}.cycle_length = cycle; |
---|
63 | end |
---|
64 | % |
---|
65 | nc{'PHYTO'}.long_name = ncchar('Phytoplankton'); |
---|
66 | nc{'PHYTO'}.long_name = 'Phytoplankton'; |
---|
67 | nc{'PHYTO'}.units = ncchar('mMol N m-3'); |
---|
68 | nc{'PHYTO'}.units = 'mMol N m-3'; |
---|
69 | nc{'PHYTO'}.fields = ncchar('PHYTO, scalar, series'); |
---|
70 | nc{'PHYTO'}.fields = 'PHYTO, scalar, series'; |
---|
71 | % |
---|
72 | endef(nc); |
---|
73 | % |
---|
74 | % record the time |
---|
75 | % |
---|
76 | nc{'phyto_time'}(:)=time; |
---|
77 | % |
---|
78 | % loop on time |
---|
79 | % |
---|
80 | for l=1:tlen |
---|
81 | disp(['time index: ',num2str(l),' of total: ',num2str(tlen)]) |
---|
82 | nc{'PHYTO'}(l,:,:,:)=theta*squeeze(nc{'CHLA'}(l,:,:,:)); |
---|
83 | end |
---|
84 | close(nc); |
---|
85 | return |
---|