/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_set_E.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_set_E.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (hide annotations) (download)
Sat Feb 6 15:35:47 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
Changes since 1.5: +20 -83 lines
- diags_display.m diags_driver.m diags_driver_tex.m: improve help sections.
- diags_set_D.m diags_set_E.m diags_set_F.m: move budget computations to
  separate functions (calc_budget_heat.m calc_budget_mass.m calc_budget_salt.m).

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

  ViewVC Help
Powered by ViewVC 1.1.22