source: Roms_tools/Preprocessing_tools/create_bry_Z.m @ 2

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

import Roms_Agrif

File size: 5.7 KB
Line 
1function create_bry_Z(zbryname,grdname,title,obc,...
2                      Z,time,cycle,clobber);
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4%
5%   This function create the header of a Netcdf boundary
6%   file (on a z grid).
7%
8%   Input:
9%
10%   zbryname     Netcdf climatology file name (character string).
11%   grdname      Netcdf grid file name (character string).
12%   obc          open boundaries flag (1=open , [S E N W]).
13%   Z            Depth of vertical levels.(Vector)
14%   time         time.(vector)
15%   cycle        Length (days) for cycling the climatology.(Real)
16%   clobber      Switch to allow or not writing over an existing
17%                file.(character string)
18%
19%  Further Information: 
20%  http://www.brest.ird.fr/Roms_tools/
21
22%  This file is part of ROMSTOOLS
23%
24%  ROMSTOOLS is free software; you can redistribute it and/or modify
25%  it under the terms of the GNU General Public License as published
26%  by the Free Software Foundation; either version 2 of the License,
27%  or (at your option) any later version.
28%
29%  ROMSTOOLS is distributed in the hope that it will be useful, but
30%  WITHOUT ANY WARRANTY; without even the implied warranty of
31%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32%  GNU General Public License for more details.
33%
34%  You should have received a copy of the GNU General Public License
35%  along with this program; if not, write to the Free Software
36%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37%  MA  02111-1307  USA
38%
39%  Copyright (c) 2001-2006 by Pierrick Penven
40%  e-mail:Pierrick.Penven@ird.fr 
41%
42%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43disp(' ')
44disp([' Creating the file : ',zbryname])
45disp(' ')
46%
47%  Read the grid file and check the topography
48%
49nc = netcdf(grdname, 'nowrite');
50Lp=length(nc('xi_rho'));
51Mp=length(nc('eta_rho'));
52status=close(nc);
53L=Lp-1;
54M=Mp-1;
55%
56%  Create the boundary file
57%
58type = 'BOUNDARY Z (or OA) file' ;
59history = 'ROMS' ;
60nc = netcdf(zbryname,clobber);
61result = redef(nc);
62%
63%  Create dimensions
64%
65nc('xi_u') = L;
66nc('xi_rho') = Lp;
67nc('eta_v') = M;
68nc('eta_rho') = Mp;
69nc('Z') = length(Z);
70nc('bry_time') = length(time);
71nc('one') = 1;
72%
73%  Create variables and attributes
74%
75nc{'Z'} = ncdouble('Z') ;
76nc{'Z'}.long_name = ncchar('Depth');
77nc{'Z'}.long_name = 'Depth';
78nc{'Z'}.units = ncchar('m');
79nc{'Z'}.units = 'm';
80%
81nc{'bry_time'} = ncdouble('bry_time') ;
82nc{'bry_time'}.long_name = ncchar('time for temperature climatology');
83nc{'bry_time'}.long_name = 'time for temperature climatology';
84nc{'bry_time'}.units = ncchar('day');
85nc{'bry_time'}.units = 'day';
86nc{'bry_time'}.cycle_length = cycle;%
87%
88if obc(1)==1
89%
90%   Southern boundary
91%
92  nc{'temp_south'} = ncdouble('bry_time','Z','xi_rho') ;
93  nc{'temp_south'}.long_name = ncchar('southern boundary potential temperature');
94  nc{'temp_south'}.long_name = 'southern boundary potential temperature';
95  nc{'temp_south'}.units = ncchar('Celsius');
96  nc{'temp_south'}.units = 'Celsius';
97%
98  nc{'salt_south'} = ncdouble('bry_time','Z','xi_rho') ;
99  nc{'salt_south'}.long_name = ncchar('southern boundary salinity');
100  nc{'salt_south'}.long_name = 'southern boundary salinity';
101  nc{'salt_south'}.units = ncchar('PSU');
102  nc{'salt_south'}.units = 'PSU';
103%
104end
105%
106if obc(2)==1
107%
108%   Eastern boundary
109%
110  nc{'temp_east'} = ncdouble('bry_time','Z','eta_rho') ;
111  nc{'temp_east'}.long_name = ncchar('eastern boundary potential temperature');
112  nc{'temp_east'}.long_name = 'eastern boundary potential temperature';
113  nc{'temp_east'}.units = ncchar('Celsius');
114  nc{'temp_east'}.units = 'Celsius';
115%
116  nc{'salt_east'} = ncdouble('bry_time','Z','eta_rho') ;
117  nc{'salt_east'}.long_name = ncchar('eastern boundary salinity');
118  nc{'salt_east'}.long_name = 'eastern boundary salinity';
119  nc{'salt_east'}.units = ncchar('PSU');
120  nc{'salt_east'}.units = 'PSU';
121%
122end
123%
124if obc(3)==1
125%
126%   Northern boundary
127%
128  nc{'temp_north'} = ncdouble('bry_time','Z','xi_rho') ;
129  nc{'temp_north'}.long_name = ncchar('northern boundary potential temperature');
130  nc{'temp_north'}.long_name = 'northern boundary potential temperature';
131  nc{'temp_north'}.units = ncchar('Celsius');
132  nc{'temp_north'}.units = 'Celsius';
133%
134  nc{'salt_north'} = ncdouble('bry_time','Z','xi_rho') ;
135  nc{'salt_north'}.long_name = ncchar('northern boundary salinity');
136  nc{'salt_north'}.long_name = 'northern boundary salinity';
137  nc{'salt_north'}.units = ncchar('PSU');
138  nc{'salt_north'}.units = 'PSU';
139%
140end
141%
142if obc(4)==1
143%
144%   Western boundary
145%
146  nc{'temp_west'} = ncdouble('bry_time','Z','eta_rho') ;
147  nc{'temp_west'}.long_name = ncchar('western boundary potential temperature');
148  nc{'temp_west'}.long_name = 'western boundary potential temperature';
149  nc{'temp_west'}.units = ncchar('Celsius');
150  nc{'temp_west'}.units = 'Celsius';
151%
152  nc{'salt_west'} = ncdouble('bry_time','Z','eta_rho') ;
153  nc{'salt_west'}.long_name = ncchar('western boundary salinity');
154  nc{'salt_west'}.long_name = 'western boundary salinity';
155  nc{'salt_west'}.units = ncchar('PSU');
156  nc{'salt_west'}.units = 'PSU';
157%
158end
159%
160%
161% Create global attributes
162%
163nc.title = ncchar(title);
164nc.title = title;
165nc.date = ncchar(date);
166nc.date = date;
167nc.clim_file = ncchar(zbryname);
168nc.clim_file = zbryname;
169nc.grd_file = ncchar(grdname);
170nc.grd_file = grdname;
171nc.type = ncchar(type);
172nc.type = type;
173nc.history = ncchar(history);
174nc.history = history;
175%
176% Leave define mode
177%
178result = endef(nc);
179%
180% Write variables
181%
182nc{'Z'}(:) =  Z;
183nc{'bry_time'}(:) =  time;
184if obc(1)==1
185  nc{'temp_south'}(:) =  0;
186  nc{'salt_south'}(:) =  0;
187end
188if obc(2)==1
189  nc{'temp_east'}(:) =  0;
190  nc{'salt_east'}(:) =  0;
191end
192if obc(3)==1
193  nc{'temp_north'}(:) =  0;
194  nc{'salt_north'}(:) =  0;
195end
196if obc(4)==1
197  nc{'temp_west'}(:) =  0;
198  nc{'salt_west'}(:) =  0;
199end
200close(nc)
201return
202
203
Note: See TracBrowser for help on using the repository browser.