[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20020107: ncgen issue



>To: address@hidden
>From: Roy Britten <address@hidden>
>Subject: ncgen issue
>Organization: QSS Group, Inc., NASA Ames Research Center
>Keywords: 200201072127.g07LRhN00541, ncgen bug, multidimensional text variables

Hi Roy,

I've got a fix for the ncgen bug report you sent in; thanks for
reporting the problem.  You can either do a one-line patch to a source
file and rebuild ncgen or you can get a copy of netCDF-3.5.1-beta3
that has the fix and rebuild from that.

The one-line patch for ncgen/ncgentab.c is to replace the statement

                               var_len += rec_len * (1 + valnum - 
var_len)/rec_len;

with

                               var_len = rec_len * (1 + valnum / rec_len);

and then invoke "make in the ncgen directory, and then "make install"
after you've verified the fix..

I've tested this in netCDF 3.5.0 and 3.5.1-beta2, but I'm fairly
confident it will work for netCDF 3.4 as well.

Alternatively, if you want to build a release with the fix already
incorporated, get:

  ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-3.5.1-beta3.tar.Z

The problem manifested itself on IRIX platforms for multidimensional
text variables parsed from CDL, but the underlying problem bug
involved calling realloc() too often.  SGI's realloc seems to be
stricter than on other platforms in moving only the allocated space
and no extra space when a realloc is necessary, so the error that was
occurring on other platforms was masked by moving a larger block of
allocated space than absolutely necessary or by moving the block into
zeroed out memory.

Anyway, please let us know if the above doesn't fix the problem and
thanks again for providing the bug report.

--Russ

You wrote:

> I've encountered a problem using ncgen that I would appreciate your
> advice on. We're currently looking at using netCDF to temporarily store
> large sets of character string data (not my decision ...); ncgen is
> failing in the following manner:
> 
> ncgen:
> ncgen: -: netcdf library version 3.4 of Oct 28 1999 20:27:24 $
> ncdump:
> netcdf library version 3.4 of Oct 28 1999 20:27:24 $
> platform:
> IRIX64 6.5
> 
> I use here a simple example where we assume that we wish to store
> character strings of max length 20 characters, in "clusters" of 4
> strings:
> 
> netcdf problem {
> dimensions:
>       strlen = 20;
>       numfields = 4;
>       numrecords = unlimited;
> variables:
>       char    fieldnames      (numrecords, numfields, strlen);
> data:
>  fieldnames =
> 
>       "a",
>       "b",
>       "c",
>       "d",
> 
>       "e",
>       "f",
>       "g",
>       "h";
> }
> 
> 
> ncgen -b will run on this file, but when the output is run through
> ncdump the following output results:
> 
> 
> netcdf problem {
> dimensions:
>         strlen = 20 ;
>         numfields = 4 ;
>         numrecords = UNLIMITED ; // (2 currently)
> variables:
>         char fieldnames(numrecords, numfields, strlen) ;
> data:
> 
>  fieldnames =
>   "a",
>   "b",
>   "c",
>   "d",
>   "e",
>   "f",
>   "g\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000c",
>   "h" ;
> }
> 
> 
> Furthermore, as soon as another character string is added to the data,
> taking the value of numrecords > 2, we dump core:
> 
> 
> $ ncgen -b problem.cdl
> Bus error (core dumped)
> 
> 
> However, if numrecords is changed from unlimited to any appropriate
> value, ncgen runs without crashing, and ncdump reports the expected
> result, for all data sizes that I've attempted (up to ~10kB).
> 
> Is this a known issue?
> 
> Thanks,
> Roy Britten.
> 
> 
> -- 
> Roy Britten                                address@hidden
> QSS Group, Inc.                            Phone: (650) 604-4532
> NASA Ames Research Center, MS 269-1        Fax:   (650) 604-3594
> Moffett Field, CA 94035-1000, USA          Bldg. N269, Rm. 260x21