Esempio n. 1
0
void
dumpgroup(Symbol* g)
{
    if(debug <= 1) return; 
    fdebug("group %s {\n",(g==NULL?"null":g->name));
    if(g != NULL && g->subnodes != NULL) {    
	int i;
	for(i=0;i<listlength(g->subnodes);i++) {
	    Symbol* sym = (Symbol*)listget(g->subnodes,i);
	    char* tname;
	    if(sym->objectclass == NC_PRIM
	       || sym->objectclass == NC_TYPE) {
		tname = nctypename(sym->subclass);
	    } else
		tname = nctypename(sym->objectclass);
	    fdebug("    %3d:  %s\t%s\t%s\n",
		i,
		sym->name,
		tname,
		(sym->ref.is_ref?"ref":"")
		);
	}
    }
    fdebug("}\n");
}
Esempio n. 2
0
char*
ncclassname(nc_class ncc)
{
    char* s;
    if(ncc >= NC_NAT && ncc <= NC_COMPOUND)
	return nctypename((nc_type)ncc);
    if(ncc == NC_FILLVALUE) return "NC_FILL";
    if(ncc >= NC_GRP && ncc <= NC_PRIM)
	return ncclassnames[ncc - NC_GRP];
    s = poolalloc(128);    
    sprintf(s,"NC_<%d>",ncc);
    return s;
}
Esempio n. 3
0
void
convert1(Constant* src, Constant* dst)
{
    Constvalue tmp;
    unsigned char* bytes = NULL;
    size_t bytelen;

    dst->lineno = src->lineno;

    /* Need to translate all possible sources to all possible sinks.*/
    /* Rather than have a nested switch, combine the src and target into*/
    /* a single value so we can do a single n*n-way switch*/

    /* special case for src being NC_FILLVALUE*/
    if(src->nctype == NC_FILLVALUE) {
	if(dst->nctype != NC_FILLVALUE) {
	    nc_getfill(dst);
	} 
	return;
    }

    /* special case handling for src being NC_ECONST*/
    if(src->nctype == NC_ECONST) {
	if(dst->nctype == NC_ECONST) {
	    dst->value = src->value;
	} else {
	    Symbol* econst;
	    econst = src->value.enumv;
	    convert1(&econst->typ.econst,dst);
	}
	return;
    } else if(dst->nctype == NC_ECONST) {
	/* special case for dst being NC_ECONST*/
	semerror(lineno,"Conversion to enum not supported (yet)");
	return;
    }

    if(src->nctype == NC_OPAQUE) {
        bytes = makebytestring(src->value.opaquev.stringv,&bytelen);
    }

#define CASE(nc1,nc2) (nc1*256+nc2)
	switch (CASE(src->nctype,dst->nctype)) {
case CASE(NC_CHAR,NC_CHAR):
    tmp.charv  = src->value.charv;
    break;
case CASE(NC_CHAR,NC_BYTE):
    tmp.int8v  = (unsigned char)src->value.charv;
    break;
case CASE(NC_CHAR,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.charv;
    break;
case CASE(NC_CHAR,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.charv;
    break;
case CASE(NC_CHAR,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.charv;
    break;
case CASE(NC_CHAR,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.charv;
    break;
case CASE(NC_CHAR,NC_SHORT):
    tmp.int16v	= (short)src->value.charv;
    break;
case CASE(NC_CHAR,NC_INT):
    tmp.int32v	= (int)src->value.charv;
    break;
case CASE(NC_CHAR,NC_INT64):
    tmp.int64v	 = (long long)src->value.charv;
    break;
case CASE(NC_CHAR,NC_FLOAT):
    tmp.floatv	= (float)src->value.charv;
    break;
case CASE(NC_CHAR,NC_DOUBLE):
    tmp.doublev = (double)src->value.charv;
    break;

case CASE(NC_BYTE,NC_CHAR):
    tmp.charv	= (char)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_SHORT):
    tmp.int16v	= (short)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_INT):
    tmp.int32v	= (int)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_INT64):
    tmp.int64v	 = (long long)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_FLOAT):
    tmp.floatv	= (float)src->value.uint8v;
    break;
case CASE(NC_BYTE,NC_DOUBLE):
    tmp.doublev = (double)src->value.uint8v;
    break;

case CASE(NC_UBYTE,NC_CHAR):
    tmp.charv	= (char)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_SHORT):
    tmp.int16v	= (short)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_INT):
    tmp.int32v	= (int)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_INT64):
    tmp.int64v	 = (long long)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_FLOAT):
    tmp.floatv	= (float)src->value.uint8v;
    break;
