1 |
function []=diags_driver(dirModel,dirMat,years,setDiags,doInteractive); |
2 |
% DIAGS_DRIVER(dirModel,dirMat,years,setDiags,doInteractive); |
3 |
% |
4 |
% computes estimation and physical diagnostics (setDiags) that |
5 |
% can be included in the standard analysis from the data (for |
6 |
% selected years) located in dirModel and stores the results |
7 |
% in dirMat. |
8 |
% |
9 |
%notes: dirModel is the directory containing 'diags/' or 'nctiles/' |
10 |
% dirMat is [dirModel 'mat/'] by default |
11 |
% years may be set to a vector (e.g. [1992:2011]) or to |
12 |
% 'climatology' when using a climatological year |
13 |
% setDiags is by default set to {'A','B','C','MLD'} |
14 |
% doInteractive=1 allows users to specify parameters interactively |
15 |
% whereas doInteractive = 0 (default) uses ECCO v4 parameters |
16 |
|
17 |
gcmfaces_global; global myparms; |
18 |
|
19 |
%%%%%%%%%%%%%%% |
20 |
%pre-processing |
21 |
%%%%%%%%%%%%%%% |
22 |
|
23 |
if isempty(who('doInteractive')); doInteractive=0; end; |
24 |
myswitch=diags_pre_process(dirModel,dirMat,doInteractive); |
25 |
diags_grid(dirModel,doInteractive); %reload mygrid if needed |
26 |
|
27 |
dirModel=[dirModel '/']; |
28 |
if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end; |
29 |
|
30 |
%%%%%%%%%%%%%%%%%%%% |
31 |
%set loop parameters |
32 |
%%%%%%%%%%%%%%%%%%%% |
33 |
|
34 |
if ischar(years); |
35 |
if strcmp(years,'climatology'); |
36 |
years=myparms.yearFirst; |
37 |
else; |
38 |
error('unknown specification of years'); |
39 |
end; |
40 |
end; |
41 |
|
42 |
years=years-myparms.yearFirst+1; |
43 |
if myparms.diagsAreMonthly; |
44 |
years=years(years<=myparms.recInAve(2)/12); |
45 |
lChunk=12; |
46 |
end; |
47 |
if myparms.diagsAreAnnual; |
48 |
years=years(years<=myparms.recInAve(2)); |
49 |
lChunk=1; |
50 |
end; |
51 |
|
52 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
53 |
%now do the selected computation chunk: |
54 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
55 |
|
56 |
if isempty(who('setDiags')); |
57 |
setDiags={'A','B','C','MLD'}; |
58 |
if myswitch.doBudget; setDiags={setDiags{:},'D'}; end; |
59 |
if myswitch.doProfiles; setDiags={setDiags{:},'profiles'}; end; |
60 |
if myswitch.doCost; setDiags={setDiags{:},'ecco'}; end; |
61 |
if myswitch.doCtrl; setDiags={setDiags{:},'ctrl'}; end; |
62 |
elseif ischar(setDiags); |
63 |
setDiags={setDiags}; |
64 |
end; |
65 |
|
66 |
for iDiag=1:length(setDiags); |
67 |
|
68 |
nmDiag=setDiags{iDiag}; |
69 |
|
70 |
normalLoop=~strcmp(nmDiag,'B')&~strcmp(nmDiag,'D')&... |
71 |
~strcmp(nmDiag,'profiles')&~strcmp(nmDiag,'ecco')&~strcmp(nmDiag,'ctrl'); |
72 |
|
73 |
if normalLoop; |
74 |
for myYear=years; |
75 |
diags_select(dirModel,dirMat,nmDiag,lChunk,myYear); |
76 |
end; |
77 |
|
78 |
elseif strcmp(nmDiag,'B'); |
79 |
recInAve=[myparms.recInAve(1):myparms.recInAve(2)]; |
80 |
diags_select(dirModel,dirMat,'B',1,recInAve); |
81 |
|
82 |
elseif strcmp(nmDiag,'D'); |
83 |
for kk=myparms.budgetList; |
84 |
for myYear=years; |
85 |
diags_select(dirModel,dirMat,{nmDiag,kk},lChunk,myYear); |
86 |
end; |
87 |
end; |
88 |
|
89 |
elseif strcmp(nmDiag,'profiles')&myswitch.doProfiles; |
90 |
fprintf('> starting insitu_diags\n'); |
91 |
insitu_diags(dirMat,1); |
92 |
|
93 |
elseif strcmp(nmDiag,'ecco')&myswitch.doCost; |
94 |
fprintf('!cost_altimeter is commented out because it requires >32G and >30min\n'); |
95 |
fprintf('! User may uncomment the following line if enough memory is available\n\n'); |
96 |
%cost_altimeter(dirModel,dirMat); |
97 |
fprintf('> starting cost_sst\n'); |
98 |
cost_sst(dirModel,dirMat,1); |
99 |
fprintf('> starting cost_seaice\n'); |
100 |
cost_seaicearea(dirModel,dirMat,1); |
101 |
|
102 |
elseif strcmp(nmDiag,'ctrl')&myswitch.doCtrl; |
103 |
cost_xx(dirModel,dirMat,1); |
104 |
|
105 |
end; |
106 |
|
107 |
end; |
108 |
|