NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi -I'm getting a crash when calling nc_get_vara to read large amounts of data. This is happening with netCDF4.1.2 and also the beta and snapshot versions of 4.1.3 (netcdf-4.1.3-rc1-snapshot2011050612). I configure netcdf with hdf 1.8.6, and with:
$ configure --prefix=/home/users/ansley/local/linux --disable-shared --enable-dap --enable-dap-remote-tests --with-zlib=/usr/local --enable-netcdf-4 --enable-ncgen4 --enable-largefile
Reading, say, 360x180x100 is successful but 360x180x600 fails, with a crash inside buildcachenode34 in cache.c
(What cache is this? Are there settings I can make regarding caching? What has happened to use of the .dodsrc file? I have a .dodsrc file but it has caching turned off.)
I've attached a test program showing this, based on test_vara.c from the tests in the ncdap_test/
thanks -Ansley
/* test_vara_big.c Crash on the call to nc_get_vara_float when the region is large. */ /* netcdf4.1.2, netcdf4.1.3beta and snapshots /* 5/11/2011 */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <netcdf.h> #define URL "http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/COADS/coads_air.cdf" #define VAR "AIR" #define X 180 #define Y 90 #define T 1680 /* A second example showing the same behavior. /* #define URL "http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/coads/1degree/global/enh/air.mean.nc" /* /* #define VAR "air" /* /* #define X 360 /* #define Y 180 /* #define T 616 */ #define RANK 3 #define ERRCODE 2 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} #undef DEBUG static float threeD[T][Y][X]; static dims[RANK] = {T,Y,X}; /* Define whole variable start/count */ static size_t start0[RANK] = {0,0,0}; static size_t count0[RANK] = {T,Y,X}; int main() { int ncid, varid; int retval,i; size_t start[RANK]; size_t count[RANK]; memset((void*)threeD,0,sizeof(threeD)); if((retval = nc_open(URL, NC_NOWRITE, &ncid))) ERR(retval); if((retval = nc_inq_varid(ncid, VAR, &varid))) ERR(retval); /* test 1: Read the first 100 timesteps */ memcpy(start,start0,sizeof(start0)); memcpy(count,count0,sizeof(count0)); count[0] = 100; printf("*** read 100 timesteps\n"); if((retval = nc_get_vara_float(ncid,varid,start,count,(float*)threeD))) ERR(retval); /* test 2: Read the whole variable */ memcpy(start,start0,sizeof(start0)); memcpy(count,count0,sizeof(count0)); printf("*** read entire variable\n"); if((retval = nc_get_vara_float(ncid,varid,start,count,(float*)threeD))) ERR(retval); if((retval = nc_close(ncid))) ERR(retval); return 0; }
netcdfgroup
archives: