home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / test / tv1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  3.0 KB  |  122 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/tv1.c,v 1.4 1992/10/23 19:09:28 koziol beta koziol $
  30.  
  31. $Log: tv1.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:07  likkai
  46.  * Initial revision
  47.  *
  48. */
  49. /*
  50.     =================================
  51.     HDF VSET TEST PROGRAM
  52.     Jason Ng Feb-28-92 NCSA
  53.     =================================
  54. */
  55.  
  56. #include "vg.h"
  57.  
  58. #define FS "tv1.hdf"
  59. main(ac,av) 
  60. int ac;
  61. char**av;
  62. {
  63.     int num;
  64.  
  65.     if(ac!=2) num = 5;
  66.     else sscanf(av[1],"%d",&num);
  67.  
  68.     printf("%s: tests the basic vgroup and vdata creation routines\n", av[0]);
  69.     printf("creates %d vgroups and %d vdatas in %s\n",num,num,FS);
  70.     createm(FS,num);
  71.     printf("success: file %s created.\n", FS);
  72.     printf("use the utility vshow to examine this file:\n");
  73.     printf("\t\tvshow %s +\n",FS);
  74.     printf("results should be as in %s.result\n",av[0]);
  75. }
  76.  
  77. createm(fs,n) char*fs;
  78. int n;
  79. {
  80.     VGROUP * vg;
  81.     VDATA * vs;
  82.     HFILEID f;
  83.     char ss[30];
  84.     int i,ne=0;
  85.     float buf[100];
  86.  
  87.     if( FAIL==(f=DFvsetopen(fs,DFACC_ALL,0))) {
  88.         printf("open err %s\n",fs);
  89.         exit(0);
  90.     }
  91.     for(i=0;i<n;i++) {
  92.         vg = (VGROUP*) Vattach(f,-1,"w");
  93.         sprintf(ss,"test_vgroup#%d",i);
  94.         Vsetname(vg,ss);
  95.         Vdetach(vg);
  96.         printf("created VGROUP %s \n",ss);
  97.     }
  98.  
  99.     for(i=0;i<n;i++) {
  100.         ne +=5;
  101.         vs = (VDATA*) VSattach(f,-1,"w");
  102.         sprintf(ss,"vdata#%d",i);
  103.         VSsetname(vs,ss);
  104.         VSfdefine(vs,"PRESS",DFNT_FLOAT32,1);
  105.         VSsetfields(vs,"PRESS");
  106.         makefloatdata(buf,ne);
  107.         VSwrite(vs, (unsigned char *) buf, ne, FULL_INTERLACE);
  108.         VSdetach(vs);
  109.         printf("created VDATA %s with %d elements\n",ss,ne);
  110.     }
  111.     DFvsetclose(f);
  112. }
  113.  
  114. makefloatdata(xx,n) 
  115. int n; 
  116. float xx[];
  117. {
  118.     int i;
  119.     for(i=0;i<n;i++) xx[i] = n*100.0 + i*i;
  120. }
  121.  
  122.