-
Notifications
You must be signed in to change notification settings - Fork 0
/
cal_gateway_flux_MPI_ESM1_2_LR_v2.m
364 lines (329 loc) · 19.9 KB
/
cal_gateway_flux_MPI_ESM1_2_LR_v2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
S_ref = 34.8;
T_ref = 0;
dname = '/home/swang/Data/grid_and_mask/areacello_cmip6/';
fname = 'areacello_Ofx_MPI-ESM1-2-LR_historical_r1i1p1f1_gn.nc';
lat_bnds = ncread([dname,fname],'vertices_latitude');
lon_bnds = ncread([dname,fname],'vertices_longitude');
dir_root = '/media/swang/CMIP6_5/';
mdl_name = 'MPI-ESM1-2-LR';
dir_mdl = [dir_root,mdl_name,'/'];
fsec = '~/Data/grid_and_mask/areacello_cmip6/MPI-ESM1-2-LR_sections.mat';
load(fsec);
scenario_list = {'historical','ssp126','ssp245','ssp370','ssp585'};
scenario_list = {'historical','ssp245','ssp585'};
ensemble_list = {'r1i1p1f1'};
year_s = 1950;
% year_e = 1950;
year_e = 2100;
rEarth = 12735000/2.0;% m
for iensem=1:length(ensemble_list)
for iscenario=1:length(scenario_list)
for iyear=year_s:year_e
if (iyear<=2014 & ~strcmp(char(scenario_list(iscenario)),'historical')) continue;end;
if (iyear>2014 & strcmp(char(scenario_list(iscenario)),'historical')) continue;end;
disp('___Calculating Section tranport__________________');
disp(['___',char(scenario_list(iscenario)),' : ',num2str(iyear)]);
fu = ['uo_Omon_',mdl_name,'_',char(scenario_list(iscenario)),'_',char(ensemble_list(iensem)),'_*_',num2str(iyear),'.nc'];
fv = ['vo_Omon_',mdl_name,'_',char(scenario_list(iscenario)),'_',char(ensemble_list(iensem)),'_*_',num2str(iyear),'.nc'];
fs = ['so_Omon_',mdl_name,'_',char(scenario_list(iscenario)),'_',char(ensemble_list(iensem)),'_*_',num2str(iyear),'.nc'];
ft = ['thetao_Omon_',mdl_name,'_',char(scenario_list(iscenario)),'_',char(ensemble_list(iensem)),'_*_',num2str(iyear),'.nc'];
aa = dir([dir_mdl,fu]);
fu = [dir_mdl,'/',aa.name];
aa = dir([dir_mdl,fv]);
fv = [dir_mdl,'/',aa.name];
aa = dir([dir_mdl,fs]);
fs = [dir_mdl,'/',aa.name];
aa = dir([dir_mdl,ft]);
ft = [dir_mdl,'/',aa.name];
dep = ncread(fu,'lev');
dep_bnds = ncread(fu,'lev_bnds');
dz = dep_bnds(2,:) - dep_bnds(1,:);
u3d = ncread(fu,'uo');
v3d = ncread(fv,'vo');
s3d = ncread(fs,'so');
t3d = ncread(ft,'thetao');
u3d = mean(u3d,4);
v3d = mean(v3d,4);
s3d = mean(s3d,4);
t3d = mean(t3d,4);
u3d = reshape(u3d,[],length(dep));
v3d = reshape(v3d,[],length(dep));
s3d = reshape(s3d,[],length(dep));
t3d = reshape(t3d,[],length(dep));
%% Fram Strait
u2d = u3d(Fram_strait,:);
v2d = v3d(Fram_strait,:);
s2d = s3d(Fram_strait,:);
t2d = t3d(Fram_strait,:);
vol_fram = zeros(3,1);
fw_fram = zeros(3,1);
ht_fram = zeros(3,1);
s_fram = 0;
t_fram = 0;
dy = [];
for inod = 1:length(Fram_strait)
nod_lons = lon_bnds(:,Fram_strait(inod));
nod_lats = lat_bnds(:,Fram_strait(inod));
lon1 = nod_lons(1); lat1 = nod_lats(1);
lon2 = nod_lons(2); lat2 = nod_lats(2);
dy = [dy rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
end
dy = dy';
dyy = repmat(dy,1,length(dep));
dzz = repmat(dz,length(Fram_strait),1);
dA = dyy.*dzz;
loc1 = find(u2d>0);
loc2 = find(u2d<0);
% s_fram(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA));% net
% s_fram(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% s_fram(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% t_fram(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA));% net
% t_fram(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% t_fram(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% s_fram = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
% t_fram = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_fram(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_fram(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
s_fram(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
t_fram(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
t_fram(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
t_fram(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
vol_fram(1,1) = nansum(nansum(u2d.*dA));% net
vol_fram(2,1) = nansum(nansum(u2d(loc1).*dA(loc1)));% in
vol_fram(3,1) = nansum(nansum(u2d(loc2).*dA(loc2)));% out
fw_fram(1,1) = nansum(nansum(u2d.*dA.*(S_ref-s2d)/S_ref));% net
fw_fram(2,1) = nansum(nansum(u2d(loc1).*dA(loc1).*(S_ref-s2d(loc1))/S_ref));%
fw_fram(3,1) = nansum(nansum(u2d(loc2).*dA(loc2).*(S_ref-s2d(loc2))/S_ref));%
ht_fram(1,1) = 4.2e6*nansum(nansum(u2d.*dA.*(t2d-T_ref)));%
ht_fram(2,1) = 4.2e6*nansum(nansum(u2d(loc1).*dA(loc1).*(t2d(loc1)-T_ref)));%
ht_fram(3,1) = 4.2e6*nansum(nansum(u2d(loc2).*dA(loc2).*(t2d(loc2)-T_ref)));%
%% Bering Strait
u2d = u3d(Bering_strait,:);
v2d = v3d(Bering_strait,:);
s2d = s3d(Bering_strait,:);
t2d = t3d(Bering_strait,:);
vol_bering = zeros(3,1);
fw_bering = zeros(3,1);
ht_bering = zeros(3,1);
s_bering = 0;
t_bering = 0;
dx = [];
for inod = 1:length(Bering_strait)
nod_lons = lon_bnds(:,Bering_strait(inod));
nod_lats = lat_bnds(:,Bering_strait(inod));
lon1 = nod_lons(3); lat1 = nod_lats(3);
lon2 = nod_lons(2); lat2 = nod_lats(2);
dx = [dx rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
end
dx = dx';
dxx = repmat(dx,1,length(dep));
dzz = repmat(dz,length(Bering_strait),1);
dA = dxx.*dzz;
loc1 = find(v2d>0);
loc2 = find(v2d<0);
% s_bering(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA));% net
% s_bering(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% s_bering(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% t_bering(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA));% net
% t_bering(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% t_bering(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% s_bering = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
% t_bering = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_bering(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_bering(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA((loc1))));% in
s_bering(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA((loc2))));% in
t_bering(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
t_bering(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
t_bering(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA((loc2))));% out
vol_bering(1,1) = nansum(nansum(v2d.*dA));% net
vol_bering(2,1) = nansum(nansum(v2d(loc1).*dA(loc1)));% in
vol_bering(3,1) = nansum(nansum(v2d(loc2).*dA(loc2)));% out
fw_bering(1,1) = nansum(nansum(v2d.*dA.*(S_ref-s2d)/S_ref));%
fw_bering(2,1) = nansum(nansum(v2d(loc1).*dA(loc1).*(S_ref-s2d(loc1))/S_ref));%
fw_bering(3,1) = nansum(nansum(v2d(loc2).*dA(loc2).*(S_ref-s2d(loc2))/S_ref));%
ht_bering(1,1) = 4.2e6*nansum(nansum(v2d.*dA.*(t2d-T_ref)));%
ht_bering(2,1) = 4.2e6*nansum(nansum(v2d(loc1).*dA(loc1).*(t2d(loc1)-T_ref)));%
ht_bering(3,1) = 4.2e6*nansum(nansum(v2d(loc2).*dA(loc2).*(t2d(loc2)-T_ref)));%
%% Davis Strait
u2d = u3d(Davis_strait,:);
v2d = v3d(Davis_strait,:);
s2d = s3d(Davis_strait,:);
t2d = t3d(Davis_strait,:);
vol_davis = zeros(3,1);
fw_davis = zeros(3,1);
ht_davis = zeros(3,1);
s_davis = 0;
t_davis = 0;
dx = [];
for inod = 1:length(Davis_strait)
nod_lons = lon_bnds(:,Davis_strait(inod));
nod_lats = lat_bnds(:,Davis_strait(inod));
lon1 = nod_lons(3); lat1 = nod_lats(3);
lon2 = nod_lons(2); lat2 = nod_lats(2);
dx = [dx rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
end
dx = dx';
dxx = repmat(dx,1,length(dep));
dzz = repmat(dz,length(Davis_strait),1);
dA = dxx.*dzz;
loc1 = find(v2d>0);
loc2 = find(v2d<0);
% s_davis(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA));% net
% s_davis(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% s_davis(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% t_davis(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA));% net
% t_davis(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% t_davis(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% s_davis = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
% t_davis = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_davis(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_davis(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
s_davis(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
t_davis(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
t_davis(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
t_davis(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
vol_davis(1,1) = nansum(nansum(v2d.*dA));% net
vol_davis(2,1) = nansum(nansum(v2d(loc1).*dA(loc1)));% in
vol_davis(3,1) = nansum(nansum(v2d(loc2).*dA(loc2)));% out
fw_davis(1,1) = nansum(nansum(v2d.*dA.*(S_ref-s2d)/S_ref));%
fw_davis(2,1) = nansum(nansum(v2d(loc1).*dA(loc1).*(S_ref-s2d(loc1))/S_ref));%
fw_davis(3,1) = nansum(nansum(v2d(loc2).*dA(loc2).*(S_ref-s2d(loc2))/S_ref));%
ht_davis(1,1) = 4.2e6*nansum(nansum(v2d.*dA.*(t2d-T_ref)));%
ht_davis(2,1) = 4.2e6*nansum(nansum(v2d(loc1).*dA(loc1).*(t2d(loc1)-T_ref)));%
ht_davis(3,1) = 4.2e6*nansum(nansum(v2d(loc2).*dA(loc2).*(t2d(loc2)-T_ref)));%
%% Denmark Strait
u2d = u3d(Denmark_strait,:);
v2d = v3d(Denmark_strait,:);
s2d = s3d(Denmark_strait,:);
t2d = t3d(Denmark_strait,:);
vol_denmark = zeros(3,1);
fw_denmark = zeros(3,1);
ht_denmark = zeros(3,1);
s_denmark = 0;
t_denmark = 0;
dy = [];
for inod = 1:length(Denmark_strait)
nod_lons = lon_bnds(:,Denmark_strait(inod));
nod_lats = lat_bnds(:,Denmark_strait(inod));
lon1 = nod_lons(2); lat1 = nod_lats(2);
lon2 = nod_lons(1); lat2 = nod_lats(1);
dy = [dy rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
end
% dy = flipud(dy');
dy = dy';
dyy = repmat(dy,1,length(dep));
dzz = repmat(dz,length(Denmark_strait),1);
dA = dyy.*dzz;
loc1 = find(u2d>0);
loc2 = find(u2d<0);
% s_denmark(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA));% net
% s_denmark(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% s_denmark(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% t_denmark(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA));% net
% t_denmark(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% t_denmark(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% s_denmark = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
% t_denmark = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_denmark(1,1) = nansum(nansum(s2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
s_denmark(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
s_denmark(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
t_denmark(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA(~isnan(s2d))));% net
t_denmark(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
t_denmark(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
vol_denmark(1,1) = nansum(nansum(u2d.*dA));% net
vol_denmark(2,1) = nansum(nansum(u2d(loc1).*dA(loc1)));% in
vol_denmark(3,1) = nansum(nansum(u2d(loc2).*dA(loc2)));% out
fw_denmark(1,1) = nansum(nansum(u2d.*dA.*(S_ref-s2d)/S_ref));%
fw_denmark(2,1) = nansum(nansum(u2d(loc1).*dA(loc1).*(S_ref-s2d(loc1))/S_ref));%
fw_denmark(3,1) = nansum(nansum(u2d(loc2).*dA(loc2).*(S_ref-s2d(loc2))/S_ref));%
ht_denmark(1,1) = 4.2e6*nansum(nansum(u2d.*dA.*(t2d-T_ref)));%
ht_denmark(2,1) = 4.2e6*nansum(nansum(u2d(loc1).*dA(loc1).*(t2d(loc1)-T_ref)));%
ht_denmark(3,1) = 4.2e6*nansum(nansum(u2d(loc2).*dA(loc2).*(t2d(loc2)-T_ref)));%
% voltransp_denmark = nansum(nansum(u2d.*dA));%
%% Barents Sea Opening
u2d = u3d(Barents_opening,:);
v2d = v3d(Barents_opening,:);
s2d = s3d(Barents_opening,:);
t2d = t3d(Barents_opening,:);
vol_bso = zeros(3,1);
fw_bso = zeros(3,1);
ht_bso = zeros(3,1);
s_bso = 0;
t_bso = 0;
dx = []; dy = [];
for inod = 1:length(Barents_opening)
nod_lons = lon_bnds(:,Barents_opening(inod));
nod_lats = lat_bnds(:,Barents_opening(inod));
lon1 = nod_lons(3); lat1 = nod_lats(3);
lon2 = nod_lons(2); lat2 = nod_lats(2);
dx = [dx rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
lon1 = nod_lons(1); lat1 = nod_lats(1);
lon2 = nod_lons(2); lat2 = nod_lats(2);
dy = [dy rEarth*acos(cosd(lat1)*cosd(lat2)*cosd(lon1-lon2)+sind(lat1)*sind(lat2))];
end
dx = dx'; dy = dy';
dxx = repmat(dx,1,length(dep));
dyy = repmat(dy,1,length(dep));
dzz = repmat(dz,length(Barents_opening),1);
dAx = dxx.*dzz;
dAy = dyy.*dzz;
% !!!!!!!!!!!!!!!!!!!!!!!!!!
% the calculation of BSO is grid dependent
% In FIO-ESM, it is BSO inflow when uo>0 or vo<0
loc1u = find(u2d>0);
loc2u = find(u2d<0);
loc1v = find(v2d>0);
loc2v = find(v2d<0);
% s_bso(1,1) = nansum(nansum(s2d.*(dAx+dAy)))/nansum(nansum(dAx+dAy));% net
% s_bso(2,1) = nansum(nansum(s2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% s_bso(3,1) = nansum(nansum(s2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% t_bso(1,1) = nansum(nansum(t2d.*dA))/nansum(nansum(dA));% net
% t_bso(2,1) = nansum(nansum(t2d(loc1).*dA(loc1)))/nansum(nansum(dA(loc1)));% in
% t_bso(3,1) = nansum(nansum(t2d(loc2).*dA(loc2)))/nansum(nansum(dA(loc2)));% out
% s_bso = nansum(nansum(s2d.*(dAx+dAy)))/nansum(nansum(dAx(~isnan(s2d))+dAy(~isnan(s2d))));% net
% t_bso = nansum(nansum(t2d.*(dAx+dAy)))/nansum(nansum(dAx(~isnan(s2d))+dAy(~isnan(s2d))));% net
s_bso(1,1) = nansum(nansum(s2d.*(dAx+dAy)))/nansum(nansum(dAx(~isnan(s2d))+dAy(~isnan(s2d))));% net
s_bso(2,1) = (nansum(nansum(s2d(loc1u).*dAy(loc1u)))+nansum(nansum(s2d(loc2v).*dAx(loc2v))))/(nansum(nansum(dAy(loc1u)))+nansum(nansum(dAx(loc2v))));% in
s_bso(3,1) = (nansum(nansum(s2d(loc2u).*dAy(loc2u)))+nansum(nansum(s2d(loc1v).*dAx(loc1v))))/(nansum(nansum(dAy(loc2u)))+nansum(nansum(dAx(loc1v))));% out
t_bso(1,1) = nansum(nansum(t2d.*(dAx+dAy)))/nansum(nansum(dAx(~isnan(s2d))+dAy(~isnan(s2d))));% net
t_bso(2,1) = (nansum(nansum(t2d(loc1u).*dAy(loc1u)))+nansum(nansum(t2d(loc2v).*dAx(loc2v))))/(nansum(nansum(dAy(loc1u)))+nansum(nansum(dAx(loc2v))));% in
t_bso(3,1) = (nansum(nansum(t2d(loc2u).*dAy(loc2u)))+nansum(nansum(t2d(loc1v).*dAx(loc1v))))/(nansum(nansum(dAy(loc2u)))+nansum(nansum(dAx(loc1v))));% in
vol_bso(1,1) = nansum(nansum(u2d.*dAy-v2d.*dAx));
vol_bso(2,1) = nansum(nansum(u2d(loc1u).*dAy(loc1u)))-nansum(nansum(v2d(loc2v).*dAx(loc2v)));
vol_bso(3,1) = nansum(nansum(u2d(loc2u).*dAy(loc2u)))-nansum(nansum(v2d(loc1v).*dAx(loc1v)));
fw_bso(1,1) = nansum(nansum(u2d.*dAy.*(S_ref-s2d)/S_ref))-nansum(nansum(v2d.*dAx.*(S_ref-s2d)/S_ref));%
fw_bso(2,1) = nansum(nansum(u2d(loc1u).*dAy(loc1u).*(S_ref-s2d(loc1u))/S_ref))-nansum(nansum(v2d(loc2v).*dAx(loc2v).*(S_ref-s2d(loc2v))/S_ref));%
fw_bso(3,1) = nansum(nansum(u2d(loc2u).*dAy(loc2u).*(S_ref-s2d(loc2u))/S_ref))-nansum(nansum(v2d(loc1v).*dAx(loc1v).*(S_ref-s2d(loc1v))/S_ref));%
ht_bso(1,1) = 4.2e6*nansum(nansum(u2d.*dAy.*(t2d-T_ref)))-nansum(nansum(v2d.*dAx.*(t2d-T_ref)));%
ht_bso(2,1) = 4.2e6*nansum(nansum(u2d(loc1u).*dAy(loc1u).*(t2d(loc1u)-T_ref)))-nansum(nansum(v2d(loc2v).*dAx(loc2v).*(t2d(loc2v)-T_ref)));%
ht_bso(3,1) = 4.2e6*nansum(nansum(u2d(loc2u).*dAy(loc2u).*(t2d(loc2u)-T_ref)))-nansum(nansum(v2d(loc1v).*dAx(loc1v).*(t2d(loc1v)-T_ref)));%
% voltransp_bso = nansum(nansum(u2d.*dAy-v2d.*dAx));%
fout = [dir_mdl,'/Gateway_flux_yearly_',char(scenario_list(iscenario)),'_',char(ensemble_list(iensem)),'_',num2str(iyear)];
save(fout,'vol_fram','fw_fram','ht_fram','s_fram','t_fram',...
'vol_bering','fw_bering','ht_bering','s_bering','t_bering',...
'vol_davis','fw_davis','ht_davis','s_davis','t_davis',...
'vol_denmark','fw_denmark','ht_denmark','s_denmark','t_denmark',...
'vol_bso','fw_bso','ht_bso','s_bso','t_bso');
end
end
end
%%
return;
scatter(x_cent(Fram_strait),y_cent(Fram_strait),20,'k','Filled');
m_scatter(lon_bnds(Fram_strait(1)),lat_bnds(Fram_strait(1)),20,'r','Filled');
figure;
contourf(dA);
colorbar;
figure;
contourf(s2d);
colorbar;
figure;
contourf(u2d);
colorbar;
colormap(cmocean('balance',10));
caxis([-0.1 0.1]);
figure;
contourf(v2d);
colorbar;
colormap(cmocean('balance',10));
caxis([-0.1 0.1]);