1 |
function []=diags_inifin_D(kBudget,test3d,dirSnap,dirMat); |
2 |
% DIAGS_INIFIN_D(kBudget,test3d,dirSnap,dirMat); |
3 |
|
4 |
gcmfaces_global; global myparms; |
5 |
|
6 |
[listTimes]=diags_list_times({dirSnap},{'budg2d_snap_set1'}); |
7 |
|
8 |
if kBudget==1&~test3d; |
9 |
nmSnap='budg2d_snap_set2'; |
10 |
listBudgs={'budgMo','budgHo','budgSo','budgMi','budgHi','budgSi'}; |
11 |
elseif kBudget==1&test3d; |
12 |
nmSnap='budg3d_snap_set1'; |
13 |
listBudgs={'budgMo','budgHo','budgSo','budgMi','budgHi','budgSi'}; |
14 |
else; |
15 |
nmSnap=['budg2d_snap_set3_' num2str(kBudget)]; |
16 |
listBudgs={'budgMo','budgHo','budgSo'}; |
17 |
end; |
18 |
|
19 |
%load fields: |
20 |
ini=sprintf('.%010d',listTimes(1)); |
21 |
fin=sprintf('.%010d',listTimes(end)); |
22 |
|
23 |
H{1}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' ini],'rec',1); |
24 |
H{2}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' fin],'rec',1); |
25 |
if ~test3d; |
26 |
tmp1=mk3D(mygrid.DRF,mygrid.hFacC).*mygrid.hFacC; |
27 |
tmp2=sum(tmp1(:,:,kBudget:length(mygrid.RC)),3)./mygrid.Depth; |
28 |
H{1}=tmp2.*H{1}+tmp2.*mygrid.Depth; |
29 |
H{2}=tmp2.*H{2}+tmp2.*mygrid.Depth; |
30 |
else; |
31 |
tmp1=mk3D(mygrid.DRF,mygrid.hFacC).*mygrid.hFacC; |
32 |
tmp2=tmp1.*mk3D(H{1}./mygrid.Depth,tmp1); |
33 |
H{1}=(tmp1+tmp2); |
34 |
tmp2=tmp1.*mk3D(H{2}./mygrid.Depth,tmp1); |
35 |
H{2}=(tmp1+tmp2); |
36 |
end; |
37 |
|
38 |
SIheff{1}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' ini],'rec',2); |
39 |
SIheff{2}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' fin],'rec',2); |
40 |
|
41 |
SIsnow{1}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' ini],'rec',3); |
42 |
SIsnow{2}=rdmds2gcmfaces([dirSnap 'budg2d_snap_set1' fin],'rec',3); |
43 |
|
44 |
if test3d; |
45 |
tmpfac{1}=H{1}; |
46 |
tmpfac{2}=H{2}; |
47 |
else; |
48 |
tmpfac{1}=1; |
49 |
tmpfac{2}=1; |
50 |
end; |
51 |
|
52 |
THETA{1}=tmpfac{1}.*rdmds2gcmfaces([dirSnap nmSnap ini],'rec',1); |
53 |
THETA{2}=tmpfac{2}.*rdmds2gcmfaces([dirSnap nmSnap fin],'rec',1); |
54 |
|
55 |
SALT{1}=tmpfac{1}.*rdmds2gcmfaces([dirSnap nmSnap ini],'rec',2); |
56 |
SALT{2}=tmpfac{2}.*rdmds2gcmfaces([dirSnap nmSnap fin],'rec',2); |
57 |
|
58 |
for ii=1:length(listBudgs); |
59 |
budgName=listBudgs{ii}; |
60 |
|
61 |
%set directory name |
62 |
dirOut=fullfile(dirMat,'..',filesep); |
63 |
sufbudg=''; if kBudget>1; sufbudg=num2str(kBudget); end; |
64 |
dirOut=fullfile(dirOut,['diags_set_' budgName sufbudg],filesep); |
65 |
if ~isdir(dirOut); mkdir(dirOut); end; |
66 |
|
67 |
for tt=1:2; |
68 |
switch budgName; |
69 |
case 'budgMo'; fld=myparms.rhoconst*H{tt}; |
70 |
case 'budgHo'; fld=myparms.rcp*THETA{tt}; |
71 |
case 'budgSo'; fld=myparms.rhoconst*SALT{tt}; |
72 |
case 'budgMi'; fld=myparms.rhoi*SIheff{tt}+myparms.rhosn*SIsnow{tt}; |
73 |
case 'budgHi'; fld=-myparms.flami*myparms.rhoi*SIheff{tt}-myparms.flami*myparms.rhosn*SIsnow{tt}; |
74 |
case 'budgSi'; fld=myparms.SIsal0*myparms.rhoi*SIheff{tt}; |
75 |
end; |
76 |
fld=fld.*repmat(mygrid.RAC,[1 1 size(fld{1},3)]); |
77 |
if tt==1; nmOut='ini.bin'; else; nmOut='fin.bin'; end; |
78 |
fprintf(['writing: ' dirOut nmOut '\n']); |
79 |
write2file([dirOut nmOut],convert2gcmfaces(fld),64); |
80 |
end; |
81 |
end; |
82 |
|
83 |
|