case CASE(NC_UBYTE,NC_DOUBLE):
    tmp.doublev = (double)src->value.uint8v;
    break;

case CASE(NC_USHORT,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_SHORT):
    tmp.int16v	= (short)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_INT):
    tmp.int32v	= (int)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_INT64):
    tmp.int64v	 = (long long)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_FLOAT):
    tmp.floatv	= (float)src->value.uint16v;
    break;
case CASE(NC_USHORT,NC_DOUBLE):
    tmp.doublev = (double)src->value.uint16v;
    break;

case CASE(NC_UINT,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_SHORT):
    tmp.int16v	= (short)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_INT):
    tmp.int32v	= (int)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_INT64):
    tmp.int64v	 = (long long)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_FLOAT):
    tmp.floatv	= (float)src->value.uint32v;
    break;
case CASE(NC_UINT,NC_DOUBLE):
    tmp.doublev = (double)src->value.uint32v;
    break;

case CASE(NC_UINT64,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_SHORT):
    tmp.int16v	= (short)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_INT):
    tmp.int32v	= (int)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_INT64):
    tmp.int64v	 = (long long)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_FLOAT):
    tmp.floatv	= (float)src->value.uint64v;
    break;
case CASE(NC_UINT64,NC_DOUBLE):
    tmp.doublev = (double)src->value.uint64v;
    break;

case CASE(NC_SHORT,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_SHORT):
    tmp.int16v	= (short)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_INT):
    tmp.int32v	= (int)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_INT64):
    tmp.int64v	 = (long long)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_FLOAT):
    tmp.floatv	= (float)src->value.int16v;
    break;
case CASE(NC_SHORT,NC_DOUBLE):
    tmp.doublev = (double)src->value.int16v;
    break;

case CASE(NC_INT,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.int32v;
    break;
case CASE(NC_INT,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.int32v;
    break;
case CASE(NC_INT,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.int32v;
    break;
case CASE(NC_INT,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.int32v;
    break;
case CASE(NC_INT,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.int32v;
    break;
case CASE(NC_INT,NC_SHORT):
    tmp.int16v	= (short)src->value.int32v;
    break;
case CASE(NC_INT,NC_INT):
    tmp.int32v	= (int)src->value.int32v;
    break;
case CASE(NC_INT,NC_INT64):
    tmp.int64v	 = (long long)src->value.int32v;
    break;
case CASE(NC_INT,NC_FLOAT):
    tmp.floatv	= (float)src->value.int32v;
    break;
case CASE(NC_INT,NC_DOUBLE):
    tmp.doublev = (double)src->value.int32v;
    break;

case CASE(NC_INT64,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.int64v;
    break;
case CASE(NC_INT64,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.int64v;
    break;
case CASE(NC_INT64,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.int64v;
    break;
case CASE(NC_INT64,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.int64v;
    break;
case CASE(NC_INT64,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.int64v;
    break;
case CASE(NC_INT64,NC_SHORT):
    tmp.int16v	= (short)src->value.int64v;
    break;
case CASE(NC_INT64,NC_INT):
    tmp.int32v	= (int)src->value.int64v;
    break;
case CASE(NC_INT64,NC_INT64):
    tmp.int64v	 = (long long)src->value.int64v;
    break;
case CASE(NC_INT64,NC_FLOAT):
    tmp.floatv	= (float)src->value.int64v;
    break;
case CASE(NC_INT64,NC_DOUBLE):
    tmp.doublev = (double)src->value.int64v;
    break;

case CASE(NC_FLOAT,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_SHORT):
    tmp.int16v	= (short)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_INT):
    tmp.int32v	= (int)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_INT64):
    tmp.int64v	 = (long long)src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_FLOAT):
    tmp.floatv = src->value.floatv;
    break;
case CASE(NC_FLOAT,NC_DOUBLE):
    tmp.doublev = (isnan(src->value.floatv)?NAN:(double)src->value.floatv);
    break;
case CASE(NC_DOUBLE,NC_BYTE):
    tmp.uint8v	= (unsigned char)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_UBYTE):
    tmp.uint8v	= (unsigned char)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_USHORT):
    tmp.uint16v = (unsigned short)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_UINT):
    tmp.uint32v = (unsigned int)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_UINT64):
    tmp.uint64v	 = (unsigned long long)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_SHORT):
    tmp.int16v	= (short)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_INT):
    tmp.int32v	= (int)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_INT64):
    tmp.int64v	 = (long long)src->value.doublev;
    break;
