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