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

Re: 20020228: problems with 2 large double arrays



>To: address@hidden
>From: Laura Scott <address@hidden>
>Subject: problems with 2 large double arrays
>Organization: UCAR/Unidata
>Keywords: 200202281919.g1SJJxx27621

Hi Laura,

> I need to create two arrays for a netCDF file, one is 32767x42 char and
> the other is 32767x255 char.  My initial requirements were for just the
> first array.  No matter what I tried to do to initialize that array - I
> would get several records of just memory garbage.
> 
> NOTE: I add a datafile name to this array each time a new file is
> entered into my archive system, so when I create the netCDF datafile,
> only one array is filled and the others I would like to be empty
> strings.  As each new file enters the archive - I get this array and
> look for the first "" entry, add my new filename into that position and
> put the data back into the netCDF file.
> 
> When my requirements changed and I had to add the second array - I get a
> segmentation fault when the varput command is called.  If I reduce the
> first dimension of the second array (say to 500) for the varput command
> - no seg fault.  I might add that I still have the vardef for 32767,255?
> 
> So basically - I was wondering how I can cleanly define these two large
> arrays, initialize them to "", and not get a seg fault when I write the
> netCDF datafile out?  I am using C 4.0 version on a UNIX box.

One simple way to initialize the file is to use the "ncgen" utility to
generate the netCDF file from the following CDL:

netcdf filelist {
dimensions:
        NF = 32767;
        alen = 42;
        blen = 255;
variables:
        char a(NF,alen);
        char b(NF,blen);
data:
        a = "";
        b = "";
}

If you store the above in a file named "filelist.cdl", for example and
then invoke the command:

  ncgen -o filelist.nc -b filelist.cdl

it will create the output binary netCDF file "filelist.nc" from the
input text CDL file "filelist.cdl".

If you would rather have a program to initialize the file, you should
be able to use ncgen to do that too.  For example, to get a Fortran
program that will initialize the file, you would typically use:

  ncgen -f filelist.cdl > filelist.f

and similarly for C with a "-c" flag.  However, the simple example
above reveals a bug in ncgen for generating the Fortran or C to
initialize large text arrays, so unfortunately the above will not work
in this case.  I've filed a bug report on this ncgen bug, but it
shouldn't prevent you from being able to append new data to the file.

If you can send us the program for how you are trying to add data to
the file, we can see if we can determine what's causing the problem.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu