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
RevLine 
[4950]1function varargout=runme(varargin)
2%RUNME - test deck for ISSM nightly runs
3%
[5085]4% In a test deck directory (tests/Vertification/NightlyRun for example)
5% The following command will launch all the existing tests:
[4950]6% >> runme
[5085]7% To run the tests 101 and 102:
8% >> runme('id',[101 102])
[4950]9% etc...
10%
11% Available options:
[5085]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)
[5271]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
[5085]19% ...
[4950]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;
[5085]29% runme('exclude',101);
30% md=runme('id',102,'procedure','model');
[4950]31
[6926]32%Get ISSM_TIER variable
33ISSM_TIER=issmtier();
[4950]34
[5050]35%Check inputs
36% {{{1
[4950]37if nargout>1
38 help runme
39 error('runme error message: bad usage');
40end
41
[5050]42%recover options
43options=pairoptions(varargin{:});
44% }}}
45
46%Process options
47%GET benchmark {{{1
48benchmark=getfieldvalue(options,'benchmark','nightly');
[8854]49if ~ismember(benchmark,{'all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing'})
[11527]50 disp('runme warning: benchmark not supported, defaulting to test ''nightly''')
[5050]51 benchmark='nighlty';
52end
53% }}}
54%GET procedure {{{1
[4950]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
[5050]60% }}}
[5084]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% }}}
[5050]68%GET RANK and NUMPROCS for mutlithreaded runs {{{1
[4999]69rank=getfieldvalue(options,'rank',1);
70numprocs=getfieldvalue(options,'numprocs',1);
71if (numprocs<rank), numprocs=1; end
[5050]72% }}}
73%GET ids {{{1
[4950]74list=dir;%use dir, as it seems to act OS independent
75list_ids=[];
76for i=1:numel(list),
[5315]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')
[4950]81 end
82end
[4999]83[i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
84list_ids=list_ids(i1:i2);
85
[4950]86test_ids=getfieldvalue(options,'id',list_ids);
87test_ids=intersect(test_ids,list_ids);
[5050]88% }}}
[5085]89%GET exculde {{{1
90exclude_ids=getfieldvalue(options,'exclude',[]);
[7071]91exclude_ids=[exclude_ids];
[5085]92pos=find(ismember(test_ids,exclude_ids));
93test_ids(pos)=[];
94% }}}
[5050]95%Process Ids according to benchmarks{{{1
96if strcmpi(benchmark,'nightly'),
97 test_ids=intersect(test_ids,[1:999]);
[5272]98elseif strcmpi(benchmark,'ismip'),
[5271]99 test_ids=intersect(test_ids,[1101:1199]);
[5272]100elseif strcmpi(benchmark,'eismint'),
[5271]101 test_ids=intersect(test_ids,[1201:1299]);
[5272]102elseif strcmpi(benchmark,'thermal'),
[5271]103 test_ids=intersect(test_ids,[1301:1399]);
[5272]104elseif strcmpi(benchmark,'mesh'),
[5271]105 test_ids=intersect(test_ids,[1401:1499]);
[5362]106elseif strcmpi(benchmark,'validation'),
107 test_ids=intersect(test_ids,[1001:1999]);
[8854]108elseif strcmpi(benchmark,'tranforcing'),
109 test_ids=intersect(test_ids,[1501:1502]);
[5050]110end
111% }}}
[4950]112
113%Loop over tests and launch sequence
[5501]114root=pwd;
[4950]115for id=test_ids,
116 try,
117
118 %Execute test
[5501]119 eval(['cd ' root ]);
120 id_string=IdToName(id);
[4950]121 eval(['test' num2str(id)]);
122
123 %UPDATE ARCHIVE?
124 archive_name=['Archive' num2str(id) ];
125 if strcmpi(procedure,'update'),
126
[8135]127 if ~strcmp(oshostname(),'larsen');
[8150]128 error(['Nighlty run archives must be saved on "larsen" (hostname is "' oshostname() '")']);
[8135]129 end
[4950]130 for k=1:length(field_names),
131 field=field_values{k};
132 eval([ archive_name '_field' num2str(k) ' = field ;']);
133 end
[7358]134 eval(['save ../Archives/' archive_name ' ' archive_name '_field*']);
[4950]135 disp(sprintf(['File ./../Archives/' archive_name ' saved\n']));
136
137 %ELSE: CHECK TEST
138 else,
139
140 %load archive
[7358]141 load(['../Archives/' archive_name ]);
[4950]142
143 for k=1:length(field_names),
144
[4999]145 try,
146 %Get field and tolerance
147 field=field_values{k};
148 fieldname=field_names{k};
149 tolerance=field_tolerances{k};
[4950]150
[4999]151 %compare to archive
152 eval(['archive=' archive_name '_field' num2str(k) ';']);
[11027]153 error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive))+eps));
[4950]154
[4999]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'],...
[5501]158 error_diff,tolerance,id,id_string,fieldname));
[4999]159 else
160 disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
[5501]161 error_diff,tolerance,id,id_string,fieldname));
[4999]162 end
163
164 catch me2
165
166 %something went wrong, print failure message:
167 directory=strsplit(pwd,'/');
[5104]168 message=getReport(me2);
[5084]169 if strcmpi(output,'nightly')
[6088]170 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
[5084]171 fprintf(fid,'%s',message);
172 fprintf(fid,'\n------------------------------------------------------------------\n');
173 fclose(fid);
[5501]174 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
[5084]175 elseif strcmpi(output,'daily');
[6088]176 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
[5084]177 fprintf(fid,'%s',message);
178 fprintf(fid,'\n------------------------------------------------------------------\n');
179 fclose(fid);
[5501]180 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
[5104]181 else
[11995]182 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
[5104]183 rethrow(me2);
[5084]184 end
[4950]185 end
186 end
187 end
188
189 catch me,
190
191 %something went wrong, print failure message:
192 directory=strsplit(pwd,'/');
[5104]193 message=getReport(me);
[5084]194 if strcmpi(output,'nightly')
[6088]195 fid=fopen([ISSM_TIER '/nightlylog/matlaberror.log'], 'at');
[5084]196 fprintf(fid,'%s',message);
197 fprintf(fid,'\n------------------------------------------------------------------\n');
198 fclose(fid);
[5501]199 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
[5084]200 elseif strcmpi(output,'daily');
[6088]201 fid=fopen([ISSM_TIER '/dailylog/matlaberror.log'], 'at');
[5084]202 fprintf(fid,'%s',message);
203 fprintf(fid,'\n------------------------------------------------------------------\n');
204 fclose(fid);
[5501]205 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
[5104]206 else
[11995]207 disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
[5104]208 rethrow(me);
[5084]209 end
[4950]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.