Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

tests.h File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <float.h>
#include "netcdf.h"
#include "error.h"

Go to the source code of this file.


Defines

#define NO_NETCDF_2   1
#define X_CHAR_MIN   CHAR_MIN
#define X_CHAR_MAX   CHAR_MAX
#define X_BYTE_MIN   (-128)
#define X_BYTE_MAX   127
#define X_SHORT_MIN   (-32768)
#define X_SHORT_MAX   32767
#define X_INT_MIN   (-2147483648.)
#define X_INT_MAX   2147483647
#define X_FLOAT_MAX   3.40282347e+38f
#define X_FLOAT_MIN   (-X_FLOAT_MAX)
#define X_DOUBLE_MAX   1.7976931348623157e+308
#define X_DOUBLE_MIN   (-X_DOUBLE_MAX)
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
#define ABS(x)   ((x) < 0 ? -(x) : (x))
#define NTYPES   6
#define NDIMS   5
#define NVARS   136
#define NRECS   2
#define NGATTS   NTYPES
#define RECDIM   0
#define MAX_RANK   3
#define MAX_NELS   64
#define MAX_DIM_LEN   4
#define MAX_NATTS   3
#define text_min   CHAR_MIN
#define uchar_min   0
#define schar_min   SCHAR_MIN
#define short_min   SHRT_MIN
#define int_min   INT_MIN
#define long_min   LONG_MIN
#define float_min   (-FLT_MAX)
#define double_min   (-DBL_MAX)
#define text_max   CHAR_MAX
#define uchar_max   UCHAR_MAX
#define schar_max   SCHAR_MAX
#define short_max   SHRT_MAX
#define int_max   INT_MAX
#define long_max   LONG_MAX
#define float_max   FLT_MAX
#define double_max   DBL_MAX
#define BAD_ID   -1
#define BAD_DIMID   -1
#define BAD_VARID   -2
#define BAD_ATTNUM   -1
#define BAD_TYPE   (nc_type) 0
#define BAD_FILLMODE   -1
#define BAD_NAME   "a+b"
#define LEN_OF(array)   ((sizeof array) / (sizeof array[0]))
#define VARID(varid)   (varid < 0 ? NC_GLOBAL : varid)
#define NATTS(varid)   (varid < 0 ? NGATTS : var_natts[varid])
#define ATT_NAME(varid, j)   (varid < 0 ? gatt_name[j] : att_name[varid][j])
#define ATT_TYPE(varid, j)   (varid < 0 ? gatt_type[j] : att_type[varid][j])
#define ATT_LEN(varid, j)   (varid < 0 ? gatt_len[j] : att_len[varid][j])
#define NCT_CHAR   NCT_TEXT

Typedefs

typedef char text
typedef signed char schar
typedef unsigned char uchar

Enumerations

enum  nct_itype {
  NCT_UNSPECIFIED = 0, NCT_UCHAR = 1, NCT_TEXT = 16, NCT_SCHAR = 17,
  NCT_SHORT = 18, NCT_INT = 20, NCT_LONG = 22, NCT_FLOAT = 36,
  NCT_DOUBLE = 40
}

Functions

