Computational Cluster Programs

How to Use the HDF and HDF5 Libraries on ATS-Hosted Clusters

Installed location:

  • HDF4 is installed in: /u/local/apps/hdf/current.
  • HDF5 is installed in: /u/local/apps/hdf5/current.

How to run HDF4 from a C program

In your program include the appropriate HDF header files and call the: appropriate HDF functions.

To compile and link enter:

gcc pgm.c -I$HDF_HOME/include -L$HDF_HOME/lib -lmfhdf -ldf -ljpeg -lz -o pgm
Replace pgm.c with the name of the file containing your source code and pgm with the name of the executable to be created. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include HDF_HOME/lib.

Set HDF_HOME to be: /u/local/apps/hdf/current. You can either set an environment variable or replace $HDF_HOME in the command shown above.

How to run HDF4 from a Fortran program

In your program include the appropriate HDF header files and call the: appropriate HDF functions.

To compile and link enter:

ifort pgm.f90 -I$HDF_HOME/include -L$HDF_HOME/lib -lmfhdf -ldf -ljpeg -lz -o pgm
Replace pgm.f90 with the name of the file containing your source code and pgm with the name of the executable to be created.

Set HDF_HOME to be: /u/local/apps/hdf/current. You can either set an environment variable or replace $HDF_HOME in the command shown above.

See also the compiling instructions from the HDF group.

An exmaple of compiling sd_create.f on Hoffman2 cluster:

 $ ifort sd_create.f -L/u/local/apps/hdf/current/lib -lmfhdf -ldf -ljpeg -lz
 $ a.out
 
 ... sd.hdf created
 ... data1 created
 ... data written out
 ... file closed

How to run HDF5 from a C program

In your program include the appropriate HDF header files and call the: appropriate HDF5 functions.

To compile and link using the gcc compiler enter:

gcc pgm.c -I$HDF5_HOME/include -L$HDF5_HOME/lib -lhdf5_hl -lhdf5 -lz -lm -static -o pgm
or:
h5cc pgm.c -o pgm

To compile and link using the Intel compiler enter:

icc pgm.c -I$HDF5_HOME/include -L$HDF5_HOME/lib -lhdf5_hl -lhdf5 -lz -lm -static-intel -o pgm

Replace pgm.c with the name of the file containing your source code and pgm with the name of the executable to be created. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include HDF5_HOME/lib.

Set HDF5_HOME to be: /u/local/apps/hdf5/current. You can either set an environment variable or replace $HDF5_HOME in the command shown above.

How to run HDF5 from a Fortran 90 program

In your program include the appropriate HDF5 header files and call the: appropriate HDF functions.

To compile and link enter:

ifort pgm.f90 -L$HDF5_HOME/lib -lhdf5_fortran -lhdf5 -lz -lm -static-intel -o pgm
or:
h5fc pgm.f90 -static-intel -o pgm
Replace pgm.f90 with the name of the file containing your source code and pgm with the name of the executable to be created. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include HDF5_HOME/lib.

Set HDF5_HOME to be: /u/local/apps/hdf5/current. You can either set an environment variable or replace $HDF5_HOME in the command shown above.

How to run HDF5 from a Fortran 77 program

HDF5 cannot be called from Fortran 77.