|
Last change
on this file since 20690 was 20690, checked in by Mathieu Morlighem, 10 years ago |
|
NEW: marhsall strings instead of enums
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [19787] | 1 | function marshall(md){
|
|---|
| 2 | //MARSHALL - outputs a typed array buffer to be send to the issm module.
|
|---|
| 3 | //
|
|---|
| 4 | // The routine creates a compatible binary stream from @model md
|
|---|
| 5 | // This binary stream will be used for single cpu runs using the issm module.
|
|---|
| 6 | //
|
|---|
| 7 | // Usage:
|
|---|
| 8 | // fid=marshall(md)
|
|---|
| 9 |
|
|---|
| 10 | if (md.verbose.solution){
|
|---|
| 11 | console.log('marshalling file ' + md.miscellaneous.name + '.bin');
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | //open file for binary writing
|
|---|
| [20268] | 15 | var fid=new fileptr('mode','w');
|
|---|
| [19787] | 16 |
|
|---|
| 17 | //Go through all model fields: check that it is a class and call checkconsistency
|
|---|
| 18 | for (field in md){
|
|---|
| 19 |
|
|---|
| 20 | //Some properties do not need to be marshalled
|
|---|
| [19824] | 21 | if (field == 'results' | field =='radaroverlay' | field == 'toolkits' | field =='cluster' | field == 'flaim' | field == 'priv') continue;
|
|---|
| [19787] | 22 |
|
|---|
| 23 | //Check that current field is a class
|
|---|
| 24 | if(typeof md[field] == 'function'){
|
|---|
| 25 | continue;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | //Marshall current object
|
|---|
| [20690] | 29 | md[field].marshall(['md.'+field],md,fid);
|
|---|
| [19787] | 30 | }
|
|---|
| 31 |
|
|---|
| [20690] | 32 | //Last, write "md.EOF" to make sure that the binary file is not corrupt
|
|---|
| 33 | WriteData(fid,'XXX','name','md.EOF','data',true,'format','Boolean');
|
|---|
| [19787] | 34 | return fid;
|
|---|
| 35 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.