This page provides Makefile templates and more C and Fortran 77 examples on how to read HDF-EOS2 swath data using the HDF-EOS2 library.
HDF-EOS2 swath 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 the executable 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 binaries from C sources.
The following shows a skeleton of Makefile that can be used to build
read_swath from read_swath.c.
CFLAGS and LDFLAGS set paths to the HDF-EOS2 library.
Users do not need to set paths to the HDF4 library here because h4cc
sets them automatically. LIBS specifies libraries used by the program.
Both hdfeos and Gctp are from HDF-EOS2. Change read_swath to your own
executable name.
If users do not 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 compile an HDF-EOS2 Fortran program.
The following shows a skeleton of Makefile that can be used to build read_swath from
read_swath.f. We assume that the Fortran 77 compiler is available.
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 shows one possible Makefile that
builds read_swath from read_swath.f without using h4fc.
is available and the HDF4 library is built with the SZIP
library.
If the HDF4 library is not built with the SZIP library, neither LDFLAGS nor LIBS needs to contain
the SZIP library.
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 23.8H_Approx._Res.3_TB_(not-resampled) data field, the Longitude field and the Latitude from the Low_Res_Swath swath.
This data product is distributed by GES-DISC. Download one file here. See C code or Fortran 77 code that reads the Height data field, the Longitude field and the Latitude field from the MODIS_Swath_Type_GEO swath.
This data product is distributed by GHRC. Download one file here. See C code or Fortran 77 code that reads the 23800.37 MHz data field, the Longitude field and the Latitude field from the Orbit 2805 swath.
This data product is distributed by LaRC. Download one file here. See C code or Fortran 77 code that reads the CO Total Column data field, the Longitude field and the Latitude field from the MOP02 swath.