const char * s_nc_type (nc_type)
void test_nc_strerror (void)
void test_nc_open (void)
void test_nc_close (void)
void test_nc_inq (void)
void test_nc_inq_natts (void)
void test_nc_inq_ndims (void)
void test_nc_inq_nvars (void)
void test_nc_inq_unlimdim (void)
void test_nc_inq_dimid (void)
void test_nc_inq_dim (void)
void test_nc_inq_dimlen (void)
void test_nc_inq_dimname (void)
void test_nc_inq_varid (void)
void test_nc_inq_vardimid (void)
void test_nc_inq_varname (void)
void test_nc_inq_varnatts (void)
void test_nc_inq_varndims (void)
void test_nc_inq_vartype (void)
void test_nc_inq_var (void)
void test_nc_get_var_double (void)
void test_nc_get_var_float (void)
void test_nc_get_var_int (void)
void test_nc_get_var_long (void)
void test_nc_get_var_schar (void)
void test_nc_get_var_short (void)
void test_nc_get_var_text (void)
void test_nc_get_var_uchar (void)
void test_nc_get_var (void)
void test_nc_get_var1_double (void)
void test_nc_get_var1_float (void)
void test_nc_get_var1_int (void)
void test_nc_get_var1_long (void)
void test_nc_get_var1_schar (void)
void test_nc_get_var1_short (void)
void test_nc_get_var1_text (void)
void test_nc_get_var1_uchar (void)
void test_nc_get_var1 (void)
void test_nc_get_vara_double (void)
void test_nc_get_vara_float (void)
void test_nc_get_vara_int (void)
void test_nc_get_vara_long (void)
void test_nc_get_vara_schar (void)
void test_nc_get_vara_short (void)
void test_nc_get_vara_text (void)
void test_nc_get_vara_uchar (void)
void test_nc_get_vara (void)
void test_nc_get_vars (void)
void test_nc_get_vars_double (void)
void test_nc_get_vars_float (void)
void test_nc_get_vars_int (void)
void test_nc_get_vars_long (void)
void test_nc_get_vars_schar (void)
void test_nc_get_vars_short (void)
void test_nc_get_vars_text (void)
void test_nc_get_vars_uchar (void)
void test_nc_get_varm (void)
void test_nc_get_varm_double (void)
void test_nc_get_varm_float (void)
void test_nc_get_varm_int (void)
void test_nc_get_varm_long (void)
void test_nc_get_varm_schar (void)
void test_nc_get_varm_short (void)
void test_nc_get_varm_text (void)
void test_nc_get_varm_uchar (void)
void test_nc_get_att (void)
void test_nc_get_att_double (void)
void test_nc_get_att_float (void)
void test_nc_get_att_int (void)
void test_nc_get_att_long (void)
void test_nc_get_att_schar (void)
void test_nc_get_att_short (void)
void test_nc_get_att_text (void)
void test_nc_get_att_uchar (void)
void test_nc_put_var_double (void)
void test_nc_put_var_float (void)
void test_nc_put_var_int (void)
void test_nc_put_var_long (void)
void test_nc_put_var_schar (void)
void test_nc_put_var_short (void)
void test_nc_put_var_text (void)
void test_nc_put_var_uchar (void)
void test_nc_put_var (void)
void test_nc_put_var1_double (void)
void test_nc_put_var1_float (void)
void test_nc_put_var1_int (void)
void test_nc_put_var1_long (void)
void test_nc_put_var1_schar (void)
void test_nc_put_var1_short (void)
void test_nc_put_var1_text (void)
void test_nc_put_var1_uchar (void)
void test_nc_put_var1 (void)
void test_nc_put_vara_double (void)
void test_nc_put_vara_float (void)
void test_nc_put_vara_int (void)
void test_nc_put_vara_long (void)
void test_nc_put_vara_schar (void)
void test_nc_put_vara_short (void)
void test_nc_put_vara_text (void)
void test_nc_put_vara_uchar (void)
void test_nc_put_vara (void)
void test_nc_put_vars_double (void)
void test_nc_put_vars_float (void)
void test_nc_put_vars_int (void)
void test_nc_put_vars_long (void)
void test_nc_put_vars_schar (void)
void test_nc_put_vars_short (void)
void test_nc_put_vars_text (void)
void test_nc_put_vars_uchar (void)
void test_nc_put_vars (void)
void test_nc_put_varm_double (void)
void test_nc_put_varm_float (void)
void test_nc_put_varm_int (void)
void test_nc_put_varm_long (void)
void test_nc_put_varm_schar (void)
void test_nc_put_varm_short (void)
void test_nc_put_varm_text (void)
void test_nc_put_varm_uchar (void)
void test_nc_put_varm (void)
void test_nc_put_att (void)
void test_nc_put_att_double (void)
void test_nc_put_att_float (void)
void test_nc_put_att_int (void)
void test_nc_put_att_long (void)
void test_nc_put_att_schar (void)
void test_nc_put_att_short (void)
void test_nc_put_att_text (void)
void test_nc_put_att_uchar (void)
void test_nc_create (void)
void test_nc_redef (void)
void test_nc_enddef (void)
void test_nc_sync (void)
void test_nc_abort (void)
void test_nc_def_dim (void)
void test_nc_rename_dim (void)
void test_nc_def_var (void)
void test_nc_rename_var (void)
void test_nc_copy_att (void)
void test_nc_inq_att (void)
void test_nc_inq_attname (void)
void test_nc_inq_attid (void)
void test_nc_inq_attlen (void)
void test_nc_inq_atttype (void)
void test_nc_rename_att (void)
void test_nc_del_att (void)
void test_nc_set_fill (void)
void print_nok (int nok)
int inRange (const double value, const nc_type datatype)
int inRange3 (const double value, const nc_type datatype, const nct_itype itype)
int equal (const double x, const double y, nc_type extType, nct_itype itype)
int int_vec_eq (const int *v1, const int *v2, const int n)
int roll (int n)
int toMixedBase (size_t number, size_t length, const size_t base[], size_t result[])
size_t fromMixedBase (size_t length, size_t number[], size_t base[])
int nc2dbl (const nc_type datatype, const void *p, double *result)
int dbl2nc (const double d, const nc_type datatype, void *p)
double hash (const nc_type type, const int rank, const size_t *index)
double hash4 (const nc_type type, const int rank, const size_t *index, const nct_itype itype)
void init_gvars (void)
void def_dims (int ncid)
void def_vars (int ncid)
void put_atts (int ncid)
void put_vars (int ncid)
void write_file (char *filename)
void check_dims (int ncid)
void check_vars (int ncid)
void check_atts (int ncid)
void check_file (char *filename)
int nctypelen (nc_type datatype)
int nc_put_att (int ncid, int varid, const char *name, nc_type datatype, size_t len, const void *value)
int nc_get_att (int ncid, int varid, const char *name, void *value)
int nc_put_var1 (int ncid, int varid, const size_t *index, const void *value)
int nc_get_var1 (int ncid, int varid, const size_t *index, void *value)
int nc_put_vara (int ncid, int varid, const size_t *start, const size_t *count, const void *value)
int nc_get_vara (int ncid, int varid, const size_t *start, const size_t *count, void *value)
int nc_put_vars (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const void *value)
int nc_get_vars (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, void *value)
int nc_put_varm (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const ptrdiff_t *map, const void *value)
int nc_get_varm (int ncid, int varid, const size_t *start, const size_t *count, const ptrdiff_t *stride, const ptrdiff_t *map, void *value)

Variables

char testfile []
char scratch []
int read_only
int verbose
int nfails
char dim_name [NDIMS][3]
size_t dim_len [NDIMS]
char var_name [NVARS][2+MAX_RANK]
nc_type var_type [NVARS]
size_t var_rank [NVARS]
int var_dimid [NVARS][MAX_RANK]
size_t var_shape [NVARS][MAX_RANK]
size_t var_nels [NVARS]
size_t var_natts [NVARS]
char att_name [NVARS][MAX_NATTS][2]
char gatt_name [NGATTS][3]
nc_type att_type [NVARS][NGATTS]
nc_type gatt_type [NGATTS]
size_t att_len [NVARS][MAX_NATTS]
size_t gatt_len [NGATTS]

Define Documentation

#define ABS      ((x) < 0 ? -(x) : (x))
 

Definition at line 77 of file tests.h.

