1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2 | % |
---|
3 | % Build a ROMS climatology file |
---|
4 | % |
---|
5 | % Extrapole and interpole temperature and salinity from a |
---|
6 | % Climatology to get boundary and initial conditions for |
---|
7 | % ROMS (climatology and initial netcdf files) . |
---|
8 | % Get the velocities and sea surface elevation via a |
---|
9 | % geostrophic computation. |
---|
10 | % |
---|
11 | % Data input format (netcdf): |
---|
12 | % temperature(T, Z, Y, X) |
---|
13 | % T : time [Months] |
---|
14 | % Z : Depth [m] |
---|
15 | % Y : Latitude [degree north] |
---|
16 | % X : Longitude [degree east] |
---|
17 | % |
---|
18 | % Data source : IRI/LDEO Climate Data Library (World Ocean Atlas 1998) |
---|
19 | % http://ingrid.ldgo.columbia.edu/ |
---|
20 | % http://iridl.ldeo.columbia.edu/SOURCES/.NOAA/.NODC/.WOA98/ |
---|
21 | % |
---|
22 | % Pierrick Penven, IRD, 2002. |
---|
23 | % |
---|
24 | % Version of 10-Oct-2002 |
---|
25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
26 | clear all |
---|
27 | close all |
---|
28 | %%%%%%%%%%%%%%%%%%%%% USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%%% |
---|
29 | % |
---|
30 | % Common parameters |
---|
31 | % |
---|
32 | romstools_param |
---|
33 | % |
---|
34 | % Title |
---|
35 | % |
---|
36 | title='Climatology'; |
---|
37 | % |
---|
38 | % Switches for selecting what to process (1=ON) |
---|
39 | % |
---|
40 | makeclim=1; %1: process boundary data |
---|
41 | makeoa=1; %1: process oa data |
---|
42 | makeini=1; %1: process initial data |
---|
43 | % |
---|
44 | % Grid file name - Climatology file name |
---|
45 | % Initial file name - OA file name |
---|
46 | % |
---|
47 | grdname='roms_grd.nc'; |
---|
48 | clmname='roms_clm.nc'; |
---|
49 | ininame='roms_ini.nc'; |
---|
50 | oaname ='roms_oa.nc'; |
---|
51 | % |
---|
52 | % Day of initialisation |
---|
53 | % |
---|
54 | tini=15; |
---|
55 | % |
---|
56 | % Set times and cycles: monthly climatology for all data |
---|
57 | % |
---|
58 | time=[15:30:345]; % time |
---|
59 | cycle=360; % cycle |
---|
60 | % |
---|
61 | % Data climatology file name: |
---|
62 | % |
---|
63 | datafile='../../OCCAM_AGULHAS/Matlab/occam_agulhas_ext_clm.nc'; |
---|
64 | % |
---|
65 | % |
---|
66 | %%%%%%%%%%%%%%%%%%% END USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%% |
---|
67 | % |
---|
68 | % Title |
---|
69 | % |
---|
70 | disp(' ') |
---|
71 | disp([' Making the clim: ',clmname]) |
---|
72 | disp(' ') |
---|
73 | disp([' Title: ',title]) |
---|
74 | % |
---|
75 | % Read in the grid |
---|
76 | % |
---|
77 | disp(' ') |
---|
78 | disp(' Read in the grid...') |
---|
79 | nc=netcdf(grdname); |
---|
80 | Lp=length(nc('xi_rho')); |
---|
81 | Mp=length(nc('eta_rho')); |
---|
82 | hmax=max(max(nc{'h'}(:))); |
---|
83 | result=close(nc); |
---|
84 | % |
---|
85 | % Create the climatology file |
---|
86 | % |
---|
87 | if (makeclim) |
---|
88 | disp(' ') |
---|
89 | disp(' Create the climatology file...') |
---|
90 | create_climfile(clmname,grdname,title,... |
---|
91 | theta_s,theta_b,hc,N,... |
---|
92 | time,cycle,'clobber'); |
---|
93 | end |
---|
94 | % |
---|
95 | % Create the OA file |
---|
96 | % |
---|
97 | if (makeoa) |
---|
98 | disp(' ') |
---|
99 | disp(' Create the OA file...') |
---|
100 | nc=netcdf(datafile); |
---|
101 | Z=nc{'Z'}(:); |
---|
102 | close(nc) |
---|
103 | create_oafile(oaname,grdname,title,Z,... |
---|
104 | time,cycle,'clobber'); |
---|
105 | % |
---|
106 | % Horizontal extrapolations |
---|
107 | % |
---|
108 | disp(' ') |
---|
109 | disp(' Horizontal interpolations') |
---|
110 | disp(' ') |
---|
111 | disp(' Temperature...') |
---|
112 | int_data_occam(oaname,datafile,'temp','lon_rho','lat_rho','temp','lonT','latT',1); |
---|
113 | disp(' ') |
---|
114 | disp(' Salinity...') |
---|
115 | int_data_occam(oaname,datafile,'salt','lon_rho','lat_rho','salt','lonT','latT',1); |
---|
116 | disp(' ') |
---|
117 | disp(' U...') |
---|
118 | int_data_occam(oaname,datafile,'u','lon_u','lat_u','u','lonU','latU',1); |
---|
119 | disp(' ') |
---|
120 | disp(' V...') |
---|
121 | int_data_occam(oaname,datafile,'v','lon_v','lat_v','v','lonU','latU',1); |
---|
122 | disp(' ') |
---|
123 | disp(' UBAR...') |
---|
124 | int_data_occam(oaname,datafile,'ubar','lon_u','lat_u','ubar','lonU','latU',0); |
---|
125 | disp(' ') |
---|
126 | disp(' VBAR...') |
---|
127 | int_data_occam(oaname,datafile,'vbar','lon_v','lat_v','vbar','lonU','latU',0); |
---|
128 | disp(' ') |
---|
129 | disp(' ZETA...') |
---|
130 | int_data_occam(oaname,datafile,'zeta','lon_rho','lat_rho','zeta','lonT','latT',0); |
---|
131 | int_data_occam(oaname,datafile,'ssh','lon_rho','lat_rho','zeta','lonT','latT',0); |
---|
132 | end |
---|
133 | % |
---|
134 | % Vertical interpolations |
---|
135 | % |
---|
136 | if (makeclim) |
---|
137 | disp(' ') |
---|
138 | disp(' Vertical interpolations') |
---|
139 | disp(' ') |
---|
140 | disp(' Temperature...') |
---|
141 | vinterp_clm(clmname,grdname,oaname,'temp','tclm_time','Z',0,'r'); |
---|
142 | disp(' ') |
---|
143 | disp(' Salinity...') |
---|
144 | vinterp_clm(clmname,grdname,oaname,'salt','sclm_time','Z',0,'r'); |
---|
145 | disp(' ') |
---|
146 | disp(' U...') |
---|
147 | vinterp_clm(clmname,grdname,oaname,'u','uclm_time','Z',0,'u'); |
---|
148 | disp(' ') |
---|
149 | disp(' V...') |
---|
150 | vinterp_clm(clmname,grdname,oaname,'v','vclm_time','Z',0,'v'); |
---|
151 | disp(' ') |
---|
152 | disp(' ZETA...') |
---|
153 | rem_avg_zeta(clmname,grdname,oaname) |
---|
154 | disp(' ') |
---|
155 | disp(' UBAR & VBAR...') |
---|
156 | barotropic_currents(clmname,grdname,obc) |
---|
157 | end |
---|
158 | % |
---|
159 | % Initial file |
---|
160 | % |
---|
161 | if (makeini) |
---|
162 | disp(' ') |
---|
163 | disp(' Initial') |
---|
164 | create_inifile(ininame,grdname,title,... |
---|
165 | theta_s,theta_b,hc,N,... |
---|
166 | tini,'clobber'); |
---|
167 | disp(' ') |
---|
168 | disp(' Temperature...') |
---|
169 | vinterp_clm(ininame,grdname,oaname,'temp','tclm_time','Z',tini,'r',1); |
---|
170 | disp(' ') |
---|
171 | disp(' Salinity...') |
---|
172 | vinterp_clm(ininame,grdname,oaname,'salt','sclm_time','Z',tini,'r',1); |
---|
173 | end |
---|
174 | % |
---|
175 | % Make a few plots |
---|
176 | % |
---|
177 | disp(' ') |
---|
178 | disp(' Make a few plots...') |
---|
179 | test_clim(clmname,grdname,'temp',1) |
---|
180 | figure |
---|
181 | test_clim(clmname,grdname,'salt',1) |
---|
182 | figure |
---|
183 | test_clim(clmname,grdname,'temp',6) |
---|
184 | figure |
---|
185 | test_clim(clmname,grdname,'salt',6) |
---|
186 | % |
---|
187 | % End |
---|
188 | % |
---|
189 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|