source: Roms_tools/Preprocessing_tools/make_bulk.m @ 2

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

import Roms_Agrif

File size: 6.9 KB
Line 
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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50clear all
51close all
52%%%%%%%%%%%%%%%%%%%%% USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%%%
53%
54romstools_param
55%
56%  Load air-sea parameters
57%
58as_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%
69sat_file     =[coads_dir,'sat.cdf'];
70sat_name     ='sat';
71sst_file     =[coads_dir,'sst.cdf'];
72sst_name     ='sst';
73airdens_file =[coads_dir,'airdens.cdf'];
74airdens_name ='airdens';
75u3_file      =[coads_dir,'u3.cdf'];
76u3_name      ='u3';
77v3_file      =[coads_dir,'v3.cdf'];
78v3_name      ='v3';
79w3_file      =[coads_dir,'w3.cdf'];
80w3_name      ='w3';
81qsea_file    =[coads_dir,'qsea.cdf'];
82qsea_name    ='qsea';
83rh_file      =[coads_dir,'rh.cdf'];
84rh_name      ='rh';
85precip_file  =[coads_dir,'precip.cdf'];
86precip_name  ='precip';
87srf_file     =[coads_dir,'shortrad.cdf'];
88srf_name     ='shortrad';
89lrf_file     =[coads_dir,'longrad.cdf'];
90lrf_name     ='longrad';
91taux_file      =[coads_dir,'taux.cdf'];
92taux_name      ='taux';
93tauy_file      =[coads_dir,'tauy.cdf'];
94tauy_name      ='tauy';
95
96%
97%
98%%%%%%%%%%%%%%%%%%% END USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%%
99%
100% Title
101%
102disp(' ')
103disp(ROMS_title)
104%
105% Read in the grid
106%
107disp(' ')
108disp(' Read in the grid...')
109nc=netcdf(grdname);
110Lp=length(nc('xi_rho'));
111Mp=length(nc('eta_rho'));
112lon=nc{'lon_rho'}(:);
113lat=nc{'lat_rho'}(:);
114lonu=nc{'lon_u'}(:);
115latu=nc{'lat_u'}(:);
116lonv=nc{'lon_v'}(:);
117latv=nc{'lat_v'}(:);
118angle=nc{'angle'}(:);
119result=close(nc);
120cosa=cos(angle);
121sina=sin(angle);
122%
123% Create the forcing file
124%
125disp(' ')
126disp(' Create the bulk forcing file...')
127create_bulk(blkname,grdname,ROMS_title,coads_time,coads_cycle);
128%
129% Loop on time
130%
131nc=netcdf(blkname,'write');
132for 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);
136end
137for 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);
142end
143for 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);
148end
149for 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);
161end
162for 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);
166end
167%
168% Compute wind rotated and at u,v points
169%
170for 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);
174end
175for 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;
185end
186%
187% Compute wind stress rotated and at u,v points
188%
189for 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);
197end
198close(nc)
199%
200% Make a few plots
201%
202if 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)
222end
223%
224% End
225%
226%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the repository browser.