1 |
gforget |
1.1 |
|
2 |
gforget |
1.2 |
choiceStruct=3; |
3 |
gforget |
1.1 |
|
4 |
|
|
%=============== |
5 |
|
|
|
6 |
|
|
if choiceStruct==1; |
7 |
|
|
structIn=[]; |
8 |
|
|
% |
9 |
|
|
structIn.vars=mygrid; |
10 |
|
|
structIn.vars.RF=structIn.vars.RF(1:50); |
11 |
|
|
% |
12 |
|
|
structIn.descr={'C-grid parameters (see MITgcm documentation for details).'}; |
13 |
|
|
% |
14 |
|
|
vars=[]; nv=length(vars)+1; |
15 |
|
|
vars(nv).fldName='XC'; vars(nv).longName='longitude'; vars(nv).units='degrees_east'; nv=length(vars)+1; |
16 |
|
|
vars(nv).fldName='YC'; vars(nv).longName='latitude'; vars(nv).units='degrees_north'; nv=length(vars)+1; |
17 |
|
|
vars(nv).fldName='XG'; vars(nv).longName='longitude'; vars(nv).units='degrees_east'; nv=length(vars)+1; |
18 |
|
|
vars(nv).fldName='YG'; vars(nv).longName='latitude'; vars(nv).units='degrees_north'; nv=length(vars)+1; |
19 |
|
|
vars(nv).fldName='RAC'; vars(nv).longName='grid cell area'; vars(nv).units='m^2'; nv=length(vars)+1; |
20 |
|
|
vars(nv).fldName='RAZ'; vars(nv).longName='grid cell area'; vars(nv).units='m^2'; nv=length(vars)+1; |
21 |
|
|
vars(nv).fldName='DXC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
22 |
|
|
vars(nv).fldName='DYC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
23 |
|
|
vars(nv).fldName='DXG'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
24 |
|
|
vars(nv).fldName='DYG'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
25 |
|
|
vars(nv).fldName='hFacC'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; |
26 |
|
|
vars(nv).fldName='hFacW'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; |
27 |
|
|
vars(nv).fldName='hFacS'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; |
28 |
|
|
vars(nv).fldName='Depth'; vars(nv).longName='sea floor depth'; vars(nv).units='m'; nv=length(vars)+1; |
29 |
|
|
vars(nv).fldName='AngleCS'; vars(nv).longName='grid orientation (cosine)'; vars(nv).units='m'; nv=length(vars)+1; |
30 |
|
|
vars(nv).fldName='AngleSN'; vars(nv).longName='grid orientation (sine)'; vars(nv).units='m'; nv=length(vars)+1; |
31 |
|
|
vars(nv).fldName='RC'; vars(nv).longName='vertical coordinate'; vars(nv).units='m'; nv=length(vars)+1; |
32 |
|
|
vars(nv).fldName='RF'; vars(nv).longName='vertical coordinate'; vars(nv).units='m'; nv=length(vars)+1; |
33 |
|
|
vars(nv).fldName='DRC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
34 |
|
|
vars(nv).fldName='DRF'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; |
35 |
|
|
% |
36 |
|
|
structIn.defs=vars; |
37 |
|
|
% |
38 |
|
|
struct2nctiles('release1/','GRID',structIn,[90 90]); |
39 |
|
|
end; |
40 |
|
|
|
41 |
|
|
%=============== |
42 |
|
|
|
43 |
|
|
if choiceStruct==2; |
44 |
|
|
budgName='budgHo' |
45 |
|
|
|
46 |
|
|
structIn=[]; |
47 |
|
|
% |
48 |
|
|
load release1/mat/diags_grid_parms.mat myparms; |
49 |
|
|
dirMat=['release1/mat/diags_set_' budgName '/']; |
50 |
|
|
fileMat=[budgName '_*.mat']; |
51 |
|
|
structIn.vars=diags_read_from_mat(dirMat,fileMat); |
52 |
|
|
|
53 |
gforget |
1.2 |
%vector of time increment |
54 |
gforget |
1.1 |
[listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'}); |
55 |
|
|
structIn.vars.dt=diff(listTimes); |
56 |
|
|
structIn.vars.dt=3600*structIn.vars.dt(1:end-1)'; |
57 |
|
|
% |
58 |
|
|
specs=structIn.vars.specs(1); |
59 |
|
|
if strcmp(specs.units,'W'); |
60 |
|
|
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
61 |
|
|
elseif strcmp(specs.units,'kg/s'); |
62 |
|
|
structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; |
63 |
|
|
elseif strcmp(specs.units,'g/s'); |
64 |
|
|
structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; |
65 |
|
|
else; |
66 |
|
|
error('unknown budget'); |
67 |
|
|
end; |
68 |
|
|
structIn.descr={structIn.descr{:},'between',specs.top,'(top) and',specs.bottom,'(bottom)'}; |
69 |
|
|
% |
70 |
|
|
vars=[]; nv=length(vars)+1; |
71 |
|
|
vars(nv).fldName='tend'; vars(nv).longName='tendency term'; vars(nv).units=specs.units; nv=length(vars)+1; |
72 |
|
|
vars(nv).fldName='trU'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
73 |
|
|
vars(nv).fldName='trV'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
74 |
|
|
vars(nv).fldName='trWtop'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
75 |
|
|
vars(nv).fldName='trWbot'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
76 |
|
|
vars(nv).fldName='dt'; vars(nv).longName='time increment'; vars(nv).units='s'; nv=length(vars)+1; |
77 |
|
|
% |
78 |
|
|
structIn.defs=vars; |
79 |
|
|
% |
80 |
|
|
struct2nctiles('release1/',budgName,structIn,[90 90]); |
81 |
|
|
|
82 |
|
|
end; |
83 |
|
|
|
84 |
gforget |
1.2 |
%=============== |
85 |
|
|
|
86 |
|
|
if choiceStruct==3; |
87 |
|
|
|
88 |
gforget |
1.5 |
%budgName='budgHo'; |
89 |
gforget |
1.4 |
|
90 |
|
|
if budgName(end)=='o'; listFlds={'tend','trU','trV','trWtop'}; |
91 |
|
|
else; listFlds={'tend','trU','trV','trWtop','trWbot'}; |
92 |
|
|
end; |
93 |
|
|
|
94 |
|
|
for ii=1:length(listFlds); |
95 |
|
|
fldName=listFlds{ii}; |
96 |
|
|
%fldName='trWtop'; |
97 |
gforget |
1.2 |
[budgName ' -- ' fldName] |
98 |
|
|
|
99 |
|
|
%directories |
100 |
|
|
dirIn='r4it11.c65i/'; |
101 |
|
|
dirMat='mat_budg3d/'; |
102 |
|
|
dirOut=fullfile(dirIn,'nctiles_budg',filesep); |
103 |
|
|
if ~isdir(dirOut); mkdir(dirOut); end; |
104 |
|
|
dirOut=fullfile(dirOut,budgName,filesep); |
105 |
|
|
if ~isdir(dirOut); mkdir(dirOut); end; |
106 |
|
|
|
107 |
|
|
%load variable |
108 |
|
|
eval(['load ' dirIn dirMat 'diags_grid_parms.mat myparms;']); |
109 |
|
|
dirMat=[dirIn dirMat 'diags_set_' budgName '/']; |
110 |
|
|
fileMat=[budgName '_*.mat']; |
111 |
|
|
tic; structIn.vars=diags_read_from_mat(dirMat,fileMat,fldName); toc; |
112 |
|
|
|
113 |
gforget |
1.3 |
%time vectors |
114 |
|
|
[listTimes]=diags_list_times({[dirIn 'diags/BUDG/']},{'budg2d_hflux_set1'}); |
115 |
|
|
structIn.vars.t0=3600*listTimes(1:end-2); |
116 |
|
|
structIn.vars.t1=3600*listTimes(2:end-1); |
117 |
|
|
|
118 |
gforget |
1.2 |
%rename trWtop as trW if adequate |
119 |
gforget |
1.4 |
if strcmp(fldName,'trWtop')&(budgName(end)=='o'); |
120 |
gforget |
1.2 |
structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); |
121 |
|
|
structIn.vars=rmfield(structIn.vars,'trWtop'); |
122 |
|
|
structIn.vars.listDiags={'trW'}; |
123 |
|
|
fldName='trW'; |
124 |
|
|
end; |
125 |
|
|
|
126 |
gforget |
1.5 |
%switch back to upward convention |
127 |
|
|
if strcmp(fldName(1:3),'trW'); |
128 |
|
|
tmp1=getfield(structIn.vars,fldName); |
129 |
|
|
structIn.vars=setfield(structIn.vars,fldName,-tmp1); |
130 |
|
|
end; |
131 |
|
|
|
132 |
gforget |
1.2 |
%general description |
133 |
|
|
tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); |
134 |
|
|
specs=tmp1.specs; |
135 |
|
|
if strcmp(specs.units,'W'); |
136 |
|
|
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
137 |
|
|
elseif strcmp(specs.units,'kg/s'); |
138 |
|
|
structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; |
139 |
|
|
elseif strcmp(specs.units,'g/s'); |
140 |
|
|
structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; |
141 |
|
|
else; |
142 |
|
|
error('unknown budget'); |
143 |
|
|
end; |
144 |
|
|
|
145 |
|
|
%variables description |
146 |
|
|
vars=[]; nv=length(vars)+1; |
147 |
|
|
vars(nv).fldName=fldName; vars(nv).units=specs.units; |
148 |
|
|
switch fldName; |
149 |
|
|
case 'tend'; vars(nv).longName='tendency term'; |
150 |
|
|
case 'trU'; vars(nv).longName='horizontal transport (U)'; |
151 |
|
|
case 'trV'; vars(nv).longName='horizontal transport (V)'; |
152 |
gforget |
1.5 |
case 'trW'; vars(nv).longName='upward vertical transport (W)'; |
153 |
|
|
case 'trWtop'; vars(nv).longName='upward vertical transport (W)'; |
154 |
|
|
case 'trWbot'; vars(nv).longName='upward vertical transport (W)'; |
155 |
gforget |
1.2 |
end; |
156 |
|
|
nv=length(vars)+1; |
157 |
|
|
vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; |
158 |
|
|
vars(nv).fldName='t1'; vars(nv).longName='final time'; vars(nv).units='s'; nv=length(vars)+1; |
159 |
|
|
% |
160 |
|
|
structIn.defs=vars; |
161 |
|
|
|
162 |
|
|
%create file |
163 |
|
|
tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; |
164 |
|
|
eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); |
165 |
|
|
|
166 |
gforget |
1.4 |
end;%for fldName=listFlds; |
167 |
|
|
|
168 |
gforget |
1.2 |
end; |
169 |
|
|
|