To compile and link a C or C++ application against your ESIO installation, the installation's include
directory and lib
directory must be added to your C/C++ compiler's include and library search paths, respectively. You will need to supply flags to link against ESIO and HDF5's basic and high-level libraries. Note that you will either need to use your MPI implementation's C/C++ compiler wrapper script, denoted here by $(MPICC)
, or you will additionally need to provide MPI-related flags within the sample commands below.
This tutorial assumes you installed HDF5 under $HDF5HOME and also that at ESIO configuration time you specified –prefix=$HOME
to install ESIO under your home directory (It may be necessary to include your home directory under in
). In this case, compiling and linking an MPI application consisting of a single source file named app.c
might look as follows:
This is error prone as you must supply the same HDF5 installation directories used at ESIO configuration time. Continuing the example, if you set your PKG_CONFIG_PATH
environment variable to contain $HOME/lib/pkgconfig
you can use pkg-config
to lookup the relevant linking information automatically:
Finally, if you are using HDF5's parallel compiler wrapper script h5pcc
the above two examples no longer need to include many HDF5-related specifics:
Using pkg-config will avoid many easy-to-make mistakes. It is highly recommended you use pkg-config with ESIO where possible.
To compile and link a Fortran 90 application against your ESIO installation, the installation's lib
directory must be added to both your Fortran compiler's include and library search paths. In particular, if you do not provide lib
within the search path you will see error messages stating that esio.mod
is missing. You will need to supply flags to link against ESIO's Fortran library (esiof
) and HDF5's basic and high-level C libraries (hdf5
and hdf5_hl
). The HDF5 Fortran libraries (hdf5_fortran
and hdf5hl_fortran
) are not
required. You do not need to have built HDF5 with Fortran support enabled.
Note that you will either need to use your MPI implementation's Fortran compiler wrapper script, denoted here by $(MPIFC)
, or you will additionally need to provide MPI-related flags within the sample commands below.
Assuming the same installation detailed in the C/C++ examples just above, you would compile and link a Fortran MPI application consisting of a single source file named app.F90
as follows:
Using pkg-config simplifies the process considerably:
Again, if you are using HDF5's parallel compiler wrapper script h5pfc
the above two examples become simpler:
Important Note: F90 module file formats are not consistent across multiple compilers. Therefore, a Fortran application and the ESIO F90 interface must be built with the same Fortran compiler family to ensure compatibility.
ESIO's pkg-config files capture many configuration-time settings so that they can be retrieved easily. For example, the MPI and HDF5 compiler wrapper scripts used to build an ESIO installation can be retrieved as follows:
These values could be used, for example, in a standalone Makefile. Provided that your PKG_CONFIG_PATH is configured correctly, such a Makefile can automatically determine the information necessary to build an ESIO-based application.
Because an ESIO installation provides pkg-config information, using ESIO with Autoconf and Automake in a C/C++ project is straightforward. The exact details are beyond the scope of this documentation, but the process consists of the following steps:
AX_MPI
within your configure.ac
to determine where your system's MPI compiler wrappers are located. CC=@MPICC@
within your Makefile.am. esio-hdf5
pkg-config information at configure time. Load the information into variables like ESIO_CFLAGS
and ESIO_LIBS
. ESIO_CFLAGS
and ESIO_LIBS
to the appropriate targets within your Makefile.am. One very good, but not ESIO-specific, write up on using GNU Autoconf/Automake with pkg-config is Using C/C++ libraries with Automake and Autoconf.