[ncl-talk] Seg fault when reading attribute from file

Kyle Griffin ksgriffin2 at wisc.edu
Thu Sep 17 09:31:11 MDT 2015


Yes, it's a seg fault, but it's quite simple to avoid. Trying to manually
read a variable's attribute from a file, and it turns out that this
attribute doesn't exist, results in a seg fault.
Lesson learned: don't read a variable's attribute if it doesn't exist.
Also, should specify that this is a true netCDF4 file. The same problem
doesn't occur with a smaller netCDF file. Both code segments are from
NCL6.3.0.


Kyle


netCDF4:

ncl 0> a=addfile("TEST_dp_stddev_0101.nc","r")

ncl 1> time=a->time

ncl 2> printVarSummary(time)


Variable: time

Type: double

Total Size: 992 bytes

            124 values

Number of Dimensions: 1

Dimensions and sizes: [time | 124]

Coordinates:

            time: [1262256..1262994]

ncl 3> time at units = a->time at units

Segmentation fault (core dumped)


netCDF3:


ncl 0> a=addfile("dp_climo_01.nc","r")

ncl 1> time=a->time

ncl 2> printVarSummary(time)


Variable: time

Type: double

Total Size: 992 bytes

            124 values

Number of Dimensions: 1

Dimensions and sizes: [time | 124]

Coordinates:

            time: [1262256..1262994]

Number Of Attributes: 1

  units : hours since 1800-01-01 00:00:00.0

ncl 3> time at units = a->time at blahblah

warning:FileReadVarAtt: (blahblah) is not an attribute of (time)
----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1407
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2 at wisc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150917/cd20263d/attachment.html 


More information about the ncl-talk mailing list