File: he5_za_wrexternaldata.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 (120 lines) | stat: -rwxr-xr-x 2,903 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 ----------------------------------------------------------------------------
 |    Copyright (C) 2002   Emergent IT Inc. and Raytheon Systems Company    |   
----------------------------------------------------------------------------
 */


#include    <HE5_HdfEosDef.h>

#define  DIM      100
#define  DIMTOT   60

int main()
{
  FILE            *in_1, *in_2, *in_3;

  herr_t          status = FAIL;

  int             i;
  int             data_out_1[DIM];
  int             data_out_2[DIM];
  int             data_out_3[DIM];
  int             data[DIMTOT];

  hid_t           zafid = FAIL;
  hid_t           ZAid  = FAIL;

  hssize_t        start[2];
  hsize_t         count[2];


  
  /* Create new data buffer */
  /* ---------------------- */
  for (i = 0; i < DIMTOT; i++)
	data[ i ] = 9999;

  /* Open the HDF-EOS za file, "ZA.he5" */
  /* --------------------------------- */
  zafid = HE5_ZAopen("ZA.he5", H5F_ACC_RDWR);
  if (zafid != FAIL)
	{
	  /* Attach the "ZA1" za */
	  /* ------------------- */
	  ZAid = HE5_ZAattach(zafid, "ZA1");
	  if (ZAid != FAIL)
		{
		  /* Write new data to the external files */
		  /* ------------------------------------ */
		  start[0] = 0;
		  count[0] = DIMTOT;
		  status = HE5_ZAwrite(ZAid, "ExtData", start, NULL, count, data);
		  printf("Status returned by HE5_ZAwrite() :    %d \n", status);
	    

		  /* Open the external data files */
		  /* ---------------------------- */
		  in_1 = fopen("external_1.data", "r");
		  in_2 = fopen("external_2.data", "r");
		  in_3 = fopen("external_3.data", "r");

		  /* Read data from external data files */
		  /* ---------------------------------- */
		  i = fread(data_out_1, sizeof(int), DIM, in_1);
		  i = fread(data_out_2, sizeof(int), DIM, in_2);
		  i = fread(data_out_3, sizeof(int), DIM, in_3);
		  
		  /* Close the external data files */
		  /* ----------------------------- */
		  fclose(in_1);
		  fclose(in_2);
		  fclose(in_3);
  
		  /* Check the contents of external files */
		  /* ------------------------------------ */
		  printf(" \n");
		  printf("Reading data from 1st file: \n");
		  printf(" \n");
		  for (i = 0; i < DIM; i++)
			printf("%d ", data_out_1[i]);

		  printf(" \n");
		  printf(" \n");
		  printf("Reading data from 2d file: \n");
		  printf(" \n");
		  for (i = 0; i < DIM; i++)
			printf("%d ", data_out_2[i]);
		  
		  printf(" \n");
		  printf(" \n");
		  printf("Reading data from 3d file: \n");
		  printf(" \n"); 
		  for (i = 0; i < DIM; i++)
			printf("%d ", data_out_3[i]);
		  printf(" \n");
		  printf(" \n");

		}
	}

  /* Detach from the za */
  /* ------------------ */
  status = HE5_ZAdetach(ZAid);
  printf("Status returned by HE5_ZAdetach() :        %d \n", status);

  /* Close the file */
  /* -------------- */
  status = HE5_ZAclose(zafid);
  printf("Status returned by HE5_ZAclose() :         %d \n", status); 
  
  return 0;
}