1 | function 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 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
43 | disp(' ') |
---|
44 | disp([' Creating the file : ',zbryname]) |
---|
45 | disp(' ') |
---|
46 | % |
---|
47 | % Read the grid file and check the topography |
---|
48 | % |
---|
49 | nc = netcdf(grdname, 'nowrite'); |
---|
50 | Lp=length(nc('xi_rho')); |
---|
51 | Mp=length(nc('eta_rho')); |
---|
52 | status=close(nc); |
---|
53 | L=Lp-1; |
---|
54 | M=Mp-1; |
---|
55 | % |
---|
56 | % Create the boundary file |
---|
57 | % |
---|
58 | type = 'BOUNDARY Z (or OA) file' ; |
---|
59 | history = 'ROMS' ; |
---|
60 | nc = netcdf(zbryname,clobber); |
---|
61 | result = redef(nc); |
---|
62 | % |
---|
63 | % Create dimensions |
---|
64 | % |
---|
65 | nc('xi_u') = L; |
---|
66 | nc('xi_rho') = Lp; |
---|
67 | nc('eta_v') = M; |
---|
68 | nc('eta_rho') = Mp; |
---|
69 | nc('Z') = length(Z); |
---|
70 | nc('bry_time') = length(time); |
---|
71 | nc('one') = 1; |
---|
72 | % |
---|
73 | % Create variables and attributes |
---|
74 | % |
---|
75 | nc{'Z'} = ncdouble('Z') ; |
---|
76 | nc{'Z'}.long_name = ncchar('Depth'); |
---|
77 | nc{'Z'}.long_name = 'Depth'; |
---|
78 | nc{'Z'}.units = ncchar('m'); |
---|
79 | nc{'Z'}.units = 'm'; |
---|
80 | % |
---|
81 | nc{'bry_time'} = ncdouble('bry_time') ; |
---|
82 | nc{'bry_time'}.long_name = ncchar('time for temperature climatology'); |
---|
83 | nc{'bry_time'}.long_name = 'time for temperature climatology'; |
---|
84 | nc{'bry_time'}.units = ncchar('day'); |
---|
85 | nc{'bry_time'}.units = 'day'; |
---|
86 | nc{'bry_time'}.cycle_length = cycle;% |
---|
87 | % |
---|
88 | if 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 | % |
---|
104 | end |
---|
105 | % |
---|
106 | if 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 | % |
---|
122 | end |
---|
123 | % |
---|
124 | if 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 | % |
---|
140 | end |
---|
141 | % |
---|
142 | if 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 | % |
---|
158 | end |
---|
159 | % |
---|
160 | % |
---|
161 | % Create global attributes |
---|
162 | % |
---|
163 | nc.title = ncchar(title); |
---|
164 | nc.title = title; |
---|
165 | nc.date = ncchar(date); |
---|
166 | nc.date = date; |
---|
167 | nc.clim_file = ncchar(zbryname); |
---|
168 | nc.clim_file = zbryname; |
---|
169 | nc.grd_file = ncchar(grdname); |
---|
170 | nc.grd_file = grdname; |
---|
171 | nc.type = ncchar(type); |
---|
172 | nc.type = type; |
---|
173 | nc.history = ncchar(history); |
---|
174 | nc.history = history; |
---|
175 | % |
---|
176 | % Leave define mode |
---|
177 | % |
---|
178 | result = endef(nc); |
---|
179 | % |
---|
180 | % Write variables |
---|
181 | % |
---|
182 | nc{'Z'}(:) = Z; |
---|
183 | nc{'bry_time'}(:) = time; |
---|
184 | if obc(1)==1 |
---|
185 | nc{'temp_south'}(:) = 0; |
---|
186 | nc{'salt_south'}(:) = 0; |
---|
187 | end |
---|
188 | if obc(2)==1 |
---|
189 | nc{'temp_east'}(:) = 0; |
---|
190 | nc{'salt_east'}(:) = 0; |
---|
191 | end |
---|
192 | if obc(3)==1 |
---|
193 | nc{'temp_north'}(:) = 0; |
---|
194 | nc{'salt_north'}(:) = 0; |
---|
195 | end |
---|
196 | if obc(4)==1 |
---|
197 | nc{'temp_west'}(:) = 0; |
---|
198 | nc{'salt_west'}(:) = 0; |
---|
199 | end |
---|
200 | close(nc) |
---|
201 | return |
---|
202 | |
---|
203 | |
---|