#define ATT_LEN varid,
j       (varid < 0 ? gatt_len[j] : att_len[varid][j])
 

Definition at line 181 of file tests.h.

#define ATT_NAME varid,
j       (varid < 0 ? gatt_name[j] : att_name[varid][j])
 

Definition at line 179 of file tests.h.

#define ATT_TYPE varid,
j       (varid < 0 ? gatt_type[j] : att_type[varid][j])
 

Definition at line 180 of file tests.h.

#define BAD_ATTNUM   -1
 

Definition at line 122 of file tests.h.

#define BAD_DIMID   -1
 

Definition at line 120 of file tests.h.

#define BAD_FILLMODE   -1
 

Definition at line 124 of file tests.h.

#define BAD_ID   -1
 

Definition at line 119 of file tests.h.

#define BAD_NAME   "a+b"
 

Definition at line 125 of file tests.h.

#define BAD_TYPE   (nc_type) 0
 

Definition at line 123 of file tests.h.

#define BAD_VARID   -2
 

Definition at line 121 of file tests.h.

#define double_max   DBL_MAX
 

Definition at line 113 of file tests.h.

Referenced by mri_max(), and mri_maxabs().

#define double_min   (-DBL_MAX)
 

Definition at line 104 of file tests.h.

Referenced by mri_min().

#define float_max   FLT_MAX
 

Definition at line 112 of file tests.h.

Referenced by mri_max().

#define float_min   (-FLT_MAX)
 

Definition at line 103 of file tests.h.

Referenced by mri_min().

#define int_max   INT_MAX
 

Definition at line 110 of file tests.h.

Referenced by mri_max(), and mri_maxabs().

#define int_min   INT_MIN
 

Definition at line 101 of file tests.h.

Referenced by mri_min().

#define LEN_OF array       ((sizeof array) / (sizeof array[0]))
 

Definition at line 127 of file tests.h.

#define long_max   LONG_MAX
 

Definition at line 111 of file tests.h.

#define long_min   LONG_MIN
 

Definition at line 102 of file tests.h.

#define MAX a,
b       ((a) > (b) ? (a) : (b))
 

Definition at line 69 of file tests.h.

#define MAX_DIM_LEN   4
 

Definition at line 91 of file tests.h.

#define MAX_NATTS   3
 

Definition at line 92 of file tests.h.

#define MAX_NELS   64
 

Definition at line 90 of file tests.h.

#define MAX_RANK   3
 

Definition at line 89 of file tests.h.

#define MIN a,
b       ((a) < (b) ? (a) : (b))
 

Definition at line 73 of file tests.h.

#define NATTS varid       (varid < 0 ? NGATTS : var_natts[varid])
 

Definition at line 178 of file tests.h.

#define NCT_CHAR   NCT_TEXT
 

#define NDIMS   5
 

Definition at line 84 of file tests.h.

#define NGATTS   NTYPES
 

Definition at line 87 of file tests.h.

#define NO_NETCDF_2   1
 

Definition at line 12 of file tests.h.

#define NRECS   2
 

Definition at line 86 of file tests.h.

#define NTYPES   6
 

Definition at line 83 of file tests.h.

#define NVARS   136
 

Definition at line 85 of file tests.h.

#define RECDIM   0
 

Definition at line 88 of file tests.h.

#define schar_max   SCHAR_MAX
 

Definition at line 108 of file tests.h.

#define schar_min   SCHAR_MIN
 

Definition at line 99 of file tests.h.

#define short_max   SHRT_MAX
 

Definition at line 109 of file tests.h.

Referenced by mri_max().

#define short_min   SHRT_MIN
 

Definition at line 100 of file tests.h.

Referenced by mri_min().

#define text_max   CHAR_MAX
 

Definition at line 106 of file tests.h.

#define text_min   CHAR_MIN
 

Definition at line 97 of file tests.h.

#define uchar_max   UCHAR_MAX
 

Definition at line 107 of file tests.h.

#define uchar_min   0
 

Definition at line 98 of file tests.h.

#define VARID varid       (varid < 0 ? NC_GLOBAL : varid)
 

Definition at line 177 of file tests.h.

#define X_BYTE_MAX   127
 

Definition at line 27 of file tests.h.

#define X_BYTE_MIN   (-128)
 

Definition at line 26 of file tests.h.

#define X_CHAR_MAX   CHAR_MAX
 

Definition at line 25 of file tests.h.

#define X_CHAR_MIN   CHAR_MIN
 

Definition at line 24 of file tests.h.

#define X_DOUBLE_MAX   1.7976931348623157e+308
 

Definition at line 44 of file tests.h.

#define X_DOUBLE_MIN   (-X_DOUBLE_MAX)
 

Definition at line 46 of file tests.h.

#define X_FLOAT_MAX   3.40282347e+38f
 

Definition at line 36 of file tests.h.

#define X_FLOAT_MIN   (-X_FLOAT_MAX)
 

Definition at line 38 of file tests.h.

#define X_INT_MAX   2147483647
 

Definition at line 31 of file tests.h.

#define X_INT_MIN   (-2147483648.)
 

Definition at line 30 of file tests.h.

#define X_SHORT_MAX   32767
 

Definition at line 29 of file tests.h.

#define X_SHORT_MIN   (-32768)
 

Definition at line 28 of file tests.h.


Typedef Documentation

typedef signed char schar
 

Definition at line 137 of file tests.h.

typedef char text
 

Definition at line 136 of file tests.h.

typedef unsigned char uchar
 

Definition at line 139 of file tests.h.


Enumeration Type Documentation

enum nct_itype
 

Enumeration values:
NCT_UNSPECIFIED 
NCT_UCHAR 
NCT_TEXT 
NCT_SCHAR 
NCT_SHORT 
NCT_INT 
NCT_LONG 
NCT_FLOAT 
NCT_DOUBLE 

