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  

t_nc.c File Reference

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "netcdf.h"

Go to the source code of this file.


Data Structures

union  getret
struct  tcdfvar

Defines

#define REDEF
#define MAXSHORT   32767
#define MAXINT   2147483647
#define MAXBYTE   127
#define FNAME   "test.nc"
#define NUM_DIMS   3
#define DONT_CARE   -1
#define NUM_RECS   8
#define SIZE_1   7
#define SIZE_2   8
#define NUM_RATTRS   6
#define Byte_id   0
#define Char_id   1
#define Short_id   2
#define Long_id   3
#define Float_id   4
#define Double_id   5
#define NUM_TESTVARS   6
#define M_E   2.7182818284590452354

Functions

void chkgot (nc_type type, union getret got, double check)
void createtestdims (int cdfid, size_t num_dims, size_t *sizes, char *dim_names[])
void testdims (int cdfid, size_t num_dims, size_t *sizes, char *dim_names[])
void createtestvars (int id, struct tcdfvar *testvars, size_t count)
void parray (char *label, size_t count, size_t array[])
void fill_seq (int id)
void check_fill_seq (int id)
int main (int ac, char *av[])

Variables

struct {
   int   num_dims
   int   num_vars
   int   num_attrs
   int   xtendim
cdesc [1]
struct {
   char   mnem [NC_MAX_NAME]
   nc_type   type
   int   ndims
   int   dims [NC_MAX_DIMS]
   int   num_attrs
vdesc [1]
struct {
   char   mnem [NC_MAX_NAME]
   nc_type   type
   size_t   len
adesc [1]
char * fname = FNAME
size_t sizes [] = { NC_UNLIMITED, SIZE_1 , SIZE_2 }
char * dim_names [] = { "record", "ixx", "iyy"}
char * reqattr []
tcdfvar testvars []
size_t indices [][3]
char chs [] = {'A','B', ((char)0xff) }
size_t s_start [] = {0,1}
size_t s_edges [] = {NUM_RECS, SIZE_1 - 1}
char sentence [NUM_RECS *SIZE_1-1]
short shs [] = {97, 99}
int birthday = 82555
float e = (float) M_E
double pinot = 3.25
double zed = 0.0

Define Documentation

#define Byte_id   0
 

#define Char_id   1
 

#define DONT_CARE   -1
 

Definition at line 38 of file t_nc.c.

#define Double_id   5
 

#define Float_id   4
 

#define FNAME   "test.nc"
 

Definition at line 36 of file t_nc.c.

#define Long_id   3
 

#define M_E   2.7182818284590452354
 

Definition at line 338 of file t_nc.c.

#define MAXBYTE   127
 

Definition at line 33 of file t_nc.c.

#define MAXINT   2147483647
 

Definition at line 32 of file t_nc.c.

#define MAXSHORT   32767
 

Definition at line 31 of file t_nc.c.

#define NUM_DIMS   3
 

Definition at line 37 of file t_nc.c.

Referenced by check_fill_seq(), fill_seq(), and main().

#define NUM_RATTRS   6
 

Definition at line 152 of file t_nc.c.

#define NUM_RECS   8
 

Definition at line 40 of file t_nc.c.

Referenced by check_fill_seq(), fill_seq(), and main().

#define NUM_TESTVARS   6
 

Definition at line 191 of file t_nc.c.

Referenced by main().

#define REDEF
 

Definition at line 18 of file t_nc.c.

#define Short_id   2
 

#define SIZE_1   7
 

Definition at line 41 of file t_nc.c.

Referenced by fill_seq(), and main().

#define SIZE_2   8
 

Definition at line 42 of file t_nc.c.

Referenced by fill_seq(), and main().


Function Documentation

void check_fill_seq int    id [static]
 

Definition at line 271 of file t_nc.c.

References getret::fl, nc_get_var1_float(), num_dims, NUM_DIMS, NUM_RECS, parray(), and sizes.

Referenced by main().

00272 {
00273         size_t vindices[NUM_DIMS];
00274         size_t *cc, *mm;
00275         union getret got;
00276         int ii = 0;
00277         float val;
00278 
00279         sizes[0] = NUM_RECS;
00280         cc = vindices;
00281         while (cc < &vindices[num_dims])
00282                 *cc++ = 0; 
00283 
00284         /* ripple counter */
00285         cc = vindices;
00286         mm = sizes;
00287         while (*vindices < *sizes)
00288         {
00289             while (*cc < *mm)
00290             {
00291                 if (mm == &sizes[num_dims - 1])
00292                 {
00293         if(nc_get_var1_float(id, Float_id, vindices, &got.fl[0]) == -1) 
00294                 goto bad_ret;
00295         val = (float) ii;
00296         if(val != got.fl[0])
00297         {
00298                 parray("indices", NUM_DIMS, vindices);
00299                 (void) printf("\t%f != %f\n", val, got.fl[0]);
00300         }
00301                     (*cc)++; ii++;
00302                     continue;
00303                 }
00304                 cc++;
00305                 mm++;
00306             }
00307                 if(cc == vindices)
00308                         break;
00309             *cc = 0;
00310             cc--;
00311             mm--;
00312             (*cc)++;
00313         }
00314         return;
00315 bad_ret :
00316         (void) printf("couldn't get a var in check_fill_seq() %d\n",
00317                 ii);
00318         return;
00319 }

void chkgot nc_type    type,
union getret    got,
double    check
[static]
 

Definition at line 76 of file t_nc.c.

References getret::by, check, getret::dbl, getret::fl, getret::in, getret::sh, and type.

Referenced by main().

00077 {
00078         switch(type){
00079         case NC_BYTE :
00080                 assert( (char)check == got.by[0] );
00081                 break;
00082         case NC_CHAR :  /* TODO */
00083                 assert( (char)check == got.by[0] );
00084                 break;
00085         case NC_SHORT :
00086                 assert( (short)check == got.sh[0] );
00087                 break;
00088         case NC_INT :
00089                 assert( (int)check == got.in[0] );
00090                 break;
00091         case NC_FLOAT :
00092                 assert( (float)check == got.fl[0] );
00093                 break;
00094         case NC_DOUBLE :
00095                 assert( check == got.dbl );
00096                 break;
00097         default:
00098                 break;
00099         }
00100 }

void createtestdims int    cdfid,
size_t    num_dims,
size_t *    sizes,
char *    dim_names[]
[static]
 

Definition at line 110 of file t_nc.c.

References dim_names, nc_def_dim(), num_dims, and sizes.

Referenced by main().

00111 {
00112         int dimid;
00113         while(num_dims-- != 0)
00114         {
00115                 assert( nc_def_dim(cdfid, *dim_names++, *sizes, &dimid)
00116                          == NC_NOERR);
00117                 sizes++;
00118         }
00119 
00120 }

void createtestvars int    id,
struct tcdfvar   testvars,
size_t    count
[static]
 

Definition at line 194 of file t_nc.c.

References tcdfvar::dims, tcdfvar::fieldnam, tcdfvar::mnem, nc_def_var(), nc_put_att_double(), nc_put_att_text(), tcdfvar::ndims, reqattr, tcdfvar::scalemax, tcdfvar::scalemin, testvars, tcdfvar::type, tcdfvar::units, tcdfvar::validmax, and tcdfvar::validmin.

Referenced by main().

00195 {
00196         int ii;
00197         int varid;
00198         struct tcdfvar *vp = testvars;
00199 
00200         for(ii = 0; (size_t) ii < count; ii++, vp++ )
00201         {
00202                 assert(nc_def_var(id, vp->mnem, vp->type, vp->ndims, vp->dims,
00203                                  &varid)
00204                          == NC_NOERR ); 
00205 
00206                 assert(
00207                         nc_put_att_text(id,ii,reqattr[0],strlen(vp->units),
00208                                 vp->units)
00209                         == NC_NOERR); 
00210                 assert(
00211                         nc_put_att_double(id,ii,reqattr[1],NC_DOUBLE,1,
00212                                 &vp->validmin)
00213                         == NC_NOERR); 
00214                 assert(
00215                         nc_put_att_double(id,ii,reqattr[2],NC_DOUBLE,1,
00216                                 &vp->validmax)
00217                         == NC_NOERR); 
00218                 assert(
00219                         nc_put_att_double(id,ii,reqattr[3],NC_DOUBLE,1,
00220                                 &vp->scalemin)
00221                         == NC_NOERR); 
00222                 assert(
00223                         nc_put_att_double(id,ii,reqattr[4],NC_DOUBLE,1,
00224                                 &vp->scalemax)
00225                         == NC_NOERR); 
00226                 assert(
00227                         nc_put_att_text(id,ii,reqattr[5],strlen(vp->fieldnam),
00228                                 vp->fieldnam)
00229                         == NC_NOERR); 
00230         }
00231 }

void fill_seq int    id [static]
 

Definition at line 244 of file t_nc.c.

References nc_put_vara_float(), num_dims, NUM_DIMS, NUM_RECS, SIZE_1, SIZE_2, and sizes.

Referenced by main().

00245 {
00246         float values[NUM_RECS * SIZE_1 * SIZE_2];
00247         size_t vindices[NUM_DIMS];
00248 
00249         {
00250                 size_t ii = 0;
00251                 for(; ii < sizeof(values)/sizeof(values[0]); ii++)
00252                 {
00253                         values[ii] = (float) ii;
00254                 }
00255         }
00256 
00257         /* zero the vindices */
00258         {
00259                 size_t *cc = vindices;
00260                 while (cc < &vindices[num_dims])
00261                         *cc++ = 0; 
00262         }
00263 
00264         sizes[0] = NUM_RECS;
00265 
00266         assert( nc_put_vara_float(id, Float_id, vindices, sizes, values)== NC_NOERR);
00267 
00268 }

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 346 of file t_nc.c.

References adesc, birthday, getret::by, cdesc, check_fill_seq(), chkgot(), chs, createtestdims(), createtestvars(), getret::dbl, dim_names, tcdfvar::dims, e, tcdfvar::fieldnam, fill_seq(), getret::fl, fname, getret::in, indices, tcdfvar::mnem, nc__create(), nc__enddef(), nc__open(), nc_close(), nc_del_att(), nc_get_att_double(), nc_get_att_text(), 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_get_var_double(), nc_get_vara_schar(), nc_get_vara_text(), nc_inq(), nc_inq_att(), nc_inq_attname(), nc_inq_dim(), nc_inq_var(), nc_put_att_double(), nc_put_att_int(), nc_put_att_text(), nc_put_var1_double(), nc_put_var1_float(), nc_put_var1_int(), nc_put_var1_schar(), nc_put_var1_short(), nc_put_var1_text(), nc_put_vara_schar(), nc_put_vara_text(), nc_redef(), nc_rename_att(), nc_rename_dim(), nc_strerror(), nc_sync(), num_dims, NUM_DIMS, NUM_RECS, NUM_TESTVARS, pinot, reqattr, s_edges, s_start, tcdfvar::scalemax, tcdfvar::scalemin, sentence, getret::sh, shs, SIZE_1, SIZE_2, sizes, testdims(), testvars, tcdfvar::type, tcdfvar::units, tcdfvar::validmax, tcdfvar::validmin, vdesc, and zed.

00347 {
00348         int ret;
00349         int      id;
00350         char buf[256];
00351 #ifdef SYNCDEBUG
00352         char *str = "one";
00353 #endif
00354         int ii;
00355         size_t ui;
00356         struct tcdfvar *tvp = testvars;
00357         union getret got;
00358         const size_t initialsz = 8192;
00359         size_t chunksz = 8192;
00360         size_t align = 8192/32;
00361 
00362         ret = nc__create(fname,NC_NOCLOBBER, initialsz, &chunksz, &id);
00363         if(ret != NC_NOERR) {
00364                 (void) fprintf(stderr, "trying again\n");
00365                 ret = nc__create(fname,NC_CLOBBER, initialsz, &chunksz, &id);
00366         }
00367         if(ret != NC_NOERR) 
00368                 exit(ret);
00369         
00370         assert( nc_put_att_text(id, NC_GLOBAL,
00371                 "TITLE", 12, "another name") == NC_NOERR);
00372         assert( nc_get_att_text(id, NC_GLOBAL,
00373                 "TITLE", buf) == NC_NOERR);
00374 /*      (void) printf("title 1 \"%s\"\n", buf); */
00375         assert( nc_put_att_text(id, NC_GLOBAL,
00376                 "TITLE", strlen(fname), fname) == NC_NOERR);
00377         assert( nc_get_att_text(id, NC_GLOBAL,
00378                 "TITLE", buf) == NC_NOERR);
00379         buf[strlen(fname)] = 0;
00380 /*      (void) printf("title 2 \"%s\"\n", buf); */
00381         assert( strcmp(fname, buf) == 0);
00382 
00383         createtestdims(id, NUM_DIMS, sizes, dim_names);
00384         testdims(id, NUM_DIMS, sizes, dim_names);
00385 
00386         createtestvars(id, testvars, NUM_TESTVARS); 
00387 
00388         {
00389         int ifill = -1; double dfill = -9999;
00390         assert( nc_put_att_int(id, Long_id,
00391                 _FillValue, NC_INT, 1, &ifill) == NC_NOERR);
00392         assert( nc_put_att_double(id, Double_id,
00393                 _FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR);
00394         }
00395 
00396 #ifdef REDEF
00397         assert( nc__enddef(id, 0, align, 0, 2*align) == NC_NOERR );
00398         assert( nc_put_var1_int(id, Long_id, indices[3], &birthday) 
00399                 == NC_NOERR );
00400         fill_seq(id);
00401         assert( nc_redef(id) == NC_NOERR );
00402 /*      assert( nc_rename_dim(id,2, "a long dim name") == NC_NOERR); */
00403 #endif
00404 
00405         assert( nc_rename_dim(id,1, "IXX") == NC_NOERR);
00406         assert( nc_inq_dim(id, 1, buf, &ui) == NC_NOERR);
00407         (void) printf("dimrename: %s\n", buf);
00408         assert( nc_rename_dim(id,1, dim_names[1]) == NC_NOERR);
00409 
00410 #ifdef ATTRX
00411         assert( nc_rename_att(id, 1, "UNITS", "units") == NC_NOERR);
00412         assert( nc_del_att(id, 4, "FIELDNAM")== NC_NOERR);
00413         assert( nc_del_att(id, 2, "SCALEMIN")== NC_NOERR);
00414         assert( nc_del_att(id, 2, "SCALEMAX")== NC_NOERR);
00415 #endif /* ATTRX */
00416 
00417         assert( nc__enddef(id, 0, align, 0, 2*align) == NC_NOERR );
00418 
00419 #ifndef REDEF
00420         fill_seq(id);
00421         assert( nc_put_var1_int(id, Long_id, indices[3], &birthday)== NC_NOERR );
00422 #endif
00423 
00424         assert( nc_put_vara_schar(id, Byte_id, s_start, s_edges,
00425                 (signed char *)sentence)
00426                 == NC_NOERR);
00427         assert( nc_put_var1_schar(id, Byte_id, indices[6], (signed char *)(chs+1))
00428                 == NC_NOERR);
00429         assert( nc_put_var1_schar(id, Byte_id, indices[5], (signed char *)chs)
00430                 == NC_NOERR);
00431 
00432         assert( nc_put_vara_text(id, Char_id, s_start, s_edges, sentence)
00433                 == NC_NOERR);
00434         assert( nc_put_var1_text(id, Char_id, indices[6], (chs+1))
00435                 == NC_NOERR) ;
00436         assert( nc_put_var1_text(id, Char_id, indices[5], chs)
00437                 == NC_NOERR);
00438 
00439         assert( nc_put_var1_short(id, Short_id, indices[4], shs)
00440                 == NC_NOERR);
00441 
00442         assert( nc_put_var1_float(id, Float_id, indices[2], &e)
00443                 == NC_NOERR);
00444 
00445         assert( nc_put_var1_double(id, Double_id, indices[1], &zed)
00446                 == NC_NOERR);
00447         assert( nc_put_var1_double(id, Double_id, indices[0], &pinot)
00448                 == NC_NOERR);
00449 
00450 
00451 #ifdef SYNCDEBUG
00452         (void) printf("Hit Return to sync\n");
00453         gets(str);
00454         nc_sync(id,0);
00455         (void) printf("Sync done. Hit Return to continue\n");
00456         gets(str);
00457 #endif /* SYNCDEBUG */
00458 
00459         ret = nc_close(id);
00460         (void) printf("nc_close ret = %d\n\n", ret);
00461 
00462 
00463 /*
00464  *      read it
00465  */
00466         ret = nc__open(fname,NC_NOWRITE, &chunksz, &id);
00467         if(ret != NC_NOERR)
00468         {
00469                 (void) printf("Could not open %s: %s\n", fname,
00470                         nc_strerror(ret));
00471                 exit(1);
00472         }
00473         (void) printf("reopen id = %d for filename %s\n",
00474                 id, fname);
00475 
00476         /*      NC      */ 
00477         (void) printf("NC ");
00478         assert( nc_inq(id, &(cdesc->num_dims), &(cdesc->num_vars),
00479                 &(cdesc->num_attrs), &(cdesc->xtendim) ) == NC_NOERR);
00480         assert((size_t) cdesc->num_dims == num_dims);
00481         assert(cdesc->num_attrs == 1);
00482         assert(cdesc->num_vars == NUM_TESTVARS);
00483         (void) printf("done\n");
00484         
00485         /*      GATTR   */
00486         (void) printf("GATTR ");
00487 
00488         assert( nc_inq_attname(id, NC_GLOBAL, 0, adesc->mnem) == 0);
00489         assert(strcmp("TITLE",adesc->mnem) == 0);
00490         assert( nc_inq_att(id, NC_GLOBAL, adesc->mnem, &(adesc->type), &(adesc->len))== NC_NOERR);
00491         assert( adesc->type == NC_CHAR );
00492         assert( adesc->len == strlen(fname) );
00493         assert( nc_get_att_text(id, NC_GLOBAL, "TITLE", buf)== NC_NOERR);
00494         buf[adesc->len] = 0;
00495         assert( strcmp(fname, buf) == 0);
00496 
00497         /*      VAR     */
00498         (void) printf("VAR ");
00499         assert( cdesc->num_vars == NUM_TESTVARS );
00500 
00501         for(ii = 0; ii < cdesc->num_vars; ii++, tvp++ ) 
00502         {
00503                 int jj;
00504                 assert( nc_inq_var(id, ii,
00505                         vdesc->mnem,
00506                         &(vdesc->type),
00507                         &(vdesc->ndims),
00508                         vdesc->dims,
00509                         &(vdesc->num_attrs)) == NC_NOERR);
00510                 if(strcmp(tvp->mnem , vdesc->mnem) != 0)
00511                 {
00512                         (void) printf("attr %d mnem mismatch %s, %s\n",
00513                                 ii, tvp->mnem, vdesc->mnem);
00514                         continue;
00515                 }
00516                 if(tvp->type != vdesc->type)
00517                 {
00518                         (void) printf("attr %d type mismatch %d, %d\n",
00519                                 ii, tvp->type, vdesc->type);
00520                         continue;
00521                 }
00522                 for(jj = 0; jj < vdesc->ndims; jj++ )
00523                 {
00524                         if(tvp->dims[jj] != vdesc->dims[jj] )
00525                         {
00526                 (void) printf(
00527                 "inconsistant dim[%d] for variable %d: %d != %d\n",
00528                 jj, ii, tvp->dims[jj], vdesc->dims[jj] );
00529                         continue;
00530                         }
00531                 }
00532 
00533                 /* VATTR */
00534                 (void) printf("VATTR\n");
00535                 for(jj=0; jj<vdesc->num_attrs; jj++ ) 
00536                 {
00537                         assert( nc_inq_attname(id, ii, jj, adesc->mnem) == NC_NOERR);
00538                         if( strcmp(adesc->mnem, reqattr[jj]) != 0 )
00539                         {
00540                                 (void) printf("var %d attr %d mismatch %s != %s\n",
00541                                         ii, jj, adesc->mnem, reqattr[jj] );
00542                                 break;
00543                         }
00544                 }
00545 
00546                 if( nc_inq_att(id, ii, reqattr[0], &(adesc->type), &(adesc->len))
00547                         != -1) {
00548                 assert( adesc->type == NC_CHAR );
00549                 assert( adesc->len == strlen(tvp->units) );
00550                 assert( nc_get_att_text(id,ii,reqattr[0],buf)== NC_NOERR); 
00551                 buf[adesc->len] = 0;
00552                 assert( strcmp(tvp->units, buf) == 0);
00553                 }
00554 
00555                 if(
00556                         nc_inq_att(id, ii, reqattr[1], &(adesc->type), &(adesc->len))
00557                         != -1)
00558                 {
00559                 assert( adesc->type == NC_DOUBLE );
00560                 assert( adesc->len == 1 );
00561                 assert( nc_get_att_double(id, ii, reqattr[1], &got.dbl)== NC_NOERR);
00562                 chkgot(adesc->type, got, tvp->validmin);
00563                 }
00564 
00565                 if(
00566                         nc_inq_att(id, ii, reqattr[2], &(adesc->type), &(adesc->len))
00567                         != -1)
00568                 {
00569                 assert( adesc->type == NC_DOUBLE );
00570                 assert( adesc->len == 1 );
00571                 assert( nc_get_att_double(id, ii, reqattr[2], &got.dbl)== NC_NOERR);
00572                 chkgot(adesc->type, got, tvp->validmax);
00573                 }
00574 
00575                 if(
00576                         nc_inq_att(id, ii, reqattr[3], &(adesc->type), &(adesc->len))
00577                         != -1)
00578                 {
00579                 assert( adesc->type == NC_DOUBLE );
00580                 assert( adesc->len ==1 );
00581                 assert( nc_get_att_double(id, ii, reqattr[3], &got.dbl)== NC_NOERR);
00582                 chkgot(adesc->type, got, tvp->scalemin);
00583                 }
00584 
00585                 if(
00586                         nc_inq_att(id, ii, reqattr[4], &(adesc->type), &(adesc->len))
00587                         != -1)
00588                 {
00589                 assert( adesc->type == NC_DOUBLE );
00590                 assert( adesc->len == 1 );
00591                 assert( nc_get_att_double(id, ii, reqattr[4], &got.dbl)== NC_NOERR);
00592                 chkgot(adesc->type, got, tvp->scalemax);
00593                 }
00594 
00595                 if( nc_inq_att(id, ii, reqattr[5], &(adesc->type), &(adesc->len))== NC_NOERR)
00596                 {
00597                 assert( adesc->type == NC_CHAR );
00598                 assert( adesc->len == strlen(tvp->fieldnam) );
00599                 assert( nc_get_att_text(id,ii,reqattr[5],buf)== NC_NOERR); 
00600                 buf[adesc->len] = 0;
00601                 assert( strcmp(tvp->fieldnam, buf) == 0);
00602                 }
00603         }
00604 
00605         (void) printf("fill_seq ");
00606         check_fill_seq(id);
00607         (void) printf("Done\n");
00608 
00609         assert( nc_get_var1_double(id, Double_id, indices[0], &got.dbl)== NC_NOERR);
00610         (void) printf("got val = %f\n", got.dbl );
00611 
00612         assert( nc_get_var1_double(id, Double_id, indices[1], &got.dbl)== NC_NOERR);
00613         (void) printf("got val = %f\n", got.dbl );
00614 
00615         assert( nc_get_var1_float(id, Float_id, indices[2], &got.fl[0])== NC_NOERR);
00616         (void) printf("got val = %f\n", got.fl[0] );
00617 
00618         assert( nc_get_var1_int(id, Long_id, indices[3], &got.in[0])== NC_NOERR);
00619         (void) printf("got val = %d\n", got.in[0] );
00620 
00621         assert( nc_get_var1_short(id, Short_id, indices[4], &got.sh[0])== NC_NOERR);
00622         (void) printf("got val = %d\n", got.sh[0] );
00623 
00624         assert( nc_get_var1_text(id, Char_id, indices[5], &got.by[0]) == NC_NOERR);
00625         (void) printf("got NC_CHAR val = %c (0x%02x) \n",
00626                  got.by[0] , got.by[0]);
00627 
00628         assert( nc_get_var1_text(id, Char_id, indices[6], &got.by[0]) == NC_NOERR);
00629         (void) printf("got NC_CHAR val = %c (0x%02x) \n",
00630                  got.by[0], got.by[0] );
00631 
00632         (void) memset(buf,0,sizeof(buf));
00633         assert( nc_get_vara_text(id, Char_id, s_start, s_edges, buf) == NC_NOERR);
00634         (void) printf("got NC_CHAR val = \"%s\"\n", buf);
00635 
00636         assert( nc_get_var1_schar(id, Byte_id, indices[5],
00637                         (signed char *)&got.by[0])== NC_NOERR);
00638         (void) printf("got val = %c (0x%02x) \n", got.by[0] , got.by[0]);
00639 
00640         assert( nc_get_var1_schar(id, Byte_id, indices[6],
00641                         (signed char *)&got.by[0])== NC_NOERR);
00642         (void) printf("got val = %c (0x%02x) \n", got.by[0], got.by[0] );
00643 
00644         (void) memset(buf,0,sizeof(buf));
00645         assert( nc_get_vara_schar(id, Byte_id, s_start, s_edges,
00646                         (signed char *)buf)== NC_NOERR );
00647         (void) printf("got val = \"%s\"\n", buf);
00648 
00649         {
00650                 double dbuf[NUM_RECS * SIZE_1 * SIZE_2];
00651                 assert(nc_get_var_double(id, Float_id, dbuf) == NC_NOERR);
00652                 (void) printf("got vals = %f ... %f\n", dbuf[0],
00653                          dbuf[NUM_RECS * SIZE_1 * SIZE_2 -1] );
00654         }
00655 
00656         ret = nc_close(id);
00657         (void) printf("re nc_close ret = %d\n", ret);
00658 
00659         return 0;
00660 }

void parray char *    label,
size_t    count,
size_t    array[]
[static]
 

Definition at line 234 of file t_nc.c.

References array.

Referenced by check_fill_seq().

00235 {
00236         (void) fprintf(stdout, "%s", label);
00237         (void) fputc('\t',stdout);      
00238         for(; count != 0; count--, array++)
00239                 (void) fprintf(stdout," %lu", (unsigned long) *array);
00240 }

void testdims int    cdfid,
size_t    num_dims,
size_t *    sizes,
char *    dim_names[]
[static]
 

Definition at line 124 of file t_nc.c.

References dim_names, nc_inq_dim(), num_dims, and sizes.

Referenced by main().

00125 {
00126         int ii;
00127         size_t size;
00128         char cp[NC_MAX_NAME];
00129         for(ii=0; (size_t) ii < num_dims; ii++, sizes++)
00130         {
00131                 assert( nc_inq_dim(cdfid, ii, cp, &size) == NC_NOERR);
00132                 if( size != *sizes)
00133                         (void) fprintf(stderr, "%d: %lu != %lu\n",
00134                                 ii, (unsigned long)size, (unsigned long)*sizes);
00135                 assert( size == *sizes);
00136                 assert( strcmp(cp, *dim_names++) == 0);
00137         }
00138 
00139 }

Variable Documentation

struct { ... } adesc[1] [static]
 

Referenced by main().

int birthday = 82555 [static]
 

Definition at line 337 of file t_nc.c.

Referenced by main().

struct { ... } cdesc[1] [static]
 

Referenced by main().

char chs[] = {'A','B', ((char)0xff) } [static]
 

Definition at line 331 of file t_nc.c.

Referenced by main().

char* dim_names[] = { "record", "ixx", "iyy"} [static]
 

Definition at line 107 of file t_nc.c.

Referenced by createtestdims(), main(), and testdims().

int dims[NC_MAX_DIMS]
 

Definition at line 55 of file t_nc.c.

float e = (float) M_E [static]
 

Definition at line 339 of file t_nc.c.

Referenced by main().

char* fname = FNAME [static]
 

Definition at line 102 of file t_nc.c.

Referenced by main().

size_t indices[][3] [static]
 

Initial value:

 {
        {0, 1, 3},
        {0, 3, 0},
        {1, 2, 3},
        {3, 2, 1},
        {2, 1, 3},
        {1, 0, 0},
        {0, 0, 0},
}

Definition at line 321 of file t_nc.c.

Referenced by main().

size_t len
 

Definition at line 62 of file t_nc.c.

char mnem[NC_MAX_NAME]
 

Definition at line 60 of file t_nc.c.

int ndims
 

Definition at line 54 of file t_nc.c.

Referenced by do_ncdump(), nc_def_var(), ncinquire(), ncvardef(), ncvarget(), ncvarget1(), ncvargetg(), ncvargets(), ncvarinq(), ncvarput(), ncvarput1(), ncvarputg(), ncvarputs(), new_NC_var(), new_x_NC_var(), upcorner(), and v1h_get_NC_var().

int num_attrs
 

Definition at line 56 of file t_nc.c.

size_t num_dims = NUM_DIMS
 

Definition at line 105 of file t_nc.c.

Referenced by check_fill_seq(), createtestdims(), fill_seq(), main(), and testdims().

int num_vars
 

Definition at line 46 of file t_nc.c.

double pinot = 3.25 [static]
 

Definition at line 340 of file t_nc.c.

Referenced by main().

char* reqattr[] [static]
 

Initial value:

 {
        "UNITS",
        "VALIDMIN",
        "VALIDMAX",
        "SCALEMIN",
        "SCALEMAX",
        "FIELDNAM",
        _FillValue
}

Definition at line 143 of file t_nc.c.

Referenced by createtestvars(), and main().

size_t s_edges[] = {NUM_RECS, SIZE_1 - 1} [static]
 

Definition at line 333 of file t_nc.c.

Referenced by main().

size_t s_start[] = {0,1} [static]
 

Definition at line 332 of file t_nc.c.

Referenced by main().

char sentence[NUM_RECS* SIZE_1 -1] [static]
 

Initial value:

        "The red death had long devastated the country."

Definition at line 334 of file t_nc.c.

Referenced by main().

short shs[] = {97, 99} [static]
 

Definition at line 336 of file t_nc.c.

Referenced by main().

size_t sizes[] = { NC_UNLIMITED, SIZE_1 , SIZE_2 } [static]
 

Definition at line 106 of file t_nc.c.

Referenced by check_fill_seq(), createtestdims(), fill_seq(), main(), and testdims().

struct tcdfvar testvars[] [static]
 

Referenced by createtestvars(), and main().

nc_type type
 

Definition at line 61 of file t_nc.c.

Referenced by chkgot().

struct { ... } vdesc[1] [static]
 

Referenced by main().

int xtendim
 

Definition at line 48 of file t_nc.c.

double zed = 0.0 [static]
 

Definition at line 341 of file t_nc.c.

Referenced by main().

 

Powered by Plone

This site conforms to the following standards: