mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Fixed doxygen installation guide source file to preserve line breaks
in code and scripts. Fixed bug NCF-171: error reading external int into longlong or writing from longlong array to external int on 32-bit platforms and classic format files. Promoted test demonstrating NCF-171 bug from longlong array from "extra test" to "test".
This commit is contained in:
parent
dbaf62f5e6
commit
1f4eeafcb9
@ -328,7 +328,7 @@ swapn8b(void *dst, const void *src, size_t nn)
|
||||
|
||||
/* x_schar */
|
||||
|
||||
/* We don't implement and x_schar primitives. */
|
||||
/* We don't implement any x_schar primitives. */
|
||||
|
||||
|
||||
/* x_short */
|
||||
@ -756,37 +756,21 @@ ncx_get_int_uint(const void *xp, unsigned int *ip)
|
||||
int
|
||||
ncx_get_int_longlong(const void *xp, long long *ip)
|
||||
{
|
||||
#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
|
||||
get_ix_int(xp, (ix_int *)ip);
|
||||
return ENOERR;
|
||||
#else
|
||||
ix_int xx;
|
||||
get_ix_int(xp, &xx);
|
||||
*ip = xx;
|
||||
# if IX_INT_MAX > LONG_MAX /* unlikely */
|
||||
if(xx > LONG_MAX || xx < LONG_MIN)
|
||||
return NC_ERANGE;
|
||||
# endif
|
||||
return ENOERR;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
ncx_get_int_ulonglong(const void *xp, unsigned long long *ip)
|
||||
{
|
||||
#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
|
||||
get_ix_int(xp, (ix_int *)ip);
|
||||
return ENOERR;
|
||||
#else
|
||||
ix_int xx;
|
||||
get_ix_int(xp, &xx);
|
||||
*ip = xx;
|
||||
# if IX_INT_MAX > LONG_MAX /* unlikely */
|
||||
if(xx > LONG_MAX || xx < LONG_MIN)
|
||||
return NC_ERANGE;
|
||||
# endif
|
||||
if(xx < 0)
|
||||
return NC_ERANGE;
|
||||
return ENOERR;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
@ -2827,36 +2811,9 @@ ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *tp)
|
||||
NCX_GETN(int, int)
|
||||
NCX_GETN(int, uint)
|
||||
#endif
|
||||
#if X_SIZEOF_INT == SIZEOF_LONG
|
||||
/* optimized version */
|
||||
int
|
||||
ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
(void) memcpy(tp, *xpp, nelems * sizeof(long));
|
||||
# else
|
||||
swapn4b(tp, *xpp, nelems);
|
||||
# endif
|
||||
*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
int
|
||||
ncx_getn_int_ulonglong(const void **xpp, size_t nelems, unsigned long long *tp)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
(void) memcpy(tp, *xpp, nelems * sizeof(long));
|
||||
# else
|
||||
swapn4b(tp, *xpp, nelems);
|
||||
# endif
|
||||
*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
#else
|
||||
NCX_GETN(int, longlong)
|
||||
NCX_GETN(int, ulonglong)
|
||||
#endif
|
||||
|
||||
NCX_GETN(int, float)
|
||||
NCX_GETN(int, double)
|
||||
@ -2892,35 +2849,9 @@ ncx_putn_int_uint(void **xpp, size_t nelems, const unsigned int *tp)
|
||||
NCX_PUTN(int, int)
|
||||
NCX_PUTN(int, uint)
|
||||
#endif
|
||||
#if X_SIZEOF_INT == SIZEOF_LONG
|
||||
/* optimized version */
|
||||
int
|
||||
ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
|
||||
# else
|
||||
swapn4b(*xpp, tp, nelems);
|
||||
# endif
|
||||
*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
int
|
||||
ncx_putn_int_ulonglong(void **xpp, size_t nelems, const unsigned long long *tp)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
|
||||
# else
|
||||
swapn4b(*xpp, tp, nelems);
|
||||
# endif
|
||||
*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
|
||||
return ENOERR;
|
||||
}
|
||||
#else
|
||||
NCX_PUTN(int, longlong)
|
||||
NCX_PUTN(int, ulonglong)
|
||||
#endif
|
||||
NCX_PUTN(int, float)
|
||||
NCX_PUTN(int, double)
|
||||
|
||||
|
@ -93,17 +93,17 @@ services</a>.
|
||||
|
||||
Build zlib like this:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
./configure --prefix=/home/ed/local
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
Then you build HDF5, specifying the location of the zlib library:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
./configure --with-zlib=/home/ed/local --prefix=/home/ed/local
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
Note that for shared libraries, you may need to add the install
|
||||
directory to the LD_LIBRARY_PATH environment variable. See
|
||||
@ -117,10 +117,10 @@ After HDF5 is done, build netcdf, specifying the location of the
|
||||
HDF5, zlib, and (if built into HDF5) the szip header files and
|
||||
libraries in the CPPFLAGS and LDFLAGS environment variables. For example:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
CPPFLAGS=-I/home/ed/local/include LDFLAGS=-L/home/ed/local/lib ./configure --prefix=/home/ed/local
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
The configure script will try to find necessary tools in your
|
||||
path. When you run configure you may optionally use the --prefix
|
||||
@ -144,10 +144,10 @@ on OPeNDAP servers.)
|
||||
To build without support for the netCDF-4 formats or the additional
|
||||
netCDF-4 functions, but with remote access, use:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
./configure --prefix=/home/ed/local --disable-netcdf-4
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
(Replace ``/home/ed/local'' with the name of the directory where
|
||||
netCDF is to be installed.)
|
||||
@ -157,17 +157,17 @@ supported remote data access, using the OPeNDAP protocols. To build
|
||||
with full support for netCDF-4 APIs and format but without remote
|
||||
client access, use:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
./configure --prefix=/home/ed/local --disable-dap
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
To build without netCDF-4 support or remote client access, use:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
./configure --prefix=/home/ed/local --disable-netcdf-4 --disable-dap
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
If you get the message that netCDF installed correctly, then you are
|
||||
done!
|
||||
@ -193,10 +193,10 @@ the mpicc wrapper script, in the case of MPICH2.
|
||||
The following works to build HDF5 with parallel I/O on our netCDF
|
||||
testing system:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
CC=mpicc ./configure --enable-parallel --prefix=/shecky/local_par --with-zlib=/shecky/local_par
|
||||
make check install
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
If the HDF5 used by netCDF has been built with parallel I/O, then
|
||||
netCDF will also be built with support for parallel I/O. This allows
|
||||
@ -221,9 +221,9 @@ L) for the names of the libraries.
|
||||
For example, one user reports that she can build other applications
|
||||
with netCDF-4 by setting the LIBS environment variable:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
LIBS='-L/X/netcdf-4.0/lib -lnetcdf -L/X/hdf5-1.8.6/lib -lhdf5_hl -lhdf5 -lz -lm -L/X/szip-2.1/lib -lsz'
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
For shared builds, only -lnetcdf is needed. All other libraries will
|
||||
be found automatically.
|
||||
@ -234,9 +234,9 @@ needed for the local netCDF installation.
|
||||
For example, this works for linking an application named myapp.c with
|
||||
netCDF-4 libraries:
|
||||
|
||||
<code>
|
||||
\verbatim
|
||||
cc -o myapp myapp.c `nc-config --cflags --libs`
|
||||
</code>
|
||||
\endverbatim
|
||||
|
||||
\page configure_options ./configure options
|
||||
|
||||
|
@ -16,16 +16,15 @@ tst_diskless4.cdl tst_diskless4.nc
|
||||
|
||||
# These are the tests which are always run.
|
||||
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm tst_names \
|
||||
tst_nofill tst_nofill2 tst_nofill3
|
||||
tst_nofill tst_nofill2 tst_nofill3 tst_atts3
|
||||
|
||||
if USE_NETCDF4
|
||||
TESTPROGRAMS += tst_atts
|
||||
endif
|
||||
|
||||
# Tests bugs in netCDF-3 type conversions, move to always run after bugs are fixed
|
||||
if EXTRA_TESTS
|
||||
TESTPROGRAMS += tst_atts3
|
||||
endif # EXTRA_TESTS
|
||||
# if EXTRA_TESTS
|
||||
# TESTPROGRAMS +=
|
||||
# endif # EXTRA_TESTS
|
||||
|
||||
# These are the source files for the main workhorse test program,
|
||||
# nc_test. If you pass nc_test, you are doing well.
|
||||
|
@ -217,8 +217,7 @@ main(int argc, char **argv)
|
||||
/* for (i = 0; i < ATT_LEN; i++) */
|
||||
/* if (uint_in[i] != (unsigned int) int_out[i]) ERR; */
|
||||
|
||||
/* This is bug NCF-171: on 32-bit platforms, values returned
|
||||
don't zero out upper 4 bytes of long long */
|
||||
/* This was bug NCF-171: on 32-bit platforms, bad values returned */
|
||||
if (nc_get_att_longlong(ncid, NC_GLOBAL, ATT_INT_NAME, longlong_in)) ERR;
|
||||
for (i = 0; i < ATT_LEN; i++)
|
||||
if (longlong_in[i] != (long long) int_out[i]) ERR;
|
||||
@ -445,8 +444,7 @@ main(int argc, char **argv)
|
||||
for (i = 0; i < ATT_LEN; i++)
|
||||
if (longlong_in[i] != short_out[i]) ERR;
|
||||
if (nc_get_att_longlong(ncid, NC_GLOBAL, ATT_INT_NAME, longlong_in)) ERR;
|
||||
/* This is bug NCF-171: on 32-bit platforms, values returned
|
||||
don't zero out upper 4 bytes of long long */
|
||||
/* This was bug NCF-171: on 32-bit platforms, bad values returned */
|
||||
if (nc_get_att_longlong(ncid, NC_GLOBAL, ATT_INT_NAME, longlong_in)) ERR;
|
||||
for (i = 0; i < ATT_LEN; i++)
|
||||
if (longlong_in[i] != (long long) int_out[i]) ERR;
|
||||
|
Loading…
Reference in New Issue
Block a user