Definition at line 358 of file tests.h.

00358              {
00359         NCT_UNSPECIFIED = 0,
00360         NCT_UCHAR =     1,      /* unsigned char */
00361         NCT_TEXT =      16,     /* char */
00362 #define NCT_CHAR NCT_TEXT
00363         NCT_SCHAR =     17,     /* signed char */
00364         NCT_SHORT =     18,     /* short */
00365         NCT_INT =       20,     /* int */
00366         NCT_LONG =      22,     /* long */
00367         NCT_FLOAT =     36,     /* float */
00368         NCT_DOUBLE =    40      /* double */
00369 } nct_itype;

Function Documentation

void check_atts int    ncid
 

void check_dims int    ncid
 

void check_file char *    filename
 

void check_vars int    ncid
 

int dbl2nc const double    d,
const nc_type    datatype,
void *    p
 

void def_dims int    ncid
 

void def_vars int    ncid
 

int equal const double    x,
const double    y,
nc_type    extType,
nct_itype    itype
 

size_t fromMixedBase size_t    length,
size_t    number[],
size_t    base[]
 

double hash const nc_type    type,
const int    rank,
const size_t *    index
 

Referenced by mk_hashtab(), and x_rsne().

double hash4 const nc_type    type,
const int    rank,
const size_t *    index,
const nct_itype    itype
 

void init_gvars void   
 

int inRange const double    value,
const nc_type    datatype
 

int inRange3 const double    value,
const nc_type    datatype,
const nct_itype    itype
 

int int_vec_eq const int *    v1,
const int *    v2,
const int    n
 

int nc2dbl const nc_type    datatype,
const void *    p,
double *    result
 

int nc_get_att int    ncid,
int    varid,
const char *    name,
void *    value
 

Definition at line 2214 of file attr.c.

References name, nc_get_att_double(), nc_get_att_float(), nc_get_att_int(), nc_get_att_long(), nc_get_att_schar(), nc_get_att_short(), nc_get_att_text(), NC_lookupattr(), and NC_attr::type.

Referenced by ncattget().

02215 {
02216         int status;
02217         NC_attr *attrp;
02218 
02219         status = NC_lookupattr(ncid, varid, name, &attrp);
02220         if(status != NC_NOERR)
02221                 return status;
02222 
02223         switch (attrp->type) {
02224         case NC_BYTE:
02225                 return nc_get_att_schar(ncid, varid, name,
02226                         (schar *)value);
02227         case NC_CHAR:
02228                 return nc_get_att_text(ncid, varid, name,
02229                         (char *)value);
02230         case NC_SHORT:
02231                 return nc_get_att_short(ncid, varid, name,
02232                         (short *)value);
02233         case NC_INT:
02234 #if (SIZEOF_INT >= X_SIZEOF_INT)
02235                 return nc_get_att_int(ncid, varid, name,
02236                         (int *)value);
02237 #elif SIZEOF_LONG == X_SIZEOF_INT
02238                 return nc_get_att_long(ncid, varid, name,
02239                         (long *)value);
02240 #endif
02241         case NC_FLOAT:
02242                 return nc_get_att_float(ncid, varid, name,
02243                         (float *)value);
02244         case NC_DOUBLE:
02245                 return nc_get_att_double(ncid, varid, name,
02246                         (double *)value);
02247         }
02248         return NC_EBADTYPE;
02249 }

int nc_get_var1 int    ncid,
int    varid,
const size_t *    index,
void *    value
 

Definition at line 4920 of file putget.c.

References NC_check_id(), nc_get_var1_double(), nc_get_var1_float(), nc_get_var1_int(), nc_get_var1_schar(), nc_get_var1_short(), nc_get_var1_text(), NC_lookupvar(), and NC_var::type.

Referenced by ncvarget1().

04921 {
04922         int status;
04923         NC *ncp;
04924         const NC_var *varp;
04925 
04926         status = NC_check_id(ncid, &ncp); 
04927         if(status != NC_NOERR)
04928                 return status;
04929 
04930         varp = NC_lookupvar(ncp, varid);
04931         if(varp == NULL)
04932                 return NC_ENOTVAR;
04933 
04934         switch(varp->type){
04935         case NC_CHAR:
04936                 return nc_get_var1_text(ncid, varid, coord,
04937                         (char *) value);
04938         case NC_BYTE:
04939                 return nc_get_var1_schar(ncid, varid, coord,
04940                         (schar *) value);
04941         case NC_SHORT:
04942                 return nc_get_var1_short(ncid, varid, coord,
04943                         (short *) value);
04944         case NC_INT:
04945                 return nc_get_var1_int(ncid, varid, coord,
04946                         (int *) value);
04947         case NC_FLOAT:
04948                 return nc_get_var1_float(ncid, varid, coord,
04949                         (float *) value);
04950         case NC_DOUBLE: 
04951                 return nc_get_var1_double(ncid, varid, coord,
04952                         (double *) value);
04953         }
04954         return NC_EBADTYPE;
04955 }

int nc_get_vara int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
void *    value
 

Definition at line 6663 of file putget.c.

References NC_check_id(), nc_get_vara_double(), nc_get_vara_float(), nc_get_vara_int(), nc_get_vara_long(), nc_get_vara_schar(), nc_get_vara_short(), nc_get_vara_text(), NC_indef, NC_lookupvar(), and NC_var::type.

Referenced by ncvarget().

