[netcdfgroup] Opendap problem

NetCDF group,

Recently we are testing opendap with NetCDF.
Our code give segmentation vault, and we trace back this to NetCDF opendap.

The link we tried is:
http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.dailyavgs/pressure/air.1948.nc

We tried "ncdump -h …", which worked fine, but "ncdump -v air …" gave 
segmentation fault.

We tried a simple c code, below, which give segmentation fault as well.

Has anyone seen this before?

Thanks,

Wei

---------
C - code:

#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

int main(int *argc, char **argv)
{
    char flnm[] = 
"http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.dailyavgs/pressure/air.1948.nc";;
    int status;                        /* error status */
    int ncid;                          /* netCDF ID */
    int varid;                         /* variable ID */
    static size_t start[16];
    static size_t count[16];
    short  *vals;
    nc_type type;                  /* variable type */
    int ndims;                     /* number of dims */
    int dimids[NC_MAX_VAR_DIMS];   /* dimension IDs */
    int natts;                     /* number of attributes */
    int nvars, ngatts, unlimdimid;
    size_t length, recs;
    char recname[NC_MAX_NAME+1];
    int n;

    status = nc_open(flnm, NC_NOWRITE, &ncid);
  /*
   *if (status != NC_NOERR) handle_error(status);
   */

    fprintf(stderr, "ncid = %d\n", ncid);

    status = nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid);

    status = nc_inq_varid(ncid, "air", &varid);

    fprintf(stderr, "varid = %d\n", varid);

    status = nc_inq_var(ncid, varid, 0, &type, &ndims, dimids,
                        &natts);

    length = 1;
    for(n = 0; n < ndims; ++n)
    {
        status = nc_inq_dim(ncid, dimids[n], recname, &count[n]);
        fprintf(stderr, "dim %d: id = %d, name: <%s>, length = %ld\n",
                n, dimids[n], recname, (long) count[n]);
        length *= count[n];
        start[n] = 0;
    }

    fprintf(stderr, "length = %ld\n", (long) length);

    vals = (short *) malloc(length * sizeof(short));

  /*read values*/
    status = nc_get_vara(ncid, varid, start, count, vals);

    fprintf(stderr, "vals[0] = %d\n", vals[0]);

    free(vals);

    return ( 0 );
}


Error message:

ncid = 65536
varid = 4
dim 0: id = 0, name: <time>, length = 366
dim 1: id = 2, name: <level>, length = 17
dim 2: id = 1, name: <lat>, length = 73
dim 3: id = 3, name: <lon>, length = 144
length = 65405664

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
0x000000010003163c in buildcachenode34 (nccomm=0x100f15c00, 
constraint=0x102602650, varlist=0x102602490, cachep=0x7fff5fbfb148, 
isprefetch=0) at cache.c:231
231                 cache->cachesize -= node->xdrsize;
(gdb) where
#0  0x000000010003163c in buildcachenode34 (nccomm=0x100f15c00, 
constraint=0x102602650, varlist=0x102602490, cachep=0x7fff5fbfb148, 
isprefetch=0) at cache.c:231
#1  0x0000000100046998 in nc3d_getvarx (ncid=65536, varid=4, 
startp=0x1004679e0, countp=0x100467960, stridep=0x10048b2a0, data=0x104000000, 
dsttype0=3) at getvara3.c:192
#2  0x000000010004a9fb in NCD3_get_vara (ncid=65536, varid=4, 
start=0x1004679e0, edges=0x100467960, value=0x104000000, memtype=3) at 
ncd3dispatch.c:203
#3  0x0000000100008b90 in NC_get_vara (ncid=65536, varid=4, start=0x1004679e0, 
edges=0x100467960, value=0x104000000, memtype=3) at var.c:172
#4  0x000000010000a7df in nc_get_vara (ncid=65536, varid=4, start=0x1004679e0, 
edges=0x100467960, value=0x104000000) at var.c:939
#5  0x0000000100001ab2 in main ()





huangwei@xxxxxxxx
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924






  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: