Changeset 18806
- Timestamp:
- 11/18/14 14:03:44 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/IoModel.cpp
r18521 r18806 1229 1229 } 1230 1230 /*}}}*/ 1231 void IoModel::FetchMultipleData(IssmDouble** pvector, int* pnum_instances,int data_enum){/*{{{*/ 1232 1233 int num_instances; 1234 fpos_t* file_positions=NULL; 1235 1236 /*output: */ 1237 IssmDouble* vector=NULL; 1238 1239 /*intermediary: */ 1240 IssmPDouble scalar; 1241 int *codes = NULL; 1242 int code; 1243 1244 /*recover my_rank:*/ 1245 int my_rank=IssmComm::GetRank(); 1246 1247 /*Get file pointers to beginning of the data (multiple instances of it): */ 1248 file_positions=this->SetFilePointersToData(&codes,NULL,&num_instances,data_enum); 1249 1250 if(num_instances){ 1251 1252 /*Allocate vector :*/ 1253 vector=xNew<IssmDouble>(num_instances); 1254 1255 for(int i=0;i<num_instances;i++){ 1256 1257 if(my_rank==0){ 1258 code=codes[i]; 1259 1260 if(code!=3)_error_("expecting a double for enum " << EnumToStringx(data_enum)); 1261 1262 /*We have to read a double from disk: */ 1263 fsetpos(fid,file_positions+i); 1264 if(my_rank==0){ 1265 if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1) _error_("could not read scalar "); 1266 } 1267 } 1268 ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 1269 1270 /*Assign: */ 1271 vector[i]=scalar; 1272 } 1273 } 1274 1275 /*Free ressources:*/ 1276 xDelete<fpos_t>(file_positions); 1277 xDelete<int>(codes); 1278 1279 /*Assign output pointers: */ 1280 *pvector=vector; 1281 *pnum_instances=num_instances; 1282 } 1283 /*}}}*/ 1231 1284 void IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){/*{{{*/ 1232 1285
Note:
See TracChangeset
for help on using the changeset viewer.