06665 {
06666         int status;
06667         NC *ncp;
06668         const NC_var *varp;
06669 
06670         status = NC_check_id(ncid, &ncp); 
06671         if(status != NC_NOERR)
06672                 return status;
06673 
06674         if(NC_indef(ncp))
06675                 return NC_EINDEFINE;
06676 
06677         varp = NC_lookupvar(ncp, varid);
06678         if(varp == NULL)
06679                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06680 
06681         switch(varp->type){
06682         case NC_CHAR:
06683                 return nc_get_vara_text(ncid, varid, start, edges,
06684                         (char *) value);
06685         case NC_BYTE:
06686                 return nc_get_vara_schar(ncid, varid, start, edges,
06687                         (schar *) value);
06688         case NC_SHORT:
06689                 return nc_get_vara_short(ncid, varid, start, edges,
06690                         (short *) value);
06691         case NC_INT:
06692 #if (SIZEOF_INT >= X_SIZEOF_INT)
06693                 return nc_get_vara_int(ncid, varid, start, edges,
06694                         (int *) value);
06695 #elif SIZEOF_LONG == X_SIZEOF_INT
06696                 return nc_get_vara_long(ncid, varid, start, edges,
06697                         (long *) value);
06698 #else
06699 #error "nc_get_vara implementation"
06700 #endif
06701         case NC_FLOAT:
06702                 return nc_get_vara_float(ncid, varid, start, edges,
06703                         (float *) value);
06704         case NC_DOUBLE: 
06705                 return nc_get_vara_double(ncid, varid, start, edges,
06706                         (double *) value);
06707         }
06708         return NC_EBADTYPE;
06709 }

int nc_get_varm int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
const ptrdiff_t *    stride,
const ptrdiff_t *    map,
void *    value
 

Definition at line 9707 of file putget.c.

References calloc, free, NC_check_id(), nc_get_varm_double(), nc_get_varm_float(), nc_get_varm_int(), nc_get_varm_long(), nc_get_varm_schar(), nc_get_varm_short(), nc_get_varm_text(), NC_lookupvar(), nctypelen(), NC_var::ndims, stride, and NC_var::type.

Referenced by nc_get_vars(), and ncvargetg().

09715 {
09716         int status;
09717         NC *ncp;
09718         const NC_var *varp;
09719         ptrdiff_t *cvtmap = NULL;
09720 
09721         status = NC_check_id(ncid, &ncp); 
09722         if(status != NC_NOERR)
09723                 return status;
09724 
09725         varp = NC_lookupvar(ncp, varid);
09726         if(varp == NULL)
09727                 return NC_ENOTVAR;
09728 
09729         if(map != NULL && varp->ndims != 0)
09730         {
09731                 /*
09732                  * convert map units from bytes to units of sizeof(type)
09733                  */
09734                 size_t ii;
09735                 const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type);
09736                 cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t));
09737                 if(cvtmap == NULL)
09738                         return NC_ENOMEM;
09739                 for(ii = 0; ii < varp->ndims; ii++)
09740                 {
09741                         if(map[ii] % szof != 0) 
09742                         {
09743                                 free(cvtmap);
09744                                 return NC_EINVAL;
09745                         }
09746                         cvtmap[ii] = map[ii] / szof;
09747                 }
09748                 map = cvtmap;
09749         }
09750 
09751         switch(varp->type){
09752         case NC_CHAR:
09753                 status =  nc_get_varm_text(ncid, varid, start, edges,
09754                         stride, map,
09755                         (char *) value);
09756                 break;
09757         case NC_BYTE:
09758                 status = nc_get_varm_schar(ncid, varid, start, edges,
09759                         stride, map,
09760                         (schar *) value);
09761                 break;
09762         case NC_SHORT:
09763                 status = nc_get_varm_short(ncid, varid, start, edges,
09764                         stride, map,
09765                         (short *) value);
09766                 break;
09767         case NC_INT:
09768 #if (SIZEOF_INT >= X_SIZEOF_INT)
09769                 status = nc_get_varm_int(ncid, varid, start, edges,
09770                         stride, map,
09771                         (int *) value);
09772 #elif SIZEOF_LONG == X_SIZEOF_INT
09773                 status = nc_get_varm_long(ncid, varid, start, edges,
09774                         stride, map,
09775                         (long *) value);
09776 #else
09777 #error "nc_get_varm implementation"
09778 #endif
09779                 break;
09780         case NC_FLOAT:
09781                 status = nc_get_varm_float(ncid, varid, start, edges,
09782                         stride, map,
09783                         (float *) value);
09784                 break;
09785         case NC_DOUBLE: 
09786                 status = nc_get_varm_double(ncid, varid, start, edges,
09787                         stride, map,
09788                         (double *) value);
09789                 break;
09790         default:
09791                 status = NC_EBADTYPE;
09792                 break;
09793         }
09794 
09795         if(cvtmap != NULL)
09796         {
09797                 free(cvtmap);
09798         }
09799         return status;
09800 }

int nc_get_vars int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
const ptrdiff_t *    stride,
void *    value
 

Definition at line 8069 of file putget.c.

References nc_get_varm(), and stride.

Referenced by ncvargets().

08076 {
08077         return nc_get_varm (ncid, varid, start, edges,
08078                          stride, 0, value);
08079 }

int nc_put_att int    ncid,
int    varid,
const char *    name,
nc_type    datatype,
size_t    len,
const void *    value
 

Definition at line 2175 of file attr.c.

References name, nc_put_att_double(), nc_put_att_float(), nc_put_att_int(), nc_put_att_long(), nc_put_att_schar(), nc_put_att_short(), and nc_put_att_text().

Referenced by ncattput().

