Changeset 5967
- Timestamp:
- Nov 18, 2008, 12:31:51 PM (16 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r5847 r5967 848 848 zl, 849 849 zr, 850 ((double*) normal -> data)[0], 850 ((double*) normal -> data)[0], 851 851 ((double*) normal -> data)[1], 852 852 epsilon, H0, g, -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5965 r5967 6243 6243 6244 6244 def test_urs2sts_read_mux2_pyIII(self): 6245 """Varying start and fin sh times6245 """Varying start and finish times 6246 6246 """ 6247 6247 tide = 1 … … 11048 11048 if __name__ == "__main__": 11049 11049 11050 #suite = unittest.makeSuite(Test_Data_Manager,'test')11050 suite = unittest.makeSuite(Test_Data_Manager,'test') 11051 11051 #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsI_beyond_model_time') 11052 11052 #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV_sinewave_ordering') … … 11057 11057 11058 11058 # FIXME (Ole): This is the test that fails under Windows 11059 suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux_platform_problem2')11059 #suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux_platform_problem2') 11060 11060 #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV') 11061 11061 -
anuga_core/source/anuga/shallow_water/urs_ext.c
r5964 r5967 179 179 char susMuxFileName; 180 180 long numData; 181 size_t elements_read; // fread return value 182 int block_size; 181 183 182 184 /* Allocate space for the names and the weights and pointers to the data*/ … … 218 220 { 219 221 fprintf(stderr, "cannot open file %s\n", muxFileName); 220 return 0;222 return -1; 221 223 } 222 224 223 225 if (!i) 224 226 { 225 fread(total_number_of_stations, sizeof(int), 1, fp); 227 elements_read = fread(total_number_of_stations, sizeof(int), 1, fp); 228 if ((int) elements_read != 1){ 229 fprintf(stderr, "(1) Read %d number of elements, should have been 1\n", 230 elements_read); 231 return -2; 232 } 226 233 227 234 fros = (int*) malloc(*total_number_of_stations*numSrc*sizeof(int)); … … 231 238 mytgs = (struct tgsrwg*) malloc(*total_number_of_stations*sizeof(struct tgsrwg)); 232 239 233 fread(mytgs0, *total_number_of_stations*sizeof(struct tgsrwg), 1, fp); 240 block_size = *total_number_of_stations*sizeof(struct tgsrwg); 241 elements_read = fread(mytgs0, block_size , 1, fp); 242 if ((int) elements_read != 1){ 243 fprintf(stderr, "(2) Read %d number of elements, should have been 1\n", 244 elements_read); 245 return -2; 246 } 234 247 } 235 248 else 236 249 { 237 250 // Check that the mux files are compatible 238 fread(&numsta, sizeof(int), 1, fp); 251 elements_read = fread(&numsta, sizeof(int), 1, fp); 252 if ((int) elements_read != 1){ 253 fprintf(stderr, "(3) Read %d number of elements, should have been 1\n", 254 elements_read); 255 return -2; 256 } 257 239 258 if(numsta != *total_number_of_stations) 240 259 { … … 243 262 muxFileNameArray[0]); 244 263 fclose(fp); 245 return 0;264 return -1; 246 265 } 247 266 248 fread(mytgs, numsta*sizeof(struct tgsrwg), 1, fp); 249 267 block_size = numsta*sizeof(struct tgsrwg); 268 elements_read = fread(mytgs, block_size, 1, fp); 269 if ((int) elements_read != 1){ 270 fprintf(stderr, "(4) Read %d number of elements, should have been 1\n", 271 elements_read); 272 return -2; 273 } 274 275 250 276 for (j = 0; j < numsta; j++) 251 277 { … … 256 282 muxFileNameArray[0]); 257 283 fclose(fp); 258 return 0;284 return -1; 259 285 } 260 286 if (mytgs[j].nt != mytgs0[j].nt) … … 264 290 muxFileNameArray[0]); 265 291 fclose(fp); 266 return 0;292 return -1; 267 293 } 268 294 … … 275 301 276 302 /* Read the start and stop times for this source */ 277 fread(fros + i*(*total_number_of_stations), 278 *total_number_of_stations*sizeof(int), 1, fp); 279 fread(lros + i*(*total_number_of_stations), 280 *total_number_of_stations*sizeof(int), 1, fp); 303 elements_read = fread(fros + i*(*total_number_of_stations), 304 *total_number_of_stations*sizeof(int), 1, fp); 305 if ((int) elements_read != 1){ 306 fprintf(stderr, "(4) Read %d number of elements, should have been 1\n", 307 elements_read); 308 return -3; 309 } 310 311 312 elements_read = fread(lros + i*(*total_number_of_stations), 313 *total_number_of_stations*sizeof(int), 1, fp); 314 if ((int) elements_read != 1){ 315 fprintf(stderr, "(5) Read %d number of elements, should have been 1\n", 316 elements_read); 317 return -3; 318 } 281 319 282 320 /* Compute the size of the data block for this source */ … … 289 327 { 290 328 fprintf(stderr,"Size of data block appears to be negative!\n"); 291 return 0;329 return -1; 292 330 } 293 331 … … 309 347 free(mytgs); 310 348 311 return 1;349 return 0; // Succesful execution 312 350 } 313 351 … … 329 367 long numData; 330 368 331 int len_sts_data ;369 int len_sts_data, error_code; 332 370 float **sts_data; 333 371 float *temp_sts_data; … … 337 375 int number_of_time_steps, N; 338 376 double delta_t; 377 378 size_t elements_read; 339 379 340 380 // Shorthands pointing to memory blocks for each source … … 343 383 344 384 345 _read_mux2_headers(numSrc, 346 muxFileNameArray, 347 &total_number_of_stations, 348 &number_of_time_steps, 349 &delta_t, 350 verbose); 385 error_code = _read_mux2_headers(numSrc, 386 muxFileNameArray, 387 &total_number_of_stations, 388 &number_of_time_steps, 389 &delta_t, 390 verbose); 391 if (error_code != 0) { 392 printf("urs_ext.c: Internal function _read_mux2_headers failed: Error code = %d\n", 393 error_code); 394 395 return NULL; 396 } 397 351 398 352 399 // Apply rule that an empty permutation file means 'take all stations' … … 430 477 total_number_of_stations); 431 478 432 fread(muxData, ((int) numData)*sizeof(float), 1, fp); 479 480 481 elements_read = fread(muxData, ((int) numData)*sizeof(float), 1, fp); 482 483 if ((int) elements_read == 0 && ferror(fp)) { 484 //fprintf(stderr, "Numdata = %d\n", (int) numData); 485 fprintf(stderr, "(6) Read %d number of elements, should have been 1\n", 486 elements_read); 487 return NULL; 488 } 489 433 490 fclose(fp); 491 434 492 435 493 // FIXME (Ole): This is where Nariman and Ole traced the platform dependent
Note: See TracChangeset
for help on using the changeset viewer.