[cig-commits] r22939 - cs/autoconf/trunk

elliott.sales.de.andrade at geodynamics.org elliott.sales.de.andrade at geodynamics.org
Tue Oct 8 00:11:37 PDT 2013


Author: elliott.sales.de.andrade
Date: 2013-10-08 00:11:36 -0700 (Tue, 08 Oct 2013)
New Revision: 22939

Modified:
   cs/autoconf/trunk/cit_adios.m4
Log:
Rewrite ADIOS macros.

* Push and pop language so macro doesn't change it globally.
* Fix unbalanced parentheses/brackets.
* Combine the macros into one, because why would you call one and not
  the other?
* Use the adios_config program to find the settings for headers and
  libraries. Just using -ladiosf doesn't work if your ADIOS is built
  statically and requires linking with other things.
* The library test was wrong since it only tests compilation and not
  linking.

Modified: cs/autoconf/trunk/cit_adios.m4
===================================================================
--- cs/autoconf/trunk/cit_adios.m4	2013-10-08 07:11:30 UTC (rev 22938)
+++ cs/autoconf/trunk/cit_adios.m4	2013-10-08 07:11:36 UTC (rev 22939)
@@ -6,39 +6,61 @@
 # ======================================================================
 
 # ----------------------------------------------------------------------
-# CIT_ADIOS_HEADER
+# CIT_ADIOS_CONFIG
 # ----------------------------------------------------------------------
-AC_DEFUN([CIT_ADIOS_HEADER], [
-  AC_REQUIRE_CPP
-  AC_LANG(C)
-  AC_CHECK_HEADER([adios.h], [], [
-    AC_MSG_ERROR([adios C header not found; try CPPFLAGS="-I<adios include dir>"])
-  ])dnl
-])dnl CIT_ADIOS_HEADER
+AC_DEFUN([CIT_ADIOS_CONFIG], [
+  dnl ADIOS comes with a program that *should* tell us how to link with it.
+  AC_ARG_VAR([ADIOS_CONFIG], [Path to adios_config program that indicates how to compile with it.])
+  AC_PATH_PROG([ADIOS_CONFIG], [adios_config])
 
+  if test "x$ADIOS_CONFIG" = "x"; then
+    AC_MSG_ERROR([adios_config program not found; try setting ADIOS_CONFIG to point to it])
+  fi
 
-# ----------------------------------------------------------------------
-# CIT_ADIOS_LIB
-# ----------------------------------------------------------------------
-AC_DEFUN([CIT_ADIOS_LIB], [
-  AC_LANG(Fortran)
-  AC_MSG_CHECKING([for adios_init in -ladiosf])
-  dnl Sample ADIOS program must be compiled with mpif90 in order to link
-  dnl the proper libraries (eg the ones bundled with openmpi)
-  FC_BCK=$FC
-  FC=$MPIFC
-  AC_COMPILE_IFELSE(
-    [AC_LANG_PROGRAM([[]],
-	             [[use adios_write_mod; call adios_init_noxml(MPI_COMM_WORLD, ierr)]])],
-    [AC_MSG_RESULT(yes)],
-    [AC_MSG_RESULT(no)
-     AC_MSG_ERROR([adiosf library not found; try LDFLAGS="-L<adios lib dir>" 
-					     and FCFLAGS="-I<adios inc dir>"])
-    ])dnl
-  dnl Revert the Fortran compiler to its initial value
-  FC=$FC_BCK
-  ]))
-])dnl CIT_ADIOS_LIB
+  AC_LANG_PUSH([Fortran])
+  FC_save="$FC"
+  FCFLAGS_save="$FCFLAGS"
+  LIBS_save="$LIBS"
+  FC="$MPIFC" dnl Must use mpi compiler.
 
+  dnl First check for directory with ADIOS modules
+  AC_MSG_CHECKING([for ADIOS modules])
+  ADIOS_FCFLAGS=`$ADIOS_CONFIG -c -f`
+  FCFLAGS="$ADIOS_FCFLAGS $FCFLAGS"
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([], [[
+    use adios_read_mod
+    use adios_write_mod
+    ]])
+  ], [
+    AC_MSG_RESULT(yes)
+  ], [
+    AC_MSG_RESULT(no)
+    AC_MSG_ERROR([ADIOS modules not found; is ADIOS built with Fortran support for this compiler?])
+  ])
 
+  dnl Now check for libraries that must be linked.
+  AC_MSG_CHECKING([for ADIOS libraries])
+  FCFLAGS="$ADIOS_FCFLAGS $FCFLAGS_save"
+  ADIOS_LIBS=`$ADIOS_CONFIG -l -f`
+  LIBS="$ADIOS_LIBS $LIBS"
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([],
+                    [[use adios_write_mod; call adios_init_noxml(MPI_COMM_WORLD, ierr)]])
+  ], [
+    AC_MSG_RESULT(yes)
+  ], [
+    AC_MSG_RESULT(no)
+    AC_MSG_ERROR([ADIOS libraries not found.])
+  ])
+
+  FC="$FC_save"
+  FCFLAGS="$FCFLAGS_save"
+  LIBS="$LIBS_save"
+  AC_LANG_POP([Fortran])
+
+  AC_SUBST([ADIOS_FCFLAGS])
+  AC_SUBST([ADIOS_LIBS])
+])dnl CIT_ADIOS_CONFIG
+
 dnl end of file



More information about the CIG-COMMITS mailing list