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 |
|
|
|
45 |
|
|
end; |
46 |
|
|
|
47 |
gforget |
1.2 |
%=============== |
48 |
|
|
|
49 |
|
|
if choiceStruct==3; |
50 |
|
|
|
51 |
gforget |
1.5 |
%budgName='budgHo'; |
52 |
gforget |
1.4 |
|
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 |
gforget |
1.2 |
[budgName ' -- ' fldName] |
61 |
|
|
|
62 |
|
|
%directories |
63 |
|
|
dirIn='r4it11.c65i/'; |
64 |
|
|
dirMat='mat_budg3d/'; |
65 |
|
|
dirOut=fullfile(dirIn,'nctiles_budg',filesep); |
66 |
|
|
if ~isdir(dirOut); mkdir(dirOut); end; |
67 |
|
|
dirOut=fullfile(dirOut,budgName,filesep); |
68 |
|
|
if ~isdir(dirOut); mkdir(dirOut); end; |
69 |
|
|
|
70 |
|
|
%load variable |
71 |
|
|
eval(['load ' dirIn dirMat 'diags_grid_parms.mat myparms;']); |
72 |
|
|
dirMat=[dirIn dirMat 'diags_set_' budgName '/']; |
73 |
|
|
fileMat=[budgName '_*.mat']; |
74 |
|
|
tic; structIn.vars=diags_read_from_mat(dirMat,fileMat,fldName); toc; |
75 |
|
|
|
76 |
gforget |
1.3 |
%time vectors |
77 |
|
|
[listTimes]=diags_list_times({[dirIn 'diags/BUDG/']},{'budg2d_hflux_set1'}); |
78 |
|
|
structIn.vars.t0=3600*listTimes(1:end-2); |
79 |
|
|
structIn.vars.t1=3600*listTimes(2:end-1); |
80 |
|
|
|
81 |
gforget |
1.2 |
%rename trWtop as trW if adequate |
82 |
gforget |
1.4 |
if strcmp(fldName,'trWtop')&(budgName(end)=='o'); |
83 |
gforget |
1.2 |
structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); |
84 |
|
|
structIn.vars=rmfield(structIn.vars,'trWtop'); |
85 |
|
|
structIn.vars.listDiags={'trW'}; |
86 |
|
|
fldName='trW'; |
87 |
|
|
end; |
88 |
|
|
|
89 |
gforget |
1.5 |
%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 |
gforget |
1.2 |
%general description |
96 |
|
|
tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); |
97 |
|
|
specs=tmp1.specs; |
98 |
|
|
if strcmp(specs.units,'W'); |
99 |
|
|
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
100 |
|
|
elseif strcmp(specs.units,'kg/s'); |
101 |
|
|
structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; |
102 |
|
|
elseif strcmp(specs.units,'g/s'); |
103 |
|
|
structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; |
104 |
|
|
else; |
105 |
|
|
error('unknown budget'); |
106 |
|
|
end; |
107 |
|
|
|
108 |
|
|
%variables description |
109 |
|
|
vars=[]; nv=length(vars)+1; |
110 |
|
|
vars(nv).fldName=fldName; vars(nv).units=specs.units; |
111 |
|
|
switch fldName; |
112 |
|
|
case 'tend'; vars(nv).longName='tendency term'; |
113 |
|
|
case 'trU'; vars(nv).longName='horizontal transport (U)'; |
114 |
|
|
case 'trV'; vars(nv).longName='horizontal transport (V)'; |
115 |
gforget |
1.5 |
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 |
gforget |
1.2 |
end; |
119 |
|
|
nv=length(vars)+1; |
120 |
|
|
vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; |
121 |
|
|
vars(nv).fldName='t1'; vars(nv).longName='final time'; vars(nv).units='s'; nv=length(vars)+1; |
122 |
|
|
% |
123 |
|
|
structIn.defs=vars; |
124 |
|
|
|
125 |
|
|
%create file |
126 |
|
|
tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; |
127 |
|
|
eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); |
128 |
|
|
|
129 |
gforget |
1.4 |
end;%for fldName=listFlds; |
130 |
|
|
|
131 |
gforget |
1.2 |
end; |
132 |
|
|
|