1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2 | % |
---|
3 | % Build a ROMS bulk file |
---|
4 | % |
---|
5 | % Extrapole and interpole surface data to get surface boundary |
---|
6 | % conditions for ROMS (forcing netcdf file) |
---|
7 | % |
---|
8 | % Data input format (netcdf): |
---|
9 | % taux(T, Y, X) |
---|
10 | % T : time [Months] |
---|
11 | % Y : Latitude [degree north] |
---|
12 | % X : Longitude [degree east] |
---|
13 | % |
---|
14 | % Data source : IRI/LDEO Climate Data Library |
---|
15 | % (Atlas of Surface Marine Data 1994) |
---|
16 | % |
---|
17 | % http://ingrid.ldgo.columbia.edu/ |
---|
18 | % http://iridl.ldeo.columbia.edu/SOURCES/.DASILVA/ |
---|
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) 2005 by Patrick Marchesiello and Pierrick Penven |
---|
41 | % e-mail:Patrick.Marchesiello@ird.fr |
---|
42 | % |
---|
43 | % Updated 2006/09/29 by Pierrick Penven (add a test for the plots) |
---|
44 | % Updated 2006/10/02 by Pierrick Penven (add the 'tmp file' for |
---|
45 | % ext_data) |
---|
46 | % Updated 2006/10/05 by Pierrick Penven (add coads_dir) |
---|
47 | % Updated 25-Oct-2006 by Pierrick Penven (uwnd and vwnd) |
---|
48 | % |
---|
49 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
50 | clear all |
---|
51 | close all |
---|
52 | %%%%%%%%%%%%%%%%%%%%% USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%%% |
---|
53 | % |
---|
54 | romstools_param |
---|
55 | % |
---|
56 | % Load air-sea parameters |
---|
57 | % |
---|
58 | as_consts |
---|
59 | % |
---|
60 | % sat : Surface atmospheric temperature |
---|
61 | % airdens : Surface atmospheric density |
---|
62 | % w3 : Wind speed at 10 meters |
---|
63 | % qsea : Sea level specific humidity |
---|
64 | % rh : relative humidity |
---|
65 | % precip : precipitation rate |
---|
66 | % shortrad : Short wave radiation |
---|
67 | % longrade : Outgoing long wave radiation |
---|
68 | % |
---|
69 | sat_file =[coads_dir,'sat.cdf']; |
---|
70 | sat_name ='sat'; |
---|
71 | sst_file =[coads_dir,'sst.cdf']; |
---|
72 | sst_name ='sst'; |
---|
73 | airdens_file =[coads_dir,'airdens.cdf']; |
---|
74 | airdens_name ='airdens'; |
---|
75 | u3_file =[coads_dir,'u3.cdf']; |
---|
76 | u3_name ='u3'; |
---|
77 | v3_file =[coads_dir,'v3.cdf']; |
---|
78 | v3_name ='v3'; |
---|
79 | w3_file =[coads_dir,'w3.cdf']; |
---|
80 | w3_name ='w3'; |
---|
81 | qsea_file =[coads_dir,'qsea.cdf']; |
---|
82 | qsea_name ='qsea'; |
---|
83 | rh_file =[coads_dir,'rh.cdf']; |
---|
84 | rh_name ='rh'; |
---|
85 | precip_file =[coads_dir,'precip.cdf']; |
---|
86 | precip_name ='precip'; |
---|
87 | srf_file =[coads_dir,'shortrad.cdf']; |
---|
88 | srf_name ='shortrad'; |
---|
89 | lrf_file =[coads_dir,'longrad.cdf']; |
---|
90 | lrf_name ='longrad'; |
---|
91 | taux_file =[coads_dir,'taux.cdf']; |
---|
92 | taux_name ='taux'; |
---|
93 | tauy_file =[coads_dir,'tauy.cdf']; |
---|
94 | tauy_name ='tauy'; |
---|
95 | |
---|
96 | % |
---|
97 | % |
---|
98 | %%%%%%%%%%%%%%%%%%% END USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%% |
---|
99 | % |
---|
100 | % Title |
---|
101 | % |
---|
102 | disp(' ') |
---|
103 | disp(ROMS_title) |
---|
104 | % |
---|
105 | % Read in the grid |
---|
106 | % |
---|
107 | disp(' ') |
---|
108 | disp(' Read in the grid...') |
---|
109 | nc=netcdf(grdname); |
---|
110 | Lp=length(nc('xi_rho')); |
---|
111 | Mp=length(nc('eta_rho')); |
---|
112 | lon=nc{'lon_rho'}(:); |
---|
113 | lat=nc{'lat_rho'}(:); |
---|
114 | lonu=nc{'lon_u'}(:); |
---|
115 | latu=nc{'lat_u'}(:); |
---|
116 | lonv=nc{'lon_v'}(:); |
---|
117 | latv=nc{'lat_v'}(:); |
---|
118 | angle=nc{'angle'}(:); |
---|
119 | result=close(nc); |
---|
120 | cosa=cos(angle); |
---|
121 | sina=sin(angle); |
---|
122 | % |
---|
123 | % Create the forcing file |
---|
124 | % |
---|
125 | disp(' ') |
---|
126 | disp(' Create the bulk forcing file...') |
---|
127 | create_bulk(blkname,grdname,ROMS_title,coads_time,coads_cycle); |
---|
128 | % |
---|
129 | % Loop on time |
---|
130 | % |
---|
131 | nc=netcdf(blkname,'write'); |
---|
132 | for tindex=1:length(coads_time) |
---|
133 | time=nc{'bulk_time'}(tindex); |
---|
134 | nc{'tair'}(tindex,:,:) = ext_data(sat_file,sat_name,tindex,... |
---|
135 | lon,lat,time,Roa,1); |
---|
136 | end |
---|
137 | for tindex=1:length(coads_time) |
---|
138 | time=nc{'bulk_time'}(tindex); |
---|
139 | % percent -> fraction |
---|
140 | nc{'rhum'}(tindex,:,:) = 0.01*ext_data(rh_file,rh_name,tindex,... |
---|
141 | lon,lat,time,Roa,1); |
---|
142 | end |
---|
143 | for tindex=1:length(coads_time) |
---|
144 | time=nc{'bulk_time'}(tindex); |
---|
145 | % mm/(3hour) -> centimeter day-1 |
---|
146 | nc{'prate'}(tindex,:,:)= 0.8*ext_data(precip_file,precip_name,tindex,... |
---|
147 | lon,lat,time,Roa,1); |
---|
148 | end |
---|
149 | for tindex=1:length(coads_time) |
---|
150 | time=nc{'bulk_time'}(tindex); |
---|
151 | radlw=ext_data(lrf_file,lrf_name,tindex,... |
---|
152 | lon,lat,time,Roa,1); |
---|
153 | nc{'radlw'}(tindex,:,:)=radlw; |
---|
154 | |
---|
155 | % radlw_in: substract upward gray-body longwave flux |
---|
156 | % and make it positive downward |
---|
157 | sst= ext_data(sst_file,sst_name,tindex,... |
---|
158 | lon,lat,time,Roa,1); |
---|
159 | lwup=emiss_lw.*sigmaSB.*((sst+CtoK).^4); |
---|
160 | nc{'radlw_in'}(tindex,:,:)=-(radlw-lwup); |
---|
161 | end |
---|
162 | for tindex=1:length(coads_time) |
---|
163 | time=nc{'bulk_time'}(tindex); |
---|
164 | nc{'radsw'}(tindex,:,:)= ext_data(srf_file,srf_name,tindex,... |
---|
165 | lon,lat,time,Roa,1); |
---|
166 | end |
---|
167 | % |
---|
168 | % Compute wind rotated and at u,v points |
---|
169 | % |
---|
170 | for tindex=1:length(coads_time) |
---|
171 | time=nc{'bulk_time'}(tindex); |
---|
172 | nc{'wspd'}(tindex,:,:) = ext_data(w3_file,w3_name,tindex,... |
---|
173 | lon,lat,time,Roa,1); |
---|
174 | end |
---|
175 | for tindex=1:length(coads_time) |
---|
176 | time=nc{'bulk_time'}(tindex); |
---|
177 | uwnd = ext_data(u3_file,u3_name,tindex,... |
---|
178 | lon,lat,time,Roa,1); |
---|
179 | vwnd = ext_data(v3_file,v3_name,tindex,... |
---|
180 | lon,lat,time,Roa,1); |
---|
181 | u10=rho2u_2d(uwnd.*cosa+vwnd.*sina); |
---|
182 | v10=rho2v_2d(vwnd.*cosa-uwnd.*sina); |
---|
183 | nc{'uwnd'}(tindex,:,:) = u10; |
---|
184 | nc{'vwnd'}(tindex,:,:) = v10; |
---|
185 | end |
---|
186 | % |
---|
187 | % Compute wind stress rotated and at u,v points |
---|
188 | % |
---|
189 | for tindex=1:length(coads_time) |
---|
190 | time=nc{'sms_time'}(tindex); |
---|
191 | tx=ext_data(taux_file,taux_name,tindex,... |
---|
192 | lon,lat,time,Roa,2); |
---|
193 | ty=ext_data(tauy_file,tauy_name,tindex,... |
---|
194 | lon,lat,time,Roa,2); |
---|
195 | nc{'sustr'}(tindex,:,:)=rho2u_2d(tx.*cosa + ty.*sina); |
---|
196 | nc{'svstr'}(tindex,:,:)=rho2v_2d(ty.*cosa - tx.*sina); |
---|
197 | end |
---|
198 | close(nc) |
---|
199 | % |
---|
200 | % Make a few plots |
---|
201 | % |
---|
202 | if makeplot==1 |
---|
203 | disp(' ') |
---|
204 | disp(' Make a few plots...') |
---|
205 | test_forcing(blkname,grdname,'tair',[1 4 7 10],3,coastfileplot) |
---|
206 | figure |
---|
207 | test_forcing(blkname,grdname,'rhum',[1 4 7 10],3,coastfileplot) |
---|
208 | figure |
---|
209 | test_forcing(blkname,grdname,'prate',[1 4 7 10],3,coastfileplot) |
---|
210 | figure |
---|
211 | test_forcing(blkname,grdname,'uwnd',[1 4 7 10],3,coastfileplot) |
---|
212 | figure |
---|
213 | test_forcing(blkname,grdname,'vwnd',[1 4 7 10],3,coastfileplot) |
---|
214 | figure |
---|
215 | test_forcing(blkname,grdname,'wspd',[1 4 7 10],3,coastfileplot) |
---|
216 | figure |
---|
217 | test_forcing(blkname,grdname,'radlw',[1 4 7 10],3,coastfileplot) |
---|
218 | figure |
---|
219 | test_forcing(blkname,grdname,'radlw_in',[1 4 7 10],3,coastfileplot) |
---|
220 | figure |
---|
221 | test_forcing(blkname,grdname,'radsw',[1 4 7 10],3,coastfileplot) |
---|
222 | end |
---|
223 | % |
---|
224 | % End |
---|
225 | % |
---|
226 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|