[no subject]

Lakshmi,

> I am trying to put an AVHRR data set in to netCDF format. 
> 
> While doing this, I enountered a problem with ncgen. 

 ...

> When I execute ncgen,
> 
>        It defines all the dimentions, variables and attributes.
>        Then when it starts storing video_data, it core dumps with
>        segmentation fault.

The problem is caused by a bug in ncgen; it isn't checking the size of one
string before copying to the end of another string that might not have
enough space.  This occurs in using the "-c" option to ncgen to generate C
code.  Ncgen is generating a single C statement for initializing a variable
with lots of values at compile-time, and the statement is too long for the
character array in which the statement is constructed.  You can get around
the problem in any of the following ways:

 1.  Redefine the constant C_MAX_STMNT that defines the maximum length of a
     C statment in netcdf/src/ncgen.h to be as large as you need (currently
     it is 1320 characters), and then rebuild ncgen.  You may find that
     ncgen will succeed but your compiler will fail on extremely long C
     statements.  If you have a version of "indent" or "cb" that breaks long
     C lines into shorter lines, that might help.

 2.  Don't try to use compile-time initialization for large amounts of data,
     but read the values from a file and store them with a call to
     ncvarput() instead.

 3.  Leave off the "-c" option to ncgen if all you want to do is create the
     netCDF file from the CDL file; the "-n" option does that.

 4.  Wait until I fix ncgen to eliminate this limitation or emit a
     reasonable error message.  The fix, along with other miscellaneous bug
     fixes, support for SGI platforms, and support for long (instead of int)
     dimension values will be ready in the next release of netCDF, probably
     within the next couple of weeks.

--Russ


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