case CASE(NC_DOUBLE,NC_FLOAT):
    tmp.floatv = (isnan(src->value.doublev)?NANF:(float)src->value.doublev);
    break;
case CASE(NC_DOUBLE,NC_DOUBLE):
    tmp.doublev = (double)src->value.doublev;
    break;

/* Conversion of a string to e.g. an integer should be what?*/
case CASE(NC_STRING,NC_BYTE):
    sscanf(src->value.stringv.stringv,"%hhd",&tmp.int8v); break;
case CASE(NC_STRING,NC_UBYTE):
    sscanf(src->value.stringv.stringv,"%hhu",&tmp.uint8v); break;
case CASE(NC_STRING,NC_USHORT):
    sscanf(src->value.stringv.stringv,"%hu",&tmp.uint16v); break;
case CASE(NC_STRING,NC_UINT):
    sscanf(src->value.stringv.stringv,"%u",&tmp.uint32v); break;
case CASE(NC_STRING,NC_UINT64):
    sscanf(src->value.stringv.stringv,"%llu",&tmp.uint64v); break;
case CASE(NC_STRING,NC_SHORT):
    sscanf(src->value.stringv.stringv,"%hd",&tmp.int16v); break;
case CASE(NC_STRING,NC_INT):
    sscanf(src->value.stringv.stringv,"%d",&tmp.int32v); break;
case CASE(NC_STRING,NC_INT64):
    sscanf(src->value.stringv.stringv,"%lld",&tmp.int64v); break;
case CASE(NC_STRING,NC_FLOAT):
    sscanf(src->value.stringv.stringv,"%g",&tmp.floatv); break;
case CASE(NC_STRING,NC_DOUBLE):
    sscanf(src->value.stringv.stringv,"%lg",&tmp.doublev); break;
case CASE(NC_STRING,NC_CHAR):
     tmp.charv = src->value.stringv.stringv[0];
     break;
case CASE(NC_STRING,NC_STRING):
    tmp.stringv.stringv = nulldup(src->value.stringv.stringv);
    tmp.stringv.len = src->value.stringv.len;
    break;

/* What is the proper conversion for T->STRING?*/
case CASE(NC_CHAR,NC_STRING):
    sprintf(stmp,"%c",src->value.charv);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_BYTE,NC_STRING):
    sprintf(stmp,"%hhd",src->value.uint8v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_UBYTE,NC_STRING):
    sprintf(stmp,"%hhu",src->value.uint8v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_USHORT,NC_STRING):
    sprintf(stmp,"%hu",src->value.uint16v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_UINT,NC_STRING):
    sprintf(stmp,"%u",src->value.uint32v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_UINT64,NC_STRING):
    sprintf(stmp,"%llu",src->value.uint64v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_SHORT,NC_STRING):
    sprintf(stmp,"%hd",src->value.int16v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_INT,NC_STRING):
    sprintf(stmp,"%d",src->value.int32v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_INT64,NC_STRING):
    sprintf(stmp,"%lld",src->value.int64v);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_FLOAT,NC_STRING):
    sprintf(stmp,"%.8g",src->value.floatv);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;
