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