Changeset 5611 for anuga_core/source/anuga/shallow_water/urs_ext.c
- Timestamp:
- Aug 5, 2008, 2:26:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/urs_ext.c
r5602 r5611 57 57 } 58 58 } 59 59 60 if (nft[ista] != -1) 60 61 { … … 68 69 } 69 70 } 71 70 72 if (ig == -1 || nst[ista] == -1) /* currently ig==-1 => nst[ista]==-1 */ 71 73 { 72 74 /* gauge never started recording, or was outside of all grids, 73 fill array with 0 */75 fill array with 0 */ 74 76 for(it = 0; it < nt; it++) 75 77 { … … 91 93 /* deal with the tide gauge at hand */ 92 94 if(it + 1 >= nst[ista] && it + 1 <= nft[ista]) 95 { 93 96 /* gauge is recording at this time */ 94 {95 97 memcpy(data + it, muxData + offset, sizeof(float)); 96 98 offset++; … … 116 118 if(last_it < nt - 1) 117 119 /* the loop was exited early because the gauge had 118 finished recording */120 finished recording */ 119 121 for(it = last_it+1; it < nt; it++) 120 122 data[it] = NODATA; … … 267 269 268 270 /* Read the start and stop times for this source */ 269 fread(fros + i*(*total_number_of_stations), *total_number_of_stations*sizeof(int), 1, fp); 270 fread(lros + i*(*total_number_of_stations), *total_number_of_stations*sizeof(int), 1, fp); 271 fread(fros + i*(*total_number_of_stations), 272 *total_number_of_stations*sizeof(int), 1, fp); 273 fread(lros + i*(*total_number_of_stations), 274 *total_number_of_stations*sizeof(int), 1, fp); 271 275 272 276 /* Compute the size of the data block for this source */ … … 291 295 292 296 // Store time resolution and number of timesteps 293 // These are the same for all stations , so297 // These are the same for all stations as tested above, so 294 298 // we take the first one. 295 299 *delta_t = (double)mytgs0[0].dt; … … 312 316 FILE *fp; 313 317 int total_number_of_stations, i, isrc, ista, k; 314 //struct tgsrwg* mytgs0=NULL;315 318 char *muxFileName; 316 int istart , istop;319 int istart=-1, istop=-1; 317 320 int number_of_selected_stations; 318 321 float *muxData=NULL; // Suppress warning … … 325 328 long int offset; 326 329 327 int number_of_time_steps ;330 int number_of_time_steps, N; 328 331 double delta_t; 329 //long numDataMax; 332 333 // Shorthands pointing to memory blocks for each source 334 int *fros_per_source=NULL; 335 int *lros_per_source=NULL; 330 336 331 337 _read_mux2_headers(numSrc, … … 370 376 371 377 // For each selected station, allocate space for its data 372 373 len_sts_data = mytgs0[0].nt + POFFSET; // Max length of each timeseries? 378 len_sts_data = number_of_time_steps + POFFSET; // Max length of each timeseries? 374 379 for (i = 0; i < number_of_selected_stations; i++) 375 380 { … … 381 386 return NULL; 382 387 } 383 384 ista = (int) permutation[i]; // Get global index into mux data385 386 sts_data[i][mytgs0[0].nt] = (float)mytgs0[ista].geolat;387 sts_data[i][mytgs0[0].nt + 1] = (float)mytgs0[ista].geolon;388 sts_data[i][mytgs0[0].nt + 2] = (float)mytgs0[ista].z;389 sts_data[i][mytgs0[0].nt + 3] = (float)fros[ista];390 sts_data[i][mytgs0[0].nt + 4] = (float)lros[ista];391 388 } 392 389 … … 394 391 395 392 muxData = (float*)malloc(numDataMax*sizeof(float)); 393 396 394 /* Loop over all sources */ 397 //FIXME: remove istart and istop they are not used.398 istart = -1;399 istop = -1;400 395 for (isrc = 0; isrc < numSrc; isrc++) 401 396 { 397 398 // Shorthands to local memory 399 fros_per_source = (int*) fros + isrc*total_number_of_stations; 400 lros_per_source = (int*) lros + isrc*total_number_of_stations; 401 402 403 402 404 /* Read in data block from mux2 file */ 403 405 muxFileName = muxFileNameArray[isrc]; … … 415 417 fseek(fp, offset, 0); 416 418 417 numData = getNumData(fros + isrc*total_number_of_stations,418 lros + isrc*total_number_of_stations,419 numData = getNumData(fros_per_source, 420 lros_per_source, 419 421 total_number_of_stations); 420 422 … … 431 433 ista = (int) permutation[i]; // Get global index into mux data 432 434 433 / * fill the data0 array from the mux file, and weight it */435 // fill the data0 array from the mux file, and weight it 434 436 fillDataArray(ista, 435 437 total_number_of_stations, 436 mytgs0[ista].nt, 438 number_of_time_steps, 437 439 mytgs0[ista].ig, 438 fros + isrc*total_number_of_stations,439 lros + isrc*total_number_of_stations,440 fros_per_source, 441 lros_per_source, 440 442 temp_sts_data, 441 443 &istart, … … 443 445 muxData); 444 446 445 / * weight appropriately and add */447 // Weight appropriately and add 446 448 for(k = 0; k < mytgs0[ista].nt; k++) 447 449 { … … 455 457 } 456 458 } 459 460 // Update metadata (e.g. start time and end time) 461 N = number_of_time_steps; 462 463 464 /* 465 printf("station = %d, source = %d, fros = %f, lros = %f\n", 466 ista, 467 isrc, 468 (float) fros_per_source[ista], 469 (float) lros_per_source[ista]); 470 */ 471 472 473 474 if (isrc == 0) { 475 // Assign values for first source 476 sts_data[i][N] = (float)mytgs0[ista].geolat; 477 sts_data[i][N+1] = (float)mytgs0[ista].geolon; 478 sts_data[i][N+2] = (float)mytgs0[ista].z; 479 sts_data[i][N+3] = (float)fros_per_source[ista]; 480 sts_data[i][N+4] = (float)lros_per_source[ista]; 481 } else { 482 // Update first and last timesteps for subsequent sources 483 if (sts_data[i][N+3] > (float)fros_per_source[ista]) { 484 if (verbose) { 485 printf("Adjusting start time for station %d and source %d", 486 ista, isrc); 487 printf(" from %f to %f\n", sts_data[i][N+3], (float)fros_per_source[ista]); 488 } 489 sts_data[i][N+3] = (float)fros_per_source[ista]; 490 } 491 492 493 if (sts_data[i][N+4] < (float)lros_per_source[ista]) { 494 if (verbose) { 495 printf("Adjusting end time for station %d and source %d", 496 ista, isrc); 497 printf(" from %f to %f\n", sts_data[i][N+4], (float)lros_per_source[ista]); 498 } 499 sts_data[i][N+4] = (float)lros_per_source[ista]; 500 } 501 } 457 502 } 458 503 }
Note: See TracChangeset
for help on using the changeset viewer.