1 |
gforget |
1.2 |
function [diags]=example_transports(); |
2 |
gforget |
1.4 |
%EXAMPLE_TRANSPORTS computes transports (and zonal averages) |
3 |
gforget |
1.5 |
% |
4 |
|
|
% Note: this demonstration routine includes its own call to grid_load |
5 |
|
|
% |
6 |
gforget |
1.6 |
% Example: |
7 |
|
|
% addpath gcmfaces/; gcmfaces_global; myenv.verbose=1; |
8 |
gforget |
1.5 |
% [diags]=example_transports(); |
9 |
|
|
% example_transports_disp(diags); |
10 |
gforget |
1.4 |
|
11 |
gforget |
1.1 |
gcmfaces_global; |
12 |
|
|
if myenv.verbose>0; |
13 |
|
|
gcmfaces_msg('==============================================='); |
14 |
gforget |
1.7 |
gcmfaces_msg(['*** entering example_transports: ' ... |
15 |
|
|
'load flow field form nctiles file and compute transports'],''); |
16 |
gforget |
1.1 |
end; |
17 |
|
|
|
18 |
|
|
%%%%%%%%%%%%%%%%% |
19 |
gforget |
1.4 |
%load grid: |
20 |
gforget |
1.1 |
%%%%%%%%%%%%%%%%% |
21 |
|
|
|
22 |
gforget |
1.4 |
if isempty(mygrid); |
23 |
|
|
grid_load; |
24 |
gforget |
1.1 |
end; |
25 |
gforget |
1.2 |
|
26 |
gforget |
1.4 |
myenv.nctilesdir=fullfile('release1',filesep,'nctiles_climatology',filesep); |
27 |
gforget |
1.1 |
|
28 |
|
|
if ~isdir(myenv.nctilesdir); |
29 |
gforget |
1.9 |
myenv.nctilesdir=fullfile('release2_climatology',filesep,'nctiles_climatology',filesep); |
30 |
|
|
end; |
31 |
|
|
|
32 |
|
|
if ~isdir(myenv.nctilesdir); |
33 |
gforget |
1.1 |
diags=[]; |
34 |
gforget |
1.3 |
help gcmfaces_demo; |
35 |
gforget |
1.1 |
warning(['skipping example_transports (missing ' myenv.nctilesdir ')']); |
36 |
|
|
return; |
37 |
|
|
end; |
38 |
|
|
|
39 |
|
|
if myenv.verbose>0; |
40 |
gforget |
1.9 |
gcmfaces_msg('* call gcmfaces_lines_zonal : determine grid lines that closely follow lines of'); |
41 |
|
|
gcmfaces_msg('constant latitudes and will be used in zonal mean and meridional transport computations',' '); |
42 |
gforget |
1.1 |
end; |
43 |
gforget |
1.2 |
gcmfaces_lines_zonal; |
44 |
|
|
|
45 |
gforget |
1.1 |
if myenv.verbose>0; |
46 |
|
|
gcmfaces_msg('* call gcmfaces_lines_transp : determine grid lines that closely follow'); |
47 |
gforget |
1.9 |
gcmfaces_msg('great circles and will be used to compute transports through select sections',' '); |
48 |
gforget |
1.1 |
end; |
49 |
|
|
% warning('skipping gcmfaces_lines_transp\n'); |
50 |
gforget |
1.5 |
[lonPairs,latPairs,names]=gcmfaces_lines_pairs; |
51 |
gforget |
1.1 |
gcmfaces_lines_transp(lonPairs,latPairs,names); |
52 |
|
|
|
53 |
|
|
%%%%%%%%%%%%%%%%% |
54 |
|
|
%do computations: |
55 |
|
|
%%%%%%%%%%%%%%%%% |
56 |
|
|
|
57 |
gforget |
1.4 |
listDiags={}; |
58 |
|
|
|
59 |
gforget |
1.1 |
% [listTimes]=diags_list_times; |
60 |
|
|
diags.listTimes=1; |
61 |
|
|
|
62 |
gforget |
1.4 |
%part 1: |
63 |
|
|
|
64 |
gforget |
1.9 |
listVars={'UVELMASS','VVELMASS','GM_PsiX','GM_PsiY'}; |
65 |
gforget |
1.4 |
missingVars={}; |
66 |
|
|
for vv=1:length(listVars); |
67 |
|
|
tmp1=[myenv.nctilesdir listVars{vv} filesep listVars{vv} '*nc']; |
68 |
|
|
if isempty(dir(tmp1)); missingVars={missingVars{:},tmp1}; end; |
69 |
|
|
end; |
70 |
|
|
|
71 |
|
|
if ~isempty(missingVars); |
72 |
|
|
fprintf('\n example_transports could not find the following files ---> skipping related computation!\n'); |
73 |
|
|
disp(missingVars'); |
74 |
|
|
else; |
75 |
|
|
|
76 |
gforget |
1.9 |
if myenv.verbose>0; gcmfaces_msg('* call read_nctiles : load velocity GM streamfunction fields');end; |
77 |
gforget |
1.4 |
|
78 |
gforget |
1.1 |
for vvv=1:length(listVars); |
79 |
|
|
vv=listVars{vvv}; |
80 |
|
|
tmp1=read_nctiles([myenv.nctilesdir vv '/' vv],vv); |
81 |
|
|
tmp1=mean(tmp1,4); |
82 |
|
|
tmp1(mygrid.mskC==0)=NaN; |
83 |
|
|
eval([vv '=tmp1;']); |
84 |
|
|
end; |
85 |
|
|
|
86 |
gforget |
1.9 |
%apply NaN-masks: |
87 |
gforget |
1.1 |
UVELMASS=UVELMASS.*mygrid.mskW; |
88 |
|
|
VVELMASS=VVELMASS.*mygrid.mskS; |
89 |
|
|
|
90 |
gforget |
1.9 |
if myenv.verbose>0; gcmfaces_msg('* call calc_bolus : compute bolus component from GM streamfunction');end; |
91 |
|
|
|
92 |
|
|
%add bolus component from GM scheme: |
93 |
|
|
[UVELbol,VVELbol,fldWbolus]=calc_bolus(GM_PsiX,GM_PsiY); |
94 |
|
|
UVELbol=UVELbol.*mygrid.mskW; VVELbol=VVELbol.*mygrid.mskS; |
95 |
|
|
UVELtot=UVELMASS+UVELbol; VVELtot=VVELMASS+VVELbol; |
96 |
|
|
|
97 |
|
|
%compute transports: |
98 |
gforget |
1.4 |
listDiags={listDiags{:},'fldBAR','gloOV','fldTRANSPORTS','gloMT_FW'}; |
99 |
gforget |
1.1 |
if myenv.verbose>0; gcmfaces_msg('* call calc_barostream : comp. barotropic stream function');end; |
100 |
|
|
[fldBAR]=calc_barostream(UVELMASS,VVELMASS); |
101 |
gforget |
1.9 |
if myenv.verbose>0; gcmfaces_msg('* call calc_overturn : comp. residual overturning stream function');end; |
102 |
|
|
[gloOV]=calc_overturn(UVELtot,VVELtot); |
103 |
gforget |
1.1 |
if myenv.verbose>0; gcmfaces_msg('* call calc_transports : comp. transects transports');end; |
104 |
|
|
[fldTRANSPORTS]=1e-6*calc_transports(UVELMASS,VVELMASS,mygrid.LINES_MASKS,{'dh','dz'}); |
105 |
|
|
if myenv.verbose>0; gcmfaces_msg('* call calc_MeridionalTransport : comp. meridional seawater transport');end; |
106 |
|
|
[gloMT_FW]=1e-6*calc_MeridionalTransport(UVELMASS,VVELMASS,1); |
107 |
|
|
|
108 |
gforget |
1.4 |
end;%if ~isempty(missingVars); |
109 |
|
|
|
110 |
|
|
%part 2: |
111 |
|
|
|
112 |
gforget |
1.1 |
listVars={'THETA','SALT','ADVx_TH','ADVy_TH','ADVx_SLT','ADVy_SLT'}; |
113 |
|
|
listVars={listVars{:},'DFxE_TH','DFyE_TH','DFxE_SLT','DFyE_SLT'}; |
114 |
gforget |
1.4 |
|
115 |
|
|
missingVars={}; |
116 |
|
|
for vv=1:length(listVars); |
117 |
|
|
tmp1=[myenv.nctilesdir listVars{vv} filesep listVars{vv} '*nc']; |
118 |
|
|
if isempty(dir(tmp1)); missingVars={missingVars{:},tmp1}; end; |
119 |
|
|
end; |
120 |
|
|
|
121 |
|
|
if ~isempty(missingVars); |
122 |
|
|
fprintf('\n example_transports could not find the following files ---> skipping related computation!\n'); |
123 |
|
|
disp(missingVars'); |
124 |
|
|
else; |
125 |
|
|
|
126 |
|
|
if myenv.verbose>0; gcmfaces_msg('* load tracer and transports fields');end; |
127 |
gforget |
1.1 |
listDiags={listDiags{:},'fldTzonmean','fldSzonmean','gloMT_H','gloMT_SLT'}; |
128 |
|
|
for vvv=1:length(listVars); |
129 |
|
|
vv=listVars{vvv}; |
130 |
|
|
tmp1=read_nctiles([myenv.nctilesdir vv '/' vv],vv); |
131 |
|
|
tmp1=mean(tmp1,4); |
132 |
|
|
tmp1(mygrid.mskC==0)=NaN; |
133 |
|
|
eval([vv '=tmp1;']); |
134 |
|
|
end; |
135 |
|
|
|
136 |
|
|
if myenv.verbose>0; gcmfaces_msg('* call calc_zonmean_T : comp. zonal mean temperature');end; |
137 |
|
|
[fldTzonmean]=calc_zonmean_T(THETA); |
138 |
|
|
if myenv.verbose>0; gcmfaces_msg('* call calc_zonmean_T : comp. zonal mean salinity');end; |
139 |
|
|
[fldSzonmean]=calc_zonmean_T(SALT); |
140 |
|
|
|
141 |
|
|
if myenv.verbose>0; gcmfaces_msg('* call calc_MeridionalTransport : comp. meridional heat transport');end; |
142 |
|
|
tmpU=(ADVx_TH+DFxE_TH); tmpV=(ADVy_TH+DFyE_TH); |
143 |
|
|
[gloMT_H]=1e-15*4e6*calc_MeridionalTransport(tmpU,tmpV,0); |
144 |
|
|
if myenv.verbose>0; gcmfaces_msg('* call calc_MeridionalTransport : comp. meridional salt transport');end; |
145 |
|
|
tmpU=(ADVx_SLT+DFxE_SLT); tmpV=(ADVy_SLT+DFyE_SLT); |
146 |
|
|
[gloMT_SLT]=1e-6*calc_MeridionalTransport(tmpU,tmpV,0); |
147 |
|
|
|
148 |
gforget |
1.4 |
end;%if ~isempty(missingVars); |
149 |
|
|
|
150 |
|
|
%part 3: format output |
151 |
|
|
|
152 |
gforget |
1.1 |
for ddd=1:length(listDiags); |
153 |
|
|
dd=listDiags{ddd}; |
154 |
|
|
eval(['diags.' dd '=' dd ';']); |
155 |
|
|
end; |
156 |
|
|
|
157 |
|
|
if myenv.verbose>0; |
158 |
|
|
gcmfaces_msg('*** leaving example_transports'); |
159 |
|
|
gcmfaces_msg('===============================================',''); |
160 |
|
|
end; |
161 |
|
|
|