Changeset 8585


Ignore:
Timestamp:
06/09/11 09:34:51 (14 years ago)
Author:
Mathieu Morlighem
Message:

improved ismodelselfconsistent: print all error messages and then error out

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/model/ismodelselfconsistent.m

    r8486 r8585  
    1010if nargin~=1,
    1111        help ismodelselfconsistent
    12         error('ismodelselfconsistent error message: wrong usage');
     12        message('ismodelselfconsistent message message: wrong usage');
    1313end
    1414%}}}
     
    2222        disp('         md.verbose=verbose;');
    2323        disp(' ');
    24         error(['field verbose should be of class ''verbose'' ']);
     24        message(['field verbose should be of class ''verbose'' ']);
    2525end
    2626%}}}
    2727%COUNTER {{{1
    2828if md.counter<3,
    29         error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
     29        message(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
    3030end
    3131%}}}
    3232%NAME{{{1
    3333if isempty(md.name),
    34         error(['model is not correctly configured: missing name!']);
     34        message(['model is not correctly configured: missing name!']);
    3535end
    3636%}}}
     
    4343end
    4444if any(~ismember(1:md.numberofnodes,sort(unique(md.elements(:)))));
    45         error('orphan nodes have been found. Check the mesh');
     45        message('orphan nodes have been found. Check the mesh');
    4646end
    4747%}}}
     
    6565        checksize(md,fields,[NaN 6]);
    6666else
    67         error('dim should be either 2 3');
     67        message('dim should be either 2 3');
    6868end
    6969checkvalues(md,{'pressureload(:,end)'},[WaterEnum() AirEnum() IceEnum()]);
     
    101101%THICKNESS = SURFACE - BED {{{1
    102102if any((md.thickness-md.surface+md.bed)>tolerance),
    103         error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
     103        message(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
    104104end
    105105%GROUNDING LINE MIGRATION {{{1
     
    107107if (md.gl_migration~=NoneEnum),
    108108        if (md.dim==3 | strcmpi(md.cluster.name,'none')),
    109                 error(['model ' md.name ' requesting grounding line migration, but grounding line module only implemented for 2d models and parallel runs!']);
     109                message(['model ' md.name ' requesting grounding line migration, but grounding line module only implemented for 2d models and parallel runs!']);
    110110        end
    111111        if isnan(md.bathymetry),
    112                 error(['model not consistent: model ' md.name ' requesting grounding line migration, but bathymetry is absent!']);
     112                message(['model not consistent: model ' md.name ' requesting grounding line migration, but bathymetry is absent!']);
    113113        end
    114114end
     
    118118if md.numrifts,
    119119        if ~(md.dim==2),
    120                 error(['model not consistent: models with rifts are only supported in 2d for now!']);
     120                message(['model not consistent: models with rifts are only supported in 2d for now!']);
    121121        end
    122122        if ~isstruct(md.rifts),
    123                 error(['model not consistent: md.rifts should be a structure!']);
     123                message(['model not consistent: md.rifts should be a structure!']);
    124124        end
    125125        if ~isempty(find(md.segmentmarkers>=2)),
    126126                %We have segments with rift markers, but no rift structure!
    127                 error(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
     127                message(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
    128128        end
    129129        %Check that rifts are filled with proper material
     
    131131else
    132132        if ~isnans(md.rifts),
    133                 error(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
     133                message(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
    134134        end
    135135end
     
    137137%FLAGS (0 or 1){{{1
    138138if ~ismember(md.artificial_diffusivity,[0 1 2]),
    139         error('model not consistent: artificial_diffusivity should be a scalar (0 or 1 or 2)');
     139        message('model not consistent: artificial_diffusivity should be a scalar (0 or 1 or 2)');
    140140end
    141141if ~ismember(md.prognostic_DG,[0 1]),
    142         error('model not consistent: prognostic_DG should be a scalar (1 or 0)');
     142        message('model not consistent: prognostic_DG should be a scalar (1 or 0)');
    143143end
    144144if ~ismember(md.lowmem,[0 1]),
    145         error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
     145        message(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
    146146end
    147147if ~ismember(md.time_adapt,[0 1]),
    148         error(['model not consistent: model ' md.name ' time_adapt field should be 0 or 1']);
     148        message(['model not consistent: model ' md.name ' time_adapt field should be 0 or 1']);
    149149end
    150150if ~ismember(md.hydrostatic_adjustment,[AbsoluteEnum IncrementalEnum]),
    151         error(['model not consistent: model ' md.name ' hydrostatic_adjustment field should be AbsoluteEnum or IncrementalEnum']);
     151        message(['model not consistent: model ' md.name ' hydrostatic_adjustment field should be AbsoluteEnum or IncrementalEnum']);
    152152end
    153153if ~ismember(md.rheology_law,[NoneEnum PatersonEnum ArrheniusEnum]),
    154         error(['model not consistent: model ' md.name ' rheology_law field should be NoneEnum, PatersonEnum or ArrheniusEnum']);
     154        message(['model not consistent: model ' md.name ' rheology_law field should be NoneEnum, PatersonEnum or ArrheniusEnum']);
    155155end
    156156%}}}
    157157%PARAMETEROUTPUT {{{1
    158158if md.numoutput~=length(md.parameteroutput),
    159         error('model not consistent: numoutput should be the same size as parameteroutput');
     159        message('model not consistent: numoutput should be the same size as parameteroutput');
    160160end
    161161%}}}
     
    163163if (md.dim==2),
    164164        if md.connectivity<9,
    165                 error('model not consistent: connectivity should be at least 9 for 2d models');
     165                message('model not consistent: connectivity should be at least 9 for 2d models');
    166166        end
    167167end
    168168if md.dim==3,
    169169        if md.connectivity<24,
    170                 error('model not consistent: connectivity should be at least 24 for 3d models');
     170                message('model not consistent: connectivity should be at least 24 for 3d models');
    171171        end
    172172end
     
    213213                pos=find(md.thickness<=0);
    214214                if any(find(md.spcthickness(pos,1)==0)),
    215                         error(['model not consistent: model ' md.name ' has some nodes with 0 thickness']);
     215                        message(['model not consistent: model ' md.name ' has some nodes with 0 thickness']);
    216216                end
    217217        end
     
    225225if md.qmu_analysis,
    226226        if md.qmu_params.evaluation_concurrency~=1,
    227                 error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
     227                message(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
    228228        end
    229229        if ~isempty(md.part),
    230230                if numel(md.part)~=md.numberofnodes,
    231                         error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofnodes x 1 ']);
     231                        message(['model not consistent: user supplied partition for qmu analysis should have size md.numberofnodes x 1 ']);
    232232                end
    233233                if find(md.part)>=md.numberofnodes,
    234                         error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
     234                        message(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
    235235                end
    236236                if min(md.part)~=0,
    237                         error(['model not consistent: partition vector not indexed from 0 on']);
     237                        message(['model not consistent: partition vector not indexed from 0 on']);
    238238                end
    239239                if max(md.part)>=md.numberofnodes,
    240                         error(['model not consistent: partition vector cannot have maximum index larger than number of nodes']);
     240                        message(['model not consistent: partition vector cannot have maximum index larger than number of nodes']);
    241241                end
    242242                if ~isempty(find(md.part<0)),
    243                         error(['model not consistent: partition vector cannot have values less than 0']);
     243                        message(['model not consistent: partition vector cannot have values less than 0']);
    244244                end
    245245                if ~isempty(find(md.part>=md.npart)),
    246                         error(['model not consistent: partition vector cannot have values more than md.npart-1']);
     246                        message(['model not consistent: partition vector cannot have values more than md.npart-1']);
    247247                end
    248248                if max(md.part)>=md.npart,
    249                         error(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
     249                        message(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
    250250                end
    251251        end
    252252        if ~md.qmu_relax,
    253253                if md.eps_rel>1.1*10^-5,
    254                         error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
     254                        message(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
    255255                end
    256256        end
     
    260260        if ~strcmpi(md.cluster.name,'none'),
    261261                if md.waitonlock==0,
    262                         error(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
     262                        message(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
    263263                end
    264264        end
     
    271271
    272272        if md.dt<=0,
    273                 error('model not consistent: field dt must be positive for a transient run')
     273                message('model not consistent: field dt must be positive for a transient run')
    274274        end
    275275        if(md.cfl_coefficient>1 | md.cfl_coefficient<0),
    276                 error(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
     276                message(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
    277277        end
    278278        if(md.cfl_coefficient>1 | md.cfl_coefficient<0),
    279                 error(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
     279                message(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
    280280        end
    281281        if ~ismember(md.isdiagnostic,[0 1]),
    282                 error('model not consistent: isdiagnostic should be a scalar (1 or 0)');
     282                message('model not consistent: isdiagnostic should be a scalar (1 or 0)');
    283283        end
    284284        if ~ismember(md.isprognostic,[0 1]),
    285                 error('model not consistent: isprognostic should be a scalar (1 or 0)');
     285                message('model not consistent: isprognostic should be a scalar (1 or 0)');
    286286        end
    287287        if ~ismember(md.isthermal,[0 1]),
    288                 error('model not consistent: isthermal should be a scalar (1 or 0)');
     288                message('model not consistent: isthermal should be a scalar (1 or 0)');
    289289        end
    290290
     
    300300        for i=1:length(forcingnames),
    301301                if md.forcings.(forcingnames{i})(end,:)~=sort(md.forcings.(forcingnames{i})(end,:)),
    302                         error(['model not consistent: model ' md.name ' forcings.' forcingnames{i} ' columns should be chronological']);
     302                        message(['model not consistent: model ' md.name ' forcings.' forcingnames{i} ' columns should be chronological']);
    303303                end
    304304        end
     
    311311        %NDT
    312312        if md.dt~=0,
    313                 error(['model not consistent: for a steadystate computation, dt must be zero.']);
     313                message(['model not consistent: for a steadystate computation, dt must be zero.']);
    314314        end
    315315
    316316        %eps:
    317317        if isnan(md.eps_rel),
    318                 error(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
     318                message(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
    319319        end
    320320end
     
    323323if md.solution_type==GroundingLineMigration2DSolutionEnum,
    324324        if strcmpi(md.cluster.name,'none'),
    325                 error(['model not consistent: ' md.solution_type ' is only implemented in parallel mode !'])
     325                message(['model not consistent: ' md.solution_type ' is only implemented in parallel mode !'])
    326326        end
    327327
    328328        if md.dt<=0,
    329                 error('model not consistent: field dt must be positive for a transient run')
    330         end
    331 
    332         %recursive call to ismodelselfconsistent
     329                message('model not consistent: field dt must be positive for a transient run')
     330        end
     331
    333332        if (md.dim~=2),
    334                 error(['model not consistent: for a ' md.solution_type ' computation, the grounding line module is only implemented in 2d !'])
     333                message(['model not consistent: for a ' md.solution_type ' computation, the grounding line module is only implemented in 2d !'])
    335334        end
    336335
    337336        if(md.cfl_coefficient>1 | md.cfl_coefficient<0),
    338                 error(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
     337                message(['model not consistent: model ' md.name ' cfl_coefficient field should between  0 and 1']);
    339338        end
    340339end
     
    343342if (md.solution_type == FlaimSolutionEnum),
    344343        if ~exist(md.fm_tracks,'file')
    345                 error(['model not consistent: fm_tracks file ''' md.fm_tracks ''' must exist.']);
     344                message(['model not consistent: fm_tracks file ''' md.fm_tracks ''' must exist.']);
    346345        end
    347346        %   probably going to need some checks on fm_flightreqs here
    348347        if (numel(md.fm_criterion) ~= md.numberofnodes) && (numel(md.fm_criterion) ~= md.numberofelements)
    349                 error(['model not consistent: fm_criterion vector must have number of nodes (' int2str(md.numberofnodes) ') or elements (' int2str(md.numberofelements) ') values, not ' int2str(numel(md.fm_criterion)) ' values.']);
     348                message(['model not consistent: fm_criterion vector must have number of nodes (' int2str(md.numberofnodes) ') or elements (' int2str(md.numberofelements) ') values, not ' int2str(numel(md.fm_criterion)) ' values.']);
    350349        end
    351350end
     
    359358end
    360359%}}}
     360
     361        if modelconsistency==false, error(['model not consistent']); end
    361362end
    362363
     
    370371                        %SINGULAR
    371372                        if ~any(sum(md.spcvelocity(:,1:2),2)==2),
    372                                 error(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
     373                                message(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
    373374                        end
    374375
     
    377378                                pos=find(md.thickness<=0);
    378379                                if any(find(md.spcthickness(pos,1)==0)),
    379                                         error(['model not consistent: model ' md.name ' has some nodes with 0 thickness']);
     380                                        message(['model not consistent: model ' md.name ' has some nodes with 0 thickness']);
    380381                                end
    381382                        end
     
    384385                        %CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
    385386                        if any(sum(isnan(md.diagnostic_ref),2)~=0 & sum(isnan(md.diagnostic_ref),2)~=6),
    386                                 error(['model not consistent: model ' md.name ' has problem with rotated spc. Each line of diagnostic_ref should contain either only NaN values or no NaN values']);
     387                                message(['model not consistent: model ' md.name ' has problem with rotated spc. Each line of diagnostic_ref should contain either only NaN values or no NaN values']);
    387388                        end
    388389                        %CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
     
    391392                                if any(dot(md.diagnostic_ref(pos,1:3),md.diagnostic_ref(pos,4:6))),
    392393                                        dot(md.diagnostic_ref(pos,1:3),md.diagnostic_ref(pos,4:6))
    393                                         error(['model not consistent: model ' md.name ' has problem with rotated spc. Vectors in diagnostic_ref (colums 1 to 3 and 4 to 6) must be orthogonal']);
     394                                        message(['model not consistent: model ' md.name ' has problem with rotated spc. Vectors in diagnostic_ref (colums 1 to 3 and 4 to 6) must be orthogonal']);
    394395                                end
    395396
     
    399400                                pos=find(sum(isnan(md.diagnostic_ref),2)==0  & md.nodeonmacayeal);
    400401                                if any(md.diagnostic_ref(pos,3:5)~=0);
    401                                         error(['model not consistent: model ' md.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (nodeonmacayeal)']);
     402                                        message(['model not consistent: model ' md.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (nodeonmacayeal)']);
    402403                                end
    403404                        end
     
    421422                        end
    422423                        if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
    423                                 error(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
     424                                message(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
    424425                        end
    425426                       
     
    435436                        end
    436437                        if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
    437                                 error(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
     438                                message(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
    438439                        end
    439440                        %}}}
     
    469470                        if (md.dim==2),
    470471                                if isnan(find(~md.spcthickness(:,1))),
    471                                         error(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
     472                                        message(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
    472473                                end
    473474                        end
     
    487488                                        return;
    488489                                else
    489                                         error(['model not consistent: for a ' EnumToString(md.solution_type) ' computation, the model must be 3d, extrude it first!'])
     490                                        message(['model not consistent: for a ' EnumToString(md.solution_type) ' computation, the model must be 3d, extrude it first!'])
    490491                                end
    491492                        end
     
    493494                        %CHECK THAT WE ARE NOT FULLY CONSTRAINED
    494495                        if isnan(find(~md.spctemperature(:,1))),
    495                                 error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
     496                                message(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
    496497                        end
    497498
     
    525526                                        return;
    526527                                else
    527                                         error(['model not consistent: for a ' EnumToString(md.solution_type) ' computation, the model must be 3d, extrude it first!'])
     528                                        message(['model not consistent: for a ' EnumToString(md.solution_type) ' computation, the model must be 3d, extrude it first!'])
    528529                                end
    529530                        end
     
    531532                        %CHECK THAT WE ARE NOT FULLY CONSTRAINED
    532533                        if isnan(find(~md.spctemperature(:,1))),
    533                                 error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
     534                                message(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
    534535                        end
    535536
     
    570571                        %       if ~md.prognostic_DG,
    571572                        %               if any(md.spcthickness(find(md.nodeonboundary))~=1),             
    572                         %                       error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);                     
     573                        %                       message(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);                   
    573574                        %               end
    574575                        %       end
     
    576577                        %Triangle with zero velocity
    577578                        if any(sum(abs(md.vx(md.elements)),2)==0 & sum(abs(md.vy(md.elements)),2)==0)
    578                                 error('model not consistent: at least one triangle has all its vertices with a zero velocity');
     579                                message('model not consistent: at least one triangle has all its vertices with a zero velocity');
    579580                        end
    580581                        %}}}
     
    588589                        %SPC
    589590                        if any(md.spcvelocity(find(md.nodeonboundary),[1:2])~=1),
    590                                 error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
     591                                message(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
    591592                        end
    592593                        %}}}
     
    597598                otherwise
    598599                        disp(['WARNING: no check implemented for analysis ' EnumToString(analysis_enum) '!']);
    599                         error('stop')
     600                        message('stop')
    600601        end
    601602
     
    610611                eval(['field=md.' fields{i} ';']);
    611612                if length(field)~=fieldlength,
    612                         error(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
     613                        message(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
    613614                end
    614615        end
     
    622623                if isnan(fieldsize(1)),
    623624                        if (size(field,2)~=fieldsize(2)),
    624                                 error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
     625                                message(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
    625626                        end
    626627                elseif isnan(fieldsize(2)),
    627628                        if (size(field,1)~=fieldsize(1)),
    628                                 error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
     629                                message(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
    629630                        end
    630631                else
     
    646647                                        disp('!!! ');
    647648                                end
    648                                 error(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
     649                                message(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
    649650                        end
    650651                end
     
    658659                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    659660                if any(isnan(field)),
    660                         error(['model not consistent: NaN values found in field ' fields{i}]);
     661                        message(['model not consistent: NaN values found in field ' fields{i}]);
    661662                end
    662663        end
     
    669670                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    670671                if any(~isreal(field)),
    671                         error(['model not consistent: complex values found in field ' fields{i}]);
     672                        message(['model not consistent: complex values found in field ' fields{i}]);
    672673                end
    673674        end
     
    680681                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    681682                if any(field<=lowerbound),
    682                         error(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
     683                        message(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
    683684                end
    684685        end
     
    691692                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    692693                if any(field<lowerbound),
    693                         error(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
     694                        message(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
    694695                end
    695696        end
     
    702703                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    703704                if any(field>=upperbound),
    704                         error(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
     705                        message(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
    705706                end
    706707        end
     
    713714                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    714715                if any(field>upperbound),
    715                         error(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
     716                        message(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
    716717                end
    717718        end
     
    724725                eval(['field=reshape(md.' fields{i} ',[prod(size(md.' fields{i} ')) 1]);']);
    725726                if any(~ismember(field,values)),
    726                         error(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
    727                 end
    728         end
    729 end
    730 %}}}
     727                        message(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
     728                end
     729        end
     730end
     731%}}}
     732
     733%error messages
     734%modelconsistency{{{1
     735function flag=modelconsistency(flag_in)
     736
     737        persistent consistency;
     738
     739        if nargin==1 & nargout==0,
     740                %OK model is inconsistent, set flag as false
     741                consistency=false;
     742        elseif nargin==0 & nargout==1,
     743                if isempty(consistency),
     744                        %modelinconsistent has never been called, model is consistent
     745                        consistency=true;
     746                end
     747        else
     748                message('Bad usage');
     749        end
     750
     751        flag=consistency;
     752end
     753%}}}
     754%message{{{1
     755function message(string)
     756
     757        disp(string);
     758        modelconsistency(false);
     759end
     760%}}}
Note: See TracChangeset for help on using the changeset viewer.