Beispiel #1
0
int 
nc_inq_vardimid(int ncid, int varid, int *dimids)
{
	int status;
	NC *ncp;
	NC_var *varp;
	size_t ii;

	status = NC_check_id(ncid, &ncp); 
	if(status != NC_NOERR)
		return status;

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR; /* TODO: is this the right error code? */

	if(dimids != 0)
	{
		for(ii = 0; ii < varp->ndims; ii++)
		{
			dimids[ii] = varp->dimids[ii];
		}
	}

	return NC_NOERR;
}
Beispiel #2
0
int 
nc_inq_varnatts(int ncid, int varid, int *nattsp)
{
	int status;
	NC *ncp;
	NC_var *varp;

	if(varid == NC_GLOBAL)
		return  nc_inq_natts(ncid, nattsp);

	status = NC_check_id(ncid, &ncp); 
	if(status != NC_NOERR)
		return status;

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR; /* TODO: is this the right error code? */

	if(nattsp != 0)
	{
		*nattsp = (int) varp->attrs.nelems;
	}

	return NC_NOERR;
}
Beispiel #3
0
int
NC3_inq_var(int ncid,
	int varid,
	char *name,
	nc_type *typep,
	int *ndimsp,
	int *dimids,
	int *nattsp)
{
	int status;
	NC *nc;
	NC3_INFO* ncp;
	NC_var *varp;
	size_t ii;

	status = NC_check_id(ncid, &nc); 
	if(status != NC_NOERR)
		return status;
	ncp = NC3_DATA(nc);

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR;

	if(name != NULL)
	{
		(void) strncpy(name, varp->name->cp, varp->name->nchars);
		name[varp->name->nchars] = 0;
	}

	if(typep != 0)
		*typep = varp->type;
	if(ndimsp != 0)
	{
		*ndimsp = (int) varp->ndims;
	}
	if(dimids != 0)
	{
		for(ii = 0; ii < varp->ndims; ii++)
		{
			dimids[ii] = varp->dimids[ii];
		}
	}
	if(nattsp != 0)
	{
		*nattsp = (int) varp->attrs.nelems;
	}

	return NC_NOERR;
}
Beispiel #4
0
Datei: var.c Projekt: Kitware/VTK
int
NC3_def_var_fill(int ncid,
	int varid,
	int no_fill,
	const void *fill_value)
{
	int status;
	NC *nc;
	NC3_INFO* ncp;
	NC_var *varp;

	status = NC_check_id(ncid, &nc);
	if(status != NC_NOERR)
		return status;
	ncp = NC3_DATA(nc);

	if(NC_readonly(ncp))
	{
		return NC_EPERM;
	}

	if(!NC_indef(ncp))
	{
		return NC_ENOTINDEFINE;
	}

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR;

	if (no_fill)
		varp->no_fill = 1;
	else
		varp->no_fill = 0;

	/* Are we setting a fill value? */
	if (fill_value != NULL && !varp->no_fill) {

		/* If there's a _FillValue attribute, delete it. */
		status = NC3_del_att(ncid, varid, _FillValue);
		if (status != NC_NOERR && status != NC_ENOTATT)
			return status;

		/* Create/overwrite attribute _FillValue */
		status = NC3_put_att(ncid, varid, _FillValue, varp->type, 1, fill_value, varp->type);
		if (status != NC_NOERR) return status;
	}

	return NC_NOERR;
}
Beispiel #5
0
int
ncmpi_inq_var(int ncid,
        int varid,
        char *name,
        nc_type *typep,
        int *ndimsp,
        int *dimids,
        int *nattsp)
{
        int status;
        NC *ncp;
        NC_var *varp;
        MPI_Offset ii;

        status = ncmpii_NC_check_id(ncid, &ncp); 
        if(status != NC_NOERR)
                return status;

        varp = elem_NC_vararray(&ncp->vars, varid);
        if(varp == NULL)
                return NC_ENOTVAR;

        if(name != NULL)
        {
                (void) strncpy(name, varp->name->cp, varp->name->nchars);
                name[varp->name->nchars] = 0;
        }

        if(typep != 0)
                *typep = varp->type;
        if(ndimsp != 0)
        {
                *ndimsp = varp->ndims;
        }
        if(dimids != 0)
        {
                for(ii = 0; ii < varp->ndims; ii++)
                {
                        dimids[ii] = varp->dimids[ii];
                }
        }
        if(nattsp != 0)
        {
                *nattsp = (int) varp->attrs.ndefined;
        }

        return NC_NOERR;
}
Beispiel #6
0
int NC_lookupvar(NC3_INFO* ncp, int varid, NC_var **varp)
{
  if(varid == NC_GLOBAL)
	{
      /* Global is error in this context */
      return NC_EGLOBAL;
	}

  if(varp)
    *varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
  else
    return NC_ENOTVAR;

  if(*varp == NULL)
    return NC_ENOTVAR;

  return NC_NOERR;

}
Beispiel #7
0
int 
nc_inq_vartype(int ncid, int varid, nc_type *typep)
{
	int status;
	NC *ncp;
	NC_var *varp;

	status = NC_check_id(ncid, &ncp); 
	if(status != NC_NOERR)
		return status;

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR;

	if(typep != 0)
		*typep = varp->type;

	return NC_NOERR;
}
Beispiel #8
0
/*
 * Given valid ncp and varid, return var
 *  else NULL on error
 * Formerly
NC_hlookupvar()
 */
NC_var *
NC_lookupvar(NC3_INFO* ncp, int varid)
{
	NC_var *varp;

	if(varid == NC_GLOBAL)
	{
		/* Global is error in this context */
		return(NULL);
	}

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
	{
		return NULL;
	}

	assert(varp != NULL);

	return(varp);
}
Beispiel #9
0
int
ncmpi_inq_varoffset(int         ncid,
                    int         varid, 
                    MPI_Offset *offset)
{
    int     status;
    NC     *ncp;
    NC_var *varp;

    status = ncmpii_NC_check_id(ncid, &ncp);
    if (status != NC_NOERR)
        return status;

    varp = elem_NC_vararray(&ncp->vars, varid);
    if (varp == NULL)
        return NC_ENOTVAR;

    if (offset != 0)
        *offset = varp->begin;

    return NC_NOERR;
}
Beispiel #10
0
int 
ncmpi_inq_varndims(int ncid,  int varid, int *ndimsp)
{
        int status;
        NC *ncp;
        NC_var *varp;

        status = ncmpii_NC_check_id(ncid, &ncp); 
        if(status != NC_NOERR)
                return status;

        varp = elem_NC_vararray(&ncp->vars, varid);
        if(varp == NULL)
                return NC_ENOTVAR; /* TODO: is this the right error code? */

        if(ndimsp != 0)
        {
                *ndimsp = (int) varp->ndims;
        }

        return NC_NOERR;
}
Beispiel #11
0
int 
nc_inq_varname(int ncid, int varid, char *name)
{
	int status;
	NC *ncp;
	NC_var *varp;

	status = NC_check_id(ncid, &ncp); 
	if(status != NC_NOERR)
		return status;

	varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
	if(varp == NULL)
		return NC_ENOTVAR;

	if(name != NULL)
	{
		(void) strncpy(name, varp->name->cp, varp->name->nchars);
		name[varp->name->nchars] = 0;
	}

	return NC_NOERR;
}