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

Annotation 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.1 - (hide annotations) (download)
Sat Feb 6 15:31:21 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
- move budget computations from diags_set_D.m to separate functions.

1 gforget 1.1 function [contOCN,hdivOCN,zdivOCN,budgSo,...
2     contICE,hdivICE,zdivICE,budgSi]=...
3     calc_budget_salt(kBudget);
4     % CALC_BUDGET_SALT(kBudget)
5    
6     gcmfaces_global;
7    
8     %get variables from caller routine:
9     %----------------------------------
10    
11     global myparms;
12    
13     list_variables={'SALT','AB_gS','SRELAX','SIheff',...
14     'SFLUX','oceSPflx','oceSflux','WSLTMASS',...
15     'ADVx_SLT','DFxE_SLT','ADVy_SLT','DFyE_SLT',...
16     'ADVxHEFF','ADVxSNOW','DFxEHEFF','DFxESNOW',...
17     'ADVyHEFF','ADVySNOW','DFyEHEFF','DFyESNOW'};
18    
19     if kBudget>1;
20     list_variables={list_variables{:},'oceSPtnd','ADVr_SLT','DFrE_SLT',...
21     'DFrI_SLT','ADVr_SLT','DFrE_SLT','DFrI_SLT'};
22     end;
23    
24     for vv=1:length(list_variables);
25     v = evalin('caller',list_variables{vv});
26     eval([list_variables{vv} '=v;']);
27     end;
28     clear v;
29    
30     test3d=length(size(ADVx_SLT{1}))>2;
31    
32     %compute mapped budget:
33     %----------------------
34    
35     contOCN=myparms.rhoconst*SALT-myparms.rhoconst*AB_gS;
36     contICE=myparms.SIsal0*myparms.rhoi*SIheff;
37     %
38     budgSo.tend=mk3D(mygrid.RAC,contOCN).*contOCN;%g/s
39     budgSi.tend=mygrid.RAC.*contICE;%g/s
40     %
41     contOCN=nansum(contOCN,3);
42     contTOT=contOCN+contICE;
43    
44     %vertical divergence (air-sea fluxes or vertical adv/dif)
45     zdivOCN=SFLUX+oceSPflx;
46     zdivICE=-zdivOCN+SRELAX;
47     %in linear surface we omit :
48     if ~myparms.useNLFS; zdivOCN=zdivOCN-myparms.rhoconst*WSLTMASS; end;
49     %working approach for real fresh water (?) and virtual salt flux
50     if ~myparms.useRFWF|~myparms.useNLFS; zdivICE=-oceSflux; end;
51     %for deep ocean layer :
52     if kBudget>1;
53     zdivOCN=-(ADVr_SLT+DFrE_SLT+DFrI_SLT)./mygrid.RAC*myparms.rhoconst;
54     zdivOCN=zdivOCN+oceSPtnd;%.*msk;
55     end;
56     zdivTOT=zdivOCN+zdivICE;
57     %
58     if test3d;
59     nr=length(mygrid.RC);
60     trWtop=-(ADVr_SLT+DFrE_SLT+DFrI_SLT)*myparms.rhoconst;
61     tmp1=mk3D(oceSPflx,oceSPtnd)-cumsum(oceSPtnd,3);
62     tmp1=tmp1.*mk3D(mygrid.RAC,tmp1);
63     trWtop(:,:,2:nr)=trWtop(:,:,2:nr)+tmp1(:,:,1:nr-1);
64     %
65     trWtop(:,:,1)=zdivOCN.*mygrid.RAC;
66     trWbot=trWtop(:,:,2:length(mygrid.RC));
67     trWbot(:,:,length(mygrid.RC))=0;
68     %
69     budgSo.trWtop=trWtop;%kg/s
70     budgSo.trWbot=trWbot;%kg/s
71     else;
72     budgSo.trWtop=mygrid.RAC.*zdivOCN; budgSo.trWbot=mygrid.RAC*0;%kg/s
73     end;
74     budgSi.trWtop=0*mygrid.RAC; budgSi.trWbot=budgSo.trWtop(:,:,1);%kg/s
75    
76     %horizontal divergence (advection and diffusion)
77     tmpUo=myparms.rhoconst*(ADVx_SLT+DFxE_SLT);
78     tmpVo=myparms.rhoconst*(ADVy_SLT+DFyE_SLT);
79     hdivOCN=calc_UV_conv(nansum(tmpUo,3),nansum(tmpVo,3));
80     tmpUi=myparms.SIsal0*(myparms.rhoi*DFxEHEFF+myparms.rhoi*ADVxHEFF);
81     tmpVi=myparms.SIsal0*(myparms.rhoi*DFyEHEFF+myparms.rhoi*ADVyHEFF);
82     hdivICE=calc_UV_conv(tmpUi,tmpVi); %no dh needed here
83     hdivTOT=hdivOCN+hdivICE;
84     %
85     budgSo.trU=tmpUo; budgSo.trV=tmpVo;%g/s
86     budgSi.trU=tmpUi; budgSi.trV=tmpVi;%g/s
87    
88    

  ViewVC Help
Powered by ViewVC 1.1.22