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 | % Pierrick Menkes, IRD, 2006. |
---|
24 | % |
---|
25 | % |
---|
26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
27 | clear all |
---|
28 | close all |
---|
29 | %%%%%%%%%%%%%%%%%%%%% USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%%% |
---|
30 | % |
---|
31 | % Common parameters |
---|
32 | % |
---|
33 | romstools_param |
---|
34 | % |
---|
35 | % Title |
---|
36 | % |
---|
37 | title='Climatology'; |
---|
38 | % |
---|
39 | % Switches for selecting what to process (1=ON) |
---|
40 | % |
---|
41 | makeclim=1; %1: process boundary data |
---|
42 | makeoa=1; %1: process oa data |
---|
43 | makeini=0; %1: process initial data |
---|
44 | % |
---|
45 | % Grid file name - Climatology file name |
---|
46 | % Initial file name - OA file name |
---|
47 | % |
---|
48 | grdname='roms_grd.nc'; |
---|
49 | frcname='roms_frc_ERS_smooth.nc' |
---|
50 | %roms_frc.nc'; |
---|
51 | clmname='roms_clm_high.nc'; |
---|
52 | ininame='roms_ini.nc'; |
---|
53 | oaname ='roms_oa_high.nc'; |
---|
54 | % |
---|
55 | % Day of initialisation |
---|
56 | % |
---|
57 | tini=0; |
---|
58 | % |
---|
59 | % Set times and cycles: monthly climatology for all data |
---|
60 | % |
---|
61 | time=[15:30:345]; % time |
---|
62 | cycle=365; % cycle |
---|
63 | % |
---|
64 | % Data climatologies file names: |
---|
65 | % |
---|
66 | % temp_month_data : monthly temperature climatology |
---|
67 | % temp_ann_data : annual temperature climatology |
---|
68 | % salt_month_data : monthly salinity climatology |
---|
69 | % salt_ann_data : annual salinity climatology |
---|
70 | % |
---|
71 | temp_month_data='../WOA2001/temp_month_corrected.cdf'; |
---|
72 | temp_ann_data='../WOA2001/temp_ann_corrected.cdf'; |
---|
73 | insitu2pot=1; %1: transform in-situ temperature to potential temperature |
---|
74 | salt_month_data='../WOA2001/salt_month_corrected.cdf'; |
---|
75 | salt_ann_data='../WOA2001/salt_ann_corrected.cdf'; |
---|
76 | % |
---|
77 | % |
---|
78 | %%%%%%%%%%%%%%%%%%% END USERS DEFINED VARIABLES %%%%%%%%%%%%%%%%%%%%%%% |
---|
79 | % |
---|
80 | % Title |
---|
81 | % |
---|
82 | disp(' ') |
---|
83 | disp([' Making the clim: ',clmname]) |
---|
84 | disp(' ') |
---|
85 | disp([' Title: ',title]) |
---|
86 | % |
---|
87 | % Read in the grid |
---|
88 | % |
---|
89 | disp(' ') |
---|
90 | disp(' Read in the grid...') |
---|
91 | nc=netcdf(grdname); |
---|
92 | Lp=length(nc('xi_rho')); |
---|
93 | Mp=length(nc('eta_rho')); |
---|
94 | hmax=max(max(nc{'h'}(:))); |
---|
95 | result=close(nc); |
---|
96 | % |
---|
97 | % Create the climatology file |
---|
98 | % |
---|
99 | if (makeclim) |
---|
100 | disp(' ') |
---|
101 | disp(' Create the climatology file...') |
---|
102 | create_climfile(clmname,grdname,title,... |
---|
103 | theta_s,theta_b,hc,N,... |
---|
104 | time,cycle,'clobber'); |
---|
105 | end |
---|
106 | % |
---|
107 | % Create the OA file |
---|
108 | % |
---|
109 | if (makeoa) |
---|
110 | disp(' ') |
---|
111 | disp(' Create the OA file...') |
---|
112 | nc=netcdf(temp_ann_data); |
---|
113 | Z=nc{'Z'}(:); |
---|
114 | kmax=max(find(Z<hmax))-1; |
---|
115 | Z=Z(1:kmax); |
---|
116 | close(nc) |
---|
117 | create_oafile(oaname,grdname,title,Z,... |
---|
118 | time,cycle,'clobber'); |
---|
119 | % |
---|
120 | % Horizontal extrapolations |
---|
121 | % |
---|
122 | disp(' ') |
---|
123 | disp(' Horizontal extrapolations') |
---|
124 | disp(' ') |
---|
125 | disp(' Temperature...') |
---|
126 | ext_tracers(oaname,temp_month_data,temp_ann_data,... |
---|
127 | 'temperature','temp','tclm_time','Z'); |
---|
128 | disp(' ') |
---|
129 | disp(' Salinity...') |
---|
130 | ext_tracers(oaname,salt_month_data,salt_ann_data,... |
---|
131 | 'salinity','salt','sclm_time','Z'); |
---|
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 | if (insitu2pot) |
---|
146 | disp(' ') |
---|
147 | disp(' Compute potential temperature from in-situ...') |
---|
148 | getpot(clmname,grdname) |
---|
149 | end |
---|
150 | % |
---|
151 | % Geostrophy |
---|
152 | % |
---|
153 | disp(' ') |
---|
154 | disp(' WARNING NO geostrophic currents IN THIS CLIM') |
---|
155 | % geost_currents(clmname,grdname,oaname,frcname,zref,obc,0) |
---|
156 | end |
---|
157 | % |
---|
158 | % Initial file |
---|
159 | % |
---|
160 | if (makeini) |
---|
161 | disp(' ') |
---|
162 | disp(' Initial') |
---|
163 | create_inifile(ininame,grdname,title,... |
---|
164 | theta_s,theta_b,hc,N,... |
---|
165 | tini,'clobber'); |
---|
166 | disp(' ') |
---|
167 | disp(' Temperature...') |
---|
168 | vinterp_clm(ininame,grdname,oaname,'temp','tclm_time','Z',tini,'r',1); |
---|
169 | disp(' ') |
---|
170 | disp(' Salinity...') |
---|
171 | vinterp_clm(ininame,grdname,oaname,'salt','sclm_time','Z',tini,'r',1); |
---|
172 | if (insitu2pot) |
---|
173 | disp(' ') |
---|
174 | disp(' Compute potential temperature from in-situ...') |
---|
175 | getpot(ininame,grdname) |
---|
176 | end |
---|
177 | end |
---|
178 | % |
---|
179 | % Make a few plots |
---|
180 | % |
---|
181 | disp(' ') |
---|
182 | disp(' Make a few plots...') |
---|
183 | test_clim(clmname,grdname,'temp',1) |
---|
184 | figure |
---|
185 | test_clim(clmname,grdname,'salt',1) |
---|
186 | figure |
---|
187 | test_clim(clmname,grdname,'temp',6) |
---|
188 | figure |
---|
189 | test_clim(clmname,grdname,'salt',6) |
---|
190 | % |
---|
191 | % End |
---|
192 | % |
---|
193 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|