Changeset 8372
- Timestamp:
- 05/20/11 08:13:26 (14 years ago)
- Location:
- issm/trunk/src/m
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk/src/m/classes/model.m ¶
r8365 r8372 5 5 6 6 classdef model 7 properties (SetAccess=public) 7 properties (SetAccess=public) %Model fields 8 8 % {{{1 9 9 %Careful here: no other class should be used as default value … … 24 24 25 25 %Mesh 26 bamg= NaN;26 bamg=struct(); 27 27 dim=0; 28 28 numberofelements=0; … … 183 183 184 184 %Forcings 185 forcings= NaN;185 forcings=struct(); 186 186 187 187 %Statics parameters … … 358 358 vwgt=[]; 359 359 %}}} 360 end 361 properties(Dependent,Hidden) %Deprecated property 362 % {{{ 363 % We must keep here ALL deprecated properties 364 % This ensures that when a model object from a previous version 365 % all fields are recovered. 366 % loadobj is then used to assign old properties to new properties 367 % But if we don't keep the old properties here, they would not be 368 % recovered when the model is loaded 369 drag; 370 p; 371 q; 372 B; 373 n; 374 melting; 375 accumulation; 376 type; 377 numberofgrids; 378 numberofgrids2d; 379 gridonhutter; 380 gridonmacayeal; 381 gridonpattyn; 382 gridonstokes; 383 uppergrids; 384 lowergrids; 385 gridonbed; 386 gridonsurface; 387 extractedgrids; 388 gridoniceshelf; 389 gridonicesheet; 390 gridonwater; 391 gridonnuna; 392 gridonboundary; 393 % }}} 394 end 395 methods (Static) 396 function md = loadobjk(md) % {{{ 397 % This function is directly called by matlab when 398 % a model object is loaded. If the input is a struct 399 % it is an old version of model and old fields must be 400 % recovered (make sure they are in the deprecated 401 % model properties) 402 403 if isstruct(md) 404 disp('Recovering model object from a previous version'); 405 406 %Ok the loaded model is a struct, initialize output and recover all fields 407 structmd=md; 408 md=model; 409 410 structfields=fields(structmd); 411 modelprops =properties(md); 412 413 for i=1:length(structfields), 414 fieldname =structfields{i}; 415 fieldvalue=getfield(structmd,fieldname); 416 if ismember(fieldname,modelprops), 417 md=setfield(md,fieldname,fieldvalue); 418 end 419 end 420 421 %Field name change 422 if isfield(structmd,'drag'), md.drag_coefficient=structmd.drag; end 423 if isfield(structmd,'p'), md.drag_p=structmd.p; end 424 if isfield(structmd,'q'), md.drag_q=structmd.p; end 425 if isfield(structmd,'B'), md.rheology_B=structmd.B; end 426 if isfield(structmd,'n'), md.rheology_n=structmd.n; end 427 if isfield(structmd,'melting'), md.melting_rate=structmd.melting; end 428 if isfield(structmd,'accumulation'), md.accumulation_rate=structmd.accumulation; end 429 if isfield(structmd,'numberofgrids'), md.numberofnodes=structmd.numberofgrids; end 430 if isfield(structmd,'numberofgrids2d'), md.numberofnodes2d=structmd.numberofgrids2d; end 431 if isfield(structmd,'gridonhutter'), md.nodeonhutter=structmd.gridonhutter; end 432 if isfield(structmd,'gridonmacayeal'), md.nodeonmacayeal=structmd.gridonmacayeal; end 433 if isfield(structmd,'gridonpattyn'), md.nodeonpattyn=structmd.gridonpattyn; end 434 if isfield(structmd,'gridonstokes'), md.nodeonstokes=structmd.gridonstokes; end 435 if isfield(structmd,'uppergrids'), md.uppernodes=structmd.uppergrids; end 436 if isfield(structmd,'lowergrids'), md.lowernodes=structmd.lowergrids; end 437 if isfield(structmd,'gridonbed'), md.nodeonbed=structmd.gridonbed; end 438 if isfield(structmd,'gridonsurface'), md.nodeonsurface=structmd.gridonsurface; end 439 if isfield(structmd,'extractedgrids'), md.extractednodes=structmd.extractedgrids; end 440 if isfield(structmd,'gridoniceshelf'), md.nodeoniceshelf=structmd.gridoniceshelf; end 441 if isfield(structmd,'gridonicesheet'), md.nodeonicesheet=structmd.gridonicesheet; end 442 if isfield(structmd,'gridonwater'), md.nodeonwater=structmd.gridonwater; end 443 if isfield(structmd,'gridonnuna'), md.nodeonnuna=structmd.gridonnuna; end 444 if isfield(structmd,'gridonboundary'), md.nodeonboundary=structmd.gridonboundary; end 445 446 %Field class change 447 if (isfield(structmd,'type') & ischar(structmd.type)), 448 if strcmpi(structmd.type,'2d'), md.dim=2; end 449 if strcmpi(structmd.type,'3d'), md.dim=3; end 450 end 451 if isnumeric(md.verbose), md.verbose=verbose; end 452 453 %New fields 454 if ~isfield(structmd,'upperelements'); 455 md.upperelements=transpose(1:md.numberofelements)+md.numberofelements2d; 456 md.upperelements(end-md.numberofelements2d+1:end)=NaN; 457 end 458 if ~isfield(structmd,'lowerelements'); 459 md.lowerelements=transpose(1:md.numberofelements)-md.numberofelements2d; 460 md.lowerelements(1:md.numberofelements2d)=NaN; 461 end 462 end 463 end% }}} 360 464 end 361 465 methods -
TabularUnified issm/trunk/src/m/classes/plotoptions.m ¶
r7106 r8372 109 109 nums=strsplit(plotnum,'-'); 110 110 if length(nums)~=2, continue; end 111 if ~isnumeric(nums) 112 error(['the option #i-j is not set properly for ' field]); 113 end 111 114 for j=nums(1):nums(2), 112 115 opt.list{j}=addfield(opt.list{j},field,rawoptions.list{i,2}); -
TabularUnified issm/trunk/src/m/model/marshall.m ¶
r8369 r8372 114 114 for i=1:numforcings, 115 115 forcing=md.forcings.(forcingnames{i}); 116 forcingname= forcingnames{i};116 forcingname=EnumToString(forcingtypes(i)); 117 117 118 118 WriteData(fid,size(forcing,2),'Integer',['forcing_' forcingname '_num_time_steps']);
Note:
See TracChangeset
for help on using the changeset viewer.