Changeset 16513
- Timestamp:
- 10/22/13 11:15:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r16503 r16513 134 134 void IoModel::CheckEnumSync(void){ 135 135 136 int my_rank; 137 int record_enum = 0; 136 int record_enum,record_length; 138 137 139 138 /*recover my_rank:*/ 140 my_rank=IssmComm::GetRank();139 int my_rank=IssmComm::GetRank(); 141 140 142 141 /*Check that some fields have been allocated*/ … … 171 170 _error_("Enums not consistent (See error message above)"); 172 171 } 172 } 173 174 /*Get last enum*/ 175 bool found = false; 176 int last_enum = 0; 177 178 /*First set FILE* position to the beginning of the file: */ 179 fseek(fid,0,SEEK_SET); 180 for(;;){ 181 /*Have we reached the end of file ?*/ 182 if(fread(&record_enum,sizeof(int),1,fid)==0){ 183 break; 184 } 185 186 /*Have we found the last Enum ?*/ 187 if(record_enum==MaximumNumberOfDefinitionsEnum+1){ 188 found = true; 189 break; 190 } 191 192 /*Check that record_enum is an enum*/ 193 if(record_enum>=0 && record_enum<=MaximumNumberOfDefinitionsEnum){ 194 if(record_enum>0) last_enum = record_enum; 195 } 196 197 /*Go to next Enum*/ 198 if(fread(&record_length,sizeof(int),1,fid)!=1) _error_("Could not read record_length"); 199 fseek(fid,record_length,SEEK_CUR); 200 } 201 if(!found){ 202 _printf0_("\n"); 203 _printf0_("=========================================================================\n"); 204 _printf0_(" Marshalled file is corrupted \n"); 205 _printf0_(" \n"); 206 _printf0_(" * If you are running an old model, send it to the ISSM developers \n"); 207 _printf0_(" so that a check is added before marshall \n"); 208 _printf0_(" * Last Enum found: " << EnumToStringx(last_enum)<<"Enum ("<<last_enum<<")\n"); 209 _printf0_(" the corresponding model field has probably been marshalled \n"); 210 _printf0_(" incorrectly \n"); 211 _printf0_(" \n"); 212 _printf0_("=========================================================================\n"); 213 _printf0_("\n"); 214 _error_("Binary file corrupted (See error message above)"); 173 215 } 174 216 }
Note:
See TracChangeset
for help on using the changeset viewer.