home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / test / tv2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  4.0 KB  |  155 lines

  1. /***************************************************************************
  2. *
  3. *
  4. *                         NCSA HDF version 3.2r2
  5. *                            October 30, 1992
  6. *
  7. * NCSA HDF Version 3.2 source code and documentation are in the public
  8. * domain.  Specifically, we give to the public domain all rights for future
  9. * licensing of the source code, all resale rights, and all publishing rights.
  10. *
  11. * We ask, but do not require, that the following message be included in all
  12. * derived works:
  13. *
  14. * Portions developed at the National Center for Supercomputing Applications at
  15. * the University of Illinois at Urbana-Champaign, in collaboration with the
  16. * Information Technology Institute of Singapore.
  17. *
  18. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  19. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  20. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  21. *
  22. ****************************************************************************
  23. */
  24.  
  25. #ifdef RCSID
  26. static char RcsId[] = "@(#)$Revision: 1.4 $";
  27. #endif
  28. /*
  29. $Header: /hdf/hdf/v3.2r2/test/RCS/tv2.c,v 1.4 1992/10/23 19:09:28 koziol beta koziol $
  30.  
  31. $Log: tv2.c,v $
  32.  * Revision 1.4  1992/10/23  19:09:28  koziol
  33.  * Updated for new Vset calls, DFvsetopen(), DFvsetclose, and changed
  34.  * VFREESPACE and VGETSPACE to HDfreespace() and HDgetspace()
  35.  *
  36.  * Revision 1.3  1992/05/27  21:51:19  chouck
  37.  * Added a few casts to VSwrite() calls
  38.  *
  39.  * Revision 1.2  1992/05/18  22:11:07  sxu
  40.  * modified constants for number types
  41.  *
  42.  * Revision 1.1  1992/03/01  22:29:07  dilg
  43.  * Initial revision
  44.  *
  45.  * Revision 1.1  1992/02/29  19:55:36  likkai
  46.  * Initial revision
  47.  *
  48. */
  49. /*
  50.     =================================
  51.     HDF VSET TEST PROGRAM
  52.     Jason Ng Feb-28-92 NCSA
  53.     =================================
  54. */
  55.  
  56.  
  57. #include "vg.h"
  58.  
  59. #define filef "tv2a.hdf"
  60. #define fileg "tv2b.hdf"
  61. #define NVDATAS 3
  62. #define CLASS "FIGURES"
  63.  
  64. static char * vdatanames[NVDATAS] = { "GNP", "INCOME", "SALESTAX"};
  65.  
  66. main (ac,av) int ac; char**av;
  67. {
  68.         
  69.     printf("%s: tests creating of vsets in 2 files simultaneously\n", av[0]);
  70.     printf("after the test, files %s and %s will each contain 2 vgroups and %d vdatas\n",
  71.     filef, fileg, NVDATAS); 
  72.  
  73.     doit();
  74.     printf("\nsuccess: files %s and %s created\n", filef, fileg);
  75.     printf("use the utility vshow to examine these files:\n");
  76.     printf("\t\tvshow %s \n",filef);
  77.     printf("\t\tvshow %s \n",fileg);
  78.     printf("results should be as in %s.result\n",av[0]);
  79.  
  80. }
  81.  
  82. doit() {
  83.     HFILEID     f, g;
  84.     VGROUP * vg1, * vg2;
  85.     VDATA  * vs1, * vs2;
  86.  
  87.     char* vgname1 = "ALASKA";
  88.     char* vgname2 = "MISSISSIPPI";
  89.  
  90.     int i;
  91.     int bb[500];
  92.     int nelt1 = 20;
  93.     int nelt2 = 15;
  94.  
  95.  
  96.     for(i=0;i<500;i++) bb[i] =i;
  97.  
  98.     if( FAIL==(f=DFvsetopen(filef,DFACC_ALL,0)))
  99.     { printf(" %s open err\n",filef); exit(0); }
  100.  
  101.     if( FAIL==(g=DFvsetopen(fileg,DFACC_ALL,0)))
  102.     { printf(" %s open err\n",fileg); exit(0); }
  103.  
  104.     vg1 = (VGROUP*) Vattach(f,-1,"w"); 
  105.     vg2 = (VGROUP*) Vattach(g,-1,"w"); 
  106.  
  107.     Vsetname(vg1,vgname1); Vsetclass (vg1,CLASS);
  108.     Vsetname(vg2,vgname2); Vsetclass (vg2,CLASS);
  109.  
  110.     printf("created vgroup [%s.%s] in file %s ok\n", vgname1, CLASS, filef);
  111.     printf("created vgroup [%s.%s] in file %s ok\n", vgname2, CLASS, fileg);
  112.  
  113.     for(i=0;i<NVDATAS;i++) {
  114.  
  115.         vs1 = (VDATA*) VSattach(f,-1,"w");
  116.         vs2 = (VDATA*) VSattach(g,-1,"w");
  117.  
  118.         VSsetname (vs1,vdatanames[i]); VSsetclass(vs1, CLASS);
  119.         VSsetname (vs2,vdatanames[i]); VSsetclass(vs2, CLASS);
  120.  
  121.         VSfdefine(vs1, "DOLLARS", DFNT_INT32,1);
  122.         VSfdefine(vs2, "DOLLARS", DFNT_INT32,1);
  123.  
  124.         VSsetfields (vs1,"DOLLARS");
  125.         VSsetfields (vs2,"DOLLARS");
  126.  
  127.         VSwrite (vs1, (unsigned char *) &bb[i*50], nelt1, 
  128.                          FULL_INTERLACE);
  129.  
  130.         VSwrite (vs2, (unsigned char *) &bb[i*50], nelt2, 
  131.                          FULL_INTERLACE);
  132.  
  133.         Vinsert (vg1,vs1);
  134.         Vinsert (vg2,vs2);
  135.  
  136.         VSdetach (vs1);
  137.         VSdetach (vs2);
  138.  
  139.         printf("created vdata %s (%d elts) linked to [%s] in %s\n",
  140.           vdatanames[i], nelt1, vgname1, filef);
  141.  
  142.         printf("created vdata %s (%d elts) linked to [%s] in %s\n",
  143.           vdatanames[i], nelt2, vgname2, fileg);
  144.     }
  145.  
  146.     Vdetach(vg1);
  147.     Vdetach(vg2);
  148.  
  149.  
  150.     DFvsetclose(f);
  151.     DFvsetclose(g);
  152.  
  153. }
  154.  
  155.