/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_budget_heat.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_budget_heat.m

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


Revision 1.9 - (show annotations) (download)
Thu Jul 28 18:30:44 2016 UTC (9 years ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.8: +4 -0 lines
- document the specific meaning of THETA, SALT, ETAN, SIheff, and SIhsnow
  (tendencies computed by diags_diff_snapshots.m) in the context of these routines

1 function [budgO,budgI,budgOI]=calc_budget_heat(kBudget);
2 % CALC_BUDGET_HEAT(kBudget)
3 %
4 % note: within this routine `THETA', `SIheff', and `SIhsnow' denote
5 % the corresponding tendencies as computed by diags_diff_snapshots.m
6 % rather than the state variables themselves.
7
8 gcmfaces_global;
9
10 %get variables from caller routine:
11 %----------------------------------
12
13 global myparms;
14
15 list_variables={'THETA','AB_gT','TRELAX','SIheff','SIhsnow',...
16 'TFLUX','geothFlux','SItflux','SIaaflux','oceQnet',...
17 'SIatmQnt','SIsnPrcp','SIacSubl','WTHMASS',...
18 'ADVx_TH','DFxE_TH','ADVy_TH','DFyE_TH',...
19 'ADVxHEFF','ADVxSNOW','DFxEHEFF','DFxESNOW',...
20 'ADVyHEFF','ADVySNOW','DFyEHEFF','DFyESNOW'};
21
22 for vv=1:length(list_variables);
23 v = evalin('caller',list_variables{vv});
24 eval([list_variables{vv} '=v;']);
25 end;
26 clear v;
27
28 test3d=length(size(ADVx_TH{1}))>2;
29
30 if test3d|kBudget>1;
31 list_variables={'oceQsw','ADVr_TH','DFrE_TH',...
32 'DFrI_TH','ADVr_TH','DFrE_TH','DFrI_TH'};
33 for vv=1:length(list_variables);
34 v = evalin('caller',list_variables{vv});
35 eval([list_variables{vv} '=v;']);
36 end;
37 clear v;
38 end;
39
40 %compute mapped budget:
41 %----------------------
42
43 budgO.tend=myparms.rcp*THETA-myparms.rcp*AB_gT;
44 budgI.tend=-myparms.flami*(SIheff*myparms.rhoi+SIhsnow*myparms.rhosn);
45 %
46 tmptend=mk3D(mygrid.RAC,budgO.tend).*budgO.tend;%Watt
47 budgO.fluxes.tend=tmptend;
48 budgO.tend=nansum(tmptend,3);
49 budgI.tend=mygrid.RAC.*budgI.tend;%Watt
50 %
51 budgOI.tend=budgO.tend+budgI.tend;
52
53 %vertical divergence (air-sea fluxes or vertical adv/dif)
54 budgO.zconv=TFLUX+geothFlux;
55 budgI.zconv=-(SItflux+TFLUX-TRELAX);
56 %in linear surface we omit :
57 if ~myparms.useNLFS; budgO.zconv=budgO.zconv-myparms.rcp*WTHMASS; end;
58 %in virtual salt flux we omit :
59 if ~myparms.useRFWF|~myparms.useNLFS; budgI.zconv=budgI.zconv+SIaaflux; end;
60 %working approach for real fresh water (?) and virtual salt flux
61 if 0; budgI.zconv=-oceQnet-SIatmQnt-myparms.flami*(SIsnPrcp-SIacSubl); end;
62 %
63 budgO.zdia=budgO.zconv;
64 %for deep ocean layer :
65 if kBudget>1;
66 budgO.zconv=-(ADVr_TH+DFrE_TH+DFrI_TH)./mygrid.RAC*myparms.rcp;
67 budgO.zdia=-(DFrE_TH+DFrI_TH)./mygrid.RAC*myparms.rcp;
68 dd=mygrid.RF(kBudget); msk=mygrid.mskC(:,:,kBudget);
69 swfrac=0.62*exp(dd/0.6)+(1-0.62)*exp(dd/20);
70 if dd<-200; swfrac=0; end;
71 budgO.zconv=budgO.zconv+swfrac*oceQsw+geothFlux;%.*msk;
72 budgO.zdia=budgO.zdia+swfrac*oceQsw+geothFlux;%.*msk;
73 end;
74 %
75 %notes: - geothFlux remains to be accounted for in 3D case
76 % - diaWtop, diaWbot remain to be implemented in 3D case
77 if test3d;
78 trWtop=-(ADVr_TH+DFrE_TH+DFrI_TH)*myparms.rcp;
79 %
80 dd=mygrid.RF(1:end-1);
81 swfrac=0.62*exp(dd/0.6)+(1-0.62)*exp(dd/20);
82 swfrac(dd<-200)=0;
83 swtop=mk3D(swfrac,trWtop).*mk3D(mygrid.RAC.*oceQsw,trWtop);
84 swtop(isnan(mygrid.mskC))=0;
85 trWtop=trWtop+swtop;
86 %
87 trWtop(:,:,1)=budgO.zconv.*mygrid.RAC;
88 trWbot=trWtop(:,:,2:length(mygrid.RC));
89 trWbot(:,:,length(mygrid.RC))=0;
90 %
91 budgO.fluxes.trWtop=trWtop;%Watt
92 budgO.fluxes.trWbot=trWbot;%Watt
93 else;
94 budgO.fluxes.trWtop=-mygrid.RAC.*(budgO.zconv-geothFlux);
95 budgO.fluxes.trWbot=mygrid.RAC.*geothFlux;%Watt
96 budgO.fluxes.diaWtop=-mygrid.RAC.*(budgO.zdia-geothFlux);
97 budgO.fluxes.diaWbot=mygrid.RAC.*geothFlux;%Watt
98 end;
99 budgI.fluxes.trWtop=-mygrid.RAC.*(budgI.zconv+budgO.zconv);
100 budgI.fluxes.trWbot=-mygrid.RAC.*budgO.zconv;%Watt
101 %
102 budgO.zconv=mk3D(mygrid.RAC,budgO.zconv).*budgO.zconv;%Watt
103 budgI.zconv=mygrid.RAC.*budgI.zconv;%Watt
104 budgOI.zconv=budgO.zconv+budgI.zconv;
105
106 %horizontal divergence (advection and diffusion)
107 tmpUo=myparms.rcp*(ADVx_TH+DFxE_TH); tmpVo=myparms.rcp*(ADVy_TH+DFyE_TH);
108 budgO.hconv=calc_UV_conv(nansum(tmpUo,3),nansum(tmpVo,3));
109 %
110 tmpUoD=myparms.rcp*DFxE_TH; tmpVoD=myparms.rcp*DFyE_TH;
111 budgO.hdia=calc_UV_conv(nansum(tmpUoD,3),nansum(tmpVoD,3));
112 %
113 tmpUi=-myparms.flami*(myparms.rhoi*DFxEHEFF+myparms.rhosn*DFxESNOW+myparms.rhoi*ADVxHEFF+myparms.rhosn*ADVxSNOW);
114 tmpVi=-myparms.flami*(myparms.rhoi*DFyEHEFF+myparms.rhosn*DFyESNOW+myparms.rhoi*ADVyHEFF+myparms.rhosn*ADVySNOW);
115 budgI.hconv=calc_UV_conv(tmpUi,tmpVi); %no dh needed here
116 budgOI.hconv=budgO.hconv+budgI.hconv;
117 %
118 budgO.fluxes.trU=tmpUo; budgO.fluxes.trV=tmpVo;%Watt
119 budgO.fluxes.diaU=tmpUoD; budgO.fluxes.diaV=tmpVoD;%Watt
120 budgI.fluxes.trU=tmpUi; budgI.fluxes.trV=tmpVi;%Watt
121

  ViewVC Help
Powered by ViewVC 1.1.22