mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-05 16:20:10 +08:00
Merge pull request #1013 from NetCDF-World-Domination-Council/ejh_long_2
removed dead code associated with old handling of NC_LONG, fixed test checking NC_ELATEFILL
This commit is contained in:
commit
eca9cdb7ee
@ -351,8 +351,7 @@ int nc4_get_typelen_mem(NC_HDF5_FILE_INFO_T *h5, nc_type xtype, size_t *len);
|
|||||||
int nc4_convert_type(const void *src, void *dest,
|
int nc4_convert_type(const void *src, void *dest,
|
||||||
const nc_type src_type, const nc_type dest_type,
|
const nc_type src_type, const nc_type dest_type,
|
||||||
const size_t len, int *range_error,
|
const size_t len, int *range_error,
|
||||||
const void *fill_value, int strict_nc3, int src_long,
|
const void *fill_value, int strict_nc3);
|
||||||
int dest_long);
|
|
||||||
|
|
||||||
/* These functions do HDF5 things. */
|
/* These functions do HDF5 things. */
|
||||||
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
|
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
|
||||||
@ -360,9 +359,9 @@ int rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
|
|||||||
int delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim);
|
int delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim);
|
||||||
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
|
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
|
||||||
int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||||
const size_t *countp, nc_type xtype, int is_long, void *op);
|
const size_t *countp, nc_type xtype, void *op);
|
||||||
int nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
int nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||||
const size_t *countp, nc_type xtype, int is_long, void *op);
|
const size_t *countp, nc_type xtype, void *op);
|
||||||
int nc4_rec_match_dimscales(NC_GRP_INFO_T *grp);
|
int nc4_rec_match_dimscales(NC_GRP_INFO_T *grp);
|
||||||
int nc4_rec_detect_need_to_preserve_dimids(NC_GRP_INFO_T *grp, nc_bool_t *bad_coord_orderp);
|
int nc4_rec_detect_need_to_preserve_dimids(NC_GRP_INFO_T *grp, nc_bool_t *bad_coord_orderp);
|
||||||
int nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order);
|
int nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order);
|
||||||
|
@ -96,7 +96,7 @@ NC_HDF4_get_vara(int ncid, int varid, const size_t *startp,
|
|||||||
if (var->type_info->hdr.id != memtype)
|
if (var->type_info->hdr.id != memtype)
|
||||||
{
|
{
|
||||||
if ((retval = nc4_convert_type(data, ip, var->type_info->hdr.id, memtype, nelem,
|
if ((retval = nc4_convert_type(data, ip, var->type_info->hdr.id, memtype, nelem,
|
||||||
&range_error, NULL, 0, 0, 0)))
|
&range_error, NULL, 0)))
|
||||||
return retval;
|
return retval;
|
||||||
free(data);
|
free(data);
|
||||||
if (range_error)
|
if (range_error)
|
||||||
|
@ -581,7 +581,7 @@ NC4_put_att(int ncid, int varid, const char *name, nc_type file_type,
|
|||||||
/* Data types are like religions, in that one can convert. */
|
/* Data types are like religions, in that one can convert. */
|
||||||
if ((retval = nc4_convert_type(data, att->data, mem_type, file_type,
|
if ((retval = nc4_convert_type(data, att->data, mem_type, file_type,
|
||||||
len, &range_error, NULL,
|
len, &range_error, NULL,
|
||||||
(h5->cmode & NC_CLASSIC_MODEL), 0, 0)))
|
(h5->cmode & NC_CLASSIC_MODEL))))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
208
libhdf5/nc4hdf.c
208
libhdf5/nc4hdf.c
@ -650,7 +650,6 @@ set_par_access(NC_HDF5_FILE_INFO_T *h5, NC_VAR_INFO_T *var, hid_t xfer_plistid)
|
|||||||
* @param startp Array of start indices.
|
* @param startp Array of start indices.
|
||||||
* @param countp Array of counts.
|
* @param countp Array of counts.
|
||||||
* @param mem_nc_type The type of the data in memory.
|
* @param mem_nc_type The type of the data in memory.
|
||||||
* @param is_long True only if NC_LONG is the memory type.
|
|
||||||
* @param data The data to be written.
|
* @param data The data to be written.
|
||||||
*
|
*
|
||||||
* @returns ::NC_NOERR No error.
|
* @returns ::NC_NOERR No error.
|
||||||
@ -667,7 +666,7 @@ set_par_access(NC_HDF5_FILE_INFO_T *h5, NC_VAR_INFO_T *var, hid_t xfer_plistid)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||||
const size_t *countp, nc_type mem_nc_type, int is_long, void *data)
|
const size_t *countp, nc_type mem_nc_type, void *data)
|
||||||
{
|
{
|
||||||
NC_GRP_INFO_T *grp;
|
NC_GRP_INFO_T *grp;
|
||||||
NC_HDF5_FILE_INFO_T *h5;
|
NC_HDF5_FILE_INFO_T *h5;
|
||||||
@ -694,8 +693,8 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
h5 = NC4_DATA(nc);
|
h5 = NC4_DATA(nc);
|
||||||
assert(grp && h5 && var && var->hdr.name);
|
assert(grp && h5 && var && var->hdr.name);
|
||||||
|
|
||||||
LOG((3, "%s: var->hdr.name %s mem_nc_type %d is_long %d",
|
LOG((3, "%s: var->hdr.name %s mem_nc_type %d",
|
||||||
__func__, var->hdr.name, mem_nc_type, is_long));
|
__func__, var->hdr.name, mem_nc_type));
|
||||||
|
|
||||||
/* Check some stuff about the type and the file. If the file must
|
/* Check some stuff about the type and the file. If the file must
|
||||||
* be switched from define mode, it happens here. */
|
* be switched from define mode, it happens here. */
|
||||||
@ -779,7 +778,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
|
|
||||||
/* Are we going to convert any data? (No converting of compound or
|
/* Are we going to convert any data? (No converting of compound or
|
||||||
* opaque types.) */
|
* opaque types.) */
|
||||||
if ((mem_nc_type != var->type_info->hdr.id || (var->type_info->hdr.id == NC_INT && is_long)) &&
|
if (mem_nc_type != var->type_info->hdr.id &&
|
||||||
mem_nc_type != NC_COMPOUND && mem_nc_type != NC_OPAQUE)
|
mem_nc_type != NC_COMPOUND && mem_nc_type != NC_OPAQUE)
|
||||||
{
|
{
|
||||||
size_t file_type_size;
|
size_t file_type_size;
|
||||||
@ -901,7 +900,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
{
|
{
|
||||||
if ((retval = nc4_convert_type(data, bufr, mem_nc_type, var->type_info->hdr.id,
|
if ((retval = nc4_convert_type(data, bufr, mem_nc_type, var->type_info->hdr.id,
|
||||||
len, &range_error, var->fill_value,
|
len, &range_error, var->fill_value,
|
||||||
(h5->cmode & NC_CLASSIC_MODEL), is_long, 0)))
|
(h5->cmode & NC_CLASSIC_MODEL))))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,7 +952,6 @@ exit:
|
|||||||
* @param countp Array of counts.
|
* @param countp Array of counts.
|
||||||
* @param mem_nc_type The type of the data in memory. (Convert to this
|
* @param mem_nc_type The type of the data in memory. (Convert to this
|
||||||
* type from file type.)
|
* type from file type.)
|
||||||
* @param is_long True only if NC_LONG is the memory type.
|
|
||||||
* @param data The data to be written.
|
* @param data The data to be written.
|
||||||
*
|
*
|
||||||
* @returns ::NC_NOERR No error.
|
* @returns ::NC_NOERR No error.
|
||||||
@ -970,7 +968,7 @@ exit:
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
||||||
const size_t *countp, nc_type mem_nc_type, int is_long, void *data)
|
const size_t *countp, nc_type mem_nc_type, void *data)
|
||||||
{
|
{
|
||||||
NC_GRP_INFO_T *grp;
|
NC_GRP_INFO_T *grp;
|
||||||
NC_HDF5_FILE_INFO_T *h5;
|
NC_HDF5_FILE_INFO_T *h5;
|
||||||
@ -998,8 +996,8 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
h5 = NC4_DATA(nc);
|
h5 = NC4_DATA(nc);
|
||||||
assert(grp && h5 && var && var->hdr.name);
|
assert(grp && h5 && var && var->hdr.name);
|
||||||
|
|
||||||
LOG((3, "%s: var->hdr.name %s mem_nc_type %d is_long %d",
|
LOG((3, "%s: var->hdr.name %s mem_nc_type %d",
|
||||||
__func__, var->hdr.name, mem_nc_type, is_long));
|
__func__, var->hdr.name, mem_nc_type));
|
||||||
|
|
||||||
/* Check some stuff about the type and the file. */
|
/* Check some stuff about the type and the file. */
|
||||||
if ((retval = check_for_vara(&mem_nc_type, var, h5)))
|
if ((retval = check_for_vara(&mem_nc_type, var, h5)))
|
||||||
@ -1151,7 +1149,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
|
|
||||||
/* Are we going to convert any data? (No converting of compound or
|
/* Are we going to convert any data? (No converting of compound or
|
||||||
* opaque types.) */
|
* opaque types.) */
|
||||||
if ((mem_nc_type != var->type_info->hdr.id || (var->type_info->hdr.id == NC_INT && is_long)) &&
|
if (mem_nc_type != var->type_info->hdr.id &&
|
||||||
mem_nc_type != NC_COMPOUND && mem_nc_type != NC_OPAQUE)
|
mem_nc_type != NC_COMPOUND && mem_nc_type != NC_OPAQUE)
|
||||||
{
|
{
|
||||||
/* We must convert - allocate a buffer. */
|
/* We must convert - allocate a buffer. */
|
||||||
@ -1194,7 +1192,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
{
|
{
|
||||||
if ((retval = nc4_convert_type(bufr, data, var->type_info->hdr.id, mem_nc_type,
|
if ((retval = nc4_convert_type(bufr, data, var->type_info->hdr.id, mem_nc_type,
|
||||||
len, &range_error, var->fill_value,
|
len, &range_error, var->fill_value,
|
||||||
(h5->cmode & NC_CLASSIC_MODEL), 0, is_long)))
|
(h5->cmode & NC_CLASSIC_MODEL))))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
|
|
||||||
/* For strict netcdf-3 rules, ignore erange errors between UBYTE
|
/* For strict netcdf-3 rules, ignore erange errors between UBYTE
|
||||||
@ -2851,25 +2849,20 @@ nc4_rec_write_groups_types(NC_GRP_INFO_T *grp)
|
|||||||
* @param range_error Pointer that gets 1 if there was a range error.
|
* @param range_error Pointer that gets 1 if there was a range error.
|
||||||
* @param fill_value The fill value.
|
* @param fill_value The fill value.
|
||||||
* @param strict_nc3 Non-zero if strict model in effect.
|
* @param strict_nc3 Non-zero if strict model in effect.
|
||||||
* @param src_long Is the source NC_LONG?
|
|
||||||
* @param dest_long Is the destination NC_LONG?
|
|
||||||
*
|
*
|
||||||
* @returns NC_NOERR No error.
|
* @returns NC_NOERR No error.
|
||||||
* @returns NC_EBADTYPE Type not found.
|
* @returns NC_EBADTYPE Type not found.
|
||||||
* @author Ed Hartnett
|
* @author Ed Hartnett
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
nc4_convert_type(const void *src, void *dest,
|
nc4_convert_type(const void *src, void *dest, const nc_type src_type,
|
||||||
const nc_type src_type, const nc_type dest_type,
|
const nc_type dest_type, const size_t len, int *range_error,
|
||||||
const size_t len, int *range_error,
|
const void *fill_value, int strict_nc3)
|
||||||
const void *fill_value, int strict_nc3, int src_long,
|
|
||||||
int dest_long)
|
|
||||||
{
|
{
|
||||||
char *cp, *cp1;
|
char *cp, *cp1;
|
||||||
float *fp, *fp1;
|
float *fp, *fp1;
|
||||||
double *dp, *dp1;
|
double *dp, *dp1;
|
||||||
int *ip, *ip1;
|
int *ip, *ip1;
|
||||||
signed long *lp, *lp1;
|
|
||||||
short *sp, *sp1;
|
short *sp, *sp1;
|
||||||
signed char *bp, *bp1;
|
signed char *bp, *bp1;
|
||||||
unsigned char *ubp, *ubp1;
|
unsigned char *ubp, *ubp1;
|
||||||
@ -2880,8 +2873,8 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
*range_error = 0;
|
*range_error = 0;
|
||||||
LOG((3, "%s: len %d src_type %d dest_type %d src_long %d dest_long %d",
|
LOG((3, "%s: len %d src_type %d dest_type %d",
|
||||||
__func__, len, src_type, dest_type, src_long, dest_long));
|
__func__, len, src_type, dest_type));
|
||||||
|
|
||||||
/* OK, this is ugly. If you can think of anything better, I'm open
|
/* OK, this is ugly. If you can think of anything better, I'm open
|
||||||
to suggestions!
|
to suggestions!
|
||||||
@ -2933,18 +2926,9 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
{
|
|
||||||
for (bp = (signed char *)src, lp = dest; count < len; count++)
|
|
||||||
*lp++ = *bp++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (bp = (signed char *)src, ip = dest; count < len; count++)
|
for (bp = (signed char *)src, ip = dest; count < len; count++)
|
||||||
*ip++ = *bp++;
|
*ip++ = *bp++;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case NC_UINT:
|
case NC_UINT:
|
||||||
for (bp = (signed char *)src, uip = dest; count < len; count++)
|
for (bp = (signed char *)src, uip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
@ -3004,18 +2988,9 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
*usp++ = *ubp++;
|
*usp++ = *ubp++;
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
{
|
|
||||||
for (ubp = (unsigned char *)src, lp = dest; count < len; count++)
|
|
||||||
*lp++ = *ubp++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ubp = (unsigned char *)src, ip = dest; count < len; count++)
|
for (ubp = (unsigned char *)src, ip = dest; count < len; count++)
|
||||||
*ip++ = *ubp++;
|
*ip++ = *ubp++;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case NC_UINT:
|
case NC_UINT:
|
||||||
for (ubp = (unsigned char *)src, uip = dest; count < len; count++)
|
for (ubp = (unsigned char *)src, uip = dest; count < len; count++)
|
||||||
*uip++ = *ubp++;
|
*uip++ = *ubp++;
|
||||||
@ -3075,10 +3050,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (sp = (short *)src, lp = dest; count < len; count++)
|
|
||||||
*lp++ = *sp++;
|
|
||||||
else
|
|
||||||
for (sp = (short *)src, ip = dest; count < len; count++)
|
for (sp = (short *)src, ip = dest; count < len; count++)
|
||||||
*ip++ = *sp++;
|
*ip++ = *sp++;
|
||||||
break;
|
break;
|
||||||
@ -3149,10 +3120,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
*usp1++ = *usp++;
|
*usp1++ = *usp++;
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (usp = (unsigned short *)src, lp = dest; count < len; count++)
|
|
||||||
*lp++ = *usp++;
|
|
||||||
else
|
|
||||||
for (usp = (unsigned short *)src, ip = dest; count < len; count++)
|
for (usp = (unsigned short *)src, ip = dest; count < len; count++)
|
||||||
*ip++ = *usp++;
|
*ip++ = *usp++;
|
||||||
break;
|
break;
|
||||||
@ -3184,98 +3151,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (src_long)
|
|
||||||
{
|
|
||||||
switch (dest_type)
|
|
||||||
{
|
|
||||||
case NC_UBYTE:
|
|
||||||
for (lp = (long *)src, ubp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_UCHAR_MAX || *lp < 0)
|
|
||||||
(*range_error)++;
|
|
||||||
*ubp++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_BYTE:
|
|
||||||
for (lp = (long *)src, bp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_SCHAR_MAX || *lp < X_SCHAR_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*bp++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_SHORT:
|
|
||||||
for (lp = (long *)src, sp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_SHORT_MAX || *lp < X_SHORT_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*sp++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_USHORT:
|
|
||||||
for (lp = (long *)src, usp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_USHORT_MAX || *lp < 0)
|
|
||||||
(*range_error)++;
|
|
||||||
*usp++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_INT: /* src is long */
|
|
||||||
if (dest_long)
|
|
||||||
{
|
|
||||||
for (lp = (long *)src, lp1 = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_LONG_MAX || *lp < X_LONG_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp1++ = *lp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* dest is int */
|
|
||||||
{
|
|
||||||
for (lp = (long *)src, ip = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_INT_MAX || *lp < X_INT_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*ip++ = *lp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_UINT:
|
|
||||||
for (lp = (long *)src, uip = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp > X_UINT_MAX || *lp < 0)
|
|
||||||
(*range_error)++;
|
|
||||||
*uip++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_INT64:
|
|
||||||
for (lp = (long *)src, lip = dest; count < len; count++)
|
|
||||||
*lip++ = *lp++;
|
|
||||||
break;
|
|
||||||
case NC_UINT64:
|
|
||||||
for (lp = (long *)src, ulip = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lp < 0)
|
|
||||||
(*range_error)++;
|
|
||||||
*ulip++ = *lp++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NC_FLOAT:
|
|
||||||
for (lp = (long *)src, fp = dest; count < len; count++)
|
|
||||||
*fp++ = *lp++;
|
|
||||||
break;
|
|
||||||
case NC_DOUBLE:
|
|
||||||
for (lp = (long *)src, dp = dest; count < len; count++)
|
|
||||||
*dp++ = *lp++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG((0, "%s: unexpected dest type. src_type %d, dest_type %d",
|
|
||||||
__func__, src_type, dest_type));
|
|
||||||
return NC_EBADTYPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (dest_type)
|
switch (dest_type)
|
||||||
{
|
{
|
||||||
case NC_UBYTE:
|
case NC_UBYTE:
|
||||||
@ -3311,24 +3186,12 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT: /* src is int */
|
case NC_INT: /* src is int */
|
||||||
if (dest_long)
|
|
||||||
{
|
|
||||||
for (ip = (int *)src, lp1 = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*ip > X_LONG_MAX || *ip < X_LONG_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp1++ = *ip++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* dest is int */
|
|
||||||
{
|
|
||||||
for (ip = (int *)src, ip1 = dest; count < len; count++)
|
for (ip = (int *)src, ip1 = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*ip > X_INT_MAX || *ip < X_INT_MIN)
|
if (*ip > X_INT_MAX || *ip < X_INT_MIN)
|
||||||
(*range_error)++;
|
(*range_error)++;
|
||||||
*ip1++ = *ip++;
|
*ip1++ = *ip++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NC_UINT:
|
case NC_UINT:
|
||||||
for (ip = (int *)src, uip = dest; count < len; count++)
|
for (ip = (int *)src, uip = dest; count < len; count++)
|
||||||
@ -3363,7 +3226,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
__func__, src_type, dest_type));
|
__func__, src_type, dest_type));
|
||||||
return NC_EBADTYPE;
|
return NC_EBADTYPE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NC_UINT:
|
case NC_UINT:
|
||||||
@ -3402,14 +3264,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (uip = (unsigned int *)src, lp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*uip > X_LONG_MAX)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp++ = *uip++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (uip = (unsigned int *)src, ip = dest; count < len; count++)
|
for (uip = (unsigned int *)src, ip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*uip > X_INT_MAX)
|
if (*uip > X_INT_MAX)
|
||||||
@ -3492,14 +3346,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (lip = (long long *)src, lp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*lip > X_LONG_MAX || *lip < X_LONG_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp++ = *lip++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (lip = (long long *)src, ip = dest; count < len; count++)
|
for (lip = (long long *)src, ip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*lip > X_INT_MAX || *lip < X_INT_MIN)
|
if (*lip > X_INT_MAX || *lip < X_INT_MIN)
|
||||||
@ -3578,14 +3424,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (ulip = (unsigned long long *)src, lp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*ulip > X_LONG_MAX)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp++ = *ulip++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (ulip = (unsigned long long *)src, ip = dest; count < len; count++)
|
for (ulip = (unsigned long long *)src, ip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*ulip > X_INT_MAX)
|
if (*ulip > X_INT_MAX)
|
||||||
@ -3664,14 +3502,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (fp = (float *)src, lp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*fp > (double)X_LONG_MAX || *fp < (double)X_LONG_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp++ = *fp++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (fp = (float *)src, ip = dest; count < len; count++)
|
for (fp = (float *)src, ip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*fp > (double)X_INT_MAX || *fp < (double)X_INT_MIN)
|
if (*fp > (double)X_INT_MAX || *fp < (double)X_INT_MIN)
|
||||||
@ -3758,14 +3588,6 @@ nc4_convert_type(const void *src, void *dest,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NC_INT:
|
case NC_INT:
|
||||||
if (dest_long)
|
|
||||||
for (dp = (double *)src, lp = dest; count < len; count++)
|
|
||||||
{
|
|
||||||
if (*dp > X_LONG_MAX || *dp < X_LONG_MIN)
|
|
||||||
(*range_error)++;
|
|
||||||
*lp++ = *dp++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
for (dp = (double *)src, ip = dest; count < len; count++)
|
for (dp = (double *)src, ip = dest; count < len; count++)
|
||||||
{
|
{
|
||||||
if (*dp > X_INT_MAX || *dp < X_INT_MIN)
|
if (*dp > X_INT_MAX || *dp < X_INT_MIN)
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
* Research. See COPYRIGHT file for copying and redistribution
|
* Research. See COPYRIGHT file for copying and redistribution
|
||||||
* conditions. */
|
* conditions. */
|
||||||
/**
|
/**
|
||||||
* @file @internal This file is part of netcdf-4, the extended netCDF
|
* @file
|
||||||
* data model/file format. This uses libhdf5 for file I/O. The resulting
|
*
|
||||||
* file may or may not be readable by the hdf5 utilities and the data model
|
* @internal This file is part of netcdf-4, a netCDF-like interface
|
||||||
* may or may not be expressable by the hdf5 utilities.
|
* for HDF5, or a HDF5 backend for netCDF, depending on your point of
|
||||||
|
* view.
|
||||||
*
|
*
|
||||||
* This file handles the nc4 attribute functions.
|
* This file handles the nc4 attribute functions.
|
||||||
*
|
*
|
||||||
@ -204,7 +205,7 @@ nc4_get_att(int ncid, int varid, const char *name, nc_type *xtype,
|
|||||||
need_to_convert++;
|
need_to_convert++;
|
||||||
if ((retval = nc4_convert_type(att->data, bufr, att->nc_typeid,
|
if ((retval = nc4_convert_type(att->data, bufr, att->nc_typeid,
|
||||||
mem_type, (size_t)att->len, &range_error,
|
mem_type, (size_t)att->len, &range_error,
|
||||||
NULL, (h5->cmode & NC_CLASSIC_MODEL), 0, 0)))
|
NULL, (h5->cmode & NC_CLASSIC_MODEL))))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
|
|
||||||
/* For strict netcdf-3 rules, ignore erange errors between UBYTE
|
/* For strict netcdf-3 rules, ignore erange errors between UBYTE
|
||||||
|
@ -1673,7 +1673,7 @@ NC4_put_vara(int ncid, int varid, const size_t *startp,
|
|||||||
if (!(nc = nc4_find_nc_file(ncid, NULL)))
|
if (!(nc = nc4_find_nc_file(ncid, NULL)))
|
||||||
return NC_EBADID;
|
return NC_EBADID;
|
||||||
|
|
||||||
return nc4_put_vara(nc, ncid, varid, startp, countp, memtype, 0, (void *)op);
|
return nc4_put_vara(nc, ncid, varid, startp, countp, memtype, (void *)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1705,6 +1705,5 @@ NC4_get_vara(int ncid, int varid, const size_t *startp,
|
|||||||
return NC_EBADID;
|
return NC_EBADID;
|
||||||
|
|
||||||
/* Get the data. */
|
/* Get the data. */
|
||||||
return nc4_get_vara(nc, ncid, varid, startp, countp, memtype,
|
return nc4_get_vara(nc, ncid, varid, startp, countp, memtype, (void *)ip);
|
||||||
0, (void *)ip);
|
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,19 @@ main(int argc, char **argv)
|
|||||||
#define FILE_NAME2 "tst_vars2_latefill.nc"
|
#define FILE_NAME2 "tst_vars2_latefill.nc"
|
||||||
printf("**** testing simple fill value attribute creation...");
|
printf("**** testing simple fill value attribute creation...");
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
int schar_data = 0;
|
int schar_data = 0;
|
||||||
size_t index[1] = {0};
|
size_t index[1] = {0};
|
||||||
|
int expected_ret;
|
||||||
int dimid;
|
int dimid;
|
||||||
|
|
||||||
|
/* Determined the expected result of setting fill value
|
||||||
|
* late. For historical reasons this is allowed for classic
|
||||||
|
* and 64-bit offset formats, but should never be done. */
|
||||||
|
if (cmode == 0 || cmode == NC_64BIT_OFFSET)
|
||||||
|
expected_ret = NC_NOERR;
|
||||||
|
else
|
||||||
|
expected_ret = NC_ELATEFILL;
|
||||||
|
|
||||||
/* Create a netcdf-4 file with one scalar var. Add fill
|
/* Create a netcdf-4 file with one scalar var. Add fill
|
||||||
* value. */
|
* value. */
|
||||||
if (nc_create(FILE_NAME2, cmode, &ncid)) ERR;
|
if (nc_create(FILE_NAME2, cmode, &ncid)) ERR;
|
||||||
@ -83,9 +91,8 @@ main(int argc, char **argv)
|
|||||||
if (nc_enddef(ncid)) ERR;
|
if (nc_enddef(ncid)) ERR;
|
||||||
if (nc_put_var1(ncid, varid, index, &schar_data)) ERR;
|
if (nc_put_var1(ncid, varid, index, &schar_data)) ERR;
|
||||||
if (nc_redef(ncid)) ERR;
|
if (nc_redef(ncid)) ERR;
|
||||||
status = nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value);
|
if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1,
|
||||||
if (status != NC_ELATEFILL)
|
&fill_value) != expected_ret) ERR;
|
||||||
printf("Error at line %d: expecting NC_ELATEFILL but got %s\n",__LINE__,nc_strerror(status));
|
|
||||||
if (nc_close(ncid)) ERR;
|
if (nc_close(ncid)) ERR;
|
||||||
|
|
||||||
/* Open the file and check. */
|
/* Open the file and check. */
|
||||||
|
Loading…
Reference in New Issue
Block a user