1 |
gforget |
1.6 |
function []=diags_driver(dirModel,dirMat,years,setDiags,doInteractive); |
2 |
gforget |
1.1 |
%object: compute the various cost and physics |
3 |
|
|
% diagnosits from model output |
4 |
gforget |
1.6 |
%input: dirModel is the directory containing 'diags/' or 'nctiles/' |
5 |
|
|
% dirMat is the directory where diagnostics results will be saved |
6 |
|
|
% if isempty(dirMat) then [dirModel 'mat/'] is used by default |
7 |
|
|
% years (vector) that states years (or sets of 12 records) to compute |
8 |
|
|
% if years=[1:4] then the first 4 years are computed |
9 |
|
|
%(optional) setDiags further specifies physical diags to be computed |
10 |
|
|
% if setDiags='A' then one set of diags ('A') is computed |
11 |
|
|
% By default three sets of diags ('A','B','C') are computed. |
12 |
|
|
%(optional) doInteractive=1 allows users to specify parameters interactively |
13 |
|
|
% doInteractive = 0 (default) uses ECCO v4 parameters |
14 |
|
|
% and omits budgets and model-data misfits analyses |
15 |
|
|
% |
16 |
|
|
%notes : eventually should also use dirMat, dirTex interactively for years=[]; |
17 |
gforget |
1.1 |
|
18 |
|
|
gcmfaces_global; global myparms; |
19 |
|
|
|
20 |
|
|
%%%%%%%%%%%%%%% |
21 |
|
|
%pre-processing |
22 |
|
|
%%%%%%%%%%%%%%% |
23 |
|
|
|
24 |
gforget |
1.6 |
if isempty(who('doInteractive')); doInteractive=0; end; |
25 |
|
|
myswitch=diags_pre_process(dirModel,dirMat,doInteractive); |
26 |
gforget |
1.1 |
|
27 |
gforget |
1.7 |
if ~doInteractive; |
28 |
|
|
myparms.yearFirst=years(1); |
29 |
|
|
myparms.yearLast=years(end); |
30 |
|
|
myparms.yearInAve=[years(1) years(end)]; |
31 |
|
|
myparms.recInAve=[1 12]+12*([years(1) years(end)]-1992); |
32 |
|
|
years=years-1992+1; |
33 |
|
|
eval(['save ' dirMat 'diags_grid_parms.mat myparms;']); |
34 |
|
|
end; |
35 |
|
|
|
36 |
gforget |
1.1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
37 |
|
|
%now do the selected computation chunk: |
38 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
39 |
|
|
|
40 |
|
|
dirModel=[dirModel '/']; |
41 |
|
|
if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end; |
42 |
|
|
|
43 |
|
|
if ~isempty(who('setDiags')); |
44 |
gforget |
1.2 |
|
45 |
gforget |
1.7 |
lChunk=12; |
46 |
gforget |
1.1 |
|
47 |
|
|
%physical diagnostics |
48 |
gforget |
1.6 |
for myYear=years; |
49 |
|
|
diags_select(dirModel,dirMat,setDiags,lChunk,myYear); |
50 |
gforget |
1.1 |
end; |
51 |
|
|
|
52 |
gforget |
1.6 |
else; |
53 |
gforget |
1.1 |
|
54 |
gforget |
1.6 |
for myYear=years; |
55 |
|
|
|
56 |
|
|
%standard physical diagnostics : |
57 |
|
|
diags_select(dirModel,dirMat,'A',12,myYear); |
58 |
gforget |
1.7 |
if ~doInteractive; |
59 |
|
|
diags_select(dirModel,dirMat,'B',12,myYear); |
60 |
|
|
elseif myYear==years(1); |
61 |
|
|
recInAve=[myparms.recInAve(1):myparms.recInAve(2)]; |
62 |
|
|
diags_select(dirModel,dirMat,'B',1,recInAve); |
63 |
|
|
end; |
64 |
gforget |
1.6 |
diags_select(dirModel,dirMat,'C',12,myYear); |
65 |
|
|
|
66 |
|
|
%budgets : |
67 |
gforget |
1.1 |
if myswitch.doBudget; |
68 |
|
|
budget_list=1; |
69 |
|
|
if ~isempty(dir([dirMat 'diags_select_budget_list.mat'])); |
70 |
|
|
eval(['load ' dirMat 'diags_select_budget_list.mat;']); |
71 |
|
|
end; |
72 |
|
|
for kk=budget_list; |
73 |
gforget |
1.6 |
diags_select(dirModel,dirMat,{'D',kk},12,myYear); |
74 |
gforget |
1.1 |
end; |
75 |
|
|
end; |
76 |
gforget |
1.6 |
|
77 |
|
|
%model-data misfits : |
78 |
|
|
% in situ profiles fit |
79 |
|
|
if myswitch.doProfiles&myYear==1; insitu_diags(dirMat,1); end; |
80 |
|
|
% altimeter fit |
81 |
|
|
if myswitch.doCost&myYear==1; cost_altimeter(dirModel,dirMat); end; |
82 |
|
|
% other cost terms |
83 |
|
|
if myswitch.doCost&myYear==1; cost_sst(dirModel,dirMat,1); end; |
84 |
|
|
if myswitch.doCost&myYear==1; cost_bp(dirModel,dirMat,1); end; |
85 |
|
|
if myswitch.doCost&myYear==1; cost_seaicearea(dirModel,dirMat,1); end; |
86 |
|
|
% controls |
87 |
|
|
if myswitch.doCtrl&myYear==1; cost_xx(dirModel,dirMat,1); end; |
88 |
|
|
|
89 |
gforget |
1.1 |
end; |
90 |
|
|
|
91 |
|
|
end; |
92 |
|
|
|