case CASE(NC_DOUBLE,NC_STRING):
    sprintf(stmp,"%.8g",src->value.doublev);
    tmp.stringv.len = nulllen(stmp);
    tmp.stringv.stringv = nulldup(stmp);
    break;

case CASE(NC_OPAQUE,NC_CHAR):
  if(bytes)
    tmp.charv	= *(char*)bytes;
  break;
case CASE(NC_OPAQUE,NC_BYTE):
  if(bytes)
    tmp.uint8v	= *(unsigned char*)bytes;
    break;
case CASE(NC_OPAQUE,NC_UBYTE):
  if(bytes)  
    tmp.uint8v	= *(unsigned char*)bytes;
  break;
case CASE(NC_OPAQUE,NC_USHORT):
  if(bytes)  
    tmp.uint16v	= *(unsigned short*)bytes;
  break;
case CASE(NC_OPAQUE,NC_UINT):
  if(bytes) 
    tmp.uint32v = *(unsigned int*)bytes;
  break;
case CASE(NC_OPAQUE,NC_UINT64):
  if(bytes)  
    tmp.uint64v	 = *(unsigned long long*)bytes;
  break;
case CASE(NC_OPAQUE,NC_SHORT):
  if(bytes)  
    tmp.int16v	= *(short*)bytes;
  break;
case CASE(NC_OPAQUE,NC_INT):
  if(bytes)  
    tmp.int32v	= *(int*)bytes;
  break;
case CASE(NC_OPAQUE,NC_INT64):
  if(bytes)  
    tmp.int64v	 = *(long long*)bytes;
  break;
case CASE(NC_OPAQUE,NC_FLOAT):
  if(bytes)  
    tmp.floatv	= *(float*)bytes;
  break;
case CASE(NC_OPAQUE,NC_DOUBLE):
  if(bytes)  
    tmp.doublev = *(double*)bytes;
  break;
