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 have a crash to report. This piece of code reads the first timestep of a dataset. It works correctly when linked with netCDF4.1.2, but segfaults when linked with 4.1.3. If I have it read the second timestep, it works correctly, linked with either version of netcdf.
/* vara_test_8 */ /* ansley.b.manke@xxxxxxxx 8/2011 */ /*linked with:cc vara_test_8.c -g -o vara_test_8 /usr/local/netcdf_413/lib/libnetcdf.a /usr/local/hdf5_187/lib/libhdf5_hl.a /usr/local/hdf5_187/lib/libhdf5.a -lz -lc -lm -lcurl
cc vara_test_8.c -g -o vara_test_8 /usr/local/netcdf_412/lib/libnetcdf.a /usr/local/hdf5_186/lib/libhdf5_hl.a /usr/local/hdf5_186/lib/libhdf5.a -lz -lc -lm -lcurl
When linked with netCDF4.1.3, reading the first timestep, the code segfaults
*/ #include<stdio.h> #include "netcdf.h" main() { int ncid; int varid; int i; int status; size_t start[3], count[3]; float dat[16200];status = nc_open("http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/COADS/coads_sst.cdf", NC_NOWRITE, &ncid);
status = nc_inq_varid(ncid, "SST", &varid); /* Read one timestep */ start[0] = 0; /* crashes if this is 0; success if it's 1 */ start[1] = 0; start[2] = 0; count[0] = 1; count[1] = 90; count[2] = 180; status = nc_get_vara_float (ncid, varid, start, count, (float*) dat); printf(" \n"); printf("********************\n"); printf("Print values read\n"); printf(" \n"); for (i=1000; i<1008; i++) { printf("i = %d, dat, %f,\n",i,dat[i]); dat[i] = 0; } status = nc_close(ncid); }
netcdfgroup
archives: