File: he5_pt_writeattrs.c

package info (click to toggle)
hdf-eos5 2%3A2.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,692 kB
  • sloc: ansic: 92,051; fortran: 31,463; sh: 11,395; makefile: 492
file content (73 lines) | stat: -rwxr-xr-x 2,378 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 ----------------------------------------------------------------------------
 |    Copyright (C) 1999   Emergent IT Inc. and Raytheon Systems Company    |
 ----------------------------------------------------------------------------
 */


#include <HE5_HdfEosDef.h>


int main()
{
  herr_t      status = FAIL;

  int         attr       = 9999;                  /* Global attribute */     
  int         attr1[ 5 ] = { 1, 2, 3, 4, 5};      /* Group attribute  */   
  int         attr2[ 5 ] = { 10, 20, 30, 40, 50}; /* Local attribute  */

  hid_t       ptfid = FAIL, PTid = FAIL;

  hsize_t     count[8];
 
  float       flt = -7.5;                         /* Global attribute */
    


  /* Open the HDF-EOS file, "Point.h5" */
  /* --------------------------------- */
  ptfid = HE5_PTopen("Point.h5", H5F_ACC_RDWR);
  printf("File ID returned by HE5_PTopen() :         %ld \n", (long) ptfid);

  /* Write attribute to "Fixed Buoy Point" */
  /* ------------------------------------- */
  PTid = HE5_PTattach(ptfid, "FixedBuoy Point");
  printf("Point ID returned by HE5_PTattach() :      %ld \n", (long) PTid);

  count[0] = 1;
  status = HE5_PTwriteattr(PTid, "GlobalAttribute_int", H5T_NATIVE_INT, count, &attr);
  printf("Status returned by HE5_PTwriteattr() :     %d \n", status);

  count[0] = 5;
  status = HE5_PTwritegrpattr(PTid, "GroupAttribute", H5T_NATIVE_INT, count, attr1);
  printf("Status returned by HE5_PTwritegrpattr() :  %d \n", status);

  status = HE5_PTwritelocattr(PTid, "Observations", "LocalAttribute", H5T_NATIVE_INT, count, attr2);
  printf("Status returned by HE5_PTwritelocattr() :  %d \n", status);

  status = HE5_PTdetach(PTid);
  printf("Status returned by HE5_PTdetach() :        %d \n", status);
    
  /* Write attributes to "Floating Buoy Point" */
  /* ----------------------------------------- */
  PTid = HE5_PTattach(ptfid, "FloatBuoy Point");
  printf("Point ID returned by HE5_PTattach() :      %ld \n", (long) PTid);

  count[0] = 1;    
  status = HE5_PTwriteattr(PTid, "GlobalAttribute_float", H5T_NATIVE_FLOAT, count, &flt);
  printf("Status returned by HE5_PTwriteattr() :     %d \n", status);    

  status = HE5_PTdetach(PTid);
  printf("Status returned by HE5_PTdetach() :        %d \n", status);

  status = HE5_PTclose(ptfid);
  printf("Status returned by HE5_PTclose() :         %d \n", status);

  return 0;
}