Problems with char array

Hello all,

I'm quite the inexperienced netCDF user, and have a problem that I
haven't been able to solve.  

In a perl program, I extract character strings from a file, and
store them in an array, as so:

...
($site, ...) = split(' ', $_);

push(@Site, sprintf("\"%s\"", $site));
...

in order to have each member of Site be a string, as: "STRING"

My corresponding netcdf CDL definitions, for use with this array,
are as:

...
dimensions:
    recNum = UNLIMITED;
    staNamLen = 6;        // 5 chars + NULL

variables:
    char staNam(recNum, staNamLen);
...


Later on in the perl program, I write the strings to a file, as:

...
print(NCDF "// Station names\n\n");
print(NCDF "    staNam = ");
print(NCDF join(", ", @Site), ";\n\n");
...


This perl program generates an output file, which I intend as input
to ncgen. The output file is therefore a CDL file, with the
dimensions and variables above, as well as this, from the data section:

...
data:

// Station names

    staNam = "PLTC2", "WSMN5", "VCIO2", etc;
...

There are 27 strings stored in staNam, with the hope of storing more
in the future.  The output file, in CDL format, is generated just fine,
and then given as input to ncgen, as:  

% ncgen output.file

to check the syntax of the generated CDL file.  ncgen responds with:

ncgen: output.file line 106: string won't fit in this variable.

Line 106 happens to be the definition of staNam, shown above.
I'm at a loss regarding this error.  Any pointers would be most
appreciated, thank you.

-Rick.
grubin@xxxxxxxxxxxx


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