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

Last change on this file since 8150 was 8150, checked in by Mathieu Morlighem, 14 years ago

minor

  • Property svn:executable set to *
File size: 6.7 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%Get ISSM_TIER variable
33ISSM_TIER=issmtier();
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',[]);
91exclude_ids=[exclude_ids];
92pos=find(ismember(test_ids,exclude_ids));
93test_ids(pos)=[];
94% }}}
95%Process Ids according to benchmarks{{{1
96if strcmpi(benchmark,'nightly'),
97 test_ids=intersect(test_ids,[1:999]);
98elseif strcmpi(benchmark,'ismip'),
99 test_ids=intersect(test_ids,[1101:1199]);
100elseif strcmpi(benchmark,'eismint'),
101 test_ids=intersect(test_ids,[1201:1299]);
102elseif strcmpi(benchmark,'thermal'),
103 test_ids=intersect(test_ids,[1301:1399]);
104elseif strcmpi(benchmark,'mesh'),
105 test_ids=intersect(test_ids,[1401:1499]);
106elseif strcmpi(benchmark,'validation'),
107 test_ids=intersect(test_ids,[1001:1999]);
108end
109% }}}
110
111%Loop over tests and launch sequence
112root=pwd;
113for id=test_ids,
114 try,
115
116 %Execute test
117 eval(['cd ' root ]);
118 id_string=IdToName(id);
119 eval(['test' num2str(id)]);
120
121 %UPDATE ARCHIVE?
122 archive_name=['Archive' num2str(id) ];
123 if strcmpi(procedure,'update'),
124
125 if ~strcmp(oshostname(),'larsen');
126 error(['Nighlty run archives must be saved on "larsen" (hostname is "' oshostname() '")']);
127 end
128 for k=1:length(field_names),
129 field=field_values{k};
130 eval([ archive_name '_field' num2str(k) ' = field ;']);
131 end
132 eval(['save ../Archives/' archive_name ' ' archive_name '_field*']);
133 disp(sprintf(['File ./../Archives/' archive_name ' saved\n']));
134
135 %ELSE: CHECK TEST
136 else,
137
138 %load archive
139 load(['../Archives/' archive_name ]);
140
141 for k=1:length(field_names),
142
143 try,
144 %Get field and tolerance
145 field=field_values{k};
146 fieldname=field_names{k};
147 tolerance=field_tolerances{k};
148
149 %compare to archive
150 eval(['archive=' archive_name '_field' num2str(k) ';']);
151 error_diff=full(max(abs(archive-field))/(max(abs(archive))+eps));
152
153 %disp test result
154 if (error_diff>tolerance);
155 disp(sprintf(['ERROR difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],...
156 error_diff,tolerance,id,id_string,fieldname));
157 else
158 disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
159 error_diff,tolerance,id,id_string,fieldname));
160 end
161
162 catch me2
163
164 %something went wrong, print failure message:
165 directory=strsplit(pwd,'/');
166 message=getReport(me2);
167 if strcmpi(output,'nightly')
168 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
169 fprintf(fid,'%s',message);
170 fprintf(fid,'\n------------------------------------------------------------------\n');
171 fclose(fid);
172 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
173 elseif strcmpi(output,'daily');
174 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
175 fprintf(fid,'%s',message);
176 fprintf(fid,'\n------------------------------------------------------------------\n');
177 fclose(fid);
178 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
179 else
180 rethrow(me2);
181 end
182 end
183 end
184 end
185
186 catch me,
187
188 %something went wrong, print failure message:
189 directory=strsplit(pwd,'/');
190 message=getReport(me);
191 if strcmpi(output,'nightly')
192 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
193 fprintf(fid,'%s',message);
194 fprintf(fid,'\n------------------------------------------------------------------\n');
195 fclose(fid);
196 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
197 elseif strcmpi(output,'daily');
198 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
199 fprintf(fid,'%s',message);
200 fprintf(fid,'\n------------------------------------------------------------------\n');
201 fclose(fid);
202 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
203 else
204 rethrow(me);
205 end
206 end
207end
208
209%output md if requested
210if nargout==1
211 varargout{1}=md;
212end
Note: See TracBrowser for help on using the repository browser.