case CASE(NC_OPAQUE,NC_OPAQUE):
    tmp.opaquev.stringv = (char*)malloc(src->value.opaquev.len+1);
    memcpy(tmp.opaquev.stringv,src->value.opaquev.stringv,src->value.opaquev.len);
    tmp.opaquev.len = src->value.opaquev.len;
    tmp.opaquev.stringv[tmp.opaquev.len] = '\0';
    break;

    /* We are missing all CASE(X,NC_ECONST) cases*/

    default:
	semerror(lineno,"transform: illegal conversion: %s/%d -> %s/%d",
		nctypename(src->nctype),src->nctype,
		nctypename(dst->nctype),dst->nctype);
	break;;
    }

    if(bytes != NULL) efree(bytes); /* cleanup*/

    /* overwrite minimum necessary parts*/
    dst->value = tmp;
}
Esempio n. 4
0
int
test_icv_read(char *filename, int xsize, int ysize, double image_min,
              double image_max, nc_type datatype, char *signtype)
{
   int icv, cdfid, img, ndims;
   static long coord[MAX_VAR_DIMS];
   static long count[MAX_VAR_DIMS];
   int dim[MAX_VAR_DIMS];
   long dim_size;
   unsigned char *image;
   int i;
   double min, max;
   int n;

   min = DBL_MAX;
   max = -DBL_MAX;

   image = malloc(xsize * ysize * nctypelen(datatype));
   if (image == NULL) {
       return (ERROR_STATUS);
   }

   /* Create the icv */
   icv=miicv_create();
   (void) miicv_setint(icv, MI_ICV_XDIM_DIR, MI_ICV_POSITIVE);
   (void) miicv_setint(icv, MI_ICV_YDIM_DIR, MI_ICV_POSITIVE);
   (void) miicv_setint(icv, MI_ICV_ZDIM_DIR, MI_ICV_POSITIVE);
   (void) miicv_setint(icv, MI_ICV_ADIM_SIZE, xsize);
   (void) miicv_setint(icv, MI_ICV_BDIM_SIZE, ysize);
   (void) miicv_setint(icv, MI_ICV_KEEP_ASPECT, FALSE);
   (void) miicv_setint(icv, MI_ICV_DO_DIM_CONV, TRUE);
   (void) miicv_setint(icv, MI_ICV_TYPE, datatype);
   (void) miicv_setstr(icv, MI_ICV_SIGN, signtype);
   (void) miicv_setdbl(icv, MI_ICV_VALID_MAX, image_max);
   (void) miicv_setdbl(icv, MI_ICV_VALID_MIN, image_min);

   /* Open the file, attach the image variable */
   cdfid=miopen(filename, NC_NOWRITE);

   /* Attach image variable */
   img=ncvarid(cdfid, MIimage);
   (void) miicv_attach(icv, cdfid, img);

   /* Get the number of dimensions and modify count and coord */
   (void) ncvarinq(cdfid, img, NULL, NULL, &ndims, dim, NULL);
   if (ndims!=3) {
      (void) fprintf(stderr, "File must have 3 dimensions\n");
      return ERROR_STATUS;
   }
   (void) ncdiminq(cdfid, dim[0], NULL, &dim_size);
   count[0]=1;
   count[1]=ysize;
   count[2]=xsize;
   coord[1]=0;
   coord[2]=0;

   /* Get the data */
   for (i=0; i<dim_size; i++) {
      coord[0]=i;
      (void) miicv_get(icv, coord, count, image);

      switch (datatype) {
      case NC_BYTE:
          if (!strcmp(signtype, MI_UNSIGNED)) {
              for (n = 0; n < xsize*ysize; n++) {
                  unsigned char uc = *(((unsigned char *)image) + n);
                  if (uc > max) {
                      max = uc;
                  }
                  if (uc < min) {
                      min = uc;
                  }
              }
          }
          else {
              for (n = 0; n < xsize*ysize; n++) {
                  signed char sc = *(((signed char *)image) + n);
                  if (sc > max) {
                      max = sc;
                  }
                  if (sc < min) {
                      min = sc;
                  }
              }
          }
          break;
      case NC_SHORT:
          if (!strcmp(signtype, MI_UNSIGNED)) {
              for (n = 0; n < xsize*ysize; n++) {
                  unsigned short uc = *(((unsigned short *)image) + n);
                  if (uc > max) {
                      max = uc;
                  }
                  if (uc < min) {
                      min = uc;
                  }
              }
          }
          else {
              for (n = 0; n < xsize*ysize; n++) {
                  signed short sc = *(((signed short *)image) + n);
                  if (sc > max) {
                      max = sc;
                  }
                  if (sc < min) {
                      min = sc;
                  }
              }
          }
          break;
      case NC_INT:
          if (!strcmp(signtype, MI_UNSIGNED)) {
              for (n = 0; n < xsize*ysize; n++) {
                  unsigned int uc = *(((unsigned int *)image) + n);
                  if (uc > max) {
                      max = uc;
                  }
                  if (uc < min) {
                      min = uc;
                  }
              }
          }
          else {
              for (n = 0; n < xsize*ysize; n++) {
                  signed int sc = *(((signed int *)image) + n);
                  if (sc > max) {
                      max = sc;
                  }
                  if (sc < min) {
                      min = sc;
                  }
              }
          }
          break;
      case NC_FLOAT:
          for (n = 0; n < xsize*ysize; n++) {
              float sc = *(((float *)image) + n);
              if (sc > max) {
                  max = sc;
              }
              if (sc < min) {
                  min = sc;
              }
          }
          break;
      case NC_DOUBLE:
          for (n = 0; n < xsize*ysize; n++) {
              double sc = *(((double *)image) + n);
              if (sc > max) {
                  max = sc;
              }
              if (sc < min) {
                  min = sc;
              }
          }
          break;
      }
      printf("%d %s %s %f %f\n", i, signtype, nctypename(datatype), min, max);
   }

   /* Close the file and free the icv */
   (void) miclose(cdfid);
   (void) miicv_free(icv);

   free(image);
   return (NORMAL_STATUS);
}