1 |
% m-file: mit_timesteps.m |
2 |
% sets up the the variables tname and timesteps for the 4x4 global runs |
3 |
|
4 |
% $Header: $ |
5 |
% $Name: $ |
6 |
|
7 |
deltat = mit_getparm('data','deltaTtracer'); |
8 |
if isempty(deltat) |
9 |
error('deltaTtracer is empty') |
10 |
end |
11 |
|
12 |
if strcmp(dname,'baseline.000') |
13 |
timesteps = [0:11]'*36e3; % one hundred years |
14 |
timesteps = [timesteps; [12:30]'*72e3]; % one hundred years (baseline experiment) |
15 |
elseif strcmp(dname,'etopo5.000') |
16 |
timesteps = [0:30]'*72e3; % one hundred years (etopo5 experiments) |
17 |
else |
18 |
if meanfields |
19 |
[dummy, timesteps] = rdmds('uVeltave',NaN); |
20 |
if isempty(timesteps) |
21 |
meanfields=0; |
22 |
error('There are no averaged fields, use meanfields=0') |
23 |
end |
24 |
timesteps = [0 timesteps]; |
25 |
else |
26 |
[dummy, timesteps] = rdmds('U',NaN); |
27 |
end |
28 |
timesteps = timesteps'; |
29 |
clear dummy |
30 |
end |
31 |
|
32 |
nt = length(timesteps); |
33 |
kt = 1:nt; |
34 |
tname = cell(nt,1); |
35 |
for k = kt |
36 |
tname{k} = sprintf('%010i',timesteps(k)); |
37 |
end |
38 |
|
39 |
%% alternative (unflexible way) |
40 |
% $$$ timesteps = [0:11]'*36e3; % one hundred years |
41 |
% $$$ timesteps = [timesteps; [12:30]'*72e3]; % one hundred years (baseline experiment) |
42 |
% $$$ clear timesteps tname kt nt |
43 |
% $$$ timesteps = [0:30]'*72e3; % one hundred years (etopo5 experiments) |
44 |
% $$$ %tincr = 20; timesteps = [0:36]'*20; % one hundred years |
45 |
% $$$ nt = length(timesteps); |
46 |
% $$$ kt = 1:nt; |
47 |
% $$$ tname = cell(nt,1); |
48 |
% $$$ for k = kt |
49 |
% $$$ tname{k} = sprintf('%010i',timesteps(k)); |
50 |
% $$$ end |
51 |
|
52 |
% create a time axis |
53 |
oneday = 3600*24; |
54 |
onemonth =oneday*30; |
55 |
oneyr=onemonth*12; |
56 |
msg_spinup = dir('spinup.tim'); |
57 |
if isempty(msg_spinup) |
58 |
tim = deltat*timesteps'; |
59 |
else |
60 |
tim = load('spinup.tim'); |
61 |
itim = find(diff(tim) == 0); |
62 |
tim(itim) = []; |
63 |
end |
64 |
% create reasonable unit; |
65 |
if max(tim(:))/oneday <= 360 |
66 |
tim = tim/oneday; |
67 |
timeunit = 'days'; |
68 |
tuname = 'day'; |
69 |
elseif max(tim(:))/onemonth <= 120 |
70 |
tim = tim/onemonth; |
71 |
timeunit = 'months'; |
72 |
tuname = 'month'; |
73 |
else |
74 |
tim = tim/oneyr; |
75 |
timeunit = 'yrs'; |
76 |
tuname = 'year'; |
77 |
end |
78 |
|
79 |
if ~exist('kmax','var') |
80 |
kmax=max(kt); |
81 |
end |
82 |
disp(['kmax = ' num2str(kmax) ', diplayed time = ' ... |
83 |
num2str(tim(kmax)) ' ' timeunit]) |
84 |
|