void f77data_array(Symbol* vsym, Bytebuffer* databuf, Datasrc* src, Odometer* odom, int index, Datalist* fillsrc) { int i; int rank = odom->rank; int lastdim = (index == (rank - 1)); /* last dimension*/ size_t delta,count,subsize; Symbol* basetype = vsym->typ.basetype; ASSERT(index >= 0 && index < rank); /* Move to the ith element */ subsize = subarraylength(&vsym->typ.dimset,index+1); delta = odom->start[index] * basetype->typ.nelems * subsize; srcmove(src,delta); count = odom->count[index]; if(lastdim) { for(;count > 0; count--) { f77data_basetype(basetype,src,databuf,fillsrc); } goto done; } /* now walk count elements and generate recursively */ for(i=0;i<count;i++) { f77data_array(vsym,databuf,src,odom,index+1,fillsrc); } done: return; }
/* Specialty wrappers for f77data_data */ void f77data_attrdata(Symbol* asym, Bytebuffer* databuf) { Datasrc* src; int typecode = asym->typ.basetype->typ.typecode; if(asym->data == NULL) return; if(typecode == NC_CHAR) { gen_charattr(asym,databuf); } else { src = datalist2src(asym->data); while(srcmore(src)) { bbAppend(databuf,' '); f77data_basetype(asym->typ.basetype,src,databuf,NULL); } } }
void f77data_array(Symbol* vsym, Bytebuffer* databuf, Datasrc* src, Odometer* odom, int index, Datalist* fillsrc) { int i; int rank = odom->rank; int firstdim = (index == 0); /* last dimension*/ int lastdim = (index == (rank - 1)); /* last dimension*/ size_t count; Symbol* basetype = vsym->typ.basetype; int isunlimited = (odom->declsize[index] == 0); int pushed=0; ASSERT(index >= 0 && index < rank); count = odom->count[index]; if(!firstdim && isunlimited && issublist(src)) { srcpush(src); pushed = 1; } if(lastdim) { for(i=0;i<count;i++) { f77data_basetype(basetype,src,databuf,fillsrc); } } else { /* now walk count elements and generate recursively */ for(i=0;i<count;i++) { f77data_array(vsym,databuf,src,odom,index+1,fillsrc); } } if(isunlimited && pushed) srcpop(src); return; }