Re: netcdf-2.4.2 nclong problem

Willa,

> I appreciate it very much if anyone can offer me a clue about what
> would cause the problem with netcdf-2.4.2 described below.
> 
> I changed all "long" to "nclong" in my programs and recompiled them 
> with netcdf-2.4.2.    All programs failed on ncvarget() function
> with this error:  (I have tested both on Solaris and DEC/OSF1)
> 
>       ncvarget: xxx: Invalid Coordinates
> 
> where xxx is variable name. I have checked input arguments "nclong start"
> and "nclong count" which all contain right values.  Besides, all 
> these programs are working with old netcdf library.

You should not change all occurrences of "long" to "nclong", only in
declarations that declare types for *data* associated with the NC_LONG
netCDF external data type (32-bit integer).  In particular, the C prototype
for ncvarget is:

    extern int ncvarget(int ncid, int varid, const long* start, 
                        const long* count, void* value)

so the types of the "start" and "count" variables should be "long*", not
"nclong*".  The latter should result in a compile error, and won't work
correctly on platforms where the "nclong" typedef is different from "long".

Only the declaration for variables corresponding to the "value" argument in
the ncvarget/put and ncattget/put functions needs to be changed from "long"
to "nclong".  Or, as the release notes say:

    This means that C/C++ programs on platforms with

      sizeof(long) > sizeof(int)

    (e.g. the DEC Alpha) will have to be recompiled and must use nclong as
    the variable type corresponding to NC_LONG data. All programs that use
    NC_LONG data should also use the nclong data type to declare such data
    for portability.
    
The requirement that NC_LONG data be declared with the "nclong" typedef was
first introduced in netCDF version 2.3.2, although programs that use "long"
instead still work on platforms where sizeof(long) == sizeof(int).

This is explained more fully in the Users Guide in the section "Language Types
Corresponding to NetCDF Data Types", available on-line at

   http://www.unidata.ucar.edu/packages/netcdf/guide_9.html#SEC56

Please let me know if this needs further clarification.

--Russ

______________________________________________________________________________

Russ Rew                                           UCAR Unidata Program
russ@xxxxxxxxxxxxxxxx                              http://www.unidata.ucar.edu


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