1 | function 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 | % ...
|
---|
16 | % 'procedure' 'check' : run the test (default)
|
---|
17 | % 'update': update the archive
|
---|
18 | % 'model' : prepare the model but no test is run
|
---|
19 | %
|
---|
20 | % Usage:
|
---|
21 | % md=runme(varargin);
|
---|
22 | %
|
---|
23 | % Examples:
|
---|
24 | % runme;
|
---|
25 | % runme('exclude',101);
|
---|
26 | % md=runme('id',102,'procedure','model');
|
---|
27 |
|
---|
28 | %use ISSM_DIR generated by startup.m
|
---|
29 | global ISSM_DIR
|
---|
30 |
|
---|
31 | %Check inputs
|
---|
32 | % {{{1
|
---|
33 | if nargout>1
|
---|
34 | help runme
|
---|
35 | error('runme error message: bad usage');
|
---|
36 | end
|
---|
37 |
|
---|
38 | %recover options
|
---|
39 | options=pairoptions(varargin{:});
|
---|
40 | % }}}
|
---|
41 |
|
---|
42 | %Process options
|
---|
43 | %GET benchmark {{{1
|
---|
44 | benchmark=getfieldvalue(options,'benchmark','nightly');
|
---|
45 | if ~ismember(benchmark,{'all','nightly'})
|
---|
46 | disp('runme warnig: benchmark not supported, defaulting to test ''nightly''')
|
---|
47 | benchmark='nighlty';
|
---|
48 | end
|
---|
49 | % }}}
|
---|
50 | %GET procedure {{{1
|
---|
51 | procedure=getfieldvalue(options,'procedure','check');
|
---|
52 | if ~ismember(procedure,{'check','update'})
|
---|
53 | disp('runme warning: procedure not supported, defaulting to test ''check''')
|
---|
54 | procedure='check';
|
---|
55 | end
|
---|
56 | % }}}
|
---|
57 | %GET output {{{1
|
---|
58 | output=getfieldvalue(options,'output','none');
|
---|
59 | if ~ismember(output,{'nightly','daily','none'})
|
---|
60 | disp('runme warning: output not supported, defaulting to test ''none''')
|
---|
61 | output='none';
|
---|
62 | end
|
---|
63 | % }}}
|
---|
64 | %GET RANK and NUMPROCS for mutlithreaded runs {{{1
|
---|
65 | rank=getfieldvalue(options,'rank',1);
|
---|
66 | numprocs=getfieldvalue(options,'numprocs',1);
|
---|
67 | if (numprocs<rank), numprocs=1; end
|
---|
68 | % }}}
|
---|
69 | %GET ids {{{1
|
---|
70 | list=dir;%use dir, as it seems to act OS independent
|
---|
71 | list_ids=[];
|
---|
72 | for i=1:numel(list),
|
---|
73 | if ( strncmpi(list(i).name,'test',4) &... %File name must start with 'test'
|
---|
74 | strncmpi(fliplr(list(i).name),fliplr('.m'),2)&... %File name must end by '.m'
|
---|
75 | ~strncmpi(fliplr(list(i).name),fliplr('_nightly.m'),10)), %File name end should be different that '_nightly.m'
|
---|
76 | list_ids(end+1)=eval(list(i).name(5:end-2)); %Keep test id only (skip 'test' and '.m')
|
---|
77 | end
|
---|
78 | end
|
---|
79 | [i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
|
---|
80 | list_ids=list_ids(i1:i2);
|
---|
81 |
|
---|
82 | test_ids=getfieldvalue(options,'id',list_ids);
|
---|
83 | test_ids=intersect(test_ids,list_ids);
|
---|
84 | % }}}
|
---|
85 | %GET exculde {{{1
|
---|
86 | exclude_ids=getfieldvalue(options,'exclude',[]);
|
---|
87 | pos=find(ismember(test_ids,exclude_ids));
|
---|
88 | test_ids(pos)=[];
|
---|
89 | % }}}
|
---|
90 | %Process Ids according to benchmarks{{{1
|
---|
91 | if strcmpi(benchmark,'nightly'),
|
---|
92 | test_ids=intersect(test_ids,[1:999]);
|
---|
93 | end
|
---|
94 | % }}}
|
---|
95 |
|
---|
96 | %Loop over tests and launch sequence
|
---|
97 | for id=test_ids,
|
---|
98 | try,
|
---|
99 |
|
---|
100 | %Execute test
|
---|
101 | eval(['test' num2str(id)]);
|
---|
102 |
|
---|
103 | %UPDATE ARCHIVE?
|
---|
104 | archive_name=['Archive' num2str(id) ];
|
---|
105 | if strcmpi(procedure,'update'),
|
---|
106 |
|
---|
107 | for k=1:length(field_names),
|
---|
108 | field=field_values{k};
|
---|
109 | eval([ archive_name '_field' num2str(k) ' = field ;']);
|
---|
110 | end
|
---|
111 | eval(['save ./../Archives/' archive_name ' ' archive_name '_field*']);
|
---|
112 | disp(sprintf(['File ./../Archives/' archive_name ' saved\n']));
|
---|
113 |
|
---|
114 | %ELSE: CHECK TEST
|
---|
115 | else,
|
---|
116 |
|
---|
117 | %load archive
|
---|
118 | load(['./../Archives/' archive_name ]);
|
---|
119 |
|
---|
120 | for k=1:length(field_names),
|
---|
121 |
|
---|
122 | try,
|
---|
123 | %Get field and tolerance
|
---|
124 | field=field_values{k};
|
---|
125 | fieldname=field_names{k};
|
---|
126 | tolerance=field_tolerances{k};
|
---|
127 |
|
---|
128 | %compare to archive
|
---|
129 | eval(['archive=' archive_name '_field' num2str(k) ';']);
|
---|
130 | error_diff=full(max(abs(archive-field))/(max(abs(archive))+eps));
|
---|
131 |
|
---|
132 | %disp test result
|
---|
133 | if (error_diff>tolerance);
|
---|
134 | disp(sprintf(['ERROR difference: %-7.2g > %7.2g test id: %i test name: %s field: %s'],...
|
---|
135 | error_diff,tolerance,id,Id2Name(id),fieldname));
|
---|
136 | else
|
---|
137 | disp(sprintf(['SUCCESS difference: %-7.2g < %7.2g test id: %i test name: %s field: %s'],...
|
---|
138 | error_diff,tolerance,id,Id2Name(id),fieldname));
|
---|
139 | end
|
---|
140 |
|
---|
141 | catch me2
|
---|
142 |
|
---|
143 | %something went wrong, print failure message:
|
---|
144 | directory=strsplit(pwd,'/');
|
---|
145 | message=getReport(me2)
|
---|
146 | if strcmpi(output,'nightly')
|
---|
147 | fid=fopen([ISSM_DIR '/nightlylog/matlaberror.log'], 'at');
|
---|
148 | fprintf(fid,'%s',message);
|
---|
149 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
150 | fclose(fid);
|
---|
151 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,Id2Name(id),'N/A'));
|
---|
152 | elseif strcmpi(output,'daily');
|
---|
153 | fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
|
---|
154 | fprintf(fid,'%s',message);
|
---|
155 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
156 | fclose(fid);
|
---|
157 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,Id2Name(id),'N/A'));
|
---|
158 | end
|
---|
159 | end
|
---|
160 | end
|
---|
161 | end
|
---|
162 |
|
---|
163 | catch me,
|
---|
164 |
|
---|
165 | %something went wrong, print failure message:
|
---|
166 | directory=strsplit(pwd,'/');
|
---|
167 | message=getReport(me)
|
---|
168 | if strcmpi(output,'nightly')
|
---|
169 | fid=fopen([ISSM_DIR '/nightlylog/matlaberror.log'], 'at');
|
---|
170 | fprintf(fid,'%s',message);
|
---|
171 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
172 | fclose(fid);
|
---|
173 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,Id2Name(id),fieldname));
|
---|
174 | elseif strcmpi(output,'daily');
|
---|
175 | fid=fopen([ISSM_DIR '/dailylog/matlaberror.log'], 'at');
|
---|
176 | fprintf(fid,'%s',message);
|
---|
177 | fprintf(fid,'\n------------------------------------------------------------------\n');
|
---|
178 | fclose(fid);
|
---|
179 | disp(sprintf(['FAILURE difference: N/A test id: %i test name: %s field: %s'],id,Id2Name(id),fieldname));
|
---|
180 | end
|
---|
181 | end
|
---|
182 | end
|
---|
183 |
|
---|
184 | %output md if requested
|
---|
185 | if nargout==1
|
---|
186 | varargout{1}=md;
|
---|
187 | end
|
---|