This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>Organization: Dept. of Oceanography, Dalhousie University >Keywords: 199502071539.AA01793 Hi Steven, > I've downloaded tbl2cdf this morning and tried to compile it. > > Am I doing something wrong? > > Skye$ gcc -o tbl2cdf -I/opt/netcdf/include -L/opt/netcdf/lib -lnetcdf > tbl2cdf.c > > tbl2cdf.c: In function `main': > tbl2cdf.c:606: warning: passing arg 3 of `ncvarput' from incompatible pointer > t > > ype > tbl2cdf.c:606: warning: passing arg 4 of `ncvarput' from incompatible pointer > t > > ype > tbl2cdf.c:639: warning: passing arg 3 of `ncvarput' from incompatible pointer > t > > ype > tbl2cdf.c:639: warning: passing arg 4 of `ncvarput' from incompatible pointer > t > > ype No, these warnings are because tbl2cdf.c has never been updated to use use longs instead of ints for coordinate indices (the `start' and `count' parameters to ncvarget() and ncvarput()). That change to netCDF was made in October 1991 with the release of version 2.0 of netCDF, to permit porting the code to 16-bit systems such as MSDOS. Here's a brief description of the change that was made to the netCDF interface at that time: ------ Wed Oct 9 1991 Changes in netCDF (1.11 to 2.0) The netCDF C interfaces were changed to use long values rather than ints for netCDF dimensions on all machines. This changed the following interfaces that formerly use "int" or "int*" for dimensions and dimension pointers: int ncdimdef(int cdfid, const char* name, int length); int ncdiminq(int cdfid, int dimid, char* name, int* length); int ncvarput1(int cdfid, int varid, int *coords, void* value); int ncvarget1(int cdfid, int varid, int *coords, void* value); int ncvarput(int cdfid, int varid, int *start, int *count, void* value); int ncvarget(int cdfid, int varid, int *start, int *count, void* value); to use "long" or "long*" instead: int ncdimdef(int cdfid, const char* name, long length); int ncdiminq(int cdfid, int dimid, char* name, long* length); int ncvarput1(int cdfid, int varid, long *coords, void* value); int ncvarget1(int cdfid, int varid, long *coords, void* value); int ncvarput(int cdfid, int varid, long *start, long *count, void* value); int ncvarget(int cdfid, int varid, long *start, long *count, void* value); No change to data representation or file formats was required, since the XDR form of integers is 32 bits. The main advantage of this change is that on platforms such as MSDOS machines on which integers are only 16 bits, it is now possible to access data from variables that have a dimension greater than 32767. This is of some practical importance, since CD-ROM disks are being written with large datasets in netCDF form, and it is desirable to be able to access this data from inexpensive 16-bit machines. Since ints and longs are the same on most current platforms (Suns, DECstations, VAXen, IBM RS6000s, SGIs, HPs, CRAYs, ...), this change does not break old code. Applications compiled with the old interface on such machines will work the same way as they did before without recompiling. Standard C compilers that support prototypes permit using int values for dimension size and automatically convert them to longs before the call. C code that uses pointers to ints instead of pointers to longs (where required by the new interfaces) will elicit warning messages from lint and from The tbl2cdf.c program is part of the collection of user-contributed netCDF software, and as such is maintained by the contributors rather than Unidata. I've CC:ed Chuck Denham, the author of this program, on this reply, in case he has a newer version we can upload into the pub/netcdf/contrib/ directory of our FTP server. If the email address I have for him isn't obsolete, he may see this (Hi, Chuck!). > ld: Undefined symbol > _ncclose > _ncdimdef > _nccreate > _ncattput > _ncvardef > _ncvarput > _ncendef > ld: l.outa05711: Permission denied > ld: l.outa05711: output write error: Bad file number > collect2: ld returned 2 exit status These messages indicate some sort of problem with the way you have specified to gcc where to find the netCDF library, or problems with the installation of that library (was it also built with gcc?). If the `make test' worked OK before you installed the netCDF library, you might check how gcc was invoked to successfully link nctest.c to the netCDF library and imitate that. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden P.O. Box 3000 http://www.unidata.ucar.edu/ Boulder, CO 80307-3000 ______________________________________________________________________________