[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
|
---|
| 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
|
---|
| 33 | ISSM_TIER=issmtier();
|
---|
[4950] | 34 |
|
---|
[5050] | 35 | %Check inputs
|
---|
| 36 | % {{{1
|
---|
[4950] | 37 | if nargout>1
|
---|
| 38 | help runme
|
---|
| 39 | error('runme error message: bad usage');
|
---|
| 40 | end
|
---|
| 41 |
|
---|
[5050] | 42 | %recover options
|
---|
| 43 | options=pairoptions(varargin{:});
|
---|
| 44 | % }}}
|
---|
| 45 |
|
---|
| 46 | %Process options
|
---|
| 47 | %GET benchmark {{{1
|
---|
| 48 | benchmark=getfieldvalue(options,'benchmark','nightly');
|
---|
[8854] | 49 | if ~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';
|
---|
| 52 | end
|
---|
| 53 | % }}}
|
---|
| 54 | %GET procedure {{{1
|
---|
[4950] | 55 | procedure=getfieldvalue(options,'procedure','check');
|
---|
| 56 | if ~ismember(procedure,{'check','update'})
|
---|
| 57 | disp('runme warning: procedure not supported, defaulting to test ''check''')
|
---|
| 58 | procedure='check';
|
---|
| 59 | end
|
---|
[5050] | 60 | % }}}
|
---|
[5084] | 61 | %GET output {{{1
|
---|
| 62 | output=getfieldvalue(options,'output','none');
|
---|
| 63 | if ~ismember(output,{'nightly','daily','none'})
|
---|
| 64 | disp('runme warning: output not supported, defaulting to test ''none''')
|
---|
| 65 | output='none';
|
---|
| 66 | end
|
---|
| 67 | % }}}
|
---|
[5050] | 68 | %GET RANK and NUMPROCS for mutlithreaded runs {{{1
|
---|
[4999] | 69 | rank=getfieldvalue(options,'rank',1);
|
---|
| 70 | numprocs=getfieldvalue(options,'numprocs',1);
|
---|
| 71 | if (numprocs<rank), numprocs=1; end
|
---|
[5050] | 72 | % }}}
|
---|
| 73 | %GET ids {{{1
|
---|
[4950] | 74 | list=dir;%use dir, as it seems to act OS independent
|
---|
| 75 | list_ids=[];
|
---|
| 76 | for 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
|
---|
| 82 | end
|
---|
[4999] | 83 | [i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
|
---|
| 84 | list_ids=list_ids(i1:i2);
|
---|
| 85 |
|
---|
[4950] | 86 | test_ids=getfieldvalue(options,'id',list_ids);
|
---|
| 87 | test_ids=intersect(test_ids,list_ids);
|
---|
[5050] | 88 | % }}}
|
---|
[5085] | 89 | %GET exculde {{{1
|
---|
| 90 | exclude_ids=getfieldvalue(options,'exclude',[]);
|
---|
[7071] | 91 | exclude_ids=[exclude_ids];
|
---|
[5085] | 92 | pos=find(ismember(test_ids,exclude_ids));
|
---|
| 93 | test_ids(pos)=[];
|
---|
| 94 | % }}}
|
---|
[5050] | 95 | %Process Ids according to benchmarks{{{1
|
---|
| 96 | if strcmpi(benchmark,'nightly'),
|
---|
| 97 | test_ids=intersect(test_ids,[1:999]);
|
---|
[5272] | 98 | elseif strcmpi(benchmark,'ismip'),
|
---|
[5271] | 99 | test_ids=intersect(test_ids,[1101:1199]);
|
---|
[5272] | 100 | elseif strcmpi(benchmark,'eismint'),
|
---|
[5271] | 101 | test_ids=intersect(test_ids,[1201:1299]);
|
---|
[5272] | 102 | elseif strcmpi(benchmark,'thermal'),
|
---|
[5271] | 103 | test_ids=intersect(test_ids,[1301:1399]);
|
---|
[5272] | 104 | elseif strcmpi(benchmark,'mesh'),
|
---|
[5271] | 105 | test_ids=intersect(test_ids,[1401:1499]);
|
---|
[5362] | 106 | elseif strcmpi(benchmark,'validation'),
|
---|
| 107 | test_ids=intersect(test_ids,[1001:1999]);
|
---|
[8854] | 108 | elseif strcmpi(benchmark,'tranforcing'),
|
---|
| 109 | test_ids=intersect(test_ids,[1501:1502]);
|
---|
[5050] | 110 | end
|
---|
| 111 | % }}}
|
---|
[4950] | 112 |
|
---|
| 113 | %Loop over tests and launch sequence
|
---|
[5501] | 114 | root=pwd;
|
---|
[4950] | 115 | for 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
|
---|
| 211 | end
|
---|
| 212 |
|
---|
| 213 | %output md if requested
|
---|
| 214 | if nargout==1
|
---|
| 215 | varargout{1}=md;
|
---|
| 216 | end
|
---|