Next: , Previous: , Up: The Macros  


ax_lib_netcdf4

Synopsis

AX_LIB_NETCDF4([serial/parallel])

Description

This macro provides tests of the availability of the NetCDF v4 library.

The optional macro argument should be either ’serial’ or ’parallel’. The macro will call nc-config to check the output of the ’–has-pnetcdf’ option and error out if the requested parallel isn’t supported.

If the optional argument is omitted, no check is made to see if NetCDF has parallel support.

The macro adds a –with-netcdf4 option accepting one of three values:

  no   - do not check for the NetCDF4 library.
  yes  - do check for NetCDF4 library in standard locations.
  path - installation prefix for NetCDF version 4.

If NetCDF4 is successfully found, this macro calls

  AC_SUBST(NETCDF4_VERSION)
  AC_SUBST(NETCDF4_CC)
  AC_SUBST(NETCDF4_CFLAGS)
  AC_SUBST(NETCDF4_CPPFLAGS)
  AC_SUBST(NETCDF4_LDFLAGS)
  AC_SUBST(NETCDF4_LIBS)
  AC_SUBST(NETCDF4_FC)
  AC_SUBST(NETCDF4_FFLAGS)
  AC_SUBST(NETCDF4_FLIBS)
  AC_DEFINE(HAVE_NETCDF4)

It also sets

  with_netcdf4="yes"
  with_netcdf4_fortran="yes"    (if NetCDF has Fortran support)
  with_netcdf4_parallel="yes"   (if NetCDF has MPI support)

If NetCDF4 is disabled or not found, this macros sets

  with_netcdf4="no"
  with_netcdf4_fortran="no"

Note it does not set with_netcdf4_parallel in this case.

Your configuration script can test $with_netcdf4 to take any further actions. NETCDF4_{C,CPP,LD}FLAGS may be used when building with C or C++. NETCDF4_F{FLAGS,LIBS} and NETCDF4_LDFLAGS should be used when building Fortran applications.

To use the macro, one would code one of the following in "configure.ac" before AC_OUTPUT:

  1) dnl Check for NetCDF4 support
     AX_LIB_NETCDF4()
  2) dnl Check for serial NetCDF4 support
     AX_LIB_NETCDF4([serial])
  3) dnl Check for parallel NetCDF4 support
     AX_LIB_NETCDF4([parallel])

One could test $with_netcdf4 for the outcome or display it as follows

  echo "NetCDF v4 support:  $with_netcdf4"

One could also for example, override the default CC in "configure.ac" to enforce compilation with the compiler that NetCDF v4 was built with:

  AX_LIB_NETCDF4([parallel])
  if test "$with_netcdf4" = "yes"; then
          CC="$NETCDF4_CC"
  else
          AC_MSG_ERROR([Unable to find NetCDF4, we need parallel NetCDF4.])
  fi

Source Code

Download the latest version of ax_lib_netcdf4.m4 or browse the macro’s revision history.

License

Copyright © 2016 Timothy Brown tbrown@freeshell.org

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.


Next: ax_lib_nettle, Previous: ax_lib_mysqlcppconn, Up: The Macros