[12325] | 1 | Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.h
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.h (revision 12264)
|
---|
| 4 | +++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.h (revision 12265)
|
---|
| 5 | @@ -40,25 +40,26 @@
|
---|
| 6 | IoModel(FILE* iomodel_handle);
|
---|
| 7 |
|
---|
| 8 | /*Input/Output*/
|
---|
| 9 | - void Constant(bool *poutput,int constant_enum);
|
---|
| 10 | - void Constant(int *poutput,int constant_enum);
|
---|
| 11 | - void Constant(double *poutput,int constant_enum);
|
---|
| 12 | - void Constant(char **poutput,int constant_enum);
|
---|
| 13 | - Param *CopyConstantObject(int constant_enum);
|
---|
| 14 | - double *Data(int dataenum);
|
---|
| 15 | - void DeleteData(int num,...);
|
---|
| 16 | - void FetchConstants(void);
|
---|
| 17 | - void FetchData(bool* pboolean,int data_enum);
|
---|
| 18 | - void FetchData(int* pinteger,int data_enum);
|
---|
| 19 | - void FetchData(double* pscalar,int data_enum);
|
---|
| 20 | - void FetchData(char** pstring,int data_enum);
|
---|
| 21 | - void FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
|
---|
| 22 | - void FetchData(double** pscalarmatrix,int* pM,int* pN,int data_enum);
|
---|
| 23 | - void FetchData(char*** pstringarray,int* pnumstrings,int data_enum);
|
---|
| 24 | - void FetchData(double*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
|
---|
| 25 | - void FetchData(int num,...);
|
---|
| 26 | - void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,double default_value=0);
|
---|
| 27 | - FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
|
---|
| 28 | + void CheckEnumSync(void);
|
---|
| 29 | + void Constant(bool *poutput,int constant_enum);
|
---|
| 30 | + void Constant(int *poutput,int constant_enum);
|
---|
| 31 | + void Constant(double *poutput,int constant_enum);
|
---|
| 32 | + void Constant(char **poutput,int constant_enum);
|
---|
| 33 | + Param *CopyConstantObject(int constant_enum);
|
---|
| 34 | + double *Data(int dataenum);
|
---|
| 35 | + void DeleteData(int num,...);
|
---|
| 36 | + void FetchConstants(void);
|
---|
| 37 | + void FetchData(bool* pboolean,int data_enum);
|
---|
| 38 | + void FetchData(int* pinteger,int data_enum);
|
---|
| 39 | + void FetchData(double* pscalar,int data_enum);
|
---|
| 40 | + void FetchData(char** pstring,int data_enum);
|
---|
| 41 | + void FetchData(int** pmatrix,int* pM,int* pN,int data_enum);
|
---|
| 42 | + void FetchData(double** pscalarmatrix,int* pM,int* pN,int data_enum);
|
---|
| 43 | + void FetchData(char*** pstringarray,int* pnumstrings,int data_enum);
|
---|
| 44 | + void FetchData(double*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
|
---|
| 45 | + void FetchData(int num,...);
|
---|
| 46 | + void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,double default_value=0);
|
---|
| 47 | + FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | #endif /* _IOMODEL_H */
|
---|
| 51 | Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.cpp
|
---|
| 52 | ===================================================================
|
---|
| 53 | --- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.cpp (revision 12264)
|
---|
| 54 | +++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/objects/IoModel.cpp (revision 12265)
|
---|
| 55 | @@ -44,6 +44,9 @@
|
---|
| 56 | /*First, keep track of the file handle: */
|
---|
| 57 | this->fid=iomodel_handle;
|
---|
| 58 |
|
---|
| 59 | + /*Check that Enums are Synchronized*/
|
---|
| 60 | + this->CheckEnumSync();
|
---|
| 61 | +
|
---|
| 62 | /*Initialize and read constants:*/
|
---|
| 63 | this->constants=new Parameters();
|
---|
| 64 | this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, doubles and strings only, nothing memory intensive*/
|
---|
| 65 | @@ -88,6 +91,35 @@
|
---|
| 66 | }
|
---|
| 67 | /*}}}*/
|
---|
| 68 |
|
---|
| 69 | +/*FUNCTION IoModel::CheckEnumSync{{{1*/
|
---|
| 70 | +void IoModel::CheckEnumSync(void){
|
---|
| 71 | +
|
---|
| 72 | + extern int my_rank;
|
---|
| 73 | + int record_enum = 0;
|
---|
| 74 | +
|
---|
| 75 | +
|
---|
| 76 | + /*Check that some fields have been allocated*/
|
---|
| 77 | + _assert_(this->fid || my_rank);
|
---|
| 78 | +
|
---|
| 79 | +
|
---|
| 80 | + /*Go find in the binary file, the position of the data we want to fetch: */
|
---|
| 81 | + if(my_rank==0){ //cpu 0
|
---|
| 82 | +
|
---|
| 83 | + /*First set FILE* position to the beginning of the file: */
|
---|
| 84 | + fseek(this->fid,0,SEEK_SET);
|
---|
| 85 | +
|
---|
| 86 | + /*Get first Enum*/
|
---|
| 87 | + if(fread(&record_enum,sizeof(int),1,this->fid)==0){
|
---|
| 88 | + _error_("Marshalled file is empty");
|
---|
| 89 | + }
|
---|
| 90 | + else{
|
---|
| 91 | + if(record_enum!=MaximumNumberOfEnums){
|
---|
| 92 | + _error_("Enums in marshalled file are not compatible with compiled code, make sure you are using the same version of ISSM");
|
---|
| 93 | + }
|
---|
| 94 | + }
|
---|
| 95 | + }
|
---|
| 96 | +}
|
---|
| 97 | +/*}}}*/
|
---|
| 98 | /*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{1*/
|
---|
| 99 | void IoModel::Constant(bool* poutput,int constant_enum){
|
---|
| 100 |
|
---|
| 101 | Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/m/model/marshall.m
|
---|
| 102 | ===================================================================
|
---|
| 103 | --- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/m/model/marshall.m (revision 12264)
|
---|
| 104 | +++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/m/model/marshall.m (revision 12265)
|
---|
| 105 | @@ -15,6 +15,9 @@
|
---|
| 106 | error(['marshall error message: could not open ' [md.miscellaneous.name '.bin'],' file for binary writing']);
|
---|
| 107 | end
|
---|
| 108 |
|
---|
| 109 | +%First, right MaximumNumberOfEnum to make sure that the Enums are synchronized
|
---|
| 110 | +WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean');
|
---|
| 111 | +
|
---|
| 112 | %Go through all model fields: check that it is a class and call checkconsistency
|
---|
| 113 | fields=properties('model');
|
---|
| 114 | for i=1:length(fields),
|
---|