1 |
gforget |
1.1 |
|
2 |
|
|
%select kBudget: |
3 |
|
|
if ~isempty(setDiagsParams); |
4 |
|
|
kBudget=setDiagsParams{1}; |
5 |
|
|
else; |
6 |
|
|
kBudget=1; |
7 |
|
|
end; |
8 |
|
|
|
9 |
|
|
%override default file name: |
10 |
|
|
%--------------------------- |
11 |
|
|
tmp1=setDiags; |
12 |
|
|
if kBudget>1; |
13 |
gforget |
1.2 |
tmp1=sprintf('E%02i',kBudget); |
14 |
gforget |
1.1 |
end; |
15 |
|
|
fileMat=['diags_set_' tmp1]; |
16 |
|
|
|
17 |
|
|
if userStep==1;%diags to be computed |
18 |
|
|
listDiags=['zm_area zm_vol_ocn zm_vol_tot zm_vol_ice']; |
19 |
|
|
listDiags=[listDiags ' zm_heat_ocn zm_heat_tot zm_heat_ice zm_heat_ocn_diff']; |
20 |
|
|
listDiags=[listDiags ' zm_salt_ocn zm_salt_tot zm_salt_ice zm_salt_ocn_diff']; |
21 |
|
|
elseif userStep==2;%input files and variables |
22 |
gforget |
1.6 |
listFlds={ 'ETAN','SIheff','SIhsnow','THETA ','SALT ','PHIBOT','geothFlux'}; |
23 |
gforget |
1.1 |
listFlds={listFlds{:},'SIatmFW ','oceFWflx','SItflux','TFLUX','SFLUX','oceSPflx','SRELAX'}; |
24 |
|
|
listFlds={listFlds{:},'oceQnet ','SIatmQnt','SIaaflux','SIsnPrcp','SIacSubl'}; |
25 |
|
|
listFlds={listFlds{:},'TRELAX','WTHMASS','WSLTMASS','oceSflux','oceQsw','oceSPtnd'}; |
26 |
|
|
if kBudget>1; |
27 |
|
|
listFlds={listFlds{:},'ADVr_TH','DFrE_TH','DFrI_TH','ADVr_SLT','DFrE_SLT','DFrI_SLT','WVELMASS'}; |
28 |
|
|
end; |
29 |
|
|
listFlds={listFlds{:},'UVELMASS','VVELMASS','AB_gT','AB_gS'}; |
30 |
|
|
listFlds={listFlds{:},'ADVx_TH ','ADVy_TH ','DFxE_TH ','DFyE_TH '}; |
31 |
|
|
listFlds={listFlds{:},'ADVx_SLT','ADVy_SLT','DFxE_SLT','DFyE_SLT'}; |
32 |
|
|
listFlds={listFlds{:},'ADVxHEFF','ADVyHEFF','DFxEHEFF','DFyEHEFF'}; |
33 |
|
|
listFlds={listFlds{:},'ADVxSNOW','ADVySNOW','DFxESNOW','DFyESNOW'}; |
34 |
|
|
listFldsNames=deblank(listFlds); |
35 |
|
|
% |
36 |
|
|
listFiles={'rate_budg2d_snap_set1','budg2d_hflux_set1','budg2d_zflux_set1','budg2d_zflux_set2'}; |
37 |
|
|
if kBudget==1; |
38 |
gforget |
1.6 |
listFiles={listFiles{:},'rate_budg2d_snap_set2','budg2d_hflux_set2','geothermalFlux'}; |
39 |
gforget |
1.1 |
else; |
40 |
|
|
tmp1=sprintf('rate_budg2d_snap_set3_%02i',kBudget); |
41 |
|
|
tmp2=sprintf('budg2d_zflux_set3_%02i',kBudget); |
42 |
|
|
tmp3=sprintf('budg2d_hflux_set3_%02i',kBudget); |
43 |
gforget |
1.6 |
tmp4=sprintf('geothermalFlux_%02i',kBudget); |
44 |
|
|
listFiles={listFiles{:},tmp1,tmp2,tmp3,tmp4}; |
45 |
gforget |
1.1 |
end; |
46 |
gforget |
1.5 |
listSubdirs={[dirMat 'BUDG/' ],[dirMat '../BUDG/' ],[dirModel 'diags/BUDG/'],[dirModel 'diags/']}; |
47 |
gforget |
1.1 |
elseif userStep==3;%computational part; |
48 |
|
|
|
49 |
|
|
%preliminary tests |
50 |
|
|
test1=isempty(dir([dirModel 'diags/BUDG/budg2d_snap_set1*'])); |
51 |
gforget |
1.2 |
test2=isempty(dir([dirMat 'BUDG/rate_budg2d_snap_set1*']))&... |
52 |
|
|
isempty(dir([dirMat '../BUDG/rate_budg2d_snap_set1*'])); |
53 |
gforget |
1.1 |
|
54 |
gforget |
1.2 |
if (strcmp(setDiags,'E')&test1&test2); |
55 |
gforget |
1.1 |
fprintf('\n abort : global and regional budgets, due to missing \n'); |
56 |
|
|
fprintf(['\n ' dirModel 'diags/BUDG/budg2d_snap_set1* \n']); |
57 |
|
|
return; |
58 |
|
|
end; |
59 |
|
|
|
60 |
gforget |
1.2 |
if (strcmp(setDiags,'E')&test2); |
61 |
gforget |
1.1 |
fprintf('\n abort : global and regional budgets, due to missing \n'); |
62 |
|
|
fprintf(['\n ' dirModel 'diags/BUDG/rate_budg2d_snap_set1* \n']); |
63 |
|
|
return; |
64 |
|
|
end; |
65 |
|
|
|
66 |
|
|
%override default file name: |
67 |
|
|
%--------------------------- |
68 |
|
|
tmp1=setDiags; |
69 |
|
|
if kBudget>1; |
70 |
|
|
tmp1=sprintf('E%02i',kBudget); |
71 |
|
|
end; |
72 |
|
|
fileMat=['diags_set_' tmp1 '_' num2str(tt) '.mat']; |
73 |
|
|
|
74 |
|
|
%fill in optional fields: |
75 |
|
|
%------------------------ |
76 |
|
|
if isempty(who('TRELAX')); TRELAX=0*mygrid.XC; end; |
77 |
|
|
if isempty(who('SRELAX')); SRELAX=0*mygrid.XC; end; |
78 |
|
|
if isempty(who('AB_gT')); AB_gT=0*mygrid.XC; end; |
79 |
|
|
if isempty(who('AB_gS')); AB_gS=0*mygrid.XC; end; |
80 |
|
|
if isempty(who('oceSPtnd')); oceSPtnd=0*mygrid.XC; end; |
81 |
|
|
if isempty(who('oceSPflx')); oceSPflx=0*mygrid.XC; end; |
82 |
|
|
if isempty(who('PHIBOT')); PHIBOT=0*mygrid.XC; end; |
83 |
gforget |
1.6 |
if isempty(who('geothFlux')); geothFlux=0; end; |
84 |
gforget |
1.1 |
|
85 |
|
|
%=======MASS========= |
86 |
gforget |
1.6 |
|
87 |
gforget |
1.7 |
[budgMo,budgMi]=calc_budget_mass(kBudget); |
88 |
gforget |
1.6 |
|
89 |
gforget |
1.7 |
contOCN=budgMo.contOCN; |
90 |
|
|
hdivOCN=budgMo.hdivOCN; |
91 |
|
|
zdivOCN=budgMo.zdivOCN; |
92 |
|
|
contICE=budgMi.contICE; |
93 |
|
|
hdivICE=budgMi.hdivICE; |
94 |
|
|
zdivICE=budgMi.zdivICE; |
95 |
gforget |
1.1 |
contTOT=contOCN+contICE; |
96 |
gforget |
1.6 |
hdivTOT=hdivOCN+hdivICE; |
97 |
gforget |
1.1 |
zdivTOT=zdivOCN+zdivICE; |
98 |
gforget |
1.6 |
|
99 |
gforget |
1.1 |
%bottom pressure for comparison: |
100 |
|
|
bp=myparms.rhoconst/9.81*PHIBOT; |
101 |
gforget |
1.6 |
|
102 |
gforget |
1.1 |
[zm_vol_tot,zm_area]=calc_budget_mean_zonal(contTOT,zdivTOT,hdivTOT); |
103 |
|
|
zm_vol_ocn=calc_budget_mean_zonal(contOCN,zdivOCN,hdivOCN); |
104 |
|
|
zm_vol_ice=calc_budget_mean_zonal(contICE,zdivICE,hdivICE); |
105 |
|
|
|
106 |
|
|
%=======HEAT======= |
107 |
|
|
|
108 |
gforget |
1.7 |
[budgHo,budgHi]=calc_budget_heat(kBudget); |
109 |
gforget |
1.6 |
|
110 |
gforget |
1.7 |
contOCN=budgHo.contOCN; |
111 |
|
|
hdivOCN=budgHo.hdivOCN; |
112 |
|
|
zdivOCN=budgHo.zdivOCN; |
113 |
|
|
contICE=budgHi.contICE; |
114 |
|
|
hdivICE=budgHi.hdivICE; |
115 |
|
|
zdivICE=budgHi.zdivICE; |
116 |
gforget |
1.1 |
contTOT=contOCN+contICE; |
117 |
gforget |
1.6 |
hdivTOT=hdivOCN+hdivICE; |
118 |
gforget |
1.1 |
zdivTOT=zdivOCN+zdivICE; |
119 |
|
|
|
120 |
|
|
zm_heat_tot=calc_budget_mean_zonal(contTOT,zdivTOT,hdivTOT); |
121 |
|
|
zm_heat_ocn=calc_budget_mean_zonal(contOCN,zdivOCN,hdivOCN); |
122 |
|
|
zm_heat_ice=calc_budget_mean_zonal(contICE,zdivICE,hdivICE); |
123 |
|
|
|
124 |
|
|
%ocean diffusion alone |
125 |
|
|
tmpU=myparms.rcp*(DFxE_TH); tmpV=myparms.rcp*(DFyE_TH); |
126 |
gforget |
1.3 |
hdivOCN=calc_UV_conv(tmpU,tmpV); |
127 |
gforget |
1.1 |
zm_heat_ocn_diff=calc_budget_mean_zonal(0*contOCN,0*zdivOCN,hdivOCN); |
128 |
|
|
|
129 |
|
|
%=======SALT======= |
130 |
|
|
|
131 |
gforget |
1.7 |
[budgSo,budgSi]=calc_budget_salt(kBudget); |
132 |
gforget |
1.6 |
|
133 |
gforget |
1.7 |
contOCN=budgSo.contOCN; |
134 |
|
|
hdivOCN=budgSo.hdivOCN; |
135 |
|
|
zdivOCN=budgSo.zdivOCN; |
136 |
|
|
contICE=budgSi.contICE; |
137 |
|
|
hdivICE=budgSi.hdivICE; |
138 |
|
|
zdivICE=budgSi.zdivICE; |
139 |
|
|
contTOT=contOCN+contICE; |
140 |
|
|
hdivTOT=hdivOCN+hdivICE; |
141 |
|
|
zdivTOT=zdivOCN+zdivICE; |
142 |
gforget |
1.1 |
contTOT=contOCN+contICE; |
143 |
gforget |
1.6 |
hdivTOT=hdivOCN+hdivICE; |
144 |
gforget |
1.1 |
zdivTOT=zdivOCN+zdivICE; |
145 |
|
|
|
146 |
|
|
zm_salt_tot=calc_budget_mean_zonal(contTOT,zdivTOT,hdivTOT); |
147 |
|
|
zm_salt_ocn=calc_budget_mean_zonal(contOCN,zdivOCN,hdivOCN); |
148 |
|
|
zm_salt_ice=calc_budget_mean_zonal(contICE,zdivICE,hdivICE); |
149 |
|
|
|
150 |
|
|
%ocean diffusion alone |
151 |
|
|
tmpU=myparms.rhoconst*(DFxE_SLT); tmpV=myparms.rhoconst*(DFyE_SLT); |
152 |
gforget |
1.3 |
hdivOCN=calc_UV_conv(tmpU,tmpV); |
153 |
gforget |
1.1 |
zm_salt_ocn_diff=calc_budget_mean_zonal(0*contOCN,0*zdivOCN,hdivOCN); |
154 |
|
|
|
155 |
|
|
%===================== COMPUTATIONAL SEQUENCE ENDS =========================% |
156 |
|
|
%===================== PLOTTING SEQUENCE BEGINS =========================% |
157 |
|
|
|
158 |
|
|
elseif userStep==-1;%plotting |
159 |
|
|
|
160 |
|
|
if isempty(setDiagsParams); |
161 |
|
|
choicePlot={'all'}; |
162 |
|
|
elseif isnumeric(setDiagsParams{1})&length(setDiagsParams)==1; |
163 |
|
|
choicePlot={'all'}; |
164 |
|
|
elseif isnumeric(setDiagsParams{1}); |
165 |
|
|
choicePlot={setDiagsParams{2:end}}; |
166 |
|
|
else; |
167 |
|
|
choicePlot=setDiagsParams; |
168 |
|
|
end; |
169 |
|
|
|
170 |
|
|
tt=[1:length(alldiag.listTimes)]; |
171 |
|
|
TT=alldiag.listTimes(tt); |
172 |
|
|
nt=length(TT); |
173 |
|
|
|
174 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'mass'))); |
175 |
|
|
|
176 |
|
|
%1.1) ocean+seaice mass budgets |
177 |
|
|
%------------------------------ |
178 |
|
|
figureL; |
179 |
|
|
%volume budget: |
180 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_tot,'kg/m2','Mass (incl. ice)'); |
181 |
|
|
%cumulative integral: |
182 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
183 |
|
|
tmp1=tmp1.*alldiag.zm_vol_tot; cumbudg=cumsum(tmp1,2); |
184 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (incl. ice)'); |
185 |
|
|
%add to tex file |
186 |
|
|
myCaption={myYmeanTxt,'mass budget (ocean+ice) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
187 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
188 |
|
|
|
189 |
|
|
%1.2) ice mass budgets |
190 |
|
|
%--------------------- |
191 |
|
|
figureL; |
192 |
|
|
%volume budget: |
193 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_ice,'kg/m2','Mass (only ice)'); |
194 |
|
|
%cumulative integral: |
195 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
196 |
|
|
tmp1=tmp1.*alldiag.zm_vol_ice; cumbudg=cumsum(tmp1,2); |
197 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (only ice)'); |
198 |
|
|
%add to tex file |
199 |
|
|
myCaption={myYmeanTxt,'mass budget (only ice) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
200 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
201 |
|
|
end; |
202 |
|
|
|
203 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'mass'))); |
204 |
|
|
|
205 |
|
|
%1.3) ocean mass budgets |
206 |
|
|
%----------------------- |
207 |
|
|
figureL; |
208 |
|
|
%volume budget: |
209 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_ocn,'kg/m2','Mass (ocean only)'); |
210 |
|
|
%cumulative integral: |
211 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
212 |
|
|
tmp1=tmp1.*alldiag.zm_vol_ocn; cumbudg=cumsum(tmp1,2); |
213 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (ocean only)'); |
214 |
|
|
%add to tex file |
215 |
|
|
myCaption={myYmeanTxt,'mass budget (ocean only) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
216 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
217 |
|
|
|
218 |
|
|
end; |
219 |
|
|
|
220 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'heat'))); |
221 |
|
|
|
222 |
|
|
%1.1) ocean+seaice heat budgets |
223 |
|
|
%------------------------------ |
224 |
|
|
figureL; |
225 |
|
|
%heat budget: |
226 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_tot,'J/m2','Heat (incl. ice)'); |
227 |
|
|
%cumulative integral: |
228 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
229 |
|
|
tmp1=tmp1.*alldiag.zm_heat_tot; cumbudg=cumsum(tmp1,2); |
230 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (incl. ice)'); |
231 |
|
|
%add to tex file |
232 |
|
|
myCaption={myYmeanTxt,'heat budget (ocean+ice) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
233 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
234 |
|
|
|
235 |
|
|
%1.2) ice heat budgets |
236 |
|
|
%--------------------- |
237 |
|
|
figureL; |
238 |
|
|
%heat budget: |
239 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_ice,'J/m2','Heat (only ice)'); |
240 |
|
|
%cumulative integral: |
241 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
242 |
|
|
tmp1=tmp1.*alldiag.zm_heat_ice; cumbudg=cumsum(tmp1,2); |
243 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (only ice)'); |
244 |
|
|
%add to tex file |
245 |
|
|
myCaption={myYmeanTxt,'heat budget (only ice) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
246 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
247 |
|
|
end; |
248 |
|
|
|
249 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'heat'))); |
250 |
|
|
|
251 |
|
|
%1.3) ocean heat budgets |
252 |
|
|
%----------------------- |
253 |
|
|
figureL; |
254 |
|
|
%heat budget: |
255 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_ocn,'J/m2','Heat (ocean only)'); |
256 |
|
|
%cumulative integral: |
257 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
258 |
|
|
tmp1=tmp1.*alldiag.zm_heat_ocn; cumbudg=cumsum(tmp1,2); |
259 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (ocean only)'); |
260 |
|
|
%add to tex file |
261 |
|
|
myCaption={myYmeanTxt,'heat budget (ocean only) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
262 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
263 |
|
|
|
264 |
|
|
end; |
265 |
|
|
|
266 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'salt'))); |
267 |
|
|
|
268 |
|
|
%1.1) ocean+seaice salt budgets |
269 |
|
|
%------------------------------ |
270 |
|
|
figureL; |
271 |
|
|
%salt budget: |
272 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_tot,'g/m2','Salt (incl. ice)'); |
273 |
|
|
%cumulative integral: |
274 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
275 |
|
|
tmp1=tmp1.*alldiag.zm_salt_tot; cumbudg=cumsum(tmp1,2); |
276 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (incl. ice)'); |
277 |
|
|
%add to tex file |
278 |
|
|
myCaption={myYmeanTxt,'salt budget (ocean+ice) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
279 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
280 |
|
|
|
281 |
|
|
%1.2) ice salt budgets |
282 |
|
|
%--------------------- |
283 |
|
|
figureL; |
284 |
|
|
%salt budget: |
285 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_ice,'g/m2','Salt (only ice)'); |
286 |
|
|
%cumulative integral: |
287 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
288 |
|
|
tmp1=tmp1.*alldiag.zm_salt_ice; cumbudg=cumsum(tmp1,2); |
289 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (only ice)'); |
290 |
|
|
%add to tex file |
291 |
|
|
myCaption={myYmeanTxt,'salt budget (only ice) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
292 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
293 |
|
|
end; |
294 |
|
|
|
295 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'salt'))); |
296 |
|
|
|
297 |
|
|
%1.3) ocean salt budgets |
298 |
|
|
%----------------------- |
299 |
|
|
figureL; |
300 |
|
|
%salt budget: |
301 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_ocn,'g/m2','Salt (ocean only)'); |
302 |
|
|
%cumulative integral: |
303 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
304 |
|
|
tmp1=tmp1.*alldiag.zm_salt_ocn; cumbudg=cumsum(tmp1,2); |
305 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (ocean only)'); |
306 |
|
|
%add to tex file |
307 |
|
|
myCaption={myYmeanTxt,'salt budget (ocean only) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
308 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
309 |
|
|
|
310 |
|
|
end; |
311 |
|
|
|
312 |
|
|
end; |
313 |
|
|
|