Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
tests.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <stdio.h>
00007 #include <string.h>
00008 #include <stdlib.h>
00009 #include <assert.h>
00010 #include <limits.h>
00011 #include <float.h>
00012 #define NO_NETCDF_2 1
00013 #include "netcdf.h"
00014 #include "error.h"
00015
00016 #if defined(_CRAY) && !defined(_CRAYIEEE)
00017 #define CRAYFLOAT 1
00018 #elif defined(_SX) && defined(_FLOAT2)
00019 #define CRAYFLOAT 1
00020 #endif
00021
00022
00023
00024 #define X_CHAR_MIN CHAR_MIN
00025 #define X_CHAR_MAX CHAR_MAX
00026 #define X_BYTE_MIN (-128)
00027 #define X_BYTE_MAX 127
00028 #define X_SHORT_MIN (-32768)
00029 #define X_SHORT_MAX 32767
00030 #define X_INT_MIN (-2147483648.)
00031 #define X_INT_MAX 2147483647
00032 #if defined(FLT_MAX_EXP) && FLT_MAX_EXP < 128
00033
00034 #define X_FLOAT_MAX FLT_MAX
00035 #else
00036 #define X_FLOAT_MAX 3.40282347e+38f
00037 #endif
00038 #define X_FLOAT_MIN (-X_FLOAT_MAX)
00039 #if CRAYFLOAT
00040
00041 #define X_DOUBLE_MAX 1.79769313486230e+308
00042 #else
00043
00044 #define X_DOUBLE_MAX 1.7976931348623157e+308
00045 #endif
00046 #define X_DOUBLE_MIN (-X_DOUBLE_MAX)
00047
00048
00049 #if _SX
00050 #if _INT64
00051 #undef INT_MAX
00052 #define INT_MAX X_INT_MAX
00053 #undef INT_MIN
00054 #define INT_MIN X_INT_MIN
00055 #undef LONG_MAX
00056 #define LONG_MAX X_INT_MAX
00057 #undef LONG_MIN
00058 #define LONG_MIN X_INT_MIN
00059 #elif _LONG64
00060 #undef LONG_MAX
00061 #define LONG_MAX 4294967295L
00062 #undef LONG_MIN
00063 #define LONG_MIN -4294967295L
00064 #endif
00065 #endif
00066
00067
00068 #ifndef MAX
00069 #define MAX(a,b) ((a) > (b) ? (a) : (b))
00070 #endif
00071
00072 #ifndef MIN
00073 #define MIN(a,b) ((a) < (b) ? (a) : (b))
00074 #endif
00075
00076 #ifndef ABS
00077 #define ABS(x) ((x) < 0 ? -(x) : (x))
00078 #endif
00079
00080
00081
00082
00083 #define NTYPES 6
00084 #define NDIMS 5
00085 #define NVARS 136
00086 #define NRECS 2
00087 #define NGATTS NTYPES
00088 #define RECDIM 0
00089 #define MAX_RANK 3
00090 #define MAX_NELS 64
00091 #define MAX_DIM_LEN 4
00092 #define MAX_NATTS 3
00093
00094
00095
00096
00097 #define text_min CHAR_MIN
00098 #define uchar_min 0
00099 #define schar_min SCHAR_MIN
00100 #define short_min SHRT_MIN
00101 #define int_min INT_MIN
00102 #define long_min LONG_MIN
00103 #define float_min (-FLT_MAX)
00104 #define double_min (-DBL_MAX)
00105
00106 #define text_max CHAR_MAX
00107 #define uchar_max UCHAR_MAX
00108 #define schar_max SCHAR_MAX
00109 #define short_max SHRT_MAX
00110 #define int_max INT_MAX
00111 #define long_max LONG_MAX
00112 #define float_max FLT_MAX
00113 #define double_max DBL_MAX
00114
00115
00116
00117
00118
00119 #define BAD_ID -1
00120 #define BAD_DIMID -1
00121 #define BAD_VARID -2
00122 #define BAD_ATTNUM -1
00123 #define BAD_TYPE (nc_type) 0
00124 #define BAD_FILLMODE -1
00125 #define BAD_NAME "a+b"
00126
00127 #define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
00128
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132
00133
00134
00135
00136 typedef char text;
00137 typedef signed char schar;
00138 #if !defined(uchar) && !defined(__osf__) && !defined(_AIX)
00139 typedef unsigned char uchar;
00140 #endif
00141
00142
00143
00144
00145
00146 extern char testfile[];
00147 extern char scratch[];
00148
00149
00150
00151 extern int read_only;
00152 extern int verbose;
00153 extern int nfails;
00154
00155
00156
00157 extern char dim_name[NDIMS][3];
00158 extern size_t dim_len[NDIMS];
00159 extern char var_name[NVARS][2+MAX_RANK];
00160 extern nc_type var_type[NVARS];
00161 extern size_t var_rank[NVARS];
00162 extern int var_dimid[NVARS][MAX_RANK];
00163 extern size_t var_shape[NVARS][MAX_RANK];
00164 extern size_t var_nels[NVARS];
00165 extern size_t var_natts[NVARS];
00166 extern char att_name[NVARS][MAX_NATTS][2];
00167 extern char gatt_name[NGATTS][3];
00168 extern nc_type att_type[NVARS][NGATTS];
00169 extern nc_type gatt_type[NGATTS];
00170 extern size_t att_len[NVARS][MAX_NATTS];
00171 extern size_t gatt_len[NGATTS];
00172
00173
00174
00175
00176
00177 #define VARID(varid) (varid < 0 ? NC_GLOBAL : varid)
00178 #define NATTS(varid) (varid < 0 ? NGATTS : var_natts[varid])
00179 #define ATT_NAME(varid,j) (varid < 0 ? gatt_name[j] : att_name[varid][j])
00180 #define ATT_TYPE(varid,j) (varid < 0 ? gatt_type[j] : att_type[varid][j])
00181 #define ATT_LEN(varid,j) (varid < 0 ? gatt_len[j] : att_len[varid][j])
00182
00183 extern const char *s_nc_type(nc_type);
00184
00185 extern void test_nc_strerror(void);
00186 extern void test_nc_open(void);
00187 extern void test_nc_close(void);
00188
00189 extern void test_nc_inq(void);
00190 extern void test_nc_inq_natts(void);
00191 extern void test_nc_inq_ndims(void);
00192 extern void test_nc_inq_nvars(void);
00193 extern void test_nc_inq_unlimdim(void);
00194
00195 extern void test_nc_inq_dimid(void);
00196 extern void test_nc_inq_dim(void);
00197 extern void test_nc_inq_dimlen(void);
00198 extern void test_nc_inq_dimname(void);
00199
00200 extern void test_nc_inq_varid(void);
00201 extern void test_nc_inq_vardimid(void);
00202 extern void test_nc_inq_varname(void);
00203 extern void test_nc_inq_varnatts(void);
00204 extern void test_nc_inq_varndims(void);
00205 extern void test_nc_inq_vartype(void);
00206 extern void test_nc_inq_var(void);
00207
00208 extern void test_nc_get_var_double(void);
00209 extern void test_nc_get_var_float(void);
00210 extern void test_nc_get_var_int(void);
00211 extern void test_nc_get_var_long(void);
00212 extern void test_nc_get_var_schar(void);
00213 extern void test_nc_get_var_short(void);
00214 extern void test_nc_get_var_text(void);
00215 extern void test_nc_get_var_uchar(void);
00216 extern void test_nc_get_var(void);
00217
00218 extern void test_nc_get_var1_double(void);
00219 extern void test_nc_get_var1_float(void);
00220 extern void test_nc_get_var1_int(void);
00221 extern void test_nc_get_var1_long(void);
00222 extern void test_nc_get_var1_schar(void);
00223 extern void test_nc_get_var1_short(void);
00224 extern void test_nc_get_var1_text(void);
00225 extern void test_nc_get_var1_uchar(void);
00226 extern void test_nc_get_var1(void);
00227
00228 extern void test_nc_get_vara_double(void);
00229 extern void test_nc_get_vara_float(void);
00230 extern void test_nc_get_vara_int(void);
00231 extern void test_nc_get_vara_long(void);
00232 extern void test_nc_get_vara_schar(void);
00233 extern void test_nc_get_vara_short(void);
00234 extern void test_nc_get_vara_text(void);
00235 extern void test_nc_get_vara_uchar(void);
00236 extern void test_nc_get_vara(void);
00237
00238 extern void test_nc_get_vars(void);
00239 extern void test_nc_get_vars_double(void);
00240 extern void test_nc_get_vars_float(void);
00241 extern void test_nc_get_vars_int(void);
00242 extern void test_nc_get_vars_long(void);
00243 extern void test_nc_get_vars_schar(void);
00244 extern void test_nc_get_vars_short(void);
00245 extern void test_nc_get_vars_text(void);
00246 extern void test_nc_get_vars_uchar(void);
00247 extern void test_nc_get_vars(void);
00248
00249 extern void test_nc_get_varm(void);
00250 extern void test_nc_get_varm_double(void);
00251 extern void test_nc_get_varm_float(void);
00252 extern void test_nc_get_varm_int(void);
00253 extern void test_nc_get_varm_long(void);
00254 extern void test_nc_get_varm_schar(void);
00255 extern void test_nc_get_varm_short(void);
00256 extern void test_nc_get_varm_text(void);
00257 extern void test_nc_get_varm_uchar(void);
00258 extern void test_nc_get_varm(void);
00259
00260 extern void test_nc_get_att(void);
00261 extern void test_nc_get_att_double(void);
00262 extern void test_nc_get_att_float(void);
00263 extern void test_nc_get_att_int(void);
00264 extern void test_nc_get_att_long(void);
00265 extern void test_nc_get_att_schar(void);
00266 extern void test_nc_get_att_short(void);
00267 extern void test_nc_get_att_text(void);
00268 extern void test_nc_get_att_uchar(void);
00269
00270 extern void test_nc_put_var_double(void);
00271 extern void test_nc_put_var_float(void);
00272 extern void test_nc_put_var_int(void);
00273 extern void test_nc_put_var_long(void);
00274 extern void test_nc_put_var_schar(void);
00275 extern void test_nc_put_var_short(void);
00276 extern void test_nc_put_var_text(void);
00277 extern void test_nc_put_var_uchar(void);
00278 extern void test_nc_put_var(void);
00279
00280 extern void test_nc_put_var1_double(void);
00281 extern void test_nc_put_var1_float(void);
00282 extern void test_nc_put_var1_int(void);
00283 extern void test_nc_put_var1_long(void);
00284 extern void test_nc_put_var1_schar(void);
00285 extern void test_nc_put_var1_short(void);
00286 extern void test_nc_put_var1_text(void);
00287 extern void test_nc_put_var1_uchar(void);
00288 extern void test_nc_put_var1(void);
00289
00290 extern void test_nc_put_vara_double(void);
00291 extern void test_nc_put_vara_float(void);
00292 extern void test_nc_put_vara_int(void);
00293 extern void test_nc_put_vara_long(void);
00294 extern void test_nc_put_vara_schar(void);
00295 extern void test_nc_put_vara_short(void);
00296 extern void test_nc_put_vara_text(void);
00297 extern void test_nc_put_vara_uchar(void);
00298 extern void test_nc_put_vara(void);
00299
00300 extern void test_nc_put_vars_double(void);
00301 extern void test_nc_put_vars_float(void);
00302 extern void test_nc_put_vars_int(void);
00303 extern void test_nc_put_vars_long(void);
00304 extern void test_nc_put_vars_schar(void);
00305 extern void test_nc_put_vars_short(void);
00306 extern void test_nc_put_vars_text(void);
00307 extern void test_nc_put_vars_uchar(void);
00308 extern void test_nc_put_vars(void);
00309
00310 extern void test_nc_put_varm_double(void);
00311 extern void test_nc_put_varm_float(void);
00312 extern void test_nc_put_varm_int(void);
00313 extern void test_nc_put_varm_long(void);
00314 extern void test_nc_put_varm_schar(void);
00315 extern void test_nc_put_varm_short(void);
00316 extern void test_nc_put_varm_text(void);
00317 extern void test_nc_put_varm_uchar(void);
00318 extern void test_nc_put_varm(void);
00319
00320 extern void test_nc_put_att(void);
00321 extern void test_nc_put_att_double(void);
00322 extern void test_nc_put_att_float(void);
00323 extern void test_nc_put_att_int(void);
00324 extern void test_nc_put_att_long(void);
00325 extern void test_nc_put_att_schar(void);
00326 extern void test_nc_put_att_short(void);
00327 extern void test_nc_put_att_text(void);
00328 extern void test_nc_put_att_uchar(void);
00329
00330 extern void test_nc_create(void);
00331 extern void test_nc_redef(void);
00332 extern void test_nc_enddef(void);
00333 extern void test_nc_sync(void);
00334 extern void test_nc_abort(void);
00335 extern void test_nc_def_dim(void);
00336 extern void test_nc_rename_dim(void);
00337 extern void test_nc_def_var(void);
00338 extern void test_nc_rename_var(void);
00339 extern void test_nc_copy_att(void);
00340
00341 extern void test_nc_inq_att(void);
00342 extern void test_nc_inq_attname(void);
00343 extern void test_nc_inq_attid(void);
00344 extern void test_nc_inq_attlen(void);
00345 extern void test_nc_inq_atttype(void);
00346
00347 extern void test_nc_rename_att(void);
00348 extern void test_nc_del_att(void);
00349 extern void test_nc_set_fill(void);
00350
00351 void print_nok(int nok);
00352
00353 int inRange(const double value, const nc_type datatype);
00354
00355
00356
00357
00358 typedef enum {
00359 NCT_UNSPECIFIED = 0,
00360 NCT_UCHAR = 1,
00361 NCT_TEXT = 16,
00362 #define NCT_CHAR NCT_TEXT
00363 NCT_SCHAR = 17,
00364 NCT_SHORT = 18,
00365 NCT_INT = 20,
00366 NCT_LONG = 22,
00367 NCT_FLOAT = 36,
00368 NCT_DOUBLE = 40
00369 } nct_itype;
00370
00371 int inRange3(const double value, const nc_type datatype, const nct_itype itype);
00372
00373 int equal(const double x, const double y, nc_type extType, nct_itype itype);
00374
00375 int int_vec_eq(const int *v1, const int *v2, const int n);
00376
00377 int roll( int n );
00378
00379 int
00380 toMixedBase(
00381 size_t number,
00382 size_t length,
00383 const size_t base[],
00384 size_t result[]);
00385
00386 size_t
00387 fromMixedBase(
00388 size_t length,
00389 size_t number[],
00390 size_t base[]);
00391
00392 int nc2dbl ( const nc_type datatype, const void *p, double *result);
00393
00394 int dbl2nc ( const double d, const nc_type datatype, void *p);
00395
00396 double hash( const nc_type type, const int rank, const size_t *index );
00397
00398 double hash4(
00399 const nc_type type,
00400 const int rank,
00401 const size_t *index,
00402 const nct_itype itype);
00403
00404 void init_gvars(void);
00405
00406 void def_dims(int ncid);
00407
00408 void def_vars(int ncid);
00409
00410 void put_atts(int ncid);
00411
00412 void put_vars(int ncid);
00413
00414 void write_file(char *filename);
00415
00416 void check_dims(int ncid);
00417
00418 void check_vars(int ncid);
00419
00420 void check_atts(int ncid);
00421
00422 void check_file(char *filename);
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 extern int
00433 nctypelen(nc_type datatype);
00434
00435 extern int
00436 nc_put_att(int ncid, int varid, const char *name, nc_type datatype,
00437 size_t len, const void *value);
00438
00439 extern int
00440 nc_get_att(int ncid, int varid, const char *name, void *value);
00441
00442 extern int
00443 nc_put_var1(int ncid, int varid, const size_t *index, const void *value);
00444
00445 extern int
00446 nc_get_var1(int ncid, int varid, const size_t *index, void *value);
00447
00448 extern int
00449 nc_put_vara(int ncid, int varid,
00450 const size_t *start, const size_t *count, const void *value);
00451
00452 extern int
00453 nc_get_vara(int ncid, int varid,
00454 const size_t *start, const size_t *count, void *value);
00455
00456 extern int
00457 nc_put_vars(int ncid, int varid,
00458 const size_t *start, const size_t *count, const ptrdiff_t *stride,
00459 const void * value);
00460
00461 extern int
00462 nc_get_vars(int ncid, int varid,
00463 const size_t *start, const size_t *count, const ptrdiff_t *stride,
00464 void * value);
00465
00466 extern int
00467 nc_put_varm(int ncid, int varid,
00468 const size_t *start, const size_t *count, const ptrdiff_t *stride,
00469 const ptrdiff_t * map, const void *value);
00470
00471 extern int
00472 nc_get_varm(int ncid, int varid,
00473 const size_t *start, const size_t *count, const ptrdiff_t *stride,
00474 const ptrdiff_t * map, void *value);
00475
00476 #ifdef __cplusplus
00477 }
00478 #endif