| Line | |
|---|
| 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
|
|---|
| 15 | var fid=new fileptr('mode','w');
|
|---|
| 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
|
|---|
| 21 | if (field == 'results' | field =='radaroverlay' | field == 'toolkits' | field =='cluster' | field == 'priv') continue;
|
|---|
| 22 |
|
|---|
| 23 | //Check that current field is a class
|
|---|
| 24 | if(typeof md[field] == 'function'){
|
|---|
| 25 | continue;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | //Marshall current object
|
|---|
| 29 | md[field].marshall(md,['md.'+field],fid);
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 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');
|
|---|
| 34 | return fid;
|
|---|
| 35 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.