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.
Hello, I have found a problem with netcdf 4.0.1 library (test program at the end. If you create a field as an unsigned short and write a number outside the signed short range with nc_put_vara_double there is a -60 status returned (range error) but the data are correctly written. Here is the output of the program and of ncdump: Creating file netcdf4.nc status = 0 Creating dimension 'dim' = 10 status = 0 Creating variable varshort (type ushort, dimension 'dim') status = 0 Writing varshort with nc_put_vara_double status = -60 netcdf netcdf4 { dimensions: dim = 10 ; variables: ushort varshort(dim) ; data: varshort = 32765, 32766, 32767, 32768, 32769, 32770, 32771, 32772, 32773, 32774 ; } Maybe there is a bug here (if not, please tell me was is wrong in my code). I have not checked other combinations of type/write routine, but maybe there is the same behavior with bytes and longs and put_xxx_double. -- Phippe Poilbarbe CLS - Space Oceanography Division ============== #include <stdio.h> #include <netcdf.h> int main(int argc, char *arvg[]) { int status; int i; int ncid; const int dimvalue = 10; int dimid; int varid; double values_r8[dimvalue]; unsigned short values_ui2[dimvalue]; size_t index = 0; size_t count = dimvalue; printf("Creating file netcdf4.nc\n"); status = nc_create( "netcdf4.nc", NC_CLOBBER|NC_NETCDF4, &ncid); printf("status = %d\n",status); if (status != 0) goto Error; printf("Creating dimension 'dim' = %d\n", dimvalue); status = nc_def_dim(ncid, "dim", dimvalue, &dimid); printf("status = %d\n",status); if (status != 0) goto Error; printf("Creating variable varshort (type ushort, dimension 'dim')\n"); status = nc_def_var(ncid, "varshort", NC_USHORT, 1, &dimid, &varid); printf("status = %d\n",status); if (status != 0) goto Error; for(i=0; i < dimvalue; i++) values_r8[i] = 32765.0 + i; printf("Writing varshort with nc_put_vara_double\n"); status = nc_put_vara_double(ncid, varid, &index, &count, values_r8); printf("status = %d\n",status); nc_close(ncid); return 0; Error: return 1; }
netcdfgroup
archives: