File: he5_gd_defexternalfld.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 (70 lines) | stat: -rwxr-xr-x 2,160 bytes parent folder | download | duplicates (9)
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
/*
 ----------------------------------------------------------------------------
 |    Copyright (C) 1999   Emergent IT Inc. and Raytheon Systems Company    |
 ----------------------------------------------------------------------------
 */


#include    <HE5_HdfEosDef.h>

/*
 * In this example we will (1) open the "Grid.h5" HDF-EOS file, (2) attach to
 * the "UTMGrid" grid, and (3) define the external data field "ExtData".
 */

int main()
{  
  herr_t          status = FAIL;

  hid_t           gdfid  = FAIL;
  hid_t           GDid   = FAIL;

  off_t           offset[3];
 
  hsize_t         size[3];
  
  
  /* Open the file, "Grid.h5", using the H5F_ACC_RDWR access code */
  /* ------------------------------------------------------------- */
  gdfid = HE5_GDopen("Grid.h5", H5F_ACC_RDWR);
  if (gdfid != FAIL)
    {	  
	  /* Attach to the "UTMgrid" grid */
	  /* ---------------------------- */
	  GDid = HE5_GDattach(gdfid, "UTMGrid");
	  if (GDid != FAIL)
		{
		  /* Set the data sizes and offsets in external files */
		  /* ------------------------------------------------ */
		  size[0] = 10 * sizeof(int);       offset[0] = 0;
		  size[1] = 20 * sizeof(int);       offset[1] = 40;
		  size[2] = 30 * sizeof(int);       offset[2] = 80;
		  
		  /* Set external data files first */
		  /* ----------------------------- */
		  status = HE5_GDsetextdata(GDid, "external_1g.data,external_2g.data,external_3g.data", offset, size);
		  printf("Status returned by HE5_GDsetextdata(...) :             %d\n",status);
 
		  /* Define field containing external data */
		  /* ------------------------------------- */
		  status = HE5_GDdeffield(GDid, "ExtData", "ExtDim", NULL, H5T_NATIVE_INT, 0);
		  printf("Status returned by HE5_GDdeffield(...\"ExtData\",..) :   %d\n",status);              
		}
	}
  
  /* Detach from the swath */
  /* --------------------- */
  status = HE5_GDdetach(GDid);
  printf("Status returned by HE5_GDdetach(...) :                 %d\n",status);

  /* Close the file */
  /* -------------- */
  status = HE5_GDclose(gdfid);
  printf("Status returned by HE5_GDclose(...) :                  %d\n",status);
  

  return 0;
}