[4950] | 1 | function 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
|
---|
[15396] | 14 | % 'benchmark' 'all' (all of them)
|
---|
[17806] | 15 | % 'nightly' (nightly run)
|
---|
[5271] | 16 | % 'ismip' : validation of ismip-hom tests
|
---|
| 17 | % 'eismint': validation of eismint tests
|
---|
| 18 | % 'thermal': validation of thermal tests
|
---|
| 19 | % 'mesh' : validation of mesh tests
|
---|
[13395] | 20 | % 'adolc' : validation of adolc tests
|
---|
[20500] | 21 | % 'slr' : validation of slr tests
|
---|
[18301] | 22 | % 'qmu' : validation of dakota tests
|
---|
[5085] | 23 | % ...
|
---|
[16137] | 24 | % 'procedure' 'check' : run the test (default)
|
---|
| 25 | % 'update': update the archive
|
---|
| 26 | % 'valgrind': check for memory leaks (default value of md.debug.valgrind needs to be changed manually)
|
---|
[17806] | 27 | % 'stoponerror' 1 or 0
|
---|
[4950] | 28 | %
|
---|
| 29 | % Usage:
|
---|
[15396] | 30 | % runme(varargin);
|
---|
[4950] | 31 | %
|
---|
| 32 | % Examples:
|
---|
| 33 | % runme;
|
---|
[5085] | 34 | % runme('exclude',101);
|
---|
[15396] | 35 | % runme('id',102,'procedure','update');
|
---|
[4950] | 36 |
|
---|
[22758] | 37 | % runme('procedure','valgrind','stoponerror',1,'exclude','IdFromString('Dak'));
|
---|
| 38 |
|
---|
[5050] | 39 | %Check inputs
|
---|
[13395] | 40 | % {{{
|
---|
[4950] | 41 | if nargout>1
|
---|
| 42 | help runme
|
---|
| 43 | error('runme error message: bad usage');
|
---|
| 44 | end
|
---|
| 45 |
|
---|
[5050] | 46 | %recover options
|
---|
| 47 | options=pairoptions(varargin{:});
|
---|
| 48 | % }}}
|
---|
| 49 |
|
---|
| 50 | %Process options
|
---|
[13395] | 51 | %GET benchmark {{{
|
---|
[5050] | 52 | benchmark=getfieldvalue(options,'benchmark','nightly');
|
---|
[20500] | 53 | if ~ismember(benchmark,{'all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing','adolc','slr','qmu'})
|
---|
[11527] | 54 | disp('runme warning: benchmark not supported, defaulting to test ''nightly''')
|
---|
[12707] | 55 | benchmark='nightly';
|
---|
[5050] | 56 | end
|
---|
| 57 | % }}}
|
---|
[13395] | 58 | %GET procedure {{{
|
---|
[4950] | 59 | procedure=getfieldvalue(options,'procedure','check');
|
---|
[16137] | 60 | if ~ismember(procedure,{'check','update','valgrind'})
|
---|
[4950] | 61 | disp('runme warning: procedure not supported, defaulting to test ''check''')
|
---|
| 62 | procedure='check';
|
---|
| 63 | end
|
---|
[5050] | 64 | % }}}
|
---|
[13395] | 65 | %GET output {{{
|
---|
[5084] | 66 | output=getfieldvalue(options,'output','none');
|
---|
[17806] | 67 | if ~ismember(output,{'nightly','none'})
|
---|
[5084] | 68 | disp('runme warning: output not supported, defaulting to test ''none''')
|
---|
| 69 | output='none';
|
---|
| 70 | end
|
---|
| 71 | % }}}
|
---|
[13975] | 72 | %GET RANK and NUMPROCS for multithreaded runs {{{
|
---|
[4999] | 73 | rank=getfieldvalue(options,'rank',1);
|
---|
| 74 | numprocs=getfieldvalue(options,'numprocs',1);
|
---|
| 75 | if (numprocs<rank), numprocs=1; end
|
---|
[5050] | 76 | % }}}
|
---|
[13395] | 77 | %GET ids {{{
|
---|
| 78 | flist=dir;%use dir, as it seems to act OS independent
|
---|
[4950] | 79 | list_ids=[];
|
---|
[13395] | 80 | for i=1:numel(flist),
|
---|
| 81 | if ( strncmp(flist(i).name,'test',4) &... %File name must start with 'test'
|
---|
| 82 | strncmp(fliplr(flist(i).name),fliplr('.m'),2)&... %File name must end by '.m'
|
---|
| 83 | ~strcmp(flist(i).name,'test.m')) %File name must be different than 'test.m'
|
---|
[14310] | 84 | id=str2num(flist(i).name(5:end-2));
|
---|
| 85 | if isempty(id),
|
---|
| 86 | disp(['WARNING: ignore file ' flist(i).name ]);
|
---|
| 87 | else
|
---|
| 88 | list_ids(end+1)=eval(flist(i).name(5:end-2)); %Keep test id only (skip 'test' and '.m')
|
---|
| 89 | end
|
---|
[4950] | 90 | end
|
---|
| 91 | end
|
---|
[4999] | 92 | [i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
|
---|
| 93 | list_ids=list_ids(i1:i2);
|
---|
| 94 |
|
---|
[4950] | 95 | test_ids=getfieldvalue(options,'id',list_ids);
|
---|
| 96 | test_ids=intersect(test_ids,list_ids);
|
---|
[5050] | 97 | % }}}
|
---|
[13395] | 98 | %GET exclude {{{
|
---|
[5085] | 99 | exclude_ids=getfieldvalue(options,'exclude',[]);
|
---|
[7071] | 100 | exclude_ids=[exclude_ids];
|
---|
[5085] | 101 | pos=find(ismember(test_ids,exclude_ids));
|
---|
| 102 | test_ids(pos)=[];
|
---|
| 103 | % }}}
|
---|
[13395] | 104 | %Process Ids according to benchmarks{{{
|
---|
[5050] | 105 | if strcmpi(benchmark,'nightly'),
|
---|
| 106 | test_ids=intersect(test_ids,[1:999]);
|
---|
[14067] | 107 | elseif strcmpi(benchmark,'validation'),
|
---|
| 108 | test_ids=intersect(test_ids,[1001:1999]);
|
---|
[5272] | 109 | elseif strcmpi(benchmark,'ismip'),
|
---|
[5271] | 110 | test_ids=intersect(test_ids,[1101:1199]);
|
---|
[5272] | 111 | elseif strcmpi(benchmark,'eismint'),
|
---|
[5271] | 112 | test_ids=intersect(test_ids,[1201:1299]);
|
---|
[5272] | 113 | elseif strcmpi(benchmark,'thermal'),
|
---|
[5271] | 114 | test_ids=intersect(test_ids,[1301:1399]);
|
---|
[5272] | 115 | elseif strcmpi(benchmark,'mesh'),
|
---|
[5271] | 116 | test_ids=intersect(test_ids,[1401:1499]);
|
---|
[14067] | 117 | elseif strcmpi(benchmark,'tranforcing'),
|
---|
| 118 | test_ids=intersect(test_ids,[1501:1502]);
|
---|
| 119 | elseif strcmpi(benchmark,'referential'),
|
---|
| 120 | test_ids=intersect(test_ids,[1601:1602]);
|
---|
[20500] | 121 | elseif strcmpi(benchmark,'slr'),
|
---|
| 122 | test_ids=intersect(test_ids,[2001:2500]);
|
---|
[13395] | 123 | elseif strcmpi(benchmark,'adolc'),
|
---|
[16560] | 124 | test_ids=intersect(test_ids,[3001:3200]);
|
---|
[18301] | 125 | elseif strcmpi(benchmark,'qmu'),
|
---|
| 126 | test_ids=intersect(test_ids,[218 234 235 412:414 417 418 420]);
|
---|
[5050] | 127 | end
|
---|
| 128 | % }}}
|
---|
[4950] | 129 |
|
---|
| 130 | %Loop over tests and launch sequence
|
---|
[5501] | 131 | root=pwd;
|
---|
[4950] | 132 | for id=test_ids,
|
---|
[19105] | 133 | disp(sprintf('%s%i%s','----------------starting:',id,'-----------------------'));
|
---|
[4950] | 134 | try,
|
---|
| 135 | %Execute test
|
---|
[22758] | 136 | cd(root);
|
---|
[19105] | 137 | id_string='N/A';
|
---|
[5501] | 138 | id_string=IdToName(id);
|
---|
[22758] | 139 | run(['test' num2str(id)]);
|
---|
[4950] | 140 |
|
---|
| 141 | %UPDATE ARCHIVE?
|
---|
| 142 | archive_name=['Archive' num2str(id) ];
|
---|
| 143 | if strcmpi(procedure,'update'),
|
---|
[21341] | 144 | delete(['../Archives/' archive_name '.arch'])
|
---|
[4950] | 145 | for k=1:length(field_names),
|
---|
| 146 | field=field_values{k};
|
---|
[21341] | 147 | archwrite(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)], field);
|
---|
[4950] | 148 | end
|
---|
[21341] | 149 | disp(sprintf(['File ./../Archives/' archive_name '.arch saved\n']));
|
---|
[4950] | 150 |
|
---|
[16137] | 151 | %CHECK for memory leaks?
|
---|
| 152 | elseif strcmpi(procedure,'valgrind'),
|
---|
| 153 | fields = fieldnames(md.results);
|
---|
| 154 | for i=1:numel(fields)
|
---|
| 155 | if ~isfield(md.results.(fields{i}),'errlog'),
|
---|
| 156 | disp(['Skipping ' fields{i}]);
|
---|
| 157 | continue;
|
---|
| 158 | else
|
---|
| 159 | disp(['Extracting results of ' fields{i}]);
|
---|
| 160 | end
|
---|
| 161 | results = md.results.(fields{i});
|
---|
| 162 | errlog = cellstr(results(1).errlog);
|
---|
| 163 |
|
---|
| 164 | %Check leaks
|
---|
| 165 | lines = strfind(errlog,'definitely lost:');
|
---|
| 166 | lines = find(~cellfun(@isempty,lines));
|
---|
| 167 | leaks = 0;
|
---|
| 168 | for j=1:numel(lines)
|
---|
| 169 | Line = errlog(lines(j));
|
---|
| 170 | Numbers = sscanf(Line{1},'==%i== definitely lost: %s bytes in %i blocks',[1 Inf]);
|
---|
| 171 | leaks = leaks + str2num(strrep(char(Numbers(2:end-1)),',',''));
|
---|
| 172 | end
|
---|
| 173 | %Check conditional jumps
|
---|
| 174 | lines = strfind(errlog,'Conditional jump or move depends on uninitialised value');
|
---|
| 175 | lines = find(~cellfun(@isempty,lines));
|
---|
| 176 | jumps = numel(lines);
|
---|
| 177 | %Check invalid read/write
|
---|
| 178 | lines = strfind(errlog,'Invalid');
|
---|
| 179 | lines = find(~cellfun(@isempty,lines));
|
---|
| 180 | inval = numel(lines);
|
---|
| 181 | if leaks==0,
|
---|
| 182 | disp(sprintf(['SUCCESS difference: 0 < 0 test id: %i test name: %s field: valgrind mem. leaks'],id,id_string));
|
---|
| 183 | else
|
---|
| 184 | disp(sprintf(['ERROR difference: %i > 0 test id: %i test name: %s field: valgrind mem. leaks'],leaks,id,id_string));
|
---|
| 185 | disp('STOP');
|
---|
| 186 | return;
|
---|
| 187 | end
|
---|
| 188 | if jumps==0,
|
---|
| 189 | disp(sprintf(['SUCCESS difference: 0 < 0 test id: %i test name: %s field: valgrind cond. jumps'],id,id_string));
|
---|
| 190 | else
|
---|
| 191 | disp(sprintf(['ERROR difference: %i > 0 test id: %i test name: %s field: valgrind cond. jumps'],jumps,id,id_string));
|
---|
| 192 | disp('STOP');
|
---|
| 193 | return;
|
---|
| 194 | end
|
---|
| 195 | if inval==0,
|
---|
| 196 | disp(sprintf(['SUCCESS difference: 0 < 0 test id: %i test name: %s field: valgrind invalid read/write'],id,id_string));
|
---|
| 197 | else
|
---|
| 198 | disp(sprintf(['ERROR difference: %i > 0 test id: %i test name: %s field: valgrind invalid read/write'],inval,id,id_string));
|
---|
| 199 | disp('STOP');
|
---|
| 200 | return;
|
---|
| 201 | end
|
---|
| 202 | end
|
---|
| 203 |
|
---|
[12707] | 204 | %ELSE: CHECK TEST
|
---|
[4950] | 205 | else,
|
---|
| 206 | for k=1:length(field_names),
|
---|
| 207 |
|
---|
[4999] | 208 | try,
|
---|
| 209 | %Get field and tolerance
|
---|
| 210 | field=field_values{k};
|
---|
| 211 | fieldname=field_names{k};
|
---|
| 212 | tolerance=field_tolerances{k};
|
---|
[4950] | 213 |
|
---|
[4999] | 214 | %compare to archive
|
---|
[21341] | 215 | %our output is in the correct order (n,1) or (1,1), so we do not need to transpose again
|
---|
| 216 | archive_cell=archread(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)]);
|
---|
| 217 | archive=archive_cell{1};
|
---|
| 218 | error_diff=full(max(abs(archive(:)-field(:)))/(max(abs(archive(:)))+eps));
|
---|
[4950] | 219 |
|
---|
[4999] | 220 | %disp test result
|
---|
[20500] | 221 | if (error_diff>tolerance | isnan(error_diff));
|
---|
[4999] | 222 | disp(sprintf(['ERROR difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],...
|
---|
[5501] | 223 | error_diff,tolerance,id,id_string,fieldname));
|
---|
[17806] | 224 | if(getfieldvalue(options,'stoponerror',0)), disp('STOP'); return; end
|
---|
[4999] | 225 | else
|
---|
| 226 | disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
|
---|
[5501] | 227 | error_diff,tolerance,id,id_string,fieldname));
|
---|
[4999] | 228 | end
|
---|
| 229 |
|
---|
| 230 | catch me2
|
---|
| 231 |
|
---|
| 232 | %something went wrong, print failure message:
|
---|
[5104] | 233 | message=getReport(me2);
|
---|
[17806] | 234 | fprintf('%s',message);
|
---|
[5084] | 235 | if strcmpi(output,'nightly')
|
---|
[19105] | 236 | fid=fopen([issmdir() '/nightlylog/matlaberror.log'], 'at');
|
---|
[5084] | 237 | fprintf(fid,'%s',message);
|
---|
| 238 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
| 239 | fclose(fid);
|
---|
[5501] | 240 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
|
---|
[5104] | 241 | else
|
---|
[11995] | 242 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,fieldname));
|
---|
[17806] | 243 | fprintf('%s',message);
|
---|
| 244 | if(getfieldvalue(options,'stoponerror',0)), disp('STOP'); return; end
|
---|
[5084] | 245 | end
|
---|
[17806] | 246 | continue;
|
---|
[4950] | 247 | end
|
---|
| 248 | end
|
---|
| 249 | end
|
---|
| 250 | catch me,
|
---|
| 251 |
|
---|
| 252 | %something went wrong, print failure message:
|
---|
[5104] | 253 | message=getReport(me);
|
---|
[17806] | 254 | fprintf('%s',message);
|
---|
[5084] | 255 | if strcmpi(output,'nightly')
|
---|
[19105] | 256 | fid=fopen([issmdir() '/nightlylog/matlaberror.log'], 'at');
|
---|
[5084] | 257 | fprintf(fid,'%s',message);
|
---|
| 258 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
| 259 | fclose(fid);
|
---|
[5501] | 260 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
|
---|
[5104] | 261 | else
|
---|
[11995] | 262 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,id_string,'N/A'));
|
---|
[5104] | 263 | rethrow(me);
|
---|
[17806] | 264 | if(getfieldvalue(options,'stoponerror',0)), disp('STOP'); return; end
|
---|
[5084] | 265 | end
|
---|
[4950] | 266 | end
|
---|
[19105] | 267 | disp(sprintf('%s%i%s','----------------finished:',id,'-----------------------'));
|
---|
[4950] | 268 | end
|
---|