source: issm/trunk/test/NightlyRun/runme.m@ 6088

Last change on this file since 6088 was 6088, checked in by Eric.Larour, 14 years ago

Updated all routines to take into account ISSM_DIR AND ISSM_TIER environment variables

  • Property svn:executable set to *
File size: 6.5 KB
Line 
1function varargout=runme(varargin)
2%RUNME - test deck for ISSM nightly runs
3%
4% In a test deck directory (tests/Vertification/NightlyRun for example)
5% The following command will launch all the existing tests:
6% >> runme
7% To run the tests 101 and 102:
8% >> runme('id',[101 102])
9% etc...
10%
11% Available options:
12% 'id' followed by the list of ids requested
13% 'exclude' ids to be excluded from the test
14% 'benchmark' 'nightly' (nightly run/ daily run)
15% 'ismip' : validation of ismip-hom tests
16% 'eismint': validation of eismint tests
17% 'thermal': validation of thermal tests
18% 'mesh' : validation of mesh tests
19% ...
20% 'procedure' 'check' : run the test (default)
21% 'update': update the archive
22% 'model' : prepare the model but no test is run
23%
24% Usage:
25% md=runme(varargin);
26%
27% Examples:
28% runme;
29% runme('exclude',101);
30% md=runme('id',102,'procedure','model');
31
32%use ISSM_TIER generated by startup.m
33global ISSM_TIER
34
35%Check inputs
36% {{{1
37if nargout>1
38 help runme
39 error('runme error message: bad usage');
40end
41
42%recover options
43options=pairoptions(varargin{:});
44% }}}
45
46%Process options
47%GET benchmark {{{1
48benchmark=getfieldvalue(options,'benchmark','nightly');
49if ~ismember(benchmark,{'all','nightly','ismip','eismint','thermal','mesh','validation'})
50 disp('runme warnig: benchmark not supported, defaulting to test ''nightly''')
51 benchmark='nighlty';
52end
53% }}}
54%GET procedure {{{1
55procedure=getfieldvalue(options,'procedure','check');
56if ~ismember(procedure,{'check','update'})
57 disp('runme warning: procedure not supported, defaulting to test ''check''')
58 procedure='check';
59end
60% }}}
61%GET output {{{1
62output=getfieldvalue(options,'output','none');
63if ~ismember(output,{'nightly','daily','none'})
64 disp('runme warning: output not supported, defaulting to test ''none''')
65 output='none';
66end
67% }}}
68%GET RANK and NUMPROCS for mutlithreaded runs {{{1
69rank=getfieldvalue(options,'rank',1);
70numprocs=getfieldvalue(options,'numprocs',1);
71if (numprocs<rank), numprocs=1; end
72% }}}
73%GET ids {{{1
74list=dir;%use dir, as it seems to act OS independent
75list_ids=[];
76for i=1:numel(list),
77 if ( strncmp(list(i).name,'test',4) &... %File name must start with 'test'
78 strncmp(fliplr(list(i).name),fliplr('.m'),2)&... %File name must end by '.m'
79 ~strcmp(list(i).name,'test.m')) %File name must be different than 'test.m'
80 list_ids(end+1)=eval(list(i).name(5:end-2)); %Keep test id only (skip 'test' and '.m')
81 end
82end
83[i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
84list_ids=list_ids(i1:i2);
85
86test_ids=getfieldvalue(options,'id',list_ids);
87test_ids=intersect(test_ids,list_ids);
88% }}}
89%GET exculde {{{1
90exclude_ids=getfieldvalue(options,'exclude',[]);
91pos=find(ismember(test_ids,exclude_ids));
92test_ids(pos)=[];
93% }}}
94%Process Ids according to benchmarks{{{1
95if strcmpi(benchmark,'nightly'),
96 test_ids=intersect(test_ids,[1:999]);
97elseif strcmpi(benchmark,'ismip'),
98 test_ids=intersect(test_ids,[1101:1199]);
99elseif strcmpi(benchmark,'eismint'),
100 test_ids=intersect(test_ids,[1201:1299]);
101elseif strcmpi(benchmark,'thermal'),
102 test_ids=intersect(test_ids,[1301:1399]);
103elseif strcmpi(benchmark,'mesh'),
104 test_ids=intersect(test_ids,[1401:1499]);
105elseif strcmpi(benchmark,'validation'),
106 test_ids=intersect(test_ids,[1001:1999]);
107end
108% }}}
109
110%Loop over tests and launch sequence
111root=pwd;
112for id=test_ids,
113 try,
114
115 %Execute test
116 eval(['cd ' root ]);
117 id_string=IdToName(id);
118 eval(['test' num2str(id)]);
119
120 %UPDATE ARCHIVE?
121 archive_name=['Archive' num2str(id) ];
122 if strcmpi(procedure,'update'),
123
124 for k=1:length(field_names),
125 field=field_values{k};
126 eval([ archive_name '_field' num2str(k) ' = field ;']);
127 end
128 eval(['save ./../Archives/' archive_name ' ' archive_name '_field*']);
129 disp(sprintf(['File ./../Archives/' archive_name ' saved\n']));
130
131 %ELSE: CHECK TEST
132 else,
133
134 %load archive
135 load(['./../Archives/' archive_name ]);
136
137 for k=1:length(field_names),
138
139 try,
140 %Get field and tolerance
141 field=field_values{k};
142 fieldname=field_names{k};
143 tolerance=field_tolerances{k};
144
145 %compare to archive
146 eval(['archive=' archive_name '_field' num2str(k) ';']);
147 error_diff=full(max(abs(archive-field))/(max(abs(archive))+eps));
148
149 %disp test result
150 if (error_diff>tolerance);
151 disp(sprintf(['ERROR difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],...
152 error_diff,tolerance,id,id_string,fieldname));
153 else
154 disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
155 error_diff,tolerance,id,id_string,fieldname));
156 end
157
158 catch me2
159
160 %something went wrong, print failure message:
161 directory=strsplit(pwd,'/');
162 message=getReport(me2);
163 if strcmpi(output,'nightly')
164 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
165 fprintf(fid,'%s',message);
166 fprintf(fid,'\n------------------------------------------------------------------\n');
167 fclose(fid);
168 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
169 elseif strcmpi(output,'daily');
170 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
171 fprintf(fid,'%s',message);
172 fprintf(fid,'\n------------------------------------------------------------------\n');
173 fclose(fid);
174 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
175 else
176 rethrow(me2);
177 end
178 end
179 end
180 end
181
182 catch me,
183
184 %something went wrong, print failure message:
185 directory=strsplit(pwd,'/');
186 message=getReport(me);
187 if strcmpi(output,'nightly')
188 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
189 fprintf(fid,'%s',message);
190 fprintf(fid,'\n------------------------------------------------------------------\n');
191 fclose(fid);
192 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
193 elseif strcmpi(output,'daily');
194 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
195 fprintf(fid,'%s',message);
196 fprintf(fid,'\n------------------------------------------------------------------\n');
197 fclose(fid);
198 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
199 else
200 rethrow(me);
201 end
202 end
203end
204
205%output md if requested
206if nargout==1
207 varargout{1}=md;
208end
Note: See TracBrowser for help on using the repository browser.