1 | function create_oafile(oaname,grdname,title,Z,... |
---|
2 | time,cycle,clobber); |
---|
3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4 | % |
---|
5 | % function nc=create_oafile(oaname,grdname,title,Z,... |
---|
6 | % time,cycle,clobber); |
---|
7 | % |
---|
8 | % This function create the header of a Netcdf OA |
---|
9 | % file. ie an intermediate file on a Z-grid. |
---|
10 | % |
---|
11 | % Input: |
---|
12 | % |
---|
13 | % oaname Netcdf OA file name (character string). |
---|
14 | % grdname Netcdf grid file name (character string). |
---|
15 | % Z Vertical levels.(Vector) |
---|
16 | % time OA time.(Vector) |
---|
17 | % clobber Switch to allow or not writing over an existing |
---|
18 | % file.(character string) |
---|
19 | % |
---|
20 | % Output |
---|
21 | % |
---|
22 | % nc Output netcdf object. |
---|
23 | % |
---|
24 | % Further Information: |
---|
25 | % http://www.brest.ird.fr/Roms_tools/ |
---|
26 | % |
---|
27 | % This file is part of ROMSTOOLS |
---|
28 | % |
---|
29 | % ROMSTOOLS is free software; you can redistribute it and/or modify |
---|
30 | % it under the terms of the GNU General Public License as published |
---|
31 | % by the Free Software Foundation; either version 2 of the License, |
---|
32 | % or (at your option) any later version. |
---|
33 | % |
---|
34 | % ROMSTOOLS is distributed in the hope that it will be useful, but |
---|
35 | % WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
36 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
37 | % GNU General Public License for more details. |
---|
38 | % |
---|
39 | % You should have received a copy of the GNU General Public License |
---|
40 | % along with this program; if not, write to the Free Software |
---|
41 | % Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
42 | % MA 02111-1307 USA |
---|
43 | % |
---|
44 | % Copyright (c) 2001-2006 by Pierrick Penven |
---|
45 | % e-mail:Pierrick.Penven@ird.fr |
---|
46 | % |
---|
47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
48 | disp(' ') |
---|
49 | disp([' Creating the file : ',oaname]) |
---|
50 | disp(' ') |
---|
51 | % |
---|
52 | % Read the grid file |
---|
53 | % |
---|
54 | nc = netcdf(grdname, 'nowrite'); |
---|
55 | lonr=nc{'lon_rho'}(:); |
---|
56 | latr=nc{'lat_rho'}(:); |
---|
57 | lonu=nc{'lon_u'}(:); |
---|
58 | latu=nc{'lat_u'}(:); |
---|
59 | lonv=nc{'lon_v'}(:); |
---|
60 | latv=nc{'lat_v'}(:); |
---|
61 | status=close(nc); |
---|
62 | [Mp,Lp]=size(lonr); |
---|
63 | L=Lp-1; |
---|
64 | M=Mp-1; |
---|
65 | % |
---|
66 | % Create the climatology file |
---|
67 | % |
---|
68 | type = 'OA file' ; |
---|
69 | history = 'ROMS' ; |
---|
70 | nc = netcdf(oaname,clobber); |
---|
71 | result = redef(nc); |
---|
72 | % |
---|
73 | % Create dimensions |
---|
74 | % |
---|
75 | nc('xi_rho') = Lp; |
---|
76 | nc('eta_rho') = Mp; |
---|
77 | nc('xi_u') = L; |
---|
78 | nc('eta_v') = M; |
---|
79 | nc('Z') = length(Z); |
---|
80 | nc('tracer') = 2; |
---|
81 | nc('tclm_time') = length(time); |
---|
82 | nc('sclm_time') = length(time); |
---|
83 | nc('uclm_time') = length(time); |
---|
84 | nc('vclm_time') = length(time); |
---|
85 | nc('v2d_time') = length(time); |
---|
86 | nc('v3d_time') = length(time); |
---|
87 | nc('ssh_time') = length(time); |
---|
88 | nc('zeta_time') = length(time); |
---|
89 | nc('one') = 1; |
---|
90 | % |
---|
91 | % Create variables |
---|
92 | % |
---|
93 | nc{'lon_rho'} = ncdouble('eta_rho','xi_rho') ; |
---|
94 | nc{'lat_rho'} = ncdouble('eta_rho','xi_rho') ; |
---|
95 | nc{'lon_u'} = ncdouble('eta_rho','xi_u') ; |
---|
96 | nc{'lat_u'} = ncdouble('eta_rho','xi_u') ; |
---|
97 | nc{'lon_v'} = ncdouble('eta_v','xi_rho') ; |
---|
98 | nc{'lat_v'} = ncdouble('eta_v','xi_rho') ; |
---|
99 | nc{'Z'} = ncdouble('Z') ; |
---|
100 | nc{'tclm_time'} = ncdouble('tclm_time') ; |
---|
101 | nc{'sclm_time'} = ncdouble('sclm_time') ; |
---|
102 | nc{'uclm_time'} = ncdouble('uclm_time') ; |
---|
103 | nc{'vclm_time'} = ncdouble('vclm_time') ; |
---|
104 | nc{'v2d_time'} = ncdouble('v2d_time') ; |
---|
105 | nc{'v3d_time'} = ncdouble('v3d_time') ; |
---|
106 | nc{'ssh_time'} = ncdouble('ssh_time') ; |
---|
107 | nc{'zeta_time'} = ncdouble('zeta_time') ; |
---|
108 | nc{'temp'} = ncdouble('tclm_time','Z','eta_rho','xi_rho') ; |
---|
109 | nc{'salt'} = ncdouble('sclm_time','Z','eta_rho','xi_rho') ; |
---|
110 | nc{'u'} = ncdouble('uclm_time','Z','eta_rho','xi_u') ; |
---|
111 | nc{'v'} = ncdouble('vclm_time','Z','eta_v','xi_rho') ; |
---|
112 | nc{'ubar'} = ncdouble('uclm_time','eta_rho','xi_u') ; |
---|
113 | nc{'vbar'} = ncdouble('vclm_time','eta_v','xi_rho') ; |
---|
114 | nc{'SSH'} = ncdouble('ssh_time','eta_rho','xi_rho') ; |
---|
115 | nc{'zeta'} = ncdouble('zeta_time','eta_rho','xi_rho') ; |
---|
116 | % |
---|
117 | % Create attributes |
---|
118 | % |
---|
119 | nc{'lon_rho'}.long_name = ncchar('longitude of RHO-points'); |
---|
120 | nc{'lon_rho'}.long_name = 'longitude of RHO-points'; |
---|
121 | nc{'lon_rho'}.units = ncchar('degree_east'); |
---|
122 | nc{'lon_rho'}.units = 'degree_east'; |
---|
123 | % |
---|
124 | nc{'lat_rho'}.latg_name = ncchar('latitude of RHO-points'); |
---|
125 | nc{'lat_rho'}.latg_name = 'latitude of RHO-points'; |
---|
126 | nc{'lat_rho'}.units = ncchar('degree_north'); |
---|
127 | nc{'lat_rho'}.units = 'degree_north'; |
---|
128 | % |
---|
129 | nc{'lon_u'}.long_name = ncchar('longitude of U-points'); |
---|
130 | nc{'lon_u'}.long_name = 'longitude of U-points'; |
---|
131 | nc{'lon_u'}.units = ncchar('degree_east'); |
---|
132 | nc{'lon_u'}.units = 'degree_east'; |
---|
133 | % |
---|
134 | nc{'lat_u'}.latg_name = ncchar('latitude of U-points'); |
---|
135 | nc{'lat_u'}.latg_name = 'latitude of U-points'; |
---|
136 | nc{'lat_u'}.units = ncchar('degree_north'); |
---|
137 | nc{'lat_u'}.units = 'degree_north'; |
---|
138 | % |
---|
139 | nc{'lon_v'}.long_name = ncchar('longitude of V-points'); |
---|
140 | nc{'lon_v'}.long_name = 'longitude of V-points'; |
---|
141 | nc{'lon_v'}.units = ncchar('degree_east'); |
---|
142 | nc{'lon_v'}.units = 'degree_east'; |
---|
143 | % |
---|
144 | nc{'lat_v'}.latg_name = ncchar('latitude of V-points'); |
---|
145 | nc{'lat_v'}.latg_name = 'latitude of V-points'; |
---|
146 | nc{'lat_v'}.units = ncchar('degree_north'); |
---|
147 | nc{'lat_v'}.units = 'degree_north'; |
---|
148 | % |
---|
149 | nc{'Z'}.long_name = ncchar('Depth'); |
---|
150 | nc{'Z'}.long_name = 'Depth'; |
---|
151 | nc{'Z'}.units = ncchar('m'); |
---|
152 | nc{'Z'}.units = 'm'; |
---|
153 | % |
---|
154 | nc{'tclm_time'}.long_name = ncchar('time for temperature climatology'); |
---|
155 | nc{'tclm_time'}.long_name = 'time for temperature climatology'; |
---|
156 | nc{'tclm_time'}.units = ncchar('day'); |
---|
157 | nc{'tclm_time'}.units = 'day'; |
---|
158 | nc{'tclm_time'}.cycle_length = cycle; |
---|
159 | % |
---|
160 | nc{'sclm_time'}.long_name = ncchar('time for salinity climatology'); |
---|
161 | nc{'sclm_time'}.long_name = 'time for salinity climatology'; |
---|
162 | nc{'sclm_time'}.units = ncchar('day'); |
---|
163 | nc{'sclm_time'}.units = 'day'; |
---|
164 | nc{'sclm_time'}.cycle_length = cycle; |
---|
165 | % |
---|
166 | nc{'uclm_time'}.long_name = ncchar('time for u climatology'); |
---|
167 | nc{'uclm_time'}.long_name = 'time for u climatology'; |
---|
168 | nc{'uclm_time'}.units = ncchar('day'); |
---|
169 | nc{'uclm_time'}.units = 'day'; |
---|
170 | nc{'uclm_time'}.cycle_length = cycle; |
---|
171 | % |
---|
172 | nc{'vclm_time'}.long_name = ncchar('time for v climatology'); |
---|
173 | nc{'vclm_time'}.long_name = 'time for v climatology'; |
---|
174 | nc{'vclm_time'}.units = ncchar('day'); |
---|
175 | nc{'vclm_time'}.units = 'day'; |
---|
176 | nc{'vclm_time'}.cycle_length = cycle; |
---|
177 | % |
---|
178 | nc{'v2d_time'}.long_name = ncchar('time for 2D velocity climatology'); |
---|
179 | nc{'v2d_time'}.long_name = 'time for 2D velocity climatology'; |
---|
180 | nc{'v2d_time'}.units = ncchar('day'); |
---|
181 | nc{'v2d_time'}.units = 'day'; |
---|
182 | nc{'v2d_time'}.cycle_length = cycle; |
---|
183 | % |
---|
184 | nc{'v3d_time'}.long_name = ncchar('time for 3D velocity climatology'); |
---|
185 | nc{'v3d_time'}.long_name = 'time for 3D velocity climatology'; |
---|
186 | nc{'v3d_time'}.units = ncchar('day'); |
---|
187 | nc{'v3d_time'}.units = 'day'; |
---|
188 | nc{'v3d_time'}.cycle_length = cycle; |
---|
189 | % |
---|
190 | nc{'ssh_time'}.long_name = ncchar('time for sea surface height'); |
---|
191 | nc{'ssh_time'}.long_name = 'time for sea surface height'; |
---|
192 | nc{'ssh_time'}.units = ncchar('day'); |
---|
193 | nc{'ssh_time'}.units = 'day'; |
---|
194 | nc{'ssh_time'}.cycle_length = cycle; |
---|
195 | % |
---|
196 | nc{'zeta_time'}.long_name = ncchar('time for zeta climatology'); |
---|
197 | nc{'zeta_time'}.long_name = 'time for zeta climatology'; |
---|
198 | nc{'zeta_time'}.units = ncchar('day'); |
---|
199 | nc{'zeta_time'}.units = 'day'; |
---|
200 | nc{'zeta_time'}.cycle_length = cycle; |
---|
201 | % |
---|
202 | nc{'temp'}.long_name = ncchar('potential temperature'); |
---|
203 | nc{'temp'}.long_name = 'potential temperature'; |
---|
204 | nc{'temp'}.units = ncchar('Celsius'); |
---|
205 | nc{'temp'}.units = 'Celsius'; |
---|
206 | % |
---|
207 | nc{'salt'}.long_name = ncchar('salinity'); |
---|
208 | nc{'salt'}.long_name = 'salinity'; |
---|
209 | nc{'salt'}.units = ncchar('PSU'); |
---|
210 | nc{'salt'}.units = 'PSU'; |
---|
211 | % |
---|
212 | nc{'u'}.long_name = ncchar('u-momentum component'); |
---|
213 | nc{'u'}.long_name = 'u-momentum component'; |
---|
214 | nc{'u'}.units = ncchar('meter second-1'); |
---|
215 | nc{'u'}.units = 'meter second-1'; |
---|
216 | % |
---|
217 | nc{'v'}.long_name = ncchar('v-momentum component'); |
---|
218 | nc{'v'}.long_name = 'v-momentum component'; |
---|
219 | nc{'v'}.units = ncchar('meter second-1'); |
---|
220 | nc{'v'}.units = 'meter second-1'; |
---|
221 | % |
---|
222 | nc{'ubar'}.long_name = ncchar('vertically integrated u-momentum component'); |
---|
223 | nc{'ubar'}.long_name = 'vertically integrated u-momentum component'; |
---|
224 | nc{'ubar'}.units = ncchar('meter second-1'); |
---|
225 | nc{'ubar'}.units = 'meter second-1'; |
---|
226 | % |
---|
227 | nc{'vbar'}.long_name = ncchar('vertically integrated v-momentum component'); |
---|
228 | nc{'vbar'}.long_name = 'vertically integrated v-momentum component'; |
---|
229 | nc{'vbar'}.units = ncchar('meter second-1'); |
---|
230 | nc{'vbar'}.units = 'meter second-1'; |
---|
231 | % |
---|
232 | nc{'SSH'}.long_name = ncchar('sea surface height'); |
---|
233 | nc{'SSH'}.long_name = 'sea surface height'; |
---|
234 | nc{'SSH'}.units = ncchar('meter'); |
---|
235 | nc{'SSH'}.units = 'meter'; |
---|
236 | % |
---|
237 | nc{'zeta'}.long_name = ncchar('sea surface height'); |
---|
238 | nc{'zeta'}.long_name = 'sea surface height'; |
---|
239 | nc{'zeta'}.units = ncchar('meter'); |
---|
240 | nc{'zeta'}.units = 'meter'; |
---|
241 | % |
---|
242 | % Create global attributes |
---|
243 | % |
---|
244 | nc.title = ncchar(title); |
---|
245 | nc.title = title; |
---|
246 | nc.date = ncchar(date); |
---|
247 | nc.date = date; |
---|
248 | nc.grd_file = ncchar(grdname); |
---|
249 | nc.grd_file = grdname; |
---|
250 | nc.type = ncchar(type); |
---|
251 | nc.type = type; |
---|
252 | nc.history = ncchar(history); |
---|
253 | nc.history = history; |
---|
254 | % |
---|
255 | % Leave define mode |
---|
256 | % |
---|
257 | result = endef(nc); |
---|
258 | % |
---|
259 | % Write variables |
---|
260 | % |
---|
261 | nc{'Z'}(:) = Z; |
---|
262 | nc{'lon_rho'}(:) = lonr; |
---|
263 | nc{'lat_rho'}(:) = latr; |
---|
264 | nc{'lon_u'}(:) = lonu; |
---|
265 | nc{'lat_u'}(:) = latu; |
---|
266 | nc{'lon_v'}(:) = lonv; |
---|
267 | nc{'lat_v'}(:) = latv; |
---|
268 | nc{'tclm_time'}(:) = time; |
---|
269 | nc{'sclm_time'}(:) = time; |
---|
270 | nc{'uclm_time'}(:) = time; |
---|
271 | nc{'vclm_time'}(:) = time; |
---|
272 | nc{'v2d_time'}(:) = time; |
---|
273 | nc{'v3d_time'}(:) = time; |
---|
274 | nc{'ssh_time'}(:) = time; |
---|
275 | nc{'zeta_time'}(:) = time; |
---|
276 | nc{'u'}(:) = 0; |
---|
277 | nc{'v'}(:) = 0; |
---|
278 | nc{'ubar'}(:) = 0; |
---|
279 | nc{'vbar'}(:) = 0; |
---|
280 | nc{'SSH'}(:) = 0; |
---|
281 | nc{'zeta'}(:) = 0; |
---|
282 | nc{'temp'}(:) = 0; |
---|
283 | nc{'salt'}(:) = 0; |
---|
284 | close(nc) |
---|
285 | return |
---|
286 | |
---|
287 | |
---|