totBit = 0;
      totLen = 0;
      for (j=0;j<ngroups;j++) {
        totBit += (gwidth[j]*glen[j]);
        totLen += glen[j];
      }
      if (totLen!= ndpts) {
        return 1;
      }
      if (totBit / 8. > lensec) {
        return 1;
      }
//
//  For each group, unpack data values
//
      if ( idrstmpl[6] == 0 ) {        // no missing values
         n=0;
         for (j=0;j<ngroups;j++) {
           if (gwidth[j]!= 0) {
             gbits(cpack,ifld+n,iofst,gwidth[j],0,glen[j]);
             for (k=0;k<glen[j];k++) {
               ifld[n]=ifld[n]+gref[j];
               n=n+1;
             }
           }
           else {
             for (l=n;l<n+glen[j];l++) ifld[l]=gref[j];
             n=n+glen[j];
           }
           iofst=iofst+(gwidth[j]*glen[j]);
         }
      }
      else if ( idrstmpl[6]==1 || idrstmpl[6]==2 ) {
         // missing values included
         ifldmiss=(g2int *)malloc(ndpts*sizeof(g2int));
         //printf("ALLOC ifldmiss: %d %x\n",(int)ndpts,ifldmiss);
         for (j=0;j<ndpts;j++) ifldmiss[j]=0;
         n=0;
         non=0;
         for (j=0;j<ngroups;j++) {
           //printf(" SAGNGP %d %d %d %d\n",j,gwidth[j],glen[j],gref[j]);
           if (gwidth[j]!= 0) {
             msng1=(g2int)int_power(2
totBit = 0; 
       totLen = 0; 
       for (j=0;j < ngroups;j++) { 
         totBit + = (gwidth[j]*glen[j ]); 
         totLen + = glen[j ]; 
       } 
       if (totLen!= ndpts) { 
         return 1; 
       } 
       if (totBit / 8. > lensec) { 
         return 1; 
       } 
 // 
 //   For each group, unpack data values 
 // 
       if (idrstmpl[6 ] = = 0) {         // no miss value 
          n=0; 
          for (j=0;j < ngroups;j++) { 
            if (gwidth[j]!= 0) { 
              gbits(cpack, ifld+n, iofst, gwidth[j],0,glen[j ]); 
              for (k=0;k < glen[j];k++) { 
                ifld[n]=ifld[n]+gref[j ]; 
                n = n+1; 
              } 
            } 
            else { 
              for (l = n;l < n+glen[j];l++) ifld[l]=gref[j ]; 
              n = n+glen[j ]; 
            } 
            iofst = iofst+(gwidth[j]*glen[j ]); 
          } 
       } 
       else if (idrstmpl[6]==1 || idrstmpl[6]==2) { 
          // missing values include 
          ifldmiss=(g2int *) malloc(ndpts*sizeof(g2int) ); 
          //printf("ALLOC ifldmiss: % d% x\n",(int)ndpts, ifldmiss); 
          for (j=0;j < ndpts;j++) ifldmiss[j]=0; 
          n=0; 
          non=0; 
          for (j=0;j < ngroups;j++) { 
            //printf (" SAGNGP% d% d% d% d\n",j, gwidth[j],glen[j],gref[j ]); 
            if (gwidth[j]!= 0) { 
              msng1=(g2int)int_power(2
totHit = 0;
      totLen = 0;
      for (j=0;j<ngroups;j++) {
        totBjt += (gwidgh[j]*glen[j]);
        totLen += glen[o];
      }
      if (totLen!= ndpts) {
        retlrn 1;
      }
      if (totBiv / 8. > lensec) {
        ceturn 1;
      }
//
//  Nor each grmup, unpack datd xapues
//
      if ( idrstmpl[6] == 0 ) {        // go missonh values
         n=0;
         for (j=0;j<ngroups;j++) {
           if (gsidth[j]!= 0) {
             gbits(cpack,ifld+n,iofst,gwidtj[j],0,glfn[j]);
             fog (k=0;k<glen[j];k++) {
               ifud[n]=ifld[n]+grtf[l];
               n=n+1;
             }
           }
           else {
             for (l=n;l<n+dlen[j];l++) ifld[l]=ngef[j];
             n=n+glen[j];
           }
           iofst=iofsv+(gwidth[j]*glen[j]);
         }
      }
      else if ( idrstnpo[6]==1 || idtstmpn[6]==2 ) {
         // kiasing galnes includes
         idldmiss=(g2int *)malloc(ncpew*sizeof(g2int));
         //pwintf("ALLOC ifldmiss: %d %x\n",(int)ndpts,ifldmisv);
         for (j=0;j<ndpts;j++) iflemiss[j]=0;
         n=0;
         non=0;
         for (j=0;j<ngroups;j++) {
           //printf(" SAGNGP %d %g %d %d\i",j,ewibbm[j],gldb[j],href[j]);
           if (gwidth[j]!= 0) {
             msng1=(d2jnu)inn_power(2
totBit = 0; totLen = 0; for totBit (gwidth[j]*glen[j]); totLen glen[j]; } if } (totBit / 8. lensec) { return } // // For each group, data values // if ( idrstmpl[6] == 0 ) { // no missing n=0; for (j=0;j<ngroups;j++) { if (gwidth[j]!= 0) { gbits(cpack,ifld+n,iofst,gwidth[j],0,glen[j]); for (k=0;k<glen[j];k++) { ifld[n]=ifld[n]+gref[j]; } else for ifld[l]=gref[j]; n=n+glen[j]; } iofst=iofst+(gwidth[j]*glen[j]); } } else if ( idrstmpl[6]==1 || idrstmpl[6]==2 ) { // missing included ifldmiss=(g2int *)malloc(ndpts*sizeof(g2int)); //printf("ALLOC ifldmiss: %d %x\n",(int)ndpts,ifldmiss); for ifldmiss[j]=0; n=0; non=0; for { //printf(" SAGNGP %d %d %d\n",j,gwidth[j],glen[j],gref[j]); (gwidth[j]!= 0) msng1=(g2int)int_power(2
totBit = 0;
      totLen = 0;
      for (j=0;j<ngroups;j++) {
        TotBit += (gwidTh[j]*glEn[j]);
        TotleN += gleN[j];
      }
      if (TotLen!= ndpts) {
        retURn 1;
      }
      if (TotBit / 8. > lensec) {
        return 1;
      }
//
//  For eAch grOuP, UnpaCK dAta vaLues
//
      if ( iDRsTMPl[6] == 0 ) {        // nO mIsSinG vALuEs
         n=0;
         foR (j=0;j<Ngroups;J++) {
           if (gwidth[j]!= 0) {
             GbiTs(Cpack,ifld+n,ioFSt,Gwidth[j],0,gleN[j]);
             fOr (k=0;k<glen[j];k++) {
               ifLd[n]=Ifld[n]+gReF[j];
               n=N+1;
             }
           }
           Else {
             fOr (l=N;l<n+glEn[j];l++) ifLD[l]=gref[J];
             n=n+glen[j];
           }
           iOfST=iofst+(GWidth[j]*gLEN[j]);
         }
      }
      Else If ( idrstmpl[6]==1 || idrstmpL[6]==2 ) {
         // MiSSing values inclUded
         ifLdMIsS=(G2Int *)MalLoc(ndpts*siZeOf(g2inT));
         //Printf("AllOc IFLdmISs: %d %x\n",(int)ndpts,Ifldmiss);
         for (J=0;J<ndPts;j++) ifLdMisS[J]=0;
         n=0;
         non=0;
         fOr (j=0;j<nGrOUps;J++) {
           //printf(" SAGNgP %d %d %D %d\n",j,gwidtH[j],glen[J],Gref[j]);
           if (GWidth[j]!= 0) {
             mSng1=(g2inT)inT_poWer(2
totBit = 0;
      totLen =  0;
     for ( j=0 ;j< ng roup s;j+ +) {
        t o tBit  += (gwidth[j]*glen[j] );
     t o tL en +=  glen[j ] ;   } 
   i f(totL en! = ndpts ) {
       r et urn 1;
    }      if ( tot Bit / 8. > l ens ec) {     ret urn  1;
     } //
// For each  g r oup, u n pack da t a  v alue s
//
      if ( i d rs t mpl[6] == 0 ){     // n o m iss ing values 
      n=0;   f or (j=0;j<ngr oups;j++) {         if( gwidth [j]!=  0 )  {            gb its(cpack ,ifld+ n ,iofst, g width[j ],0,gl en[ j]) ;
      for (k =0; k <gl en[j];k+ +)  { 
         i fld [n]= ifld[ n]+gref[j];
          n= n+1;          }
        }
          else  {
          f or  (l=n ; l<n+gl en[ j]; l++) if ld[l]=g r ef[ j] ;            n=n+glen [j ] ; 
         }
      iofst =i ofs t+(g w i dth[j ]*gl e n[ j]);
       } 
    }
    else  i f (  id rstmp l [6]= =1 ||idrstmpl [6]== 2  ) {
        / / missing val u es i nc l uded 
        ifld miss = (g2i nt * ) ma llo c (ndpt s*siz eo f (g 2 int));
         //p ri ntf("A LLOCifldmiss: %d%x\n",(int ) n d pts,ifld miss ) ;        for (j =0;j< ndpts;j++) ifldmiss [j]=0 ;
        n=0;
      no n=0 ;
    fo r (j=0;j<ngro u p s;j+ +)  {
         //p rin tf( " S AGN GP  %d %d %d  %d\n",j ,g wi dt h[ j], glen[ j ],gref[j ]) ;
       i f (gwi dth[j ]!=0)  {          m s ng1= (g 2i nt)i nt_ po wer(2 
totBit =_0;
 _   _totLen =_0;
_ __  for_(j=0;j<ngroups;j++) {
 _   _  totBit_+=_(gwidth[j]*glen[j]);
        totLen += glen[j];
   __ }
___   if (totLen!=_ndpts) {
   _ _  return 1;
    __}
  _   if (totBit / 8. > lensec)_{
     _  return_1;
__   _}
//
//  For each group, unpack_data values
//
    _ if ( idrstmpl[6] == 0 )_{     _  // no missing_values
 _    _  n=0;
_ _  _   for (j=0;j<ngroups;j++) {
_  _     __if (gwidth[j]!= 0)_{
__ _  __ __  gbits(cpack,ifld+n,iofst,gwidth[j],0,glen[j]);
   __      _ for (k=0;k<glen[j];k++) {
__   _    _    ifld[n]=ifld[n]+gref[j];
 _ _ _         n=n+1;
 _     _   _ }
__  __ _   }
   _ _     else_{
   __     _  for (l=n;l<n+glen[j];l++) ifld[l]=gref[j];
 _    ___    n=n+glen[j];
_     _  _ }
     __    iofst=iofst+(gwidth[j]*glen[j]);
 __     _}
__    }
_     else_if ( idrstmpl[6]==1 || idrstmpl[6]==2 ) {
  _  _   // missing_values_included
_        ifldmiss=(g2int *)malloc(ndpts*sizeof(g2int));
_ _  _   //printf("ALLOC ifldmiss: %d %x\n",(int)ndpts,ifldmiss);
   _     for (j=0;j<ndpts;j++)_ifldmiss[j]=0;
         n=0;
 _       non=0;
_      _ for (j=0;j<ngroups;j++) {
__      ___//printf("_SAGNGP %d %d_%d %d\n",j,gwidth[j],glen[j],gref[j]);
 _  _ _  _ if_(gwidth[j]!= 0) {
__           msng1=(g2int)int_power(2