~fluidity-core/fluidity/refactor-netcdf

« back to all changes in this revision

Viewing changes to femtools/tests/test_netcdf_reader.F90

  • Committer: Jon Hill
  • Date: 2012-06-30 19:04:04 UTC
  • Revision ID: jon.hill@imperial.ac.uk-20120630190404-gze0f7cw8ny38kf4
Adding bug fix for unpacked data, setting sensible scale and offset values

Show diffs side-by-side

added added

removed removed

Lines of Context:
316
316
  end do
317
317
  if (check .eq. 9) fail = .false.
318
318
  call report_test("[netcdf reader]", fail, .false., "Incorrect variable (with scale and offset)")  
 
319
  
 
320
 
 
321
  ! Same, but unpacked data (no scale or offset) - same data sizes, etc
 
322
  filename = "data/stationPapa_1970.nc"
 
323
  call netcdf_open_file(filename, netcdf_id, err)
 
324
  call netcdf_get_variable(netcdf_id, twoD, 't2', 1)
 
325
  fail = .true.
 
326
  if (dims(1) .eq. 3 .and. dims(2) .eq. 3) fail = .false.
 
327
  call report_test("[netcdf reader]", fail, .false., "Incorrect dimensions")
 
328
  expected_array = (/278.98044,279.56441,279.85925,279.44920,279.56060,279.85354,280.37879,280.304531,280.45687/)
 
329
  check = 0
 
330
  do i=1,3
 
331
    do j=1,3
 
332
        ! to within 5dp
 
333
        if (abs(twoD(i,j)-expected_array(i)) < 0.00001) check = check + 1
 
334
    end do
 
335
  end do
 
336
  if (check .eq. 9) fail = .false.
 
337
  call report_test("[netcdf reader]", fail, .false., "Incorrect variable (with scale and offset)")  
 
338
 
 
339
  
319
340
  deallocate(twoD)
320
341
 
321
342
 
322
343
 
323
344
 
 
345
 
324
346
  
325
347
  ! can we pull out a single variable in time
326
348