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

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/calc_budget_salt.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:45 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_salt(kBudget);
2 % CALC_BUDGET_SALT(kBudget)
3 %
4 % note: within this routine `SALT', `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={'SALT','AB_gS','SRELAX','SIheff',...
16 'SFLUX','oceSPflx','oceSflux','WSLTMASS',...
17 'ADVx_SLT','DFxE_SLT','ADVy_SLT','DFyE_SLT',...
18 'ADVxHEFF','ADVxSNOW','DFxEHEFF','DFxESNOW',...
19 'ADVyHEFF','ADVySNOW','DFyEHEFF','DFyESNOW'};
20
21 for vv=1:length(list_variables);
22 v = evalin('caller',list_variables{vv});
23 eval([list_variables{vv} '=v;']);
24 end;
25 clear v;
26
27 test3d=length(size(ADVx_SLT{1}))>2;
28
29 if test3d|kBudget>1;
30 list_variables={'oceSPtnd','ADVr_SLT','DFrE_SLT',...
31 'DFrI_SLT','ADVr_SLT','DFrE_SLT','DFrI_SLT'};
32 for vv=1:length(list_variables);
33 v = evalin('caller',list_variables{vv});
34 eval([list_variables{vv} '=v;']);
35 end;
36 clear v;
37 end;
38
39 %compute mapped budget:
40 %----------------------
41
42 budgO.tend=myparms.rhoconst*SALT-myparms.rhoconst*AB_gS;
43 budgI.tend=myparms.SIsal0*myparms.rhoi*SIheff;
44 %
45 tmptend=mk3D(mygrid.RAC,budgO.tend).*budgO.tend;%g/s
46 budgO.fluxes.tend=tmptend;
47 budgO.tend=nansum(tmptend,3);
48 budgI.tend=mygrid.RAC.*budgI.tend;%g/s
49 %
50 budgOI.tend=budgO.tend+budgI.tend;
51
52 %vertical divergence (air-sea fluxes or vertical adv/dif)
53 budgO.zconv=SFLUX+oceSPflx;
54 budgI.zconv=-budgO.zconv+SRELAX;
55 %in linear surface we omit :
56 if ~myparms.useNLFS; budgO.zconv=budgO.zconv-myparms.rhoconst*WSLTMASS; end;
57 %working approach for real fresh water (?) and virtual salt flux
58 if ~myparms.useRFWF|~myparms.useNLFS; budgI.zconv=-oceSflux; end;
59 %
60 budgO.zdia=budgO.zconv;
61 %for deep ocean layer :
62 if kBudget>1;
63 budgO.zconv=-(ADVr_SLT+DFrE_SLT+DFrI_SLT)./mygrid.RAC*myparms.rhoconst;
64 budgO.zconv=budgO.zconv+oceSPtnd;%.*msk;
65 budgO.zdia=-(DFrE_SLT+DFrI_SLT)./mygrid.RAC*myparms.rhoconst;
66 budgO.zdia=budgO.zdia+oceSPtnd;%.*msk;
67 end;
68 %
69 if test3d;
70 nr=length(mygrid.RC);
71 trWtop=-(ADVr_SLT+DFrE_SLT+DFrI_SLT)*myparms.rhoconst;
72 tmp1=mk3D(oceSPflx,oceSPtnd)-cumsum(oceSPtnd,3);
73 tmp1=tmp1.*mk3D(mygrid.RAC,tmp1);
74 trWtop(:,:,2:nr)=trWtop(:,:,2:nr)+tmp1(:,:,1:nr-1);
75 %
76 trWtop(:,:,1)=budgO.zconv.*mygrid.RAC;
77 trWbot=trWtop(:,:,2:length(mygrid.RC));
78 trWbot(:,:,length(mygrid.RC))=0;
79 %
80 budgO.fluxes.trWtop=trWtop;%kg/s
81 budgO.fluxes.trWbot=trWbot;%kg/s
82 else;
83 budgO.fluxes.trWtop=-mygrid.RAC.*budgO.zconv;
84 budgO.fluxes.trWbot=mygrid.RAC*0;%kg/s
85 budgO.fluxes.diaWtop=-mygrid.RAC.*budgO.zdia;
86 budgO.fluxes.diaWbot=mygrid.RAC*0;%kg/s
87 end;
88 budgI.fluxes.trWtop=0*mygrid.RAC;
89 budgI.fluxes.trWbot=budgO.fluxes.trWtop(:,:,1);%kg/s
90 %
91 budgO.zconv=mk3D(mygrid.RAC,budgO.zconv).*budgO.zconv;%Watt
92 budgI.zconv=mygrid.RAC.*budgI.zconv;%Watt
93 %
94 budgOI.zconv=budgO.zconv+budgI.zconv;
95
96 %horizontal divergence (advection and diffusion)
97 tmpUo=myparms.rhoconst*(ADVx_SLT+DFxE_SLT);
98 tmpVo=myparms.rhoconst*(ADVy_SLT+DFyE_SLT);
99 budgO.hconv=calc_UV_conv(nansum(tmpUo,3),nansum(tmpVo,3));
100 %
101 tmpUoD=myparms.rhoconst*(DFxE_SLT);
102 tmpVoD=myparms.rhoconst*(DFyE_SLT);
103 budgO.hdia=calc_UV_conv(nansum(tmpUoD,3),nansum(tmpVoD,3));
104 %
105 tmpUi=myparms.SIsal0*(myparms.rhoi*DFxEHEFF+myparms.rhoi*ADVxHEFF);
106 tmpVi=myparms.SIsal0*(myparms.rhoi*DFyEHEFF+myparms.rhoi*ADVyHEFF);
107 budgI.hconv=calc_UV_conv(tmpUi,tmpVi); %no dh needed here
108 budgOI.hconv=budgO.hconv+budgI.hconv;
109 %
110 budgO.fluxes.trU=tmpUo; budgO.fluxes.trV=tmpVo;%g/s
111 budgO.fluxes.diaU=tmpUoD; budgO.fluxes.diaV=tmpVoD;%g/s
112 budgI.fluxes.trU=tmpUi; budgI.fluxes.trV=tmpVi;%g/s
113

  ViewVC Help
Powered by ViewVC 1.1.22