source: Roms_tools/Preprocessing_tools/add_bry_pisces.m @ 1

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

import Roms_Agrif

File size: 14.6 KB
Line 
1function add_bry_pisces(bryname,obc,time,cycle,clobber);
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%                                                                 
4% function add_bry_pisces(bryname,grdname,title,obc...           
5%                         theta_s,theta_b,hc,N,...               
6%                         time,cycle,clobber);                   
7%                                                                 
8%   This function create the header of a Netcdf climatology       
9%   file.                                                         
10%                                                                 
11%   Input:                                                       
12%                                                                 
13%   bryname      Netcdf climatology file name (character string).
14%   obc          open boundaries flag (1=open , [S E N W]).       
15%   time         time.(vector)                                   
16%   cycle        Length (days) for cycling the climatology.(Real)
17%   clobber      Switch to allow or not writing over an existing 
18%                file.(character string)                         
19%
20%  Further Information: 
21%  http://www.brest.ird.fr/Roms_tools/
22
23%  This file is part of ROMSTOOLS
24%
25%  ROMSTOOLS is free software; you can redistribute it and/or modify
26%  it under the terms of the GNU General Public License as published
27%  by the Free Software Foundation; either version 2 of the License,
28%  or (at your option) any later version.
29%
30%  ROMSTOOLS is distributed in the hope that it will be useful, but
31%  WITHOUT ANY WARRANTY; without even the implied warranty of
32%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33%  GNU General Public License for more details.
34%
35%  You should have received a copy of the GNU General Public License
36%  along with this program; if not, write to the Free Software
37%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
38%  MA  02111-1307  USA
39%
40%  Copyright (c) 2001-2006 by Pierrick Penven
41%  e-mail:Pierrick.Penven@ird.fr 
42%  Pierrick Penven, IRD, 2005.                                    %
43%  Olivier Aumont the master, IRD, 2006.                          %
44%  Patricio Marchesiello, chief, IRD, 2007.                       %
45%  Christophe Eugene Raoul Menkes, the slave, IRD, 2007.          %
46%                                                                 %
47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48disp(' ')
49disp([' Adding PISCES data into file : ',bryname])
50disp(' ')
51%
52%  Redefine the boundary file
53%
54nc = netcdf(bryname,clobber);
55result = redef(nc);
56%
57%  Create dimensions
58%
59nc('dic_time')  = length(time);
60nc('doc_time')  = length(time);
61nc('no3_time')  = length(time);
62nc('po4_time')  = length(time);
63nc('talk_time') = length(time);
64nc('si_time')   = length(time);
65nc('fer_time')  = length(time);
66nc('o2_time')   = length(time);
67nc('one') = 1;
68%
69%  Create variables and attributes
70%
71nc{'dic_time'} = ncdouble('dic_time') ;
72nc{'dic_time'}.long_name = ncchar('time for DIC climatology');
73nc{'dic_time'}.long_name = 'time for DIC climatology';
74nc{'dic_time'}.units = ncchar('day');
75nc{'dic_time'}.units = 'day';
76nc{'dic_time'}.cycle_length = cycle;%
77%
78nc{'talk_time'} = ncdouble('talk_time') ;
79nc{'talk_time'}.long_name = ncchar('time for TALK climatology');
80nc{'talk_time'}.long_name = 'time for TALK climatology';
81nc{'talk_time'}.units = ncchar('day');
82nc{'talk_time'}.units = 'day';
83nc{'talk_time'}.cycle_length = cycle;%
84%
85nc{'no3_time'} = ncdouble('no3_time') ;
86nc{'no3_time'}.long_name = ncchar('time for NO3 climatology')
87nc{'no3_time'}.long_name = 'time for NO3 climatology';
88nc{'no3_time'}.units = ncchar('day');
89nc{'no3_time'}.units = 'day';
90nc{'no3_time'}.cycle_length = cycle;%
91%
92nc{'po4_time'} = ncdouble('po4_time') ;
93nc{'po4_time'}.long_name = ncchar('time for PO4 climatology');
94nc{'po4_time'}.long_name = 'time for PO4 climatology';
95nc{'po4_time'}.units = ncchar('day');
96nc{'po4_time'}.units = 'day';
97nc{'po4_time'}.cycle_length = cycle;%
98%
99nc{'si_time'} = ncdouble('si_time') ;
100nc{'si_time'}.long_name = ncchar('time for Si climatology');
101nc{'si_time'}.long_name = 'time for Si climatology';
102nc{'si_time'}.units = ncchar('day');
103nc{'si_time'}.units = 'day';
104nc{'si_time'}.cycle_length = cycle;%
105%
106nc{'o2_time'} = ncdouble('o2_time') ;
107nc{'o2_time'}.long_name = ncchar('time for O2 climatology');
108nc{'o2_time'}.long_name = 'time for O2 climatology';
109nc{'o2_time'}.units = ncchar('day');
110nc{'o2_time'}.units = 'day';
111nc{'o2_time'}.cycle_length = cycle;%
112%
113nc{'doc_time'} = ncdouble('doc_time') ;
114nc{'doc_time'}.long_name = ncchar('time for DOC climatology');
115nc{'doc_time'}.long_name = 'time for DOC climatology';
116nc{'doc_time'}.units = ncchar('day');
117nc{'doc_time'}.units = 'day';
118nc{'doc_time'}.cycle_length = cycle;%
119%
120nc{'fer_time'} = ncdouble('fer_time') ;
121nc{'fer_time'}.long_name = ncchar('time for FER climatology');
122nc{'fer_time'}.long_name = 'time for FER climatology';
123nc{'fer_time'}.units = ncchar('day');
124nc{'fer_time'}.units = 'day';
125nc{'fer_time'}.cycle_length = cycle;%
126%
127if obc(1)==1
128%
129%   Southern boundary
130%
131  nc{'NO3_south'} = ncdouble('no3_time','s_rho','xi_rho') ;
132  nc{'NO3_south'}.long_name = ncchar('southern boundary NO3');
133  nc{'NO3_south'}.long_name = 'southern boundary NO3';
134  nc{'NO3_south'}.units = ncchar('mMol N m-3');
135  nc{'NO3_south'}.units = 'mMol N m-3';
136%
137  nc{'PO4_south'} = ncdouble('po4_time','s_rho','xi_rho') ;
138  nc{'PO4_south'}.long_name = ncchar('southern boundary PO4');
139  nc{'PO4_south'}.long_name = 'southern boundary PO4';
140  nc{'PO4_south'}.units = ncchar('mMol N m-3');
141  nc{'PO4_south'}.units = 'mMol N m-3';
142%
143  nc{'Si_south'} = ncdouble('si_time','s_rho','xi_rho') ;
144  nc{'Si_south'}.long_name = ncchar('southern boundary Si');
145  nc{'Si_south'}.long_name = 'southern boundary Si';
146  nc{'Si_south'}.units = ncchar('mMol N m-3');
147  nc{'Si_south'}.units = 'mMol N m-3';
148%
149  nc{'O2_south'} = ncdouble('o2_time','s_rho','xi_rho') ;
150  nc{'O2_south'}.long_name = ncchar('southern boundary O2');
151  nc{'O2_south'}.long_name = 'southern boundary O2';
152  nc{'O2_south'}.units = ncchar('mMol N m-3');
153  nc{'O2_south'}.units = 'mMol N m-3';
154%
155  nc{'DIC_south'} = ncdouble('dic_time','s_rho','xi_rho') ;
156  nc{'DIC_south'}.long_name = ncchar('southern boundary DIC');
157  nc{'DIC_south'}.long_name = 'southern boundary DIC';
158  nc{'DIC_south'}.units = ncchar('mMol N m-3');
159  nc{'DIC_south'}.units = 'mMol N m-3';
160%
161  nc{'TALK_south'} = ncdouble('talk_time','s_rho','xi_rho') ;
162  nc{'TALK_south'}.long_name = ncchar('southern boundary TALK');
163  nc{'TALK_south'}.long_name = 'southern boundary TALK';
164  nc{'TALK_south'}.units = ncchar('mMol N m-3');
165  nc{'TALK_south'}.units = 'mMol N m-3';
166%
167  nc{'DOC_south'} = ncdouble('doc_time','s_rho','xi_rho') ;
168  nc{'DOC_south'}.long_name = ncchar('southern boundary DOC');
169  nc{'DOC_south'}.long_name = 'southern boundary DOC';
170  nc{'DOC_south'}.units = ncchar('mMol N m-3');
171  nc{'DOC_south'}.units = 'mMol N m-3';
172%
173  nc{'FER_south'} = ncdouble('fer_time','s_rho','xi_rho') ;
174  nc{'FER_south'}.long_name = ncchar('southern boundary Iron');
175  nc{'FER_south'}.long_name = 'southern boundary Iron';
176  nc{'FER_south'}.units = ncchar('mMol N m-3');
177  nc{'FER_south'}.units = 'mMol N m-3';
178%
179end
180%
181if obc(2)==1
182%
183%   Eastern boundary
184%
185  nc{'NO3_east'} = ncdouble('no3_time','s_rho','eta_rho') ;
186  nc{'NO3_east'}.long_name = ncchar('eastern boundary NO3');
187  nc{'NO3_east'}.long_name = 'eastern boundary NO3';
188  nc{'NO3_east'}.units = ncchar('mMol N m-3');
189  nc{'NO3_east'}.units = 'mMol N m-3';
190%
191  nc{'PO4_east'} = ncdouble('po4_time','s_rho','eta_rho') ;
192  nc{'PO4_east'}.long_name = ncchar('eastern boundary PO4');
193  nc{'PO4_east'}.long_name = 'eastern boundary PO4';
194  nc{'PO4_east'}.units = ncchar('mMol N m-3');
195  nc{'PO4_east'}.units = 'mMol N m-3';
196%
197  nc{'Si_east'} = ncdouble('si_time','s_rho','eta_rho') ;
198  nc{'Si_east'}.long_name = ncchar('eastern boundary Si');
199  nc{'Si_east'}.long_name = 'eastern boundary Si';
200  nc{'Si_east'}.units = ncchar('mMol N m-3');
201  nc{'Si_east'}.units = 'mMol N m-3';
202%
203  nc{'O2_east'} = ncdouble('o2_time','s_rho','eta_rho') ;
204  nc{'O2_east'}.long_name = ncchar('eastern boundary O2');
205  nc{'O2_east'}.long_name = 'eastern boundary O2';
206  nc{'O2_east'}.units = ncchar('mMol N m-3');
207  nc{'O2_east'}.units = 'mMol N m-3';
208%
209  nc{'DIC_east'} = ncdouble('dic_time','s_rho','eta_rho') ;
210  nc{'DIC_east'}.long_name = ncchar('eastern boundary DIC');
211  nc{'DIC_east'}.long_name = 'eastern boundary DIC';
212  nc{'DIC_east'}.units = ncchar('mMol N m-3');
213  nc{'DIC_east'}.units = 'mMol N m-3';
214%
215  nc{'TALK_east'} = ncdouble('talk_time','s_rho','eta_rho') ;
216  nc{'TALK_east'}.long_name = ncchar('eastern boundary TALK');
217  nc{'TALK_east'}.long_name = 'eastern boundary TALK';
218  nc{'TALK_east'}.units = ncchar('mMol N m-3');
219  nc{'TALK_east'}.units = 'mMol N m-3';
220%
221  nc{'DOC_east'} = ncdouble('doc_time','s_rho','eta_rho') ;
222  nc{'DOC_east'}.long_name = ncchar('eastern boundary DOC');
223  nc{'DOC_east'}.long_name = 'eastern boundary DOC';
224  nc{'DOC_east'}.units = ncchar('mMol N m-3');
225  nc{'DOC_east'}.units = 'mMol N m-3';
226%
227  nc{'FER_east'} = ncdouble('fer_time','s_rho','eta_rho') ;
228  nc{'FER_east'}.long_name = ncchar('eastern boundary Iron');
229  nc{'FER_east'}.long_name = 'eastern boundary Iron';
230  nc{'FER_east'}.units = ncchar('mMol N m-3');
231  nc{'FER_east'}.units = 'mMol N m-3';
232%
233end
234%
235if obc(3)==1
236%
237%   Northern boundary
238%
239  nc{'NO3_north'} = ncdouble('no3_time','s_rho','xi_rho') ;
240  nc{'NO3_north'}.long_name = ncchar('northern boundary NO3');
241  nc{'NO3_north'}.long_name = 'northern boundary NO3';
242  nc{'NO3_north'}.units = ncchar('mMol N m-3');
243  nc{'NO3_north'}.units = 'mMol N m-3';
244%
245  nc{'PO4_north'} = ncdouble('po4_time','s_rho','xi_rho') ;
246  nc{'PO4_north'}.long_name = ncchar('northern boundary PO4');
247  nc{'PO4_north'}.long_name = 'northern boundary PO4';
248  nc{'PO4_north'}.units = ncchar('mMol N m-3');
249  nc{'PO4_north'}.units = 'mMol N m-3';
250%
251  nc{'Si_north'} = ncdouble('si_time','s_rho','xi_rho') ;
252  nc{'Si_north'}.long_name = ncchar('northern boundary Si');
253  nc{'Si_north'}.long_name = 'northern boundary Si';
254  nc{'Si_north'}.units = ncchar('mMol N m-3');
255  nc{'Si_north'}.units = 'mMol N m-3';
256%
257  nc{'O2_north'} = ncdouble('o2_time','s_rho','xi_rho') ;
258  nc{'O2_north'}.long_name = ncchar('northern boundary O2');
259  nc{'O2_north'}.long_name = 'northern boundary O2';
260  nc{'O2_north'}.units = ncchar('mMol N m-3');
261  nc{'O2_north'}.units = 'mMol N m-3';
262%
263  nc{'DIC_north'} = ncdouble('dic_time','s_rho','xi_rho') ;
264  nc{'DIC_north'}.long_name = ncchar('northern boundary DIC');
265  nc{'DIC_north'}.long_name = 'northern boundary DIC';
266  nc{'DIC_north'}.units = ncchar('mMol N m-3');
267  nc{'DIC_north'}.units = 'mMol N m-3';
268%
269  nc{'TALK_north'} = ncdouble('talk_time','s_rho','xi_rho') ;
270  nc{'TALK_north'}.long_name = ncchar('northern boundary TALK');
271  nc{'TALK_north'}.long_name = 'northern boundary TALK';
272  nc{'TALK_north'}.units = ncchar('mMol N m-3');
273  nc{'TALK_north'}.units = 'mMol N m-3';
274%
275  nc{'DOC_north'} = ncdouble('doc_time','s_rho','xi_rho') ;
276  nc{'DOC_north'}.long_name = ncchar('northern boundary DOC');
277  nc{'DOC_north'}.long_name = 'northern boundary DOC';
278  nc{'DOC_north'}.units = ncchar('mMol N m-3');
279  nc{'DOC_north'}.units = 'mMol N m-3';
280%
281  nc{'FER_north'} = ncdouble('fer_time','s_rho','xi_rho') ;
282  nc{'FER_north'}.long_name = ncchar('northern boundary Iron');
283  nc{'FER_north'}.long_name = 'northern boundary Iron';
284  nc{'FER_north'}.units = ncchar('mMol N m-3');
285  nc{'FER_north'}.units = 'mMol N m-3';
286%
287end
288%
289if obc(4)==1
290%
291%   Western boundary
292%
293  nc{'NO3_west'} = ncdouble('no3_time','s_rho','eta_rho') ;
294  nc{'NO3_west'}.long_name = ncchar('western boundary NO3');
295  nc{'NO3_west'}.long_name = 'western boundary NO3';
296  nc{'NO3_west'}.units = ncchar('mMol N m-3');
297  nc{'NO3_west'}.units = 'mMol N m-3';
298%
299  nc{'PO4_west'} = ncdouble('po4_time','s_rho','eta_rho') ;
300  nc{'PO4_west'}.long_name = ncchar('western boundary PO4');
301  nc{'PO4_west'}.long_name = 'western boundary PO4';
302  nc{'PO4_west'}.units = ncchar('mMol N m-3');
303  nc{'PO4_west'}.units = 'mMol N m-3';
304%
305  nc{'Si_west'} = ncdouble('si_time','s_rho','eta_rho') ;
306  nc{'Si_west'}.long_name = ncchar('western boundary Si');
307  nc{'Si_west'}.long_name = 'western boundary Si';
308  nc{'Si_west'}.units = ncchar('mMol N m-3');
309  nc{'Si_west'}.units = 'mMol N m-3';
310%
311  nc{'O2_west'} = ncdouble('o2_time','s_rho','eta_rho') ;
312  nc{'O2_west'}.long_name = ncchar('western boundary O2');
313  nc{'O2_west'}.long_name = 'western boundary O2';
314  nc{'O2_west'}.units = ncchar('mMol N m-3');
315  nc{'O2_west'}.units = 'mMol N m-3';
316%
317  nc{'DIC_west'} = ncdouble('dic_time','s_rho','eta_rho') ;
318  nc{'DIC_west'}.long_name = ncchar('western boundary DIC');
319  nc{'DIC_west'}.long_name = 'western boundary DIC';
320  nc{'DIC_west'}.units = ncchar('mMol N m-3');
321  nc{'DIC_west'}.units = 'mMol N m-3';
322%
323  nc{'TALK_west'} = ncdouble('talk_time','s_rho','eta_rho') ;
324  nc{'TALK_west'}.long_name = ncchar('western boundary TALK');
325  nc{'TALK_west'}.long_name = 'western boundary TALK';
326  nc{'TALK_west'}.units = ncchar('mMol N m-3');
327  nc{'TALK_west'}.units = 'mMol N m-3';
328%
329  nc{'DOC_west'} = ncdouble('doc_time','s_rho','eta_rho') ;
330  nc{'DOC_west'}.long_name = ncchar('western boundary DOC');
331  nc{'DOC_west'}.long_name = 'western boundary DOC';
332  nc{'DOC_west'}.units = ncchar('mMol N m-3');
333  nc{'DOC_west'}.units = 'mMol N m-3';
334%
335  nc{'FER_west'} = ncdouble('fer_time','s_rho','eta_rho') ;
336  nc{'FER_west'}.long_name = ncchar('western boundary Iron');
337  nc{'FER_west'}.long_name = 'western boundary Iron';
338  nc{'FER_west'}.units = ncchar('mMol N m-3');
339  nc{'FER_west'}.units = 'mMol N m-3';
340%
341end
342%
343% Leave define mode
344%
345result = endef(nc);
346%
347% Write variables
348%
349nc{'dic_time'}(:) = time;
350nc{'doc_time'}(:) = time;
351nc{'no3_time'}(:) = time;
352nc{'po4_time'}(:) = time;
353nc{'talk_time'}(:) = time;
354nc{'si_time'}(:) = time;
355nc{'fer_time'}(:) = time;
356nc{'o2_time'}(:) = time;
357if obc(1)==1
358  nc{'NO3_south'}(:)  =  0;
359  nc{'PO4_south'}(:)  =  0;
360  nc{'Si_south'}(:) =  0;
361  nc{'O2_south'}(:)   =  0;
362  nc{'DIC_south'}(:)  =  0;
363  nc{'TALK_south'}(:) =  0;
364  nc{'DOC_south'}(:)  =  0;
365  nc{'FER_south'}(:)  =  0;
366end
367if obc(2)==1
368  nc{'NO3_east'}(:)  =  0;
369  nc{'PO4_east'}(:)  =  0;
370  nc{'Si_east'}(:) =  0;
371  nc{'O2_east'}(:)   =  0;
372  nc{'DIC_east'}(:)  =  0;
373  nc{'TALK_east'}(:) =  0;
374  nc{'DOC_east'}(:)  =  0;
375  nc{'FER_east'}(:)  =  0;
376end
377if obc(3)==1
378  nc{'NO3_north'}(:)  =  0;
379  nc{'PO4_north'}(:)  =  0;
380  nc{'Si_north'}(:) =  0;
381  nc{'O2_north'}(:)   =  0;
382  nc{'DIC_north'}(:)  =  0;
383  nc{'TALK_north'}(:) =  0;
384  nc{'DOC_north'}(:)  =  0;
385  nc{'FER_north'}(:)  =  0;
386end
387if obc(4)==1
388  nc{'NO3_west'}(:)  =  0;
389  nc{'PO4_west'}(:)  =  0;
390  nc{'Si_west'}(:) =  0;
391  nc{'O2_west'}(:)   =  0;
392  nc{'DIC_west'}(:)  =  0;
393  nc{'TALK_west'}(:) =  0;
394  nc{'DOC_west'}(:)  =  0;
395  nc{'FER_west'}(:)  =  0;
396end
397close(nc)
398return
399
Note: See TracBrowser for help on using the repository browser.