source: issm/trunk-jpl/src/m/model/marshall.m@ 12265

Last change on this file since 12265 was 12265, checked in by Mathieu Morlighem, 13 years ago

Added check that Enums are synchronized between matlab's interface and compiled code

File size: 1.4 KB
RevLine 
[465]1function marshall(md)
[11217]2%MARSHALL - outputs a compatible binary file from @model md, for certain solution type.
[1]3%
[10969]4% The routine creates a compatible binary file from @model md
[2547]5% This binary file will be used for parallel runs in JPL-package
[1]6%
7% Usage:
[465]8% marshall(md)
[1]9
[9625]10disp(['marshalling file ' md.miscellaneous.name '.bin']);
[1]11
12%open file for binary writing
[9625]13fid=fopen([ md.miscellaneous.name '.bin'],'wb');
[1]14if fid==-1,
[9625]15 error(['marshall error message: could not open ' [md.miscellaneous.name '.bin'],' file for binary writing']);
[1]16end
17
[12265]18%First, right MaximumNumberOfEnum to make sure that the Enums are synchronized
19WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean');
20
[11217]21%Go through all model fields: check that it is a class and call checkconsistency
[11221]22fields=properties('model');
[9597]23for i=1:length(fields),
[10969]24 field=fields{i};
[9597]25
[10969]26 %Some properties do not need to be marshalled
[11959]27 if ismember(field,{'results' 'radaroverlay' 'solver' 'cluster' 'flaim' 'private'}),
[10969]28 continue;
[9597]29 end
[9373]30
[10969]31 %Check that current field is an object
32 if ~isobject(md.(field))
33 checkmessage(['field ''' char(field) ''' is not an object']);
[9373]34 end
[9381]35
[10969]36 %Marshall current object
37 %disp(['marshalling ' field '...']);
[11224]38 if verLessThan('matlab', '7.6')
39 marshall(md.(field),fid);
40 else
41 md.(field).marshall(fid);
42 end
[9373]43end
[9385]44
[10969]45%close file
46st=fclose(fid);
47if st==-1,
48 error(['marshall error message: could not close file ' [md.miscellaneous.name '.bin']]);
[9385]49end
Note: See TracBrowser for help on using the repository browser.