segmentation fault: gasdf.c:3237, index out of bound

Ryo Furue furue at HAWAII.EDU
Mon Feb 18 04:40:04 EST 2008


Dear GrADS maintainers,

I'd like to report a bug.

For a netCDF file, line 3237

  3237   fgrid[ginx] = fakefgrid[indx] ;

of gasdf.c causes a segmentation fault.  It turns out that ginx
gets a negative value, which in turn is caused by

  3230   ginx = (gtinx - gridptr->dimmin[GTINDEX]) * zyxsize +
  3231          (gzinx - gridptr->dimmin[GZINDEX]) * yxsize +
  3232          (gyinx - gridptr->dimmin[GYINDEX]) * gxsize +
  3233          (gxinx - gridptr->dimmin[GXINDEX]) ;

where

   gtinx == 1
   gridptr->dimmin[GTINDEX] == 1
   gzinx == 1
   gridptr->dimmin[GZINDEX] == 30
   gyinx == 1
   gridptr->dimmin[GYINDEX] == 1
   gxinx == 1
   gridptr->dimmin[GXINDEX] == 1

Another, probably related oddity is that GrADS seems to be confused
about a vertical axis with an attribute 'positive = "down" '.
Index 1 of my depth coordinate corresponds the shallowest level
and index 30 corresponds to the deepest.  But, in GrADS, z = 1
corresponds to the deepest level.  I suspect this is the reason
for gridptr->dimmin[GZINDEX] == 30 and gzinx == 1 .

Here is how the vertical axis is defined (from ncdump -h):

 float dep(dep) ;
   dep:units = "meters" ;
   dep:axis = "Z" ;
   dep:positive = "down" ;

 dep = 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115.9789, 129.7985,
    148.0428, 171.8625, 201.8625, 238.0428, 279.7985, 325.9789, 375, 425,
    491.1513, 604.1757, 790.2066, 1068.231, 1448.231, 1930.207, 2504.176,
    3151.151, 3845 ;

I can send you my netCDF file as well as an instruction on how to
reproduce the segmentation fault.

I'm using grads-1.9b4 on Linux.

Regards,
Ryo



More information about the gradsusr mailing list