1 | function ismodelselfconsistent(md),
|
---|
2 | %ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % ismodelselfconsistent(md),
|
---|
6 |
|
---|
7 | %tolerance we use in litmus checks for the consistency of the model
|
---|
8 | tolerance=10^-12;
|
---|
9 | %check usage {{{1
|
---|
10 | if nargin~=1,
|
---|
11 | help ismodelselfconsistent
|
---|
12 | error('ismodelselfconsistent error message: wrong usage');
|
---|
13 | end
|
---|
14 | %}}}
|
---|
15 |
|
---|
16 | %recursive call for TRANSIENT {{{1
|
---|
17 | if (md.analysis_type==Transient2DSolutionEnum | md.analysis_type==Transient3DSolutionEnum),
|
---|
18 | if md.dt<=0,
|
---|
19 | error('model not consistent: field dt must be positive for a transient run')
|
---|
20 | end
|
---|
21 |
|
---|
22 | %recursive call to ismodelselfconsistent
|
---|
23 | if (md.dim==2),
|
---|
24 | analysis=[DiagnosticSolutionEnum PrognosticSolutionEnum];
|
---|
25 | else
|
---|
26 | analysis=[DiagnosticSolutionEnum PrognosticSolutionEnum ThermalSolutionEnum];
|
---|
27 | end
|
---|
28 |
|
---|
29 | for i=1:length(analysis),
|
---|
30 | md.analysis_type=analysis(i);
|
---|
31 | ismodelselfconsistent(md);
|
---|
32 | end
|
---|
33 | end
|
---|
34 | %}}}
|
---|
35 |
|
---|
36 | % Common checks
|
---|
37 | %COUNTER {{{1
|
---|
38 | if md.counter<3,
|
---|
39 | error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
|
---|
40 | end
|
---|
41 | %}}}
|
---|
42 | %NAME{{{1
|
---|
43 | if isempty(md.name),
|
---|
44 | error(['model is not correctly configured: missing name!']);
|
---|
45 | end
|
---|
46 | %}}}
|
---|
47 | %ELEMENTS{{{1
|
---|
48 | fields={'elements'};
|
---|
49 | if (md.dim==2),
|
---|
50 | checksize(md,fields,[md.numberofelements 3]);
|
---|
51 | else
|
---|
52 | checksize(md,fields,[md.numberofelements 6]);
|
---|
53 | end
|
---|
54 | %}}}
|
---|
55 | %ELEMENTSTYPE{{{1
|
---|
56 | if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2,
|
---|
57 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
58 | end
|
---|
59 | if any(ones(md.numberofelements,1)-((md.elements_type(:,1)==HutterFormulationEnum) + (md.elements_type(:,1)==MacAyealFormulationEnum) + (md.elements_type(:,1)==PattynFormulationEnum)))
|
---|
60 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
61 | end
|
---|
62 | if any(ones(md.numberofelements,1)-((md.elements_type(:,2)==StokesFormulationEnum) + (md.elements_type(:,2)==NoneFormulationEnum)))
|
---|
63 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
64 | end
|
---|
65 | if (md.dim==2),
|
---|
66 | if (ismember(PattynFormulationEnum,md.elements_type(:,1)) | ismember(StokesFormulationEnum,md.elements_type(:,2))),
|
---|
67 | error(['model not consistent: for a 2d model, only MacAyeal''s and Hutter''s elements are allowed']);
|
---|
68 | end
|
---|
69 | end
|
---|
70 | if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
|
---|
71 | error(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
|
---|
72 | end
|
---|
73 | if (md.analysis_type==DiagnosticSolutionEnum & any(ismember(MacAyealFormulationEnum,md.elements_type(:,1)) & ismember(PattynFormulationEnum,md.elements_type(:,1))))
|
---|
74 | error(['model not consistent: coupling MacAyeal/Pattyn not implemented yet']);
|
---|
75 | end
|
---|
76 | if (md.isstokes & md.analysis_type==Transient3DSolutionEnum());
|
---|
77 | error(['model not consistent: Stokes transient not implemented yet']);
|
---|
78 | end
|
---|
79 | %}}}
|
---|
80 | %DG {{{1
|
---|
81 | if md.prognostic_DG==1;
|
---|
82 | %CHECK THE COMPATIBILITY OF THE EDGES
|
---|
83 | fields={'edges'};
|
---|
84 | checksize(md,fields,[NaN 4]);
|
---|
85 | checknan(md,fields);
|
---|
86 | end
|
---|
87 | %}}}
|
---|
88 | %PRESSURELOAD{{{1
|
---|
89 | if (md.dim==2),
|
---|
90 | fields={'pressureload'};
|
---|
91 | checksize(md,fields,[NaN 4]);
|
---|
92 | elseif md.dim==3,
|
---|
93 | fields={'pressureload'};
|
---|
94 | checksize(md,fields,[NaN 6]);
|
---|
95 | else
|
---|
96 | error('dim should be either 2 3');
|
---|
97 | end
|
---|
98 | checkvalues(md,{'pressureload(:,end)'},[WaterEnum() AirEnum()]);
|
---|
99 | %}}}
|
---|
100 | %NO NAN {{{1
|
---|
101 | fields={'numberofelements','numberofgrids','x','y','z','drag_coefficient','drag_type','drag_p','drag_q',...
|
---|
102 | 'rho_ice','rho_water','rheology_B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
|
---|
103 | 'tolx','np','eps_res','max_nonlinear_iterations','exclusive','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
104 | checknan(md,fields);
|
---|
105 | %}}}}
|
---|
106 | %FIELDS >= 0 {{{1
|
---|
107 | fields={'numberofelements','numberofgrids','elements','drag_coefficient','drag_type','drag_p','drag_q',...
|
---|
108 | 'rho_ice','rho_water','rheology_B','elementoniceshelf','thickness','g','eps_res','max_nonlinear_iterations','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
|
---|
109 | 'sparsity','lowmem','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
110 | checkgreater(md,fields,0);
|
---|
111 | %}}}
|
---|
112 | %FIELDS > 0 {{{1
|
---|
113 | fields={'numberofelements','numberofgrids','elements','drag_type','drag_p',...
|
---|
114 | 'rho_ice','rho_water','rheology_B','thickness','g','max_nonlinear_iterations','eps_res','eps_rel','eps_abs','maxiter','tolx',...
|
---|
115 | 'sparsity','deltaH','DeltaH','timeacc','timedec'};
|
---|
116 | checkgreaterstrict(md,fields,0);
|
---|
117 | %}}}
|
---|
118 | %SIZE NUMBEROFELEMENTS {{{1
|
---|
119 | fields={'drag_p','drag_q','elementoniceshelf','rheology_n','elementonbed'};
|
---|
120 | checksize(md,fields,[md.numberofelements 1]);
|
---|
121 | %}}}
|
---|
122 | %SIZE NUMBEROFGRIDS {{{1
|
---|
123 | fields={'x','y','z','rheology_B','drag_coefficient','melting_rate','accumulation_rate','surface','thickness','bed','gridonbed','gridonsurface'};
|
---|
124 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
125 | %}}}
|
---|
126 | %OTHER SIZES {{{1
|
---|
127 | fields={'spcvelocity'};
|
---|
128 | checksize(md,fields,[md.numberofgrids 6]);
|
---|
129 | %}}}
|
---|
130 | %THICKNESS = SURFACE - BED {{{1
|
---|
131 | if any((md.thickness-md.surface+md.bed)>tolerance),
|
---|
132 | error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
|
---|
133 | end
|
---|
134 | %}}}
|
---|
135 | %RIFTS{{{1
|
---|
136 | if md.numrifts,
|
---|
137 | if ~(md.dim==2),
|
---|
138 | error(['model not consistent: models with rifts are only supported in 2d for now!']);
|
---|
139 | end
|
---|
140 | if ~isstruct(md.rifts),
|
---|
141 | error(['model not consistent: md.rifts should be a structure!']);
|
---|
142 | end
|
---|
143 | if ~isempty(find(md.segmentmarkers>=2)),
|
---|
144 | %We have segments with rift markers, but no rift structure!
|
---|
145 | error(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
|
---|
146 | end
|
---|
147 | %Check that rifts are filled with proper material
|
---|
148 | checkvalues(md,{'rifts.fill'},[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
|
---|
149 | else
|
---|
150 | if ~isnans(md.rifts),
|
---|
151 | error(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
|
---|
152 | end
|
---|
153 | end
|
---|
154 | %}}}
|
---|
155 | %FLAGS (0 or 1){{{1
|
---|
156 | if ~ismember(md.artificial_diffusivity,[0 1]),
|
---|
157 | error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)');
|
---|
158 | end
|
---|
159 | if ~ismember(md.prognostic_DG,[0 1]),
|
---|
160 | error('model not consistent: prognostic_DG should be a scalar (1 or 0)');
|
---|
161 | end
|
---|
162 | if ~ismember(md.lowmem,[0 1]),
|
---|
163 | error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
|
---|
164 | end
|
---|
165 | %}}}
|
---|
166 | %PARAMETEROUTPUT {{{1
|
---|
167 | if md.numoutput~=length(md.parameteroutput),
|
---|
168 | error('model not consistent: numoutput should be the same size as parameteroutput');
|
---|
169 | end
|
---|
170 | %}}}
|
---|
171 | %CONNECTIVITY {{{1
|
---|
172 | if (md.dim==2),
|
---|
173 | if md.connectivity<9,
|
---|
174 | error('model not consistent: connectivity should be at least 9 for 2d models');
|
---|
175 | end
|
---|
176 | end
|
---|
177 | if md.dim==3,
|
---|
178 | if md.connectivity<24,
|
---|
179 | error('model not consistent: connectivity should be at least 24 for 3d models');
|
---|
180 | end
|
---|
181 | end
|
---|
182 | %}}}
|
---|
183 | %PARALLEL{{{1
|
---|
184 | if ~strcmpi(md.cluster,'none'),
|
---|
185 |
|
---|
186 | %NAN VALUES
|
---|
187 | fields={'time','np'};
|
---|
188 | checknan(md,fields);
|
---|
189 |
|
---|
190 | %FIELD > 0
|
---|
191 | fields={'time','np'};
|
---|
192 | checkgreaterstrict(md,fields,0);
|
---|
193 |
|
---|
194 | end
|
---|
195 | %}}}
|
---|
196 |
|
---|
197 | % Solution checks
|
---|
198 | %DIAGNOSTIC{{{1
|
---|
199 | if md.analysis_type==DiagnosticSolutionEnum,
|
---|
200 |
|
---|
201 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
202 | if isempty(find(~md.spcvelocity(:,1:2))),
|
---|
203 | error(['model not consistent: model ' md.name ' is totally constrained horizontally, no need to solve!']);
|
---|
204 | end
|
---|
205 | if (md.dim==3),
|
---|
206 | if isempty(find(~md.spcvelocity(:,3))),
|
---|
207 | error(['model not consistent: model ' md.name ' is totally constrained vertically, no need to solve!']);
|
---|
208 | end
|
---|
209 | end
|
---|
210 |
|
---|
211 | %HUTTER ON ICESHELF WARNING
|
---|
212 | if any(md.elements_type(:,1)==HutterFormulationEnum & md.elementoniceshelf),
|
---|
213 | disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
|
---|
214 | end
|
---|
215 |
|
---|
216 | %SINGULAR
|
---|
217 | if ~any(sum(md.spcvelocity(:,1:2),2)==2),
|
---|
218 | error(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
|
---|
219 | end
|
---|
220 |
|
---|
221 | %DIRICHLET IF THICKNESS <= 0
|
---|
222 | if any(md.thickness<=0),
|
---|
223 | pos=find(md.thickness<=0);
|
---|
224 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
225 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
226 | end
|
---|
227 | end
|
---|
228 |
|
---|
229 | %INITIAL VELOCITY
|
---|
230 | if length(md.vx)==md.numberofgrids & length(md.vy)==md.numberofgrids,
|
---|
231 | fields={'vx','vy'};
|
---|
232 | checknan(md,fields);
|
---|
233 | end
|
---|
234 | end
|
---|
235 | %}}}
|
---|
236 | %PROGNOSTIC{{{1
|
---|
237 | if md.analysis_type==PrognosticSolutionEnum,
|
---|
238 |
|
---|
239 | %INITIAL VELOCITIES
|
---|
240 | fields={'vx','vy'};
|
---|
241 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
242 | checknan(md,fields);
|
---|
243 |
|
---|
244 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
245 | if (md.dim==2),
|
---|
246 | if isempty(find(~md.spcthickness(:,1))),
|
---|
247 | error(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
|
---|
248 | end
|
---|
249 | end
|
---|
250 |
|
---|
251 | end
|
---|
252 | %}}}
|
---|
253 | %STEADYSTATE{{{1
|
---|
254 | if md.analysis_type==SteadystateSolutionEnum,
|
---|
255 |
|
---|
256 | %NDT
|
---|
257 | if md.dt~=0,
|
---|
258 | error(['model not consistent: for a steadystate computation, dt must be zero.']);
|
---|
259 | end
|
---|
260 |
|
---|
261 | %PRESSURE
|
---|
262 | if isnans(md.pressure),
|
---|
263 | error(['model not consistent: for a steadystate computation, the model must have an initial pressure, even lithostatic will do.']);
|
---|
264 | end
|
---|
265 |
|
---|
266 | %eps:
|
---|
267 | if isnan(md.eps_rel),
|
---|
268 | error(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
|
---|
269 | end
|
---|
270 |
|
---|
271 | %dim:
|
---|
272 | if (md.dim==2),
|
---|
273 | error(['model not consistent: for a steadystate computation, model needs to be 3d']);
|
---|
274 | end
|
---|
275 | end
|
---|
276 | %}}}
|
---|
277 | %THERMAL {{{1
|
---|
278 | %THERMAL STEADY AND THERMAL TRANSIENT
|
---|
279 | if md.analysis_type==ThermalSolutionEnum,
|
---|
280 |
|
---|
281 | %EXTRUSION
|
---|
282 | if (md.dim==2),
|
---|
283 | error(['model not consistent: for a ' md.analysis_type ' computation, the model must be 3d, extrude it first!'])
|
---|
284 | end
|
---|
285 |
|
---|
286 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
287 | if isempty(find(~md.spctemperature(:,1))),
|
---|
288 | error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
|
---|
289 | end
|
---|
290 |
|
---|
291 | %VELOCITIES AND PRESSURE
|
---|
292 | fields={'vx','vy','vz','pressure'};
|
---|
293 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
294 | checknan(md,fields);
|
---|
295 |
|
---|
296 | end
|
---|
297 |
|
---|
298 | %THERMAL TRANSIENT
|
---|
299 | if md.analysis_type==ThermalSolutionEnum & md.dt~=0,
|
---|
300 |
|
---|
301 | %DT and NDT
|
---|
302 | fields={'dt','ndt'};
|
---|
303 | checkgreaterstrict(md,fields,0);
|
---|
304 |
|
---|
305 | %INITIAL TEMPERATURE, MELTING AND ACCUMULATION
|
---|
306 | fields={'temperature','accumulation_rate','melting_rate'};
|
---|
307 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
308 | checknan(md,fields);
|
---|
309 |
|
---|
310 | %INITIAL TEMPERATURE
|
---|
311 | fields={'temperature','spctemperature(:,2)','observed_temperature'};
|
---|
312 | checkgreater(md,fields,0)
|
---|
313 |
|
---|
314 | end
|
---|
315 | %}}}
|
---|
316 | %BALANCEDTHICKNESS{{{1
|
---|
317 | if md.analysis_type==BalancedthicknessSolutionEnum
|
---|
318 |
|
---|
319 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
320 | fields={'vx','vy','accumulation_rate','melting_rate','dhdt'};
|
---|
321 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
322 | checknan(md,fields);
|
---|
323 |
|
---|
324 | %SPC
|
---|
325 | if any(md.spcthickness(find(md.gridonboundary))~=1),
|
---|
326 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);
|
---|
327 | end
|
---|
328 | end
|
---|
329 | %}}}
|
---|
330 | %BALANCEDVELOCITIES{{{1
|
---|
331 | if md.analysis_type==BalancedvelocitiesSolutionEnum
|
---|
332 |
|
---|
333 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
334 | fields={'vx','vy','accumulation_rate','melting_rate'};
|
---|
335 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
336 | checknan(md,fields);
|
---|
337 |
|
---|
338 | %SPC
|
---|
339 | if any(md.spcvelocity(find(md.gridonboundary),[1:2])~=1),
|
---|
340 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
|
---|
341 | end
|
---|
342 | end
|
---|
343 | %}}}
|
---|
344 | %CONTROL{{{1
|
---|
345 | if md.control_analysis,
|
---|
346 |
|
---|
347 | %CONTROL TYPE
|
---|
348 | if ~ischar(md.control_type),
|
---|
349 | error('model not consistent: control_type should be a string');
|
---|
350 | end
|
---|
351 | if ~(strcmpi(md.control_type,'rheology_B') | strcmpi(md.control_type,'drag_coefficient')),
|
---|
352 | error('model not consistent: control_type should be rheology_B or drag_coefficient');
|
---|
353 | end
|
---|
354 |
|
---|
355 | %LENGTH CONTROL FIELDS
|
---|
356 | fields={'maxiter','optscal','fit','cm_jump'};
|
---|
357 | checksize(md,fields,[md.nsteps 1]);
|
---|
358 |
|
---|
359 | %FIT
|
---|
360 | checkvalues(md,{'fit'},[0 1 2 3 4]);
|
---|
361 |
|
---|
362 | %WEIGHTS
|
---|
363 | fields={'weights'};
|
---|
364 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
365 | checkgreater(md,fields,0);
|
---|
366 |
|
---|
367 | %OBSERVED VELOCITIES
|
---|
368 | fields={'vx_obs','vy_obs'};
|
---|
369 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
370 | checknan(md,fields);
|
---|
371 |
|
---|
372 | %DIRICHLET IF THICKNESS <= 0
|
---|
373 | if any(md.thickness<=0),
|
---|
374 | pos=find(md.thickness<=0);
|
---|
375 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
376 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
377 | end
|
---|
378 | end
|
---|
379 |
|
---|
380 | %parameters
|
---|
381 | fields={'cm_noisedmp'};
|
---|
382 | checknan(md,fields);
|
---|
383 | end
|
---|
384 | %}}}
|
---|
385 | %QMU {{{1
|
---|
386 | if md.qmu_analysis,
|
---|
387 | if md.qmu_params.evaluation_concurrency~=1,
|
---|
388 | error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
|
---|
389 | end
|
---|
390 | if ~isempty(md.part),
|
---|
391 | if numel(md.part)~=md.numberofgrids,
|
---|
392 | error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']);
|
---|
393 | end
|
---|
394 | if find(md.part)>=md.numberofgrids,
|
---|
395 | error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
|
---|
396 | end
|
---|
397 | if min(md.part)~=0,
|
---|
398 | error(['model not consistent: partition vector not indexed from 0 on']);
|
---|
399 | end
|
---|
400 | if max(md.part)>=md.numberofgrids,
|
---|
401 | error(['model not consistent: partition vector cannot have maximum index larger than number of grids']);
|
---|
402 | end
|
---|
403 | if ~isempty(find(md.part<0)),
|
---|
404 | error(['model not consistent: partition vector cannot have values less than 0']);
|
---|
405 | end
|
---|
406 | if ~isempty(find(md.part>=md.npart)),
|
---|
407 | error(['model not consistent: partition vector cannot have values more than md.npart-1']);
|
---|
408 | end
|
---|
409 | if max(md.part)>=md.npart,
|
---|
410 | error(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
|
---|
411 | end
|
---|
412 | end
|
---|
413 | if md.eps_rel>1.1*10^-5,
|
---|
414 | error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
|
---|
415 | end
|
---|
416 | end
|
---|
417 |
|
---|
418 | if strcmpi(md.analysis_type,'qmu'),
|
---|
419 | if ~strcmpi(md.cluster,'none'),
|
---|
420 | if md.waitonlock==0,
|
---|
421 | error(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
|
---|
422 | end
|
---|
423 | end
|
---|
424 | end
|
---|
425 | %}}}
|
---|
426 |
|
---|
427 | end
|
---|
428 |
|
---|
429 | %checks additional functions
|
---|
430 | %checklength {{{1
|
---|
431 | function checklength(md,fields,fieldlength)
|
---|
432 | %CHECKSIZE - check length of a field
|
---|
433 | for i=1:length(fields),
|
---|
434 | if length(eval(['md.' fields{i}]))~=fieldlength,
|
---|
435 | error(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
|
---|
436 | end
|
---|
437 | end
|
---|
438 | end
|
---|
439 | %}}}
|
---|
440 | %checksize {{{1
|
---|
441 | function checksize(md,fields,fieldsize)
|
---|
442 | %CHECKSIZE - check size of a field
|
---|
443 | for i=1:length(fields),
|
---|
444 | if isnan(fieldsize(1)),
|
---|
445 | if (size(eval(['md.' fields{i}]),2)~=fieldsize(2)),
|
---|
446 | %LOG warnings:
|
---|
447 | if strcmpi(fields{i},'pressureload'),
|
---|
448 | disp(' ');
|
---|
449 | disp(' If pressureload does not have the right size (one column missing), this is due to a change in md.pressure.');
|
---|
450 | disp(' To update your model, use the following line');
|
---|
451 | disp(' md.pressureload=[md.pressureload WaterEnum*md.elementoniceshelf(md.pressureload(:,end))+AirEnum*md.elementonicesheet(md.pressureload(:,end))];');
|
---|
452 | disp(' ');
|
---|
453 | end
|
---|
454 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
|
---|
455 | end
|
---|
456 | elseif isnan(fieldsize(2)),
|
---|
457 | if (size(eval(['md.' fields{i}]),1)~=fieldsize(1)),
|
---|
458 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
|
---|
459 | end
|
---|
460 | else
|
---|
461 | if ((size(eval(['md.' fields{i}]),1)~=fieldsize(1)) | (size(eval(['md.' fields{i}]),2)~=fieldsize(2)))
|
---|
462 | %LOG warnings:
|
---|
463 | if strcmpi(fields{i},'weights'),
|
---|
464 | disp(' ');
|
---|
465 | disp(' ''weights'' is a new field that should be of length numberofgrids.');
|
---|
466 | disp(' To update your model, use the following line');
|
---|
467 | disp(' md.weights=ones(md.numberofgrids,1)');
|
---|
468 | disp(' ');
|
---|
469 | end
|
---|
470 | error(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
|
---|
471 | end
|
---|
472 | end
|
---|
473 | end
|
---|
474 | end
|
---|
475 | %}}}
|
---|
476 | %checknan {{{1
|
---|
477 | function checknan(md,fields)
|
---|
478 | %CHECKNAN - check nan values of a field
|
---|
479 | for i=1:length(fields),
|
---|
480 | if any(isnan(eval(['md.' fields{i}]))),
|
---|
481 | error(['model not consistent: NaN values in field ' fields{i}]);
|
---|
482 | end
|
---|
483 | end
|
---|
484 | end
|
---|
485 | %}}}
|
---|
486 | %checkreal{{{1
|
---|
487 | function checkreal(md,fields)
|
---|
488 | %CHECKREAL - check real values of a field
|
---|
489 | for i=1:length(fields),
|
---|
490 | if any(eval(['~isreal(md.' fields{i} ')'])),
|
---|
491 | error(['model not consistent: complex values in field ' fields{i}]);
|
---|
492 | end
|
---|
493 | end
|
---|
494 | end
|
---|
495 | %}}}
|
---|
496 | %checkgreaterstrict{{{1
|
---|
497 | function checkgreaterstrict(md,fields,lowerbound)
|
---|
498 | %CHECKGREATERSTRICT - check values of a field
|
---|
499 | for i=1:length(fields),
|
---|
500 | if any(eval(['md.' fields{i} '<=' num2str(lowerbound) ])),
|
---|
501 | error(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
|
---|
502 | end
|
---|
503 | end
|
---|
504 | end
|
---|
505 | %}}}
|
---|
506 | %checkgreater{{{1
|
---|
507 | function checkgreater(md,fields,lowerbound)
|
---|
508 | %CHECKGREATER - check values of a field
|
---|
509 | for i=1:length(fields),
|
---|
510 | if any(eval(['md.' fields{i} '<' num2str(lowerbound) ])),
|
---|
511 | error(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
|
---|
512 | end
|
---|
513 | end
|
---|
514 | end
|
---|
515 | %}}}
|
---|
516 | %checklessstrict{{{1
|
---|
517 | function checklessstrict(md,fields,upperbound)
|
---|
518 | %CHECKLESSSTRICT - check values of a field
|
---|
519 | for i=1:length(fields),
|
---|
520 | if any(eval(['md.' fields{i} '>=' num2str(upperbound) ])),
|
---|
521 | error(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
|
---|
522 | end
|
---|
523 | end
|
---|
524 | end
|
---|
525 | %}}}
|
---|
526 | %checkless{{{1
|
---|
527 | function checkless(md,fields,upperbound)
|
---|
528 | %CHECKLESS - check values of a field
|
---|
529 | for i=1:length(fields),
|
---|
530 | if any(eval(['md.' fields{i} '>' num2str(upperbound) ])),
|
---|
531 | error(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
|
---|
532 | end
|
---|
533 | end
|
---|
534 | end
|
---|
535 | %}}}
|
---|
536 | %checkvalues {{{1
|
---|
537 | function checkvalues(md,fields,values)
|
---|
538 | %CHECKVALUE - check that a field has specified values
|
---|
539 | for i=1:length(fields),
|
---|
540 | if eval(['any(~ismember( md.' fields{i} ',values))']),
|
---|
541 | error(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
|
---|
542 | end
|
---|
543 | end
|
---|
544 | end
|
---|
545 | %}}}
|
---|