02182 {
02183         switch (type) {
02184         case NC_BYTE:
02185                 return nc_put_att_schar(ncid, varid, name, type, nelems,
02186                         (schar *)value);
02187         case NC_CHAR:
02188                 return nc_put_att_text(ncid, varid, name, nelems,
02189                         (char *)value);
02190         case NC_SHORT:
02191                 return nc_put_att_short(ncid, varid, name, type, nelems,
02192                         (short *)value);
02193         case NC_INT:
02194 #if (SIZEOF_INT >= X_SIZEOF_INT)
02195                 return nc_put_att_int(ncid, varid, name, type, nelems,
02196                         (int *)value);
02197 #elif SIZEOF_LONG == X_SIZEOF_INT
02198                 return nc_put_att_long(ncid, varid, name, type, nelems,
02199                         (long *)value);
02200 #endif
02201         case NC_FLOAT:
02202                 return nc_put_att_float(ncid, varid, name, type, nelems,
02203                         (float *)value);
02204         case NC_DOUBLE:
02205                 return nc_put_att_double(ncid, varid, name, type, nelems,
02206                         (double *)value);
02207         }
02208         return NC_EBADTYPE;
02209 }

int nc_put_var1 int    ncid,
int    varid,
const size_t *    index,
const void *    value
 

Definition at line 4653 of file putget.c.

References NC_check_id(), NC_lookupvar(), nc_put_var1_double(), nc_put_var1_float(), nc_put_var1_int(), nc_put_var1_schar(), nc_put_var1_short(), nc_put_var1_text(), and NC_var::type.

Referenced by ncvarput1().

04654 {
04655         int status;
04656         NC *ncp;
04657         const NC_var *varp;
04658 
04659         status = NC_check_id(ncid, &ncp); 
04660         if(status != NC_NOERR)
04661                 return status;
04662 
04663         varp = NC_lookupvar(ncp, varid);
04664         if(varp == NULL)
04665                 return NC_ENOTVAR;
04666 
04667         switch(varp->type){
04668         case NC_CHAR:
04669                 return nc_put_var1_text(ncid, varid, coord,
04670                         (const char *) value);
04671         case NC_BYTE:
04672                 return nc_put_var1_schar(ncid, varid, coord,
04673                         (const schar *) value);
04674         case NC_SHORT:
04675                 return nc_put_var1_short(ncid, varid, coord,
04676                         (const short *) value);
04677         case NC_INT:
04678                 return nc_put_var1_int(ncid, varid, coord,
04679                         (const int *) value);
04680         case NC_FLOAT:
04681                 return nc_put_var1_float(ncid, varid, coord,
04682                         (const float *) value);
04683         case NC_DOUBLE: 
04684                 return nc_put_var1_double(ncid, varid, coord,
04685                         (const double *) value);
04686         }
04687         return NC_EBADTYPE;
04688 }

int nc_put_vara int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
const void *    value
 

Definition at line 5812 of file putget.c.

References NC_check_id(), NC_indef, NC_lookupvar(), nc_put_vara_double(), nc_put_vara_float(), nc_put_vara_int(), nc_put_vara_schar(), nc_put_vara_short(), nc_put_vara_text(), NC_readonly, and NC_var::type.

Referenced by ncvarput().

05814 {
05815         int status;
05816         NC *ncp;
05817         const NC_var *varp;
05818 
05819         status = NC_check_id(ncid, &ncp); 
05820         if(status != NC_NOERR)
05821                 return status;
05822 
05823         if(NC_readonly(ncp))
05824                 return NC_EPERM;
05825 
05826         if(NC_indef(ncp))
05827                 return NC_EINDEFINE;
05828 
05829         varp = NC_lookupvar(ncp, varid);
05830         if(varp == NULL)
05831                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05832 
05833         switch(varp->type){
05834         case NC_CHAR:
05835                 return nc_put_vara_text(ncid, varid, start, edges,
05836                         (const char *) value);
05837         case NC_BYTE:
05838                 return nc_put_vara_schar(ncid, varid, start, edges,
05839                         (const schar *) value);
05840         case NC_SHORT:
05841                 return nc_put_vara_short(ncid, varid, start, edges,
05842                         (const short *) value);
05843         case NC_INT:
05844                 return nc_put_vara_int(ncid, varid, start, edges,
05845                         (const int *) value);
05846         case NC_FLOAT:
05847                 return nc_put_vara_float(ncid, varid, start, edges,
05848                         (const float *) value);
05849         case NC_DOUBLE: 
05850                 return nc_put_vara_double(ncid, varid, start, edges,
05851                         (const double *) value);
05852         }
05853         return NC_EBADTYPE;
05854 }

int nc_put_varm int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
const ptrdiff_t *    stride,
const ptrdiff_t *    map,
const void *    value
 

Definition at line 11268 of file putget.c.

References calloc, free, NC_check_id(), NC_lookupvar(), nc_put_varm_double(), nc_put_varm_float(), nc_put_varm_int(), nc_put_varm_long(), nc_put_varm_schar(), nc_put_varm_short(), nc_put_varm_text(), nctypelen(), NC_var::ndims, stride, and NC_var::type.

Referenced by nc_put_vars(), and ncvarputg().

