File: ReadGDflds.c

package info (click to toggle)
hdf-eos4 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,960 kB
  • sloc: ansic: 43,570; sh: 11,324; fortran: 9,649; makefile: 261
file content (60 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (5)
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
#include "hdf.h"


/*
 * In this example we will (1) open the "GridFile" HDF file, (2) attach to
 * the "UTMGrid", and (3) read data from the "Vegetation" field.
 */


main()
{

    intn            i, j, status;
    
    int32           gdfid, GDid;

    float32         f32=1.0;
    float32         veg[200][120];


    /*
     * Open the HDF grid file, "GridFile.hdf".
     */

    gdfid = GDopen("GridFile_created_with_hadeos_sample_file_writer_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR);


    if (gdfid != -1)
    {

	/*
	 * Attach the "UTMGrid".
	 */

	GDid = GDattach(gdfid, "UTMGrid");

	if (GDid != -1)
	{
	  status = GDreadfield(GDid, "Vegetation", 
				NULL, NULL, NULL, veg);
	  if (status == -1)
	    {
	      printf("\t\tError: Cannot read field \"Vegetation\"\n");
	      return -1;
	    }
          status = GDreadattr(GDid, "float32", &f32);
	  if (status == -1)
	    {
	      printf("\t\tError: Cannot read attribute \"float32\"\n");
	      return -1;
	    }
	}
    }

    GDdetach(GDid);

    GDclose(gdfid);

    return 0;
}