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