41 |
%=============== |
%=============== |
42 |
|
|
43 |
if choiceStruct==2; |
if choiceStruct==2; |
|
budgName='budgHo' |
|
|
|
|
|
structIn=[]; |
|
|
% |
|
|
load release1/mat/diags_grid_parms.mat myparms; |
|
|
dirMat=['release1/mat/diags_set_' budgName '/']; |
|
|
fileMat=[budgName '_*.mat']; |
|
|
structIn.vars=diags_read_from_mat(dirMat,fileMat); |
|
|
|
|
|
%vector of time increment |
|
|
[listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'}); |
|
|
structIn.vars.dt=diff(listTimes); |
|
|
structIn.vars.dt=3600*structIn.vars.dt(1:end-1)'; |
|
|
% |
|
|
specs=structIn.vars.specs(1); |
|
|
if strcmp(specs.units,'W'); |
|
|
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
|
|
elseif strcmp(specs.units,'kg/s'); |
|
|
structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; |
|
|
elseif strcmp(specs.units,'g/s'); |
|
|
structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; |
|
|
else; |
|
|
error('unknown budget'); |
|
|
end; |
|
|
structIn.descr={structIn.descr{:},'between',specs.top,'(top) and',specs.bottom,'(bottom)'}; |
|
|
% |
|
|
vars=[]; nv=length(vars)+1; |
|
|
vars(nv).fldName='tend'; vars(nv).longName='tendency term'; vars(nv).units=specs.units; nv=length(vars)+1; |
|
|
vars(nv).fldName='trU'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
|
|
vars(nv).fldName='trV'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
|
|
vars(nv).fldName='trWtop'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
|
|
vars(nv).fldName='trWbot'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
|
|
vars(nv).fldName='dt'; vars(nv).longName='time increment'; vars(nv).units='s'; nv=length(vars)+1; |
|
|
% |
|
|
structIn.defs=vars; |
|
|
% |
|
|
struct2nctiles('release1/',budgName,structIn,[90 90]); |
|
44 |
|
|
45 |
end; |
end; |
46 |
|
|
48 |
|
|
49 |
if choiceStruct==3; |
if choiceStruct==3; |
50 |
|
|
51 |
budgName='budgHo'; |
%budgName='budgHo'; |
52 |
fldName='trU'; |
|
53 |
|
if budgName(end)=='o'; listFlds={'tend','trU','trV','trWtop'}; |
54 |
|
else; listFlds={'tend','trU','trV','trWtop','trWbot'}; |
55 |
|
end; |
56 |
|
|
57 |
|
for ii=1:length(listFlds); |
58 |
|
fldName=listFlds{ii}; |
59 |
|
%fldName='trWtop'; |
60 |
[budgName ' -- ' fldName] |
[budgName ' -- ' fldName] |
61 |
|
|
62 |
%directories |
%directories |
79 |
structIn.vars.t1=3600*listTimes(2:end-1); |
structIn.vars.t1=3600*listTimes(2:end-1); |
80 |
|
|
81 |
%rename trWtop as trW if adequate |
%rename trWtop as trW if adequate |
82 |
if strcmp(fldName,'trWtop'); |
if strcmp(fldName,'trWtop')&(budgName(end)=='o'); |
83 |
structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); |
structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); |
84 |
structIn.vars=rmfield(structIn.vars,'trWtop'); |
structIn.vars=rmfield(structIn.vars,'trWtop'); |
85 |
structIn.vars.listDiags={'trW'}; |
structIn.vars.listDiags={'trW'}; |
86 |
fldName='trW'; |
fldName='trW'; |
87 |
end; |
end; |
88 |
|
|
89 |
|
%switch back to upward convention |
90 |
|
if strcmp(fldName(1:3),'trW'); |
91 |
|
tmp1=getfield(structIn.vars,fldName); |
92 |
|
structIn.vars=setfield(structIn.vars,fldName,-tmp1); |
93 |
|
end; |
94 |
|
|
95 |
%general description |
%general description |
96 |
tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); |
tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); |
97 |
specs=tmp1.specs; |
specs=tmp1.specs; |
112 |
case 'tend'; vars(nv).longName='tendency term'; |
case 'tend'; vars(nv).longName='tendency term'; |
113 |
case 'trU'; vars(nv).longName='horizontal transport (U)'; |
case 'trU'; vars(nv).longName='horizontal transport (U)'; |
114 |
case 'trV'; vars(nv).longName='horizontal transport (V)'; |
case 'trV'; vars(nv).longName='horizontal transport (V)'; |
115 |
case 'trW'; vars(nv).longName='vertical transport (W)'; |
case 'trW'; vars(nv).longName='upward vertical transport (W)'; |
116 |
|
case 'trWtop'; vars(nv).longName='upward vertical transport (W)'; |
117 |
|
case 'trWbot'; vars(nv).longName='upward vertical transport (W)'; |
118 |
end; |
end; |
119 |
nv=length(vars)+1; |
nv=length(vars)+1; |
120 |
vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; |
vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; |
126 |
tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; |
tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; |
127 |
eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); |
eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); |
128 |
|
|
129 |
|
end;%for fldName=listFlds; |
130 |
|
|
131 |
end; |
end; |
132 |
|
|