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.8 |
[budgMo,budgMi,budgMoi]=calc_budget_mass(kBudget); |
88 |
gforget |
1.6 |
|
89 |
gforget |
1.1 |
%bottom pressure for comparison: |
90 |
|
|
bp=myparms.rhoconst/9.81*PHIBOT; |
91 |
gforget |
1.6 |
|
92 |
gforget |
1.8 |
[zm_vol_tot,zm_area]=calc_budget_mean_zonal(budgMo); |
93 |
|
|
zm_vol_ocn=calc_budget_mean_zonal(budgMo); |
94 |
|
|
zm_vol_ice=calc_budget_mean_zonal(budgMi); |
95 |
gforget |
1.1 |
|
96 |
|
|
%=======HEAT======= |
97 |
|
|
|
98 |
gforget |
1.8 |
[budgHo,budgHi,budgHoi]=calc_budget_heat(kBudget); |
99 |
gforget |
1.6 |
|
100 |
gforget |
1.8 |
zm_heat_tot=calc_budget_mean_zonal(budgHo); |
101 |
|
|
zm_heat_ocn=calc_budget_mean_zonal(budgHo); |
102 |
|
|
zm_heat_ice=calc_budget_mean_zonal(budgHi); |
103 |
gforget |
1.1 |
|
104 |
|
|
%ocean diffusion alone |
105 |
|
|
tmpU=myparms.rcp*(DFxE_TH); tmpV=myparms.rcp*(DFyE_TH); |
106 |
gforget |
1.8 |
budgD.hconv=calc_UV_conv(tmpU,tmpV); |
107 |
|
|
budgD.cont=0*budgD.hconv; budgD.zconv=0*budgD.hconv; |
108 |
|
|
zm_heat_ocn_diff=calc_budget_mean_zonal(budgD); |
109 |
gforget |
1.1 |
|
110 |
|
|
%=======SALT======= |
111 |
|
|
|
112 |
gforget |
1.8 |
[budgSo,budgSi,budgSoi]=calc_budget_salt(kBudget); |
113 |
gforget |
1.6 |
|
114 |
gforget |
1.8 |
zm_salt_tot=calc_budget_mean_zonal(budgSo); |
115 |
|
|
zm_salt_ocn=calc_budget_mean_zonal(budgSo); |
116 |
|
|
zm_salt_ice=calc_budget_mean_zonal(budgSi); |
117 |
gforget |
1.1 |
|
118 |
|
|
%ocean diffusion alone |
119 |
|
|
tmpU=myparms.rhoconst*(DFxE_SLT); tmpV=myparms.rhoconst*(DFyE_SLT); |
120 |
gforget |
1.8 |
budgD.hconv=calc_UV_conv(tmpU,tmpV); |
121 |
|
|
budgD.cont=0*budgD.hconv; budgD.zconv=0*budgD.hconv; |
122 |
|
|
zm_salt_ocn_diff=calc_budget_mean_zonal(budgD); |
123 |
gforget |
1.1 |
|
124 |
|
|
%===================== COMPUTATIONAL SEQUENCE ENDS =========================% |
125 |
|
|
%===================== PLOTTING SEQUENCE BEGINS =========================% |
126 |
|
|
|
127 |
|
|
elseif userStep==-1;%plotting |
128 |
|
|
|
129 |
|
|
if isempty(setDiagsParams); |
130 |
|
|
choicePlot={'all'}; |
131 |
|
|
elseif isnumeric(setDiagsParams{1})&length(setDiagsParams)==1; |
132 |
|
|
choicePlot={'all'}; |
133 |
|
|
elseif isnumeric(setDiagsParams{1}); |
134 |
|
|
choicePlot={setDiagsParams{2:end}}; |
135 |
|
|
else; |
136 |
|
|
choicePlot=setDiagsParams; |
137 |
|
|
end; |
138 |
|
|
|
139 |
|
|
tt=[1:length(alldiag.listTimes)]; |
140 |
|
|
TT=alldiag.listTimes(tt); |
141 |
|
|
nt=length(TT); |
142 |
|
|
|
143 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'mass'))); |
144 |
|
|
|
145 |
|
|
%1.1) ocean+seaice mass budgets |
146 |
|
|
%------------------------------ |
147 |
|
|
figureL; |
148 |
|
|
%volume budget: |
149 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_tot,'kg/m2','Mass (incl. ice)'); |
150 |
|
|
%cumulative integral: |
151 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
152 |
|
|
tmp1=tmp1.*alldiag.zm_vol_tot; cumbudg=cumsum(tmp1,2); |
153 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (incl. ice)'); |
154 |
|
|
%add to tex file |
155 |
|
|
myCaption={myYmeanTxt,'mass budget (ocean+ice) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
156 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
157 |
|
|
|
158 |
|
|
%1.2) ice mass budgets |
159 |
|
|
%--------------------- |
160 |
|
|
figureL; |
161 |
|
|
%volume budget: |
162 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_ice,'kg/m2','Mass (only ice)'); |
163 |
|
|
%cumulative integral: |
164 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
165 |
|
|
tmp1=tmp1.*alldiag.zm_vol_ice; cumbudg=cumsum(tmp1,2); |
166 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (only ice)'); |
167 |
|
|
%add to tex file |
168 |
|
|
myCaption={myYmeanTxt,'mass budget (only ice) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
169 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
170 |
|
|
end; |
171 |
|
|
|
172 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'mass'))); |
173 |
|
|
|
174 |
|
|
%1.3) ocean mass budgets |
175 |
|
|
%----------------------- |
176 |
|
|
figureL; |
177 |
|
|
%volume budget: |
178 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_vol_ocn,'kg/m2','Mass (ocean only)'); |
179 |
|
|
%cumulative integral: |
180 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
181 |
|
|
tmp1=tmp1.*alldiag.zm_vol_ocn; cumbudg=cumsum(tmp1,2); |
182 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'kg','Mass (ocean only)'); |
183 |
|
|
%add to tex file |
184 |
|
|
myCaption={myYmeanTxt,'mass budget (ocean only) at each latitude in kg/m2 (upper) and integrated from South (lower).'}; |
185 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
186 |
|
|
|
187 |
|
|
end; |
188 |
|
|
|
189 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'heat'))); |
190 |
|
|
|
191 |
|
|
%1.1) ocean+seaice heat budgets |
192 |
|
|
%------------------------------ |
193 |
|
|
figureL; |
194 |
|
|
%heat budget: |
195 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_tot,'J/m2','Heat (incl. ice)'); |
196 |
|
|
%cumulative integral: |
197 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
198 |
|
|
tmp1=tmp1.*alldiag.zm_heat_tot; cumbudg=cumsum(tmp1,2); |
199 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (incl. ice)'); |
200 |
|
|
%add to tex file |
201 |
|
|
myCaption={myYmeanTxt,'heat budget (ocean+ice) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
202 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
203 |
|
|
|
204 |
|
|
%1.2) ice heat budgets |
205 |
|
|
%--------------------- |
206 |
|
|
figureL; |
207 |
|
|
%heat budget: |
208 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_ice,'J/m2','Heat (only ice)'); |
209 |
|
|
%cumulative integral: |
210 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
211 |
|
|
tmp1=tmp1.*alldiag.zm_heat_ice; cumbudg=cumsum(tmp1,2); |
212 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (only ice)'); |
213 |
|
|
%add to tex file |
214 |
|
|
myCaption={myYmeanTxt,'heat budget (only ice) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
215 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
216 |
|
|
end; |
217 |
|
|
|
218 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'heat'))); |
219 |
|
|
|
220 |
|
|
%1.3) ocean heat budgets |
221 |
|
|
%----------------------- |
222 |
|
|
figureL; |
223 |
|
|
%heat budget: |
224 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_heat_ocn,'J/m2','Heat (ocean only)'); |
225 |
|
|
%cumulative integral: |
226 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
227 |
|
|
tmp1=tmp1.*alldiag.zm_heat_ocn; cumbudg=cumsum(tmp1,2); |
228 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'J','Heat (ocean only)'); |
229 |
|
|
%add to tex file |
230 |
|
|
myCaption={myYmeanTxt,'heat budget (ocean only) at each latitude in J/m2 (upper) and integrated from South (lower).'}; |
231 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
232 |
|
|
|
233 |
|
|
end; |
234 |
|
|
|
235 |
|
|
if (kBudget==1)&(sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'salt'))); |
236 |
|
|
|
237 |
|
|
%1.1) ocean+seaice salt budgets |
238 |
|
|
%------------------------------ |
239 |
|
|
figureL; |
240 |
|
|
%salt budget: |
241 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_tot,'g/m2','Salt (incl. ice)'); |
242 |
|
|
%cumulative integral: |
243 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
244 |
|
|
tmp1=tmp1.*alldiag.zm_salt_tot; cumbudg=cumsum(tmp1,2); |
245 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (incl. ice)'); |
246 |
|
|
%add to tex file |
247 |
|
|
myCaption={myYmeanTxt,'salt budget (ocean+ice) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
248 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
249 |
|
|
|
250 |
|
|
%1.2) ice salt budgets |
251 |
|
|
%--------------------- |
252 |
|
|
figureL; |
253 |
|
|
%salt budget: |
254 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_ice,'g/m2','Salt (only ice)'); |
255 |
|
|
%cumulative integral: |
256 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
257 |
|
|
tmp1=tmp1.*alldiag.zm_salt_ice; cumbudg=cumsum(tmp1,2); |
258 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (only ice)'); |
259 |
|
|
%add to tex file |
260 |
|
|
myCaption={myYmeanTxt,'salt budget (only ice) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
261 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
262 |
|
|
end; |
263 |
|
|
|
264 |
|
|
if (sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'salt'))); |
265 |
|
|
|
266 |
|
|
%1.3) ocean salt budgets |
267 |
|
|
%----------------------- |
268 |
|
|
figureL; |
269 |
|
|
%salt budget: |
270 |
|
|
subplot(2,1,1); disp_budget_mean_zonal(mygrid.LATS,alldiag.zm_salt_ocn,'g/m2','Salt (ocean only)'); |
271 |
|
|
%cumulative integral: |
272 |
gforget |
1.4 |
tmp1=repmat(alldiag.zm_area,[3 1 1]); |
273 |
|
|
tmp1=tmp1.*alldiag.zm_salt_ocn; cumbudg=cumsum(tmp1,2); |
274 |
gforget |
1.1 |
subplot(2,1,2); disp_budget_mean_zonal(mygrid.LATS,cumbudg,'g','Salt (ocean only)'); |
275 |
|
|
%add to tex file |
276 |
|
|
myCaption={myYmeanTxt,'salt budget (ocean only) at each latitude in g/m2 (upper) and integrated from South (lower).'}; |
277 |
|
|
if addToTex&multiTimes; write2tex(fileTex,2,myCaption,gcf); end; |
278 |
|
|
|
279 |
|
|
end; |
280 |
|
|
|
281 |
|
|
end; |
282 |
|
|
|