/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/
 
Interface sample; 
 
Record 
{ 
   Real(20,5) f; 
   Real(48,10) d; 
} realrec; 
 
Record 
{ 
   Real(80,40) n; 
} realrec2; 
 
Array realrec realarray[12]; 

Array realrec2 non_native_real[12]; 
 
   Invoke iop 5 
      non_native_real,realarray; 
 
End; 
  
#define ARRAYSIZE	12 


main(argc,argv) 
   int argc; 
   char *argv[]; 
{ 
   realarray src,dest; 
   non_native_real src2,dest2; 
   Control (sample) inst; 
  
   int i; 
   static double a[ARRAYSIZE] = {1.1, 7.0, 2.0, 0.5, 255, 
			  123.45, -1.1, -8.7, -2, 0, 
			  959.3E-17, 24.5E8 }; 
 
   if (argc != 2) 
      exit(1);    
 
   for (i=0; i<ARRAYSIZE; i++) 
   { 
      src[i].f = a[i]; 
      src[i].d = a[i]; 
   } 
 
   for(i=0; i<ARRAYSIZE; i++ ) 
   { 
   int j; 
    
   src2[i].n.val[0] = 0x80; 
   for( j=1; j<=5; j++) 
     src2[i].n.val[j] = 0; 
   for( j=6; j<=16; j++) 
     src2[i].n.val[j] = i*j%256 | 1; 
   } 
 
/***************** send it out ************************/

   Bind_STUB(inst,argv[1],"w",Asn_1_ber); 
   Give inst 
   { 
      iop(src2, src); 
   } 
   Unbind(inst); 
  
/***************** receive it back ********************/

   Bind_STUB(inst,argv[1],"r",Asn_1_ber); 
   Accept inst 
   { 
      On iop(dest2, dest) 
       { 
         for (i=0; i<ARRAYSIZE; i++) 
         { 
/***************** report results *********************/

	    if (memcmp( &dest2[i].n.val[0], &src2[i].n.val[0], 16 ) != 0 ) 
               printf("###non-native[%d]: src != dest\n", i ); 
            if (src[i].f != dest[i].f) 
               printf("###float[%d]: %f != %f\n",i,src[i].f,dest[i].f); 
            if (src[i].d != dest[i].d) 
               printf("###double[%d]: %lf != %lf\n",i,src[i].d,dest[i].d); 
         } 
      }  
   } 
   Unbind(inst); 
  
   printf("test completed\n");
   return(0); 
} 
  
 
 
