fixed quick_small_files.c

This commit is contained in:
Ed Hartnett 2019-07-02 08:53:26 -06:00
parent e3f6a705b4
commit a4a8bdf7a1
3 changed files with 13 additions and 10 deletions

View File

@ -17,9 +17,9 @@ AM_LDFLAGS = ${top_builddir}/liblib/libnetcdf.la
# These are the netCDF-3 examples.
check_PROGRAMS = simple_xy_wr simple_xy_rd sfc_pres_temp_wr \
sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd format \
quick_large_files quick_small_files
quick_large_files quick_small_files sfc_pres_temp_more
TESTS = run_examples.sh format quick_large_files
TESTS = run_examples.sh format quick_large_files quick_small_files
# To build netcdf-4, or not to build netcdf-4, that is the question...
if USE_HDF5

View File

@ -37,8 +37,9 @@ return NC_EXAMPLE_ERROR; \
#define NUMVARS 2
/* This dim len is the max size the first of two fixed size variables
for an 8-byte type in classic format: int((2*31 - 4) / 8), that is,
2 GB minus a bit, on an 8 byte boundary. */
#define DIM_LEN 268435455
2 GB minus a bit, on an 8 byte boundary. That number is
268435455. But this is the longest dim len which works. */
#define DIM_LEN 268435440
int
main()

View File

@ -9,9 +9,11 @@
* pressure and temperatures, and stores additional metadata as
* dimension variables, an attribute.
*
* @author Ed Hartnett 2006/03/25
* @author Ed Hartnett started 2006/03/25, finished 2019/7/2
*/
#include <netcdf.h>
#include <stdlib.h>
#include <string.h>
#define FILE_NAME "sfc_pres_temp_more.nc"
#define NDIMS 2
@ -113,9 +115,9 @@ main()
return retval;
/* Write the phoney data. */
if ((retval = nc_put_var_float(ncid, pres_varid, pres_out)))
if ((retval = nc_put_var_float(ncid, pres_varid, (float *)pres_out)))
return retval;
if ((retval = nc_put_var_float(ncid, temp_varid, temp_out)))
if ((retval = nc_put_var_float(ncid, temp_varid, (float *)temp_out)))
return retval;
/* Close the file. */
@ -132,16 +134,16 @@ main()
return retval;
if (!(att_in = malloc(len_in)))
return NC_ENOMEM;
if (strcmp(att_in, data_poem))
if (strcmp(att_in, poem))
error++;
free(att_in);
if (error)
return -2;
/* Read the data. */
if ((retval = nc_get_var_float(ncid, pres_varid, pres_in)))
if ((retval = nc_get_var_float(ncid, pres_varid, (float *)pres_in)))
return retval;
if ((retval = nc_get_var_float(ncid, temp_varid, temp_in)))
if ((retval = nc_get_var_float(ncid, temp_varid, (float *)temp_in)))
return retval;
/* Check the data. */