11276 {
11277         int status;
11278         NC *ncp;
11279         const NC_var *varp;
11280         ptrdiff_t *cvtmap = NULL;
11281 
11282         status = NC_check_id(ncid, &ncp); 
11283         if(status != NC_NOERR)
11284                 return status;
11285 
11286         varp = NC_lookupvar(ncp, varid);
11287         if(varp == NULL)
11288                 return NC_ENOTVAR;
11289 
11290         if(map != NULL && varp->ndims != 0)
11291         {
11292                 /*
11293                  * convert map units from bytes to units of sizeof(type)
11294                  */
11295                 size_t ii;
11296                 const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type);
11297                 cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t));
11298                 if(cvtmap == NULL)
11299                         return NC_ENOMEM;
11300                 for(ii = 0; ii < varp->ndims; ii++)
11301                 {
11302                         if(map[ii] % szof != 0) 
11303                         {
11304                                 free(cvtmap);
11305                                 return NC_EINVAL;
11306                         }
11307                         cvtmap[ii] = map[ii] / szof;
11308                 }
11309                 map = cvtmap;
11310         }
11311 
11312         switch(varp->type){
11313         case NC_CHAR:
11314                 status =  nc_put_varm_text(ncid, varid, start, edges,
11315                         stride, map,
11316                         (const char *) value);
11317                 break;
11318         case NC_BYTE:
11319                 status = nc_put_varm_schar(ncid, varid, start, edges,
11320                         stride, map,
11321                         (const schar *) value);
11322                 break;
11323         case NC_SHORT:
11324                 status = nc_put_varm_short(ncid, varid, start, edges,
11325                         stride, map,
11326                         (const short *) value);
11327                 break;
11328         case NC_INT:
11329 #if (SIZEOF_INT >= X_SIZEOF_INT)
11330                 status = nc_put_varm_int(ncid, varid, start, edges,
11331                         stride, map,
11332                         (const int *) value);
11333 #elif SIZEOF_LONG == X_SIZEOF_INT
11334                 status = nc_put_varm_long(ncid, varid, start, edges,
11335                         stride, map,
11336                         (const long *) value);
11337 #else
11338 #error "nc_put_varm implementation"
11339 #endif
11340                 break;
11341         case NC_FLOAT:
11342                 status = nc_put_varm_float(ncid, varid, start, edges,
11343                         stride, map,
11344                         (const float *) value);
11345                 break;
11346         case NC_DOUBLE: 
11347                 status = nc_put_varm_double(ncid, varid, start, edges,
11348                         stride, map,
11349                         (const double *) value);
11350                 break;
11351         default:
11352                 status = NC_EBADTYPE;
11353                 break;
11354         }
11355 
11356         if(cvtmap != NULL)
11357         {
11358                 free(cvtmap);
11359         }
11360         return status;
11361 }

int nc_put_vars int    ncid,
int    varid,
const size_t *    start,
const size_t *    count,
const ptrdiff_t *    stride,
const void *    value
 

Definition at line 8190 of file putget.c.

References nc_put_varm(), and stride.

Referenced by ncvarputs().

08197 {
08198         return nc_put_varm (ncid, varid, start, edges,
08199                          stride, 0, value);
08200 }

int nctypelen nc_type    datatype
 

Definition at line 842 of file v2i.c.

00843 {
00844         switch(type){
00845         case NC_BYTE :
00846         case NC_CHAR :
00847                 return((int)sizeof(char));
00848         case NC_SHORT :
00849                 return(int)(sizeof(short));
00850         case NC_INT :
00851                 return((int)sizeof(int));
00852         case NC_FLOAT :
00853                 return((int)sizeof(float));
00854         case NC_DOUBLE : 
00855                 return((int)sizeof(double));
00856         }
00857 
00858 #ifndef NO_NETCDF_2
00859         /* else */
00860         nc_advise("nctypelen", NC_EBADTYPE, "Unknown type %d",
00861                 (int)type);
00862 #endif /* NO_NETCDF_2 */
00863         return -1;
00864 }

void print_nok int    nok
 

void put_atts int    ncid
 

void put_vars int    ncid
 

int roll int    n
 

Referenced by main(), NUD_nudge_CB(), RCREND_do_incrot(), RCREND_inc_angles(), RCREND_rotmatrix_to_angles(), REND_do_incrot(), REND_inc_angles(), REND_rotmatrix_to_angles(), RT_registration_3D_onevol(), and VOLREG_main().

const char* s_nc_type nc_type   
 

void test_nc_abort void   
 

void test_nc_close void   
 

void test_nc_copy_att void   
 

void test_nc_create void   
 

void test_nc_def_dim void   
 

void test_nc_def_var void   
 

void test_nc_del_att void   
 

void test_nc_enddef void   
 

void test_nc_get_att void   
 

void test_nc_get_att_double void   
 

void test_nc_get_att_float void   
 

void test_nc_get_att_int void   
 

void test_nc_get_att_long void   
 

void test_nc_get_att_schar void   
 

void test_nc_get_att_short void   
 

void test_nc_get_att_text void   
 

void test_nc_get_att_uchar void   
 

void test_nc_get_var void   
 

void test_nc_get_var1 void   
 

void test_nc_get_var1_double void   
 

void test_nc_get_var1_float void   
 

void test_nc_get_var1_int void   
 

void test_nc_get_var1_long void   
 

void test_nc_get_var1_schar void   
 

void test_nc_get_var1_short void   
 

void test_nc_get_var1_text void   
 

void test_nc_get_var1_uchar void   
 

void test_nc_get_var_double void   
 

void test_nc_get_var_float void   
 

void test_nc_get_var_int void   
 

void test_nc_get_var_long void   
 

void test_nc_get_var_schar void   
 

void test_nc_get_var_short void   
 

void test_nc_get_var_text void   
 

void test_nc_get_var_uchar void   
 

void test_nc_get_vara void   
 

void test_nc_get_vara_double void   
 

void test_nc_get_vara_float void   
 

void test_nc_get_vara_int void   
 

void test_nc_get_vara_long void   
 

void test_nc_get_vara_schar void   
 

void test_nc_get_vara_short void   
 

void test_nc_get_vara_text void   
 

void test_nc_get_vara_uchar void   
 

void test_nc_get_varm void   
 

void test_nc_get_varm_double void   
 

void test_nc_get_varm_float void   
 

void test_nc_get_varm_int void   
 

void test_nc_get_varm_long void   
 

void test_nc_get_varm_schar void   
 

void test_nc_get_varm_short void   
 

void test_nc_get_varm_text void   
 

void test_nc_get_varm_uchar void   
 

