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

Last change on this file since 11995 was 11995, checked in by Mathieu Morlighem, 13 years ago

merged trunk-jpl and trunk for revision 11994M

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