mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-24 18:30:51 +08:00
fix dim bad paramter issues
This commit is contained in:
parent
ee4a3b6b3d
commit
333b802861
207
libsrc4/nc4dim.c
207
libsrc4/nc4dim.c
@ -2,7 +2,7 @@
|
||||
* Research. See the COPYRIGHT file for copying and redistribution
|
||||
* conditions. */
|
||||
/**
|
||||
* @file
|
||||
* @file
|
||||
* @internal This file is part of netcdf-4, a netCDF-like interface
|
||||
* for HDF5, or a HDF5 backend for netCDF, depending on your point of
|
||||
* view.
|
||||
@ -10,7 +10,7 @@
|
||||
* This file handles the nc4 dimension functions.
|
||||
*
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "nc4internal.h"
|
||||
#include "nc4dispatch.h"
|
||||
@ -18,8 +18,8 @@
|
||||
/**
|
||||
* @internal Netcdf-4 files might have more than one unlimited
|
||||
* dimension, but return the first one anyway.
|
||||
*
|
||||
* @note that this code is inconsistent with nc_inq
|
||||
*
|
||||
* @note that this code is inconsistent with nc_inq
|
||||
*
|
||||
* @param ncid File and group ID.
|
||||
* @param unlimdimidp Pointer that gets ID of first unlimited
|
||||
@ -29,7 +29,7 @@
|
||||
* @return ::NC_EBADID Bad ncid.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
int
|
||||
NC4_inq_unlimdim(int ncid, int *unlimdimidp)
|
||||
{
|
||||
NC *nc;
|
||||
@ -38,26 +38,29 @@ NC4_inq_unlimdim(int ncid, int *unlimdimidp)
|
||||
NC_DIM_INFO_T *dim;
|
||||
int found = 0;
|
||||
int retval;
|
||||
|
||||
|
||||
LOG((2, "%s: called", __func__));
|
||||
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5);
|
||||
assert(h5 && nc && grp);
|
||||
|
||||
/* According to netcdf-3 manual, return -1 if there is no unlimited
|
||||
dimension. */
|
||||
*unlimdimidp = -1;
|
||||
for (g = grp; g && !found; g = g->parent)
|
||||
if (unlimdimidp)
|
||||
{
|
||||
for (dim = g->dim; dim; dim = dim->l.next)
|
||||
/* According to netcdf-3 manual, return -1 if there is no unlimited
|
||||
dimension. */
|
||||
*unlimdimidp = -1;
|
||||
for (g = grp; g && !found; g = g->parent)
|
||||
{
|
||||
if (dim->unlimited)
|
||||
{
|
||||
*unlimdimidp = dim->dimid;
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
for (dim = g->dim; dim; dim = dim->l.next)
|
||||
{
|
||||
if (dim->unlimited)
|
||||
{
|
||||
*unlimdimidp = dim->dimid;
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +87,7 @@ NC4_inq_unlimdim(int ncid, int *unlimdimidp)
|
||||
* @return ::NC_ENOTINDEFINE Not in define mode.
|
||||
* @return ::NC_EDIMSIZE Dim length too large.
|
||||
* @return ::NC_ENAMEINUSE Name already in use in group.
|
||||
* @return ::NC_ENOMEM Out of memory.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -97,8 +101,8 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
int retval = NC_NOERR;
|
||||
uint32_t nn_hash;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x name %s len %d", __func__, ncid, name,
|
||||
(int)len));
|
||||
LOG((2, "%s: ncid 0x%x name %s len %d", __func__, ncid, name,
|
||||
(int)len));
|
||||
|
||||
/* Find our global metadata structure. */
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
@ -107,26 +111,21 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
|
||||
/* If the file is read-only, return an error. */
|
||||
if (h5->no_write)
|
||||
return NC_EPERM;
|
||||
return NC_EPERM;
|
||||
|
||||
/* Check some stuff if strict nc3 rules are in effect. */
|
||||
if (h5->cmode & NC_CLASSIC_MODEL)
|
||||
{
|
||||
/* Only one limited dimenson for strict nc3. */
|
||||
if (len == NC_UNLIMITED)
|
||||
for (dim = grp->dim; dim; dim = dim->l.next)
|
||||
if (dim->unlimited)
|
||||
return NC_EUNLIMIT;
|
||||
for (dim = grp->dim; dim; dim = dim->l.next)
|
||||
if (dim->unlimited)
|
||||
return NC_EUNLIMIT;
|
||||
|
||||
/* Must be in define mode for stict nc3. */
|
||||
if (!(h5->flags & NC_INDEF))
|
||||
return NC_ENOTINDEFINE;
|
||||
}
|
||||
|
||||
/* If it's not in define mode, enter define mode. */
|
||||
if (!(h5->flags & NC_INDEF))
|
||||
if ((retval = NC4_redef(ncid)))
|
||||
return retval;
|
||||
return NC_ENOTINDEFINE;
|
||||
}
|
||||
|
||||
/* Make sure this is a valid netcdf name. */
|
||||
if ((retval = nc4_check_name(name, norm_name)))
|
||||
@ -136,18 +135,27 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
* int, as permitted for 64-bit offset format. */
|
||||
if (h5->cmode & NC_CLASSIC_MODEL)
|
||||
if(len > X_UINT_MAX) /* Backward compat */
|
||||
return NC_EDIMSIZE;
|
||||
return NC_EDIMSIZE;
|
||||
|
||||
/* Create a hash of the name. */
|
||||
nn_hash = hash_fast(norm_name, strlen(norm_name));
|
||||
|
||||
/* Make sure the name is not already in use. */
|
||||
for (dim = grp->dim; dim; dim = dim->l.next)
|
||||
if (nn_hash == dim->hash && !strncmp(dim->name, norm_name, NC_MAX_NAME))
|
||||
return NC_ENAMEINUSE;
|
||||
return NC_ENAMEINUSE;
|
||||
|
||||
/* If it's not in define mode, enter define mode. Do this only
|
||||
* after checking all input data, so we only enter define mode if
|
||||
* input is good. */
|
||||
if (!(h5->flags & NC_INDEF))
|
||||
if ((retval = NC4_redef(ncid)))
|
||||
return retval;
|
||||
|
||||
/* Add a dimension to the list. The ID must come from the file
|
||||
* information, since dimids are visible in more than one group. */
|
||||
nc4_dim_list_add(&grp->dim, &dim);
|
||||
if ((retval = nc4_dim_list_add(&grp->dim, &dim)))
|
||||
return retval;
|
||||
dim->dimid = grp->nc4_info->next_dimid++;
|
||||
|
||||
/* Initialize the metadata for this dimension. */
|
||||
@ -158,7 +166,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
dim->unlimited = NC_TRUE;
|
||||
|
||||
dim->hash = nn_hash;
|
||||
|
||||
|
||||
/* Pass back the dimid. */
|
||||
if (idp)
|
||||
*idp = dim->dimid;
|
||||
@ -176,6 +184,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
* @return ::NC_NOERR No error.
|
||||
* @return ::NC_EBADID Bad ncid.
|
||||
* @return ::NC_EBADDIM Dimension not found.
|
||||
* @return ::NC_EINVAL Invalid input. Name must be provided.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -189,15 +198,17 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)
|
||||
int finished = 0;
|
||||
int retval;
|
||||
uint32_t shash;
|
||||
|
||||
|
||||
LOG((2, "%s: ncid 0x%x name %s", __func__, ncid, name));
|
||||
|
||||
/* Check input. */
|
||||
if (!name)
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Find metadata for this file. */
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return retval;
|
||||
|
||||
assert(h5);
|
||||
assert(nc && grp);
|
||||
assert(h5 && nc && grp);
|
||||
|
||||
/* Normalize name. */
|
||||
if ((retval = nc4_normalize_name(name, norm_name)))
|
||||
@ -208,12 +219,12 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)
|
||||
/* Go through each dim and check for a name match. */
|
||||
for (g = grp; g && !finished; g = g->parent)
|
||||
for (dim = g->dim; dim; dim = dim->l.next)
|
||||
if (dim->hash == shash && !strncmp(dim->name, norm_name, NC_MAX_NAME))
|
||||
{
|
||||
if (idp)
|
||||
*idp = dim->dimid;
|
||||
return NC_NOERR;
|
||||
}
|
||||
if (dim->hash == shash && !strncmp(dim->name, norm_name, NC_MAX_NAME))
|
||||
{
|
||||
if (idp)
|
||||
*idp = dim->dimid;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
return NC_EBADDIM;
|
||||
}
|
||||
@ -231,6 +242,7 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)
|
||||
* @return ::NC_NOERR No error.
|
||||
* @return ::NC_EBADID Bad ncid.
|
||||
* @return ::NC_EDIMSIZE Dimension length too large.
|
||||
* @return ::NC_EBADDIM Dimension not found.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
int
|
||||
@ -247,9 +259,7 @@ NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
|
||||
/* Find our global metadata structure. */
|
||||
if ((ret = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return ret;
|
||||
|
||||
assert(h5);
|
||||
assert(nc && grp);
|
||||
assert(h5 && nc && grp);
|
||||
|
||||
/* Find the dimension and its home group. */
|
||||
if ((ret = nc4_find_dim(grp, dimid, &dim, &dim_grp)))
|
||||
@ -257,31 +267,31 @@ NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
|
||||
assert(dim);
|
||||
|
||||
/* Return the dimension name, if the caller wants it. */
|
||||
if (name && dim->name)
|
||||
strcpy(name, dim->name);
|
||||
|
||||
if (name && dim->name)
|
||||
strcpy(name, dim->name);
|
||||
|
||||
/* Return the dimension length, if the caller wants it. */
|
||||
if (lenp)
|
||||
{
|
||||
if (dim->unlimited)
|
||||
{
|
||||
/* Since this is an unlimited dimension, go to the file
|
||||
and see how many records there are. Take the max number
|
||||
of records from all the vars that share this
|
||||
dimension. */
|
||||
*lenp = 0;
|
||||
if ((ret = nc4_find_dim_len(dim_grp, dimid, &lenp)))
|
||||
return ret;
|
||||
/* Since this is an unlimited dimension, go to the file
|
||||
and see how many records there are. Take the max number
|
||||
of records from all the vars that share this
|
||||
dimension. */
|
||||
*lenp = 0;
|
||||
if ((ret = nc4_find_dim_len(dim_grp, dimid, &lenp)))
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dim->too_long)
|
||||
{
|
||||
ret = NC_EDIMSIZE;
|
||||
*lenp = NC_MAX_UINT;
|
||||
}
|
||||
else
|
||||
*lenp = dim->len;
|
||||
if (dim->too_long)
|
||||
{
|
||||
ret = NC_EDIMSIZE;
|
||||
*lenp = NC_MAX_UINT;
|
||||
}
|
||||
else
|
||||
*lenp = dim->len;
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,14 +330,14 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
||||
if (!name)
|
||||
return NC_EINVAL;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x dimid %d name %s", __func__, ncid,
|
||||
dimid, name));
|
||||
LOG((2, "%s: ncid 0x%x dimid %d name %s", __func__, ncid,
|
||||
dimid, name));
|
||||
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return retval;
|
||||
assert(nc && h5 && grp);
|
||||
|
||||
|
||||
/* Trying to write to a read-only file? No way, Jose! */
|
||||
if (h5->no_write)
|
||||
return NC_EPERM;
|
||||
@ -341,15 +351,15 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
||||
for (dim = grp->dim; dim; dim = dim->l.next)
|
||||
{
|
||||
if (!strncmp(dim->name, norm_name, NC_MAX_NAME))
|
||||
return NC_ENAMEINUSE;
|
||||
return NC_ENAMEINUSE;
|
||||
if (dim->dimid == dimid)
|
||||
tmp_dim = dim;
|
||||
tmp_dim = dim;
|
||||
}
|
||||
if (!tmp_dim)
|
||||
return NC_EBADDIM;
|
||||
dim = tmp_dim;
|
||||
|
||||
/* Check for renaming dimension w/o variable. */
|
||||
/* Check for renaming dimension w/o variable */
|
||||
if (dim->hdf_dimscaleid)
|
||||
{
|
||||
/* Sanity check */
|
||||
@ -370,7 +380,7 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
||||
strcpy(dim->name, norm_name);
|
||||
dim->hash = hash_fast(norm_name, strlen(norm_name));
|
||||
LOG((3, "dim is now named %s", dim->name));
|
||||
|
||||
|
||||
/* Check if dimension was a coordinate variable, but names are
|
||||
* different now */
|
||||
if (dim->coord_var && strcmp(dim->name, dim->coord_var->name))
|
||||
@ -394,12 +404,12 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
||||
* dimension in index 0. */
|
||||
if (var && var->dim[0] == dim)
|
||||
{
|
||||
/* Sanity check */
|
||||
assert(var->dimids[0] == dim->dimid);
|
||||
/* Sanity check */
|
||||
assert(var->dimids[0] == dim->dimid);
|
||||
|
||||
/* Reform the coordinate variable. */
|
||||
if ((retval = nc4_reform_coord_var(grp, var, dim)))
|
||||
return retval;
|
||||
/* Reform the coordinate variable. */
|
||||
if ((retval = nc4_reform_coord_var(grp, var, dim)))
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,33 +431,34 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
||||
* @return ::NC_EBADID Bad ncid.
|
||||
* @author Ed Hartnett, Dennis Heimbigner
|
||||
*/
|
||||
int
|
||||
NC4_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
|
||||
int
|
||||
NC4_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
|
||||
{
|
||||
NC_DIM_INFO_T *dim;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC *nc;
|
||||
NC_HDF5_FILE_INFO_T *h5;
|
||||
int num_unlim = 0;
|
||||
int retval;
|
||||
NC_DIM_INFO_T *dim;
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC *nc;
|
||||
NC_HDF5_FILE_INFO_T *h5;
|
||||
int num_unlim = 0;
|
||||
int retval;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x", __func__, ncid));
|
||||
LOG((2, "%s: ncid 0x%x", __func__, ncid));
|
||||
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return retval;
|
||||
assert(h5 && nc && grp);
|
||||
|
||||
/* Find info for this file and group, and set pointer to each. */
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
|
||||
return retval;
|
||||
|
||||
/* Get our dim info. */
|
||||
assert(h5);
|
||||
{
|
||||
for (dim=grp->dim; dim; dim=dim->l.next)
|
||||
{
|
||||
if (dim->unlimited)
|
||||
{
|
||||
if (unlimdimidsp)
|
||||
unlimdimidsp[num_unlim] = dim->dimid;
|
||||
num_unlim++;
|
||||
}
|
||||
if (dim->unlimited)
|
||||
{
|
||||
if (unlimdimidsp)
|
||||
unlimdimidsp[num_unlim] = dim->dimid;
|
||||
num_unlim++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,5 +468,3 @@ NC4_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/* Copyright 2003-2018, University Corporation for Atmospheric
|
||||
* Research. See the COPYRIGHT file for copying and redistribution
|
||||
* conditions.
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @internal
|
||||
@ -9,9 +13,6 @@
|
||||
* buffer of metadata information, i.e. the linked list of NC
|
||||
* structs.
|
||||
*
|
||||
* Copyright 2003-2011, University Corporation for Atmospheric
|
||||
* Research. See the COPYRIGHT file for copying and redistribution
|
||||
* conditions.
|
||||
* @author Ed Hartnett
|
||||
*/
|
||||
#include "config.h"
|
||||
@ -101,13 +102,13 @@ nc4_check_name(const char *name, char *norm_name)
|
||||
{
|
||||
char *temp;
|
||||
int retval;
|
||||
|
||||
|
||||
/* Check for NULL. */
|
||||
if (!name)
|
||||
return NC_EINVAL;
|
||||
|
||||
assert(norm_name);
|
||||
|
||||
|
||||
/* Check for NULL. */
|
||||
if (!name)
|
||||
return NC_EINVAL;
|
||||
@ -574,7 +575,7 @@ nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name)
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Recursively hunt for a netCDF type id.
|
||||
* @internal Recursively hunt for a netCDF type id.
|
||||
*
|
||||
* @param start_grp Pointer to starting group info.
|
||||
* @param target_nc_typeid NetCDF type ID to find.
|
||||
@ -1633,7 +1634,7 @@ nc4_att_list_del(NC_ATT_INFO_T **list, NC_ATT_INFO_T *att)
|
||||
|
||||
/**
|
||||
* @internal Break a coordinate variable to separate the dimension and
|
||||
* the variable.
|
||||
* the variable.
|
||||
*
|
||||
* This is called from nc_rename_dim() and nc_rename_var(). In some
|
||||
* renames, the coord variable must stay, but it is no longer a coord
|
||||
@ -1682,7 +1683,7 @@ nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T
|
||||
/* Remove the atts that go with being a coordinate var. */
|
||||
/* if ((retval = remove_coord_atts(coord_var->hdf_datasetid))) */
|
||||
/* return retval; */
|
||||
|
||||
|
||||
/* Detach dimension from variable */
|
||||
coord_var->dimscale = NC_FALSE;
|
||||
dim->coord_var = NULL;
|
||||
@ -1722,20 +1723,20 @@ delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *d
|
||||
assert(grp && dim);
|
||||
LOG((2, "%s: deleting dimscale dataset %s dimid %d", __func__, dim->name,
|
||||
dimid));
|
||||
|
||||
|
||||
/* Detach dimscale from any variables using it */
|
||||
if ((retval = rec_detach_scales(grp, dimid, dim->hdf_dimscaleid)) < 0)
|
||||
return retval;
|
||||
|
||||
|
||||
/* Close the HDF5 dataset */
|
||||
if (H5Dclose(dim->hdf_dimscaleid) < 0)
|
||||
if (H5Dclose(dim->hdf_dimscaleid) < 0)
|
||||
return NC_EHDFERR;
|
||||
dim->hdf_dimscaleid = 0;
|
||||
|
||||
|
||||
/* Now delete the dataset. */
|
||||
if (H5Gunlink(grp->hdf_grpid, dim->name) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -1758,7 +1759,7 @@ nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim)
|
||||
|
||||
assert(grp && var && dim);
|
||||
LOG((3, "%s: dim->name %s var->name %s", __func__, dim->name, var->name));
|
||||
|
||||
|
||||
/* Detach dimscales from the [new] coordinate variable */
|
||||
if(var->dimscale_attached)
|
||||
{
|
||||
|
@ -4,14 +4,16 @@
|
||||
|
||||
Test netcdf-4 dimensions.
|
||||
|
||||
$Id: tst_dims.c,v 1.30 2010/05/25 13:53:04 ed Exp $
|
||||
Ed Hartnett, Quincey Koziol, Russ Rew, Ward Fisher
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
#include <nc4internal.h>
|
||||
#include "err_macros.h"
|
||||
|
||||
#define FILE_NAME "tst_dims.nc"
|
||||
#define LAT_NAME "lat"
|
||||
#define LAT_NAME_2 "lat_2"
|
||||
#define LON_NAME "lon"
|
||||
#define LEVEL_NAME "level"
|
||||
#define TIME_NAME "time"
|
||||
@ -34,7 +36,6 @@
|
||||
#define ELEV_NAME "Elevation"
|
||||
#define HP_NAME "Number_of_Harry_Potter_Books"
|
||||
#define BUBBA "Bubba"
|
||||
|
||||
#define MAX_DIMS 5
|
||||
|
||||
int
|
||||
@ -49,6 +50,8 @@ main(int argc, char **argv)
|
||||
/* Create a netcdf-3 file with one dim. */
|
||||
if (nc_create(FILE_NAME, 0, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, &dimid)) ERR;
|
||||
/* Next line will work when PR #804 gets merged. */
|
||||
/* if (nc_def_dim(ncid + TEST_VAL_42, LAT_NAME, LAT_LEN, &dimid) != NC_EBADID) ERR; */
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Open the file and make sure nc_inq_dimids yeilds correct
|
||||
@ -80,7 +83,7 @@ main(int argc, char **argv)
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 3 || dimids_in[0] != 0 || dimids_in[1] != 1 ||
|
||||
dimids_in[2] != 2) ERR;
|
||||
dimids_in[2] != 2) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -88,7 +91,7 @@ main(int argc, char **argv)
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** Testing file with just one dimension...");
|
||||
{
|
||||
int ncid, dimid;
|
||||
int ncid, dimid, dimid2;
|
||||
int ndims_in, dimids_in[MAX_DIMS];
|
||||
size_t len_in;
|
||||
char name_in[NC_MAX_NAME + 1];
|
||||
@ -96,9 +99,70 @@ main(int argc, char **argv)
|
||||
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
|
||||
/* These will not work. */
|
||||
if (nc_def_dim(ncid + TEST_VAL_42, LAT_NAME, LAT_LEN, &dimid) != NC_EBADID) ERR;
|
||||
if (nc_def_dim(ncid, NULL, LAT_LEN, &dimid) != NC_EINVAL) ERR;
|
||||
if (nc_def_dim(ncid, BAD_NAME, LAT_LEN, &dimid) != NC_EBADNAME) ERR;
|
||||
|
||||
/* Turn off define mode. It will be turned back on
|
||||
* automatically. */
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
|
||||
/* Create the dim. */
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, &dimid)) ERR;
|
||||
|
||||
/* This will not work. */
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, &dimid2) != NC_ENAMEINUSE) ERR;
|
||||
|
||||
/* These also won't work. */
|
||||
if (nc_inq_dim(ncid + TEST_VAL_42, dimid, name_in, &len_in) != NC_EBADID) ERR;
|
||||
if (nc_inq_dim(ncid, -1, name_in, &len_in) != NC_EBADDIM) ERR;
|
||||
|
||||
/* Check out what we've got. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN || strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
|
||||
/* These will also work. */
|
||||
if (nc_inq_dim(ncid, dimid, NULL, NULL)) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, NULL, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, name_in, NULL)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
|
||||
/* These will not work. */
|
||||
if (nc_inq_dimid(ncid + TEST_VAL_42, LAT_NAME, &dimid_in) != NC_EBADID) ERR;
|
||||
if (nc_inq_dimid(ncid, NULL, &dimid_in) != NC_EINVAL) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME_2, &dimid_in) != NC_EBADDIM) ERR;
|
||||
|
||||
/* This will work. */
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, NULL)) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &dimid_in)) ERR;
|
||||
if (dimid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN) ERR;
|
||||
|
||||
/* These won't work. */
|
||||
if (nc_inq_unlimdims(ncid + TEST_VAL_42, &ndims_in, dimids_in) != NC_EBADID) ERR;
|
||||
|
||||
/* This will work. */
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, NULL)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_inq_unlimdims(ncid, NULL, NULL)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Reopen and check it out again. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
|
||||
/* This will not work. */
|
||||
if (nc_def_dim(ncid, LAT_NAME_2, LAT_LEN, &dimid) != NC_EPERM) ERR;
|
||||
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN || strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
@ -112,21 +176,69 @@ main(int argc, char **argv)
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** Testing with NULL id pointer...");
|
||||
{
|
||||
int ncid;
|
||||
int ndims_in, dimids_in[MAX_DIMS];
|
||||
size_t len_in;
|
||||
char name_in[NC_MAX_NAME + 1];
|
||||
int dimid_in;
|
||||
|
||||
/* Reopen and check it out again. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, NULL)) ERR;
|
||||
|
||||
/* Check out what we've got. */
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN || strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &dimid_in)) ERR;
|
||||
if (dimid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != LAT_LEN) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** Testing classic model file with just one unlimited dimension...");
|
||||
{
|
||||
int ncid, dimid;
|
||||
int ndims_in, dimids_in[MAX_DIMS];
|
||||
size_t len_in;
|
||||
char name_in[NC_MAX_NAME + 1];
|
||||
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
|
||||
/* Turn off define mode. */
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
|
||||
/* This will not work. */
|
||||
if (nc_def_dim(ncid, LAT_NAME, NC_UNLIMITED, &dimid) != NC_ENOTINDEFINE) ERR;
|
||||
|
||||
/* Turn on define mode. */
|
||||
if (nc_redef(ncid)) ERR;
|
||||
|
||||
/* Create the dim. */
|
||||
if (nc_def_dim(ncid, LAT_NAME, NC_UNLIMITED, &dimid)) ERR;
|
||||
|
||||
/* This will not work because of classic model. */
|
||||
if (nc_def_dim(ncid, LAT_NAME_2, NC_UNLIMITED, &dimid) != NC_EUNLIMIT) ERR;
|
||||
/* if (nc_def_dim(ncid, LAT_NAME_2, X_UINT_MAX + 10, &dimid) != NC_EDIMSIZE) ERR;*/
|
||||
|
||||
/* Check out what we've got. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != 0 || strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Reopen and check it out again. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != 0 || strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
@ -137,8 +249,20 @@ main(int argc, char **argv)
|
||||
size_t len_in;
|
||||
int ndims_in, dimids_in[MAX_DIMS];
|
||||
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, LAT_LEN, &dimid)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Reopen the file with one dim, and change the name of the dim. */
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
|
||||
/* These will not work. */
|
||||
if (nc_rename_dim(ncid + TEST_VAL_42, 0, BUBBA) != NC_EBADID) ERR;
|
||||
if (nc_rename_dim(ncid, TEST_VAL_42, BUBBA) != NC_EBADDIM) ERR;
|
||||
if (nc_rename_dim(ncid, 0, NULL) != NC_EINVAL) ERR;
|
||||
|
||||
/* Rename the dimension. */
|
||||
if (nc_rename_dim(ncid, 0, BUBBA)) ERR;
|
||||
|
||||
/* Check out what we've got. */
|
||||
@ -190,9 +314,9 @@ main(int argc, char **argv)
|
||||
int lat_T42_dims[RANK_lat_T42];
|
||||
char name[NC_MAX_NAME + 1];
|
||||
|
||||
/* =========== */
|
||||
/* Sub-test #1 */
|
||||
/* =========== */
|
||||
/* =========== */
|
||||
/* Sub-test #1 */
|
||||
/* =========== */
|
||||
/* create file with dimension and associated coordinate variable */
|
||||
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
|
||||
@ -224,9 +348,9 @@ main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
|
||||
/* =========== */
|
||||
/* Sub-test #2 */
|
||||
/* =========== */
|
||||
/* =========== */
|
||||
/* Sub-test #2 */
|
||||
/* =========== */
|
||||
/* create file with dimension and associated coordinate variable */
|
||||
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
|
||||
@ -254,9 +378,9 @@ main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
|
||||
/* =========== */
|
||||
/* Sub-test #3 */
|
||||
/* =========== */
|
||||
/* =========== */
|
||||
/* Sub-test #3 */
|
||||
/* =========== */
|
||||
/* create file with dimension and associated coordinate variable */
|
||||
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
|
||||
@ -284,9 +408,9 @@ main(int argc, char **argv)
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
|
||||
/* =========== */
|
||||
/* Sub-test #4 */
|
||||
/* =========== */
|
||||
/* =========== */
|
||||
/* Sub-test #4 */
|
||||
/* =========== */
|
||||
/* create file with dimension and associated coordinate variable */
|
||||
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
|
||||
@ -337,8 +461,14 @@ main(int argc, char **argv)
|
||||
if (len_in != NC_UNLIMITED || strcmp(name_in, LEVEL_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
|
||||
/* Th1s won't work. */
|
||||
if (nc_inq_unlimdim(ncid + TEST_VAL_42, &unlimdimid_in) != NC_EBADID) ERR;
|
||||
|
||||
/* This will work. */
|
||||
if (nc_inq_unlimdim(ncid, &unlimdimid_in)) ERR;
|
||||
if (unlimdimid_in != 0) ERR;
|
||||
if (nc_inq_unlimdim(ncid, NULL)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &nunlimdims_in, &unlimdimid_in)) ERR;
|
||||
if (nunlimdims_in != 1 || unlimdimid_in != 0) ERR;
|
||||
|
||||
@ -438,7 +568,7 @@ main(int argc, char **argv)
|
||||
if (len_in != A_LEN || strcmp(name_in, A_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 2 || dimids_in[0] != 0 ||
|
||||
dimids_in[1] != 1) ERR;
|
||||
dimids_in[1] != 1) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
|
||||
@ -479,7 +609,7 @@ main(int argc, char **argv)
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME) || xtype_in != NC_UINT64 || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
if (nc_inq_varname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME)) ERR;
|
||||
|
||||
@ -507,7 +637,7 @@ main(int argc, char **argv)
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME) || xtype_in != NC_UINT64 || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
if (nc_inq_varname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME)) ERR;
|
||||
|
||||
@ -531,7 +661,7 @@ main(int argc, char **argv)
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME) || xtype_in != NC_UINT64 || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
if (nc_inq_varname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LEVEL_NAME)) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -555,7 +685,7 @@ main(int argc, char **argv)
|
||||
/* Check out what we've got. */
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 0 || natts_in != 0 ||
|
||||
unlimdimid_in != -1) ERR;
|
||||
unlimdimid_in != -1) ERR;
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != DIM5_LEN || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
@ -567,7 +697,7 @@ main(int argc, char **argv)
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 0 || natts_in != 0 ||
|
||||
unlimdimid_in != -1) ERR;
|
||||
unlimdimid_in != -1) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != DIM5_LEN || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
@ -580,14 +710,14 @@ main(int argc, char **argv)
|
||||
/* Check it out. */
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 1 || natts_in != 0 ||
|
||||
unlimdimid_in != -1) ERR;
|
||||
unlimdimid_in != -1) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != DIM5_LEN || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, DIM5_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
@ -595,14 +725,14 @@ main(int argc, char **argv)
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 1 || natts_in != 0 ||
|
||||
unlimdimid_in != -1) ERR;
|
||||
unlimdimid_in != -1) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != DIM5_LEN || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, DIM5_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
@ -632,14 +762,14 @@ main(int argc, char **argv)
|
||||
/* Check out what we've got. */
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 1 || natts_in != 0 ||
|
||||
unlimdimid_in != 0) ERR;
|
||||
unlimdimid_in != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != 0 || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, HP_NAME) || xtype_in != NC_USHORT || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
|
||||
/* Add a record to the HP variable. */
|
||||
start[0] = 0;
|
||||
@ -661,7 +791,7 @@ main(int argc, char **argv)
|
||||
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 1 || natts_in != 0 ||
|
||||
unlimdimid_in != 0) ERR;
|
||||
unlimdimid_in != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != 1 || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
@ -674,14 +804,14 @@ main(int argc, char **argv)
|
||||
/* Check it out. */
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 2 || natts_in != 0 ||
|
||||
unlimdimid_in != 0) ERR;
|
||||
unlimdimid_in != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != 1 || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_inq_var(ncid, dim5_varid, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, DIM5_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
@ -689,14 +819,14 @@ main(int argc, char **argv)
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
|
||||
if (ndims_in != 1 || nvars_in != 2 || natts_in != 0 ||
|
||||
unlimdimid_in != 0) ERR;
|
||||
unlimdimid_in != 0) ERR;
|
||||
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
|
||||
if (len_in != 1 || strcmp(name_in, DIM5_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1 || dimids_in[0] != 0) ERR;
|
||||
if (nc_inq_var(ncid, dim5_varid, name_in, &xtype_in, &ndims_in, dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, DIM5_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
dimids_in[0] != 0 || natts_in != 0) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
@ -719,14 +849,14 @@ main(int argc, char **argv)
|
||||
|
||||
/* Lats and lons suitable for some South American data. */
|
||||
for (lat[0] = 40.0, i = 1; i < LAT_LEN; i++)
|
||||
lat[i] = lat[i - 1] + .5;
|
||||
lat[i] = lat[i - 1] + .5;
|
||||
for (lon[0] = 20.0, i = 1; i < LON_LEN; i++)
|
||||
lon[i] = lon[i - 1] + 1.5;
|
||||
lon[i] = lon[i - 1] + 1.5;
|
||||
|
||||
/* Some phoney 2D pressure data. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
pres[i][j] = 1013.1 + j;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
pres[i][j] = 1013.1 + j;
|
||||
|
||||
/* Create a file. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
@ -751,19 +881,19 @@ main(int argc, char **argv)
|
||||
if (nc_inq_dim(ncid, lon_dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != LON_LEN || strcmp(name_in, LON_NAME)) ERR;
|
||||
if (nc_inq_var(ncid, lat_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != lat_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lat_dimid || natts_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, lon_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LON_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != lon_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lon_dimid || natts_in != 0) ERR;
|
||||
|
||||
/* Check our data variable. */
|
||||
if (nc_inq_var(ncid, pres_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, PRES_NAME) || xtype_in != NC_DOUBLE || ndims_in != 2 ||
|
||||
dimids_in[0] != lat_dimid || dimids_in[1] != lon_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lat_dimid || dimids_in[1] != lon_dimid || natts_in != 0) ERR;
|
||||
|
||||
/* Write our latitude and longitude values. This writes all
|
||||
* metadata to disk too. */
|
||||
@ -776,16 +906,16 @@ main(int argc, char **argv)
|
||||
/* Check our latitude and longitude values. */
|
||||
if (nc_get_var(ncid, lat_varid, lat_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (nc_get_var_float(ncid, lon_varid, lon_in)) ERR;
|
||||
for (i = 0; i < LON_LEN; i++)
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
|
||||
/* Check our pressure values. */
|
||||
if (nc_get_var_double(ncid, pres_varid, (double *)pres_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (pres[i][j] != pres_in[i][j]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (pres[i][j] != pres_in[i][j]) ERR;
|
||||
|
||||
/* Close the file. */
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -799,33 +929,33 @@ main(int argc, char **argv)
|
||||
if (nc_inq_dim(ncid, lon_dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != LON_LEN || strcmp(name_in, LON_NAME)) ERR;
|
||||
if (nc_inq_var(ncid, lat_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != lat_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lat_dimid || natts_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, lon_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LON_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != lon_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lon_dimid || natts_in != 0) ERR;
|
||||
|
||||
/* Check our data variable. */
|
||||
if (nc_inq_var(ncid, pres_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, PRES_NAME) || xtype_in != NC_DOUBLE || ndims_in != 2 ||
|
||||
dimids_in[0] != lat_dimid || dimids_in[1] != lon_dimid || natts_in != 0) ERR;
|
||||
dimids_in[0] != lat_dimid || dimids_in[1] != lon_dimid || natts_in != 0) ERR;
|
||||
|
||||
/* Check our latitude and longitude values. */
|
||||
if (nc_get_var(ncid, lat_varid, lat_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (nc_get_var_float(ncid, lon_varid, lon_in)) ERR;
|
||||
for (i = 0; i < LON_LEN; i++)
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
|
||||
/* Check our pressure values. */
|
||||
if (nc_get_var_double(ncid, pres_varid, (double *)pres_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (pres[i][j] != pres_in[i][j]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (pres[i][j] != pres_in[i][j]) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
@ -854,27 +984,27 @@ main(int argc, char **argv)
|
||||
|
||||
/* Some phony 4D pressure data. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
pres[i][j][k][l] = 1013.1 + j;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
pres[i][j][k][l] = 1013.1 + j;
|
||||
|
||||
/* Some phony 3D hp data. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
hp[i][j][l] = 100 + l;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
hp[i][j][l] = 100 + l;
|
||||
|
||||
/* Some phony 2D elevaton data. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
elev[i][j] = 1010101022223333ULL + i + j;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
elev[i][j] = 1010101022223333ULL + i + j;
|
||||
|
||||
/* Some phony 1D lats and lons. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
lat[i] = i * 5.;
|
||||
lat[i] = i * 5.;
|
||||
for (i = 0; i < LON_LEN; i++)
|
||||
lon[i] = i * 5.;
|
||||
lon[i] = i * 5.;
|
||||
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
|
||||
@ -932,31 +1062,31 @@ main(int argc, char **argv)
|
||||
|
||||
/* Check our coordinate variables. */
|
||||
if (nc_inq_var(ncid, LAT_VARID, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != LAT_DIMID || natts_in != 0) ERR;
|
||||
dimids_in[0] != LAT_DIMID || natts_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, LON_VARID, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, LON_NAME) || xtype_in != NC_FLOAT || ndims_in != 1 ||
|
||||
dimids_in[0] != LON_DIMID || natts_in != 0) ERR;
|
||||
dimids_in[0] != LON_DIMID || natts_in != 0) ERR;
|
||||
|
||||
/* Check our data variables. */
|
||||
if (nc_inq_var(ncid, PRES_VARID, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, PRES_NAME) || xtype_in != NC_DOUBLE || ndims_in != 4 ||
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
dimids_in[2] != LEVEL_DIMID || dimids_in[3] != TIME_DIMID ||
|
||||
natts_in != 0) ERR;
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
dimids_in[2] != LEVEL_DIMID || dimids_in[3] != TIME_DIMID ||
|
||||
natts_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, ELEV_VARID, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, ELEV_NAME) || xtype_in != NC_INT64 || ndims_in != 2 ||
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
natts_in != 0) ERR;
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
natts_in != 0) ERR;
|
||||
if (nc_inq_var(ncid, HP_VARID, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (strcmp(name_in, HP_NAME) || xtype_in != NC_USHORT || ndims_in != 3 ||
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
dimids_in[2] != TIME_DIMID || natts_in != 0) ERR;
|
||||
dimids_in[0] != LAT_DIMID || dimids_in[1] != LON_DIMID ||
|
||||
dimids_in[2] != TIME_DIMID || natts_in != 0) ERR;
|
||||
|
||||
/* Write our latitude and longitude values. This writes all
|
||||
* metadata to disk too. */
|
||||
@ -975,16 +1105,16 @@ main(int argc, char **argv)
|
||||
/* Check our latitude and longitude values. */
|
||||
if (nc_get_var(ncid, lat_varid, lat_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (lat[i] != lat_in[i]) ERR;
|
||||
if (nc_get_var_float(ncid, lon_varid, lon_in)) ERR;
|
||||
for (i = 0; i < LON_LEN; i++)
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
if (lon[i] != lon_in[i]) ERR;
|
||||
|
||||
/* Make sure our pressure and hp variables are still
|
||||
* empty. get_var calls will return no error, but fetch no
|
||||
* data. */
|
||||
if (nc_inq_var(ncid, pres_varid, name_in, &xtype_in, &ndims_in,
|
||||
dimids_in, &natts_in)) ERR;
|
||||
dimids_in, &natts_in)) ERR;
|
||||
if (nc_inq_dim(ncid, dimids_in[3], NULL, &len_in)) ERR;
|
||||
if (len_in != 0) ERR;
|
||||
memset(pres_in, 0, sizeof(pres_in));
|
||||
@ -992,13 +1122,13 @@ main(int argc, char **argv)
|
||||
|
||||
/* Check our pressure values. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (0 != pres_in[i][j][k][l]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (0 != pres_in[i][j][k][l]) ERR;
|
||||
|
||||
if (nc_inq_var(ncid, hp_varid, NULL, NULL, &ndims_in,
|
||||
dimids_in, NULL)) ERR;
|
||||
dimids_in, NULL)) ERR;
|
||||
if (nc_inq_dim(ncid, dimids_in[2], NULL, &len_in)) ERR;
|
||||
if (len_in != 0) ERR;
|
||||
memset(hp_in, 0, sizeof(hp_in));
|
||||
@ -1006,9 +1136,9 @@ main(int argc, char **argv)
|
||||
|
||||
/* Check our hp values. */
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (0 != hp_in[i][j][l]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (0 != hp_in[i][j][l]) ERR;
|
||||
|
||||
/* Now use nc_put_vara to really write pressure and hp
|
||||
* data. Write TIME_LEN (4) records of each. */
|
||||
@ -1018,31 +1148,31 @@ main(int argc, char **argv)
|
||||
count[2] = LEVEL_LEN;
|
||||
count[3] = TIME_LEN;
|
||||
if (nc_put_vara(ncid, pres_varid, start, count,
|
||||
(double *)pres)) ERR;
|
||||
(double *)pres)) ERR;
|
||||
count[2] = TIME_LEN;
|
||||
if (nc_put_vara(ncid, hp_varid, start, count,
|
||||
(double *)hp)) ERR;
|
||||
(double *)hp)) ERR;
|
||||
|
||||
/* Check our pressure values. */
|
||||
if (nc_get_var_double(ncid, pres_varid, (double *)pres_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (pres[i][j][k][l] != pres_in[i][j][k][l]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (k = 0; k < LEVEL_LEN; k++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (pres[i][j][k][l] != pres_in[i][j][k][l]) ERR;
|
||||
|
||||
/* Check our elevation values. */
|
||||
if (nc_get_var_ulonglong(ncid, elev_varid, (unsigned long long *)elev_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (elev[i][j] != elev_in[i][j]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
if (elev[i][j] != elev_in[i][j]) ERR;
|
||||
|
||||
/* Check our hp values. */
|
||||
if (nc_get_var_ushort(ncid, hp_varid, (unsigned short *)hp_in)) ERR;
|
||||
for (i = 0; i < LAT_LEN; i++)
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (hp[i][j][l] != hp_in[i][j][l]) ERR;
|
||||
for (j = 0; j < LON_LEN; j++)
|
||||
for (l = 0; l <TIME_LEN; l++)
|
||||
if (hp[i][j][l] != hp_in[i][j][l]) ERR;
|
||||
|
||||
/* Close the file. */
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -1108,7 +1238,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Define a coordinate var. */
|
||||
if (nc_def_var(ncid, LON_NAME_EX, NC_FLOAT, 1, &lon_dimid,
|
||||
&lon_varid)) ERR;
|
||||
&lon_varid)) ERR;
|
||||
|
||||
/* Close the file. */
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -1121,11 +1251,11 @@ main(int argc, char **argv)
|
||||
if (ndims_in != 2) ERR;
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (dimid[i] != i) ERR;
|
||||
if (nc_inq_dimname(ncid, i, dim_name_in[i])) ERR;
|
||||
if (dimid[i] != i) ERR;
|
||||
if (nc_inq_dimname(ncid, i, dim_name_in[i])) ERR;
|
||||
}
|
||||
if (strcmp(dim_name_in[0], LAT_NAME_EX) ||
|
||||
strcmp(dim_name_in[1], LON_NAME_EX)) ERR;
|
||||
strcmp(dim_name_in[1], LON_NAME_EX)) ERR;
|
||||
|
||||
/* Close the file. */
|
||||
if (nc_close(ncid)) ERR;
|
||||
@ -1142,43 +1272,43 @@ main(int argc, char **argv)
|
||||
|
||||
if (SIZEOF_SIZE_T == 8)
|
||||
{
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, VERY_LONG_LEN, &dimid)) ERR;
|
||||
/* Create a file with one dim and nothing else. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, LAT_NAME, VERY_LONG_LEN, &dimid)) ERR;
|
||||
|
||||
/* Check it out. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT) ||
|
||||
strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &varid_in)) ERR;
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
/* Check it out. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT) ||
|
||||
strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &varid_in)) ERR;
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Reopen and check it out again. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
/* Check it out. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT) ||
|
||||
strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &varid_in)) ERR;
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
/* Reopen and check it out again. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
/* Check it out. */
|
||||
if (nc_inq_dim(ncid, dimid, name_in, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT) ||
|
||||
strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
if (ndims_in != 1) ERR;
|
||||
if (nc_inq_dimid(ncid, LAT_NAME, &varid_in)) ERR;
|
||||
if (varid_in != 0) ERR;
|
||||
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if (len_in != ((SIZEOF_SIZE_T == 8) ? VERY_LONG_LEN : NC_MAX_UINT)) ERR;
|
||||
if (nc_inq_unlimdims(ncid, &ndims_in, dimids_in)) ERR;
|
||||
if (ndims_in != 0) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
@ -1196,8 +1326,8 @@ main(int argc, char **argv)
|
||||
strcpy(file_in, "");
|
||||
if (getenv("srcdir"))
|
||||
{
|
||||
strcat(file_in, getenv("srcdir"));
|
||||
strcat(file_in, "/");
|
||||
strcat(file_in, getenv("srcdir"));
|
||||
strcat(file_in, "/");
|
||||
}
|
||||
strcat(file_in, REF_FILE_NAME);
|
||||
|
||||
@ -1207,14 +1337,14 @@ main(int argc, char **argv)
|
||||
/* Check it out. */
|
||||
ret = nc_inq_dim(ncid, dimid, name_in, &len_in);
|
||||
if ((SIZEOF_SIZE_T >= 8 && ret) ||
|
||||
(SIZEOF_SIZE_T < 8 && ret != NC_EDIMSIZE)) ERR;
|
||||
(SIZEOF_SIZE_T < 8 && ret != NC_EDIMSIZE)) ERR;
|
||||
if (SIZEOF_SIZE_T < 8)
|
||||
{
|
||||
if (len_in != NC_MAX_UINT) ERR;
|
||||
if (len_in != NC_MAX_UINT) ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len_in != VERY_LONG_LEN) ERR;
|
||||
if (len_in != VERY_LONG_LEN) ERR;
|
||||
}
|
||||
if (strcmp(name_in, LAT_NAME)) ERR;
|
||||
if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user