void test_nc_get_vars void   
 

void test_nc_get_vars_double void   
 

void test_nc_get_vars_float void   
 

void test_nc_get_vars_int void   
 

void test_nc_get_vars_long void   
 

void test_nc_get_vars_schar void   
 

void test_nc_get_vars_short void   
 

void test_nc_get_vars_text void   
 

void test_nc_get_vars_uchar void   
 

void test_nc_inq void   
 

void test_nc_inq_att void   
 

void test_nc_inq_attid void   
 

void test_nc_inq_attlen void   
 

void test_nc_inq_attname void   
 

void test_nc_inq_atttype void   
 

void test_nc_inq_dim void   
 

void test_nc_inq_dimid void   
 

void test_nc_inq_dimlen void   
 

void test_nc_inq_dimname void   
 

void test_nc_inq_natts void   
 

void test_nc_inq_ndims void   
 

void test_nc_inq_nvars void   
 

void test_nc_inq_unlimdim void   
 

void test_nc_inq_var void   
 

void test_nc_inq_vardimid void   
 

void test_nc_inq_varid void   
 

void test_nc_inq_varname void   
 

void test_nc_inq_varnatts void   
 

void test_nc_inq_varndims void   
 

void test_nc_inq_vartype void   
 

void test_nc_open void   
 

void test_nc_put_att void   
 

void test_nc_put_att_double void   
 

void test_nc_put_att_float void   
 

void test_nc_put_att_int void   
 

void test_nc_put_att_long void   
 

void test_nc_put_att_schar void   
 

void test_nc_put_att_short void   
 

void test_nc_put_att_text void   
 

void test_nc_put_att_uchar void   
 

void test_nc_put_var void   
 

void test_nc_put_var1 void   
 

void test_nc_put_var1_double void   
 

void test_nc_put_var1_float void   
 

void test_nc_put_var1_int void   
 

void test_nc_put_var1_long void   
 

void test_nc_put_var1_schar void   
 

void test_nc_put_var1_short void   
 

void test_nc_put_var1_text void   
 

void test_nc_put_var1_uchar void   
 

void test_nc_put_var_double void   
 

void test_nc_put_var_float void   
 

void test_nc_put_var_int void   
 

void test_nc_put_var_long void   
 

void test_nc_put_var_schar void   
 

void test_nc_put_var_short void   
 

void test_nc_put_var_text void   
 

void test_nc_put_var_uchar void   
 

void test_nc_put_vara void   
 

void test_nc_put_vara_double void   
 

void test_nc_put_vara_float void   
 

void test_nc_put_vara_int void   
 

void test_nc_put_vara_long void   
 

void test_nc_put_vara_schar void   
 

void test_nc_put_vara_short void   
 

void test_nc_put_vara_text void   
 

void test_nc_put_vara_uchar void   
 

void test_nc_put_varm void   
 

void test_nc_put_varm_double void   
 

void test_nc_put_varm_float void   
 

void test_nc_put_varm_int void   
 

void test_nc_put_varm_long void   
 

void test_nc_put_varm_schar void   
 

void test_nc_put_varm_short void   
 

void test_nc_put_varm_text void   
 

void test_nc_put_varm_uchar void   
 

void test_nc_put_vars void   
 

void test_nc_put_vars_double void   
 

void test_nc_put_vars_float void   
 

void test_nc_put_vars_int void   
 

void test_nc_put_vars_long void   
 

void test_nc_put_vars_schar void   
 

void test_nc_put_vars_short void   
 

void test_nc_put_vars_text void   
 

void test_nc_put_vars_uchar void   
 

void test_nc_redef void   
 

void test_nc_rename_att void   
 

void test_nc_rename_dim void   
 

void test_nc_rename_var void   
 

void test_nc_set_fill void   
 

void test_nc_strerror void   
 

void test_nc_sync void   
 

int toMixedBase size_t    number,
size_t    length,
const size_t    base[],
size_t    result[]
 

void write_file char *    filename
 


Variable Documentation

size_t att_len[NVARS][MAX_NATTS]
 

Definition at line 170 of file tests.h.

Referenced by NI_write_element().

char att_name[NVARS][MAX_NATTS][2]
 

Definition at line 166 of file tests.h.

nc_type att_type[NVARS][NGATTS]
 

Definition at line 168 of file tests.h.

size_t dim_len[NDIMS]
 

Definition at line 158 of file tests.h.

char dim_name[NDIMS][3]
 

Definition at line 157 of file tests.h.

size_t gatt_len[NGATTS]
 

Definition at line 171 of file tests.h.

char gatt_name[NGATTS][3]
 

Definition at line 167 of file tests.h.

nc_type gatt_type[NGATTS]
 

Definition at line 169 of file tests.h.

int nfails
 

Definition at line 153 of file tests.h.

int read_only
 

Definition at line 151 of file tests.h.

char scratch[]
 

Definition at line 147 of file tests.h.

Referenced by DCM_DumpElements(), and DCM_FormatElements().

char testfile[]
 

Definition at line 146 of file tests.h.

int var_dimid[NVARS][MAX_RANK]
 

Definition at line 162 of file tests.h.

char var_name[NVARS][2+MAX_RANK]
 

Definition at line 159 of file tests.h.

size_t var_natts[NVARS]
 

Definition at line 165 of file tests.h.

size_t var_nels[NVARS]
 

Definition at line 164 of file tests.h.

size_t var_rank[NVARS]
 

Definition at line 161 of file tests.h.

size_t var_shape[NVARS][MAX_RANK]
 

Definition at line 163 of file tests.h.

nc_type var_type[NVARS]
 

Definition at line 160 of file tests.h.

int verbose
 

Definition at line 152 of file tests.h.

 

Powered by Plone

This site conforms to the following standards: