This page provides Makefile templates and more C and Fortran 77 examples on how to read HDF-EOS2 grid data using the HDF-EOS2 library.
HDF-EOS2 Grid data demonstrated by these examples are from products distributed by NASA GES DISC, NSIDC, LP DAAC and LaRC.
After you write a C program, you need to build a binary using a C compiler. One easy way to build the executable is to use h4cc, which is part of the HDF4 binary distribution.
We recommend that users create Makefile
to build the executable from C sources.
The following shows a skeleton of Makefile
that can be used to build
read_grid
from read_grid.c
.
CFLAGS
and LDFLAGS
set paths to the HDF-EOS2 library.
Users do not need to set paths to the HDF4 library because h4cc
sets them automatically. LIBS
specifies names of libraries used by the program.
Both hdfeos
and Gctp
are from HDF-EOS2. Change read_grid
to your own
executable name.
If users don't use h4cc, many switches may be required based on how the HDF4 library and the HDF-EOS2 library are built.
After creating your own Makefile
, type make
or gmake
to generate
the executable program.
As h4cc is used in C, h4fc, which is part of
the HDF4 binary distribution, can be used to conveniently compile an HDF-EOS2 Fortran program.
The following shows a skeleton of Makefile
that can be used to build read_grid
from
read_grid.f
. We assumed that the Fortran 77 compiler is available.
You may get linker errors regarding underscores. Probably, Fortran compilers provide
several options about underscores, and users need to adjust the option. For example,
we used -fno-underscoring
option.
Note that h4fc is not created if the HDF4 library is built without Fortran.
Still, users can build Fortran programs because the Fortran interfaces of the HDF-EOS2 library does
not depend on HDF4's Fortran wrapper library.
The following is one possible Makefile
that
builds read_grid
from read_grid.f
without using h4fc.
LDFLAGS
nor LIBS
needs to contain
the SZIP path.
If you want to build your Fortran program with non-GNU compiler like Intel Fortran compiler or PGI Fortran compiler, do not specify any FFLAGS
option in your make file. The following is an example Makefile for Intel Fortran compiler.
After creating your own Makefile
, type make
or gmake
to generate
the executable program.
This data product is distributed by NSIDC. Download one file here. See C code or Fortran 77 code that reads the TbOceanRain data field from the MonthlyRainTotal_GeoGrid grid.
This data product is distributed by GES-DISC. Download one file here. See C code or Fortran 77 code that reads the Entropy data field from the L3Quant grid.
This data product is distributed by LP-DAAC. Download one file here. See C code or Fortran 77 code that reads the Nadir_Reflectance_Band1 data field from the MCD_CMG_BRDF_0.05Deg grid.
This data product is distributed by LaRC. Download one file here. See C code or Fortran 77 code that reads the Optical depth average data field from the AerosolParameterAverage grid.