[cig-commits] r22453 - in seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER: . DATA EXAMPLES/regional_Greece_small/DATA doc setup src/meshfem3D src/shared src/specfem3D

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Sun Jun 30 05:40:04 PDT 2013


Author: dkomati1
Date: 2013-06-30 05:40:04 -0700 (Sun, 30 Jun 2013)
New Revision: 22453

Added:
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/.gitignore
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/doc/Doxyfile
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/setup/adios_xml_files/
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver_adios.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_chunks_data_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_data_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_faces_data_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_surface_data_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_helpers.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_manager.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_arrays_solver_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_attenuation_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays_adios.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases_adios.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays_adios.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_specfem_adios_header.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/this_branch_was_created_from_revision_r21488_of_the_SUNFLOWER_branch.txt
Modified:
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_Greece_small/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/flags.guess
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/setup/config.h.in
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/finalize_mesher.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/initialize_mesher.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/meshfem3D_par.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/broadcast_compute_parameters.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/create_name_database.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_parameter_file.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/finalize_simulation.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/get_attenuation.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/initialize_simulation.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/prepare_timerun.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D_par.F90
Log:
merged branches/SUNFLOWER_ADIOS into branches/SPECFEM3D_GLOBE_SUNFLOWER


Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/.gitignore (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/.gitignore)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/.gitignore	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/.gitignore	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,7 @@
+# List files that should not be committed
+.*swp
+.*swo
+.*swn
+*~
+*.mod
+obj/*

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file	2013-06-30 12:40:04 UTC (rev 22453)
@@ -2,22 +2,22 @@
 # forward or adjoint simulation
 SIMULATION_TYPE                 = 1 
 NOISE_TOMOGRAPHY                = 0        # flag of noise tomography, three steps (1,2,3). If earthquake simulation, set it to 0.
-SAVE_FORWARD                    = .false.  # save last frame of forward simulation or not
+SAVE_FORWARD                    = .true.  # save last frame of forward simulation or not
 
 # number of chunks (1,2,3 or 6)
 NCHUNKS                         = 1 
 
 # angular width of the first chunk (not used if full sphere with six chunks)
-ANGULAR_WIDTH_XI_IN_DEGREES   = 20.d0      # angular size of a chunk
-ANGULAR_WIDTH_ETA_IN_DEGREES  = 20.d0
+ANGULAR_WIDTH_XI_IN_DEGREES   = 90.d0      # angular size of a chunk
+ANGULAR_WIDTH_ETA_IN_DEGREES  = 90.d0
 CENTER_LATITUDE_IN_DEGREES    = 40.d0
 CENTER_LONGITUDE_IN_DEGREES   = 25.d0
 GAMMA_ROTATION_AZIMUTH        = 0.d0
 
 # number of elements at the surface along the two sides of the first chunk
 # (must be multiple of 16 and 8 * multiple of NPROC below)
-NEX_XI                          = 64 
-NEX_ETA                         = 64
+NEX_XI                          = 48 
+NEX_ETA                         = 48
 
 # number of MPI processors along the two sides of the first chunk
 NPROC_XI                        = 2 
@@ -33,22 +33,22 @@
 # transversely_isotropic_prem_plus_3D_crust_2.0, 3D_anisotropic, 3D_attenuation,
 # s20rts, s362ani, s362iso, s362wmani, s362ani_prem, s362ani_3DQ, s362iso_3DQ,
 # s29ea, s29ea,sea99_jp3d1994,sea99,jp3d1994,heterogen
-MODEL                           = s362ani
+MODEL                           = 1D_transversely_isotropic_prem 
 
 # parameters describing the Earth model
-OCEANS                          = .false.
-ELLIPTICITY                     = .false.
-TOPOGRAPHY                      = .false.
-GRAVITY                         = .false.
-ROTATION                        = .false.
-ATTENUATION                     = .false.
+OCEANS                          = .true.
+ELLIPTICITY                     = .true.
+TOPOGRAPHY                      = .true.
+GRAVITY                         = .true.
+ROTATION                        = .true.
+ATTENUATION                     = .true.
 ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.
 
 # record length in minutes
-RECORD_LENGTH_IN_MINUTES        = 2.5d0
+RECORD_LENGTH_IN_MINUTES        = 0.1d0
 
 # save AVS or OpenDX movies
 MOVIE_SURFACE                   = .false.
@@ -88,7 +88,7 @@
 LOCAL_TMP_PATH                  = ./DATABASES_MPI
 
 # interval at which we output time step info and max of norm of displacement
-NTSTEP_BETWEEN_OUTPUT_INFO      = 50
+NTSTEP_BETWEEN_OUTPUT_INFO      = 500
 
 # interval in time steps for temporary writing of seismograms
 NTSTEP_BETWEEN_OUTPUT_SEISMOS   = 5000000
@@ -119,3 +119,9 @@
 # set to true to use GPUs 
 GPU_MODE                        = .false.
 
+# set to true to use GPUs 
+ADIOS_ENABLED                   = .true.
+ADIOS_FOR_FORWARD_ARRAYS        = .true.
+ADIOS_FOR_MPI_ARRAYS            = .true.
+ADIOS_FOR_ARRAYS_SOLVER         = .true.
+ADIOS_FOR_AVS_DX                = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_Greece_small/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_Greece_small/DATA/Par_file	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_Greece_small/DATA/Par_file	2013-06-30 12:40:04 UTC (rev 22453)
@@ -48,7 +48,7 @@
 ABSORBING_CONDITIONS            = .true.
 
 # record length in minutes
-RECORD_LENGTH_IN_MINUTES        = 15.0d0
+RECORD_LENGTH_IN_MINUTES        = 5.1d0
 
 # save AVS or OpenDX movies
 MOVIE_SURFACE                   = .false.
@@ -117,5 +117,12 @@
 PRINT_SOURCE_TIME_FUNCTION      = .false.
 
 # set to true to use GPUs 
-GPU_MODE                        = .true.
+GPU_MODE                        = .false.
 
+# set to true to use ADIOS 
+ADIOS_ENABLED                   = .true.
+ADIOS_FOR_FORWARD_ARRAYS        = .true.
+ADIOS_FOR_MPI_ARRAYS            = .true.
+ADIOS_FOR_ARRAYS_SOLVER         = .true.
+ADIOS_FOR_SOLVER_MESHFILES      = .true.
+ADIOS_FOR_AVS_DX                = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure	2013-06-30 12:40:04 UTC (rev 22453)
@@ -1,22 +1,20 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Specfem3D Globe 6.0.0.
+# Generated by GNU Autoconf 2.63 for Specfem3D Globe 6.0.0.
 #
 # Report bugs to <jtromp AT princeton.edu>.
 #
-#
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-#
-#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
 
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
@@ -24,15 +22,23 @@
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
 esac
+
 fi
 
 
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
 as_nl='
 '
 export as_nl
@@ -40,13 +46,7 @@
 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
   as_echo='printf %s\n'
   as_echo_n='printf %s'
 else
@@ -57,7 +57,7 @@
     as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
     as_echo_n_body='eval
       arg=$1;
-      case $arg in #(
+      case $arg in
       *"$as_nl"*)
 	expr "X$arg" : "X\\(.*\\)$as_nl";
 	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
@@ -80,7 +80,14 @@
   }
 fi
 
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
 
+
 # IFS
 # We need space, tab and new line, in precisely that order.  Quoting is
 # there to prevent editors from complaining about space-tab.
@@ -89,16 +96,15 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
+case $0 in
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
 IFS=$as_save_IFS
 
      ;;
@@ -110,16 +116,12 @@
 fi
 if test ! -f "$as_myself"; then
   $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
+  { (exit 1); exit 1; }
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
 done
 PS1='$ '
 PS2='> '
@@ -131,345 +133,330 @@
 LANGUAGE=C
 export LANGUAGE
 
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
 # CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+$as_unset CDPATH
 
-# Use a proper internal environment variable to ensure we don't fall
-  # into an infinite loop, continuously re-executing ourselves.
-  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-    _as_can_reexec=no; export _as_can_reexec;
-    # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
-  fi
-  # We don't want this to propagate to other subprocesses.
-          { _as_can_reexec=; unset _as_can_reexec;}
+
 if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
 else
-  case \`(set -o) 2>/dev/null\` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
+  as_have_required=no
 fi
-"
-  as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
 
+  if test $as_have_required = yes &&	 (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
 exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
 
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
 else
-  exitcode=1; echo positional parameters were not saved.
+  exitcode=1
+  echo as_func_ret_success failed.
 fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
-  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
-  as_have_required=yes
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
 else
-  as_have_required=no
+  exitcode=1
+  echo positional parameters were not saved.
 fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
 
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
 else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
+  as_candidate_shells=
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  as_found=:
-  case $as_dir in #(
+  case $as_dir in
 	 /*)
 	   for as_base in sh bash ksh sh5; do
-	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
-	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  break 2
-fi
-fi
+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
 	   done;;
        esac
-  as_found=false
 done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-  CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
 IFS=$as_save_IFS
 
 
-      if test "x$CONFIG_SHELL" != x; then :
-  export CONFIG_SHELL
-             # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
+      for as_shell in $as_candidate_shells $SHELL; do
+	 # Try only shells that exist, to save several forks.
+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		{ ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
 esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
+
 fi
 
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-  else
-    $as_echo "$0: Please tell bug-autoconf at gnu.org and jtromp AT
-$0: princeton.edu about your system, including any error
-$0: possibly output before this message. Then install a
-$0: modern shell, or manually run the script under such a
-$0: shell if you do have one."
-  fi
-  exit 1
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+	       as_have_required=yes
+	       if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
 fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
 fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
 fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
 
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
 
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
 
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
 
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
+test $exitcode = 0) || { (exit 1); exit 1; }
 
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+(
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
 
+_ASEOF
+}; then
+  break
+fi
 
-} # as_fn_mkdir_p
+fi
 
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
+      done
 
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+	do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+	done
+	export CONFIG_SHELL
+	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
 
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
 else
-  as_expr=false
+  exitcode=1
+  echo as_func_success failed.
 fi
 
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
 else
-  as_basename=false
+  exitcode=1
+  echo as_func_ret_success failed.
 fi
 
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
 else
-  as_dirname=false
+  exitcode=1
+  echo positional parameters were not saved.
 fi
 
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell bug-autoconf at gnu.org about your system,
+  echo including any error possibly output before this message.
+  echo This can help us improve future autoconf versions.
+  echo Configuration will now proceed without shell functions.
+}
 
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
 
 
-  as_lineno_1=$LINENO as_lineno_1a=$LINENO
-  as_lineno_2=$LINENO as_lineno_2a=$LINENO
-  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
   sed -n '
     p
     /[$]LINENO/=
@@ -486,12 +473,9 @@
       s/-\n.*//
     ' >$as_me.lineno &&
   chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
 
-  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-  # already done that, so ensure we don't try to do so again and fall
-  # in an infinite loop.  This has already happened in practice.
-  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -500,18 +484,29 @@
   exit
 }
 
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
 ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
+case `echo -n x` in
 -n*)
-  case `echo 'xy\c'` in
+  case `echo 'x\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
+  *)   ECHO_C='\c';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
@@ -526,29 +521,49 @@
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
+  as_mkdir_p=:
 else
   test -d ./-p && rmdir ./-p
   as_mkdir_p=false
 fi
 
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -557,11 +572,11 @@
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
 
+exec 7<&0 </dev/null 6>&1
+
 # Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -576,6 +591,7 @@
 subdirs=
 MFLAGS=
 MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
 
 # Identity of this package.
 PACKAGE_NAME='Specfem3D Globe'
@@ -583,7 +599,6 @@
 PACKAGE_VERSION='6.0.0'
 PACKAGE_STRING='Specfem3D Globe 6.0.0'
 PACKAGE_BUGREPORT='jtromp AT princeton.edu'
-PACKAGE_URL=''
 
 ac_unique_file="src/specfem3D/specfem3D.F90"
 # Factoring default headers for most tests.
@@ -636,6 +651,10 @@
 FLAGS_CHECK
 MPILIBS
 MPIFC
+MXML_LIB
+MXML_INC
+ADIOS_LIB
+ADIOS_INC
 EGREP
 GREP
 CPP
@@ -645,14 +664,6 @@
 CFLAGS
 CC
 FCLIBS
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
 FCENV
 OBJEXT
 EXEEXT
@@ -662,6 +673,8 @@
 FC
 COND_VTK_FALSE
 COND_VTK_TRUE
+COND_ADIOS_FALSE
+COND_ADIOS_TRUE
 COND_CUDA5_FALSE
 COND_CUDA5_TRUE
 COND_CUDA_FALSE
@@ -698,7 +711,6 @@
 program_transform_name
 prefix
 exec_prefix
-PACKAGE_URL
 PACKAGE_BUGREPORT
 PACKAGE_STRING
 PACKAGE_VERSION
@@ -711,6 +723,7 @@
 enable_option_checking
 enable_double_precision
 with_cuda
+with_adios
 with_vtk
 '
       ac_precious_vars='build_alias
@@ -724,6 +737,10 @@
 CFLAGS
 CPPFLAGS
 CPP
+ADIOS_INC
+ADIOS_LIB
+MXML_INC
+MXML_LIB
 MPIFC
 MPILIBS
 FLAGS_CHECK
@@ -797,9 +814,8 @@
   fi
 
   case $ac_option in
-  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *=)   ac_optarg= ;;
-  *)    ac_optarg=yes ;;
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
   esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
@@ -844,7 +860,8 @@
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -870,7 +887,8 @@
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1074,7 +1092,8 @@
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1090,7 +1109,8 @@
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+   { (exit 1); exit 1; }; }
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1120,17 +1140,17 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
+  -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
     ;;
 
   *=*)
     ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
     # Reject names that are not valid shell variable names.
-    case $ac_envvar in #(
-      '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-    esac
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
@@ -1139,7 +1159,7 @@
     $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
       $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
     ;;
 
   esac
@@ -1147,13 +1167,15 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
+  { $as_echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
+   { (exit 1); exit 1; }; } ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
@@ -1176,7 +1198,8 @@
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+  { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1190,6 +1213,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1204,9 +1229,11 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
+  { $as_echo "$as_me: error: working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
+  { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
 
 
 # Find the source files, if location was not specified.
@@ -1245,11 +1272,13 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+  { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
+   { (exit 1); exit 1; }; }
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1289,7 +1318,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
+  -q, --quiet, --silent   do not print \`checking...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1331,10 +1360,6 @@
 _ACEOF
 
   cat <<\_ACEOF
-
-System types:
-  --build=BUILD     configure for building on BUILD [guessed]
-  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
 _ACEOF
 fi
 
@@ -1355,6 +1380,7 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-cuda             build cuda GPU enabled version [default=no]
+  --with-adios            build ADIOS enabled version [default=no]
   --with-vtk              build VTK enabled version [default=no]
 
 Some influential environment variables:
@@ -1365,9 +1391,13 @@
   LIBS        libraries to pass to the linker, e.g. -l<library>
   CC          C compiler command
   CFLAGS      C compiler flags
-  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  ADIOS_INC   Directory where ADIOS headers are installed
+  ADIOS_LIB   Directory where ADIOS libraries are installed
+  MXML_INC    Directory where MXML headers are installed
+  MXML_LIB    Directory where MXML libraries are installed
   MPIFC       MPI Fortran compiler command
   MPILIBS     extra libraries for linking MPI programs
   FLAGS_CHECK Fortran compiler flags for non-critical subroutines
@@ -1452,347 +1482,21 @@
 if $ac_init_version; then
   cat <<\_ACEOF
 Specfem3D Globe configure 6.0.0
-generated by GNU Autoconf 2.69
+generated by GNU Autoconf 2.63
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
   exit
 fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_fc_try_compile LINENO
-# ---------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_fc_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_fc_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_fc_try_compile
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval \${$3+:} false; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## -------------------------------------- ##
-## Report this to jtromp AT princeton.edu ##
-## -------------------------------------- ##"
-     ) | sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by Specfem3D Globe $as_me 6.0.0, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
 
@@ -1828,8 +1532,8 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
-  done
+  $as_echo "PATH: $as_dir"
+done
 IFS=$as_save_IFS
 
 } >&5
@@ -1866,9 +1570,9 @@
       ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
-    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
     2)
-      as_fn_append ac_configure_args1 " '$ac_arg'"
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
       if test $ac_must_keep_next = true; then
 	ac_must_keep_next=false # Got value, back to normal.
       else
@@ -1884,13 +1588,13 @@
 	  -* ) ac_must_keep_next=true ;;
 	esac
       fi
-      as_fn_append ac_configure_args " '$ac_arg'"
+      ac_configure_args="$ac_configure_args '$ac_arg'"
       ;;
     esac
   done
 done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
 
 # When interrupted or exit'd, cleanup temporary files, and complete
 # config.log.  We remove comments because anyway the quotes in there
@@ -1902,9 +1606,11 @@
   {
     echo
 
-    $as_echo "## ---------------- ##
+    cat <<\_ASBOX
+## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##"
+## ---------------- ##
+_ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -1913,13 +1619,13 @@
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
+      *) $as_unset $ac_var ;;
       esac ;;
     esac
   done
@@ -1938,9 +1644,11 @@
 )
     echo
 
-    $as_echo "## ----------------- ##
+    cat <<\_ASBOX
+## ----------------- ##
 ## Output variables. ##
-## ----------------- ##"
+## ----------------- ##
+_ASBOX
     echo
     for ac_var in $ac_subst_vars
     do
@@ -1953,9 +1661,11 @@
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      cat <<\_ASBOX
+## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##"
+## ------------------- ##
+_ASBOX
       echo
       for ac_var in $ac_subst_files
       do
@@ -1969,9 +1679,11 @@
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      cat <<\_ASBOX
+## ----------- ##
 ## confdefs.h. ##
-## ----------- ##"
+## ----------- ##
+_ASBOX
       echo
       cat confdefs.h
       echo
@@ -1985,53 +1697,46 @@
     exit $exit_status
 ' 0
 for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
 done
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
 rm -f -r conftest* confdefs.h
 
-$as_echo "/* confdefs.h */" > confdefs.h
-
 # Predefined preprocessor variables.
 
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_NAME "$PACKAGE_NAME"
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_VERSION "$PACKAGE_VERSION"
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_STRING "$PACKAGE_STRING"
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
 _ACEOF
 
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
 
-
 # Let the site file select an alternate cache file if it wants to.
 # Prefer an explicitly selected file to automatically selected ones.
 ac_site_file1=NONE
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_file1=$CONFIG_SITE
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
   ac_site_file2=$prefix/etc/config.site
@@ -2042,23 +1747,19 @@
 for ac_site_file in "$ac_site_file1" "$ac_site_file2"
 do
   test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+  if test -r "$ac_site_file"; then
+    { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
+    . "$ac_site_file"
   fi
 done
 
 if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special files
-  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
-  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
 $as_echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . "$cache_file";;
@@ -2066,7 +1767,7 @@
     esac
   fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+  { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
 $as_echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -2081,11 +1782,11 @@
   eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
@@ -2095,17 +1796,17 @@
 	ac_old_val_w=`echo x $ac_old_val`
 	ac_new_val_w=`echo x $ac_new_val`
 	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+	  { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
 	  ac_cache_corrupted=:
 	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+	  { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
 	  eval $ac_var=\$ac_old_val
 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+	{ $as_echo "$as_me:$LINENO:   former value:  \`$ac_old_val'" >&5
 $as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+	{ $as_echo "$as_me:$LINENO:   current value: \`$ac_new_val'" >&5
 $as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
       fi;;
   esac
@@ -2117,21 +1818,44 @@
     esac
     case " $ac_configure_args " in
       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+  { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2148,7 +1872,7 @@
 # 'configure' options
 
 # Check whether --enable-double-precision was given.
-if test "${enable_double_precision+set}" = set; then :
+if test "${enable_double_precision+set}" = set; then
   enableval=$enable_double_precision; want_double_precision="$enableval"
 else
   want_double_precision=no
@@ -2166,7 +1890,7 @@
 
 
 # Check whether --with-cuda was given.
-if test "${with_cuda+set}" = set; then :
+if test "${with_cuda+set}" = set; then
   withval=$with_cuda; want_cuda="$withval"
 else
   want_cuda=no
@@ -2191,8 +1915,25 @@
 
 
 
+# Check whether --with-adios was given.
+if test "${with_adios+set}" = set; then
+  withval=$with_adios; want_adios="$withval"
+else
+  want_adios=no
+fi
+
+ if test "$want_adios" != no; then
+  COND_ADIOS_TRUE=
+  COND_ADIOS_FALSE='#'
+else
+  COND_ADIOS_TRUE='#'
+  COND_ADIOS_FALSE=
+fi
+
+
+
 # Check whether --with-vtk was given.
-if test "${with_vtk+set}" = set; then :
+if test "${with_vtk+set}" = set; then
   withval=$with_vtk; want_vtk="$withval"
 else
   want_vtk=no
@@ -2222,13 +1963,13 @@
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 if test -n "$ac_tool_prefix"; then
-  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_FC+:} false; then :
+if test "${ac_cv_prog_FC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$FC"; then
@@ -2239,24 +1980,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_FC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 FC=$ac_cv_prog_FC
 if test -n "$FC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FC" >&5
+  { $as_echo "$as_me:$LINENO: result: $FC" >&5
 $as_echo "$FC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -2266,13 +2007,13 @@
 fi
 if test -z "$FC"; then
   ac_ct_FC=$FC
-  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_FC+:} false; then :
+if test "${ac_cv_prog_ac_ct_FC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_FC"; then
@@ -2283,24 +2024,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_FC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_FC=$ac_cv_prog_ac_ct_FC
 if test -n "$ac_ct_FC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FC" >&5
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_FC" >&5
 $as_echo "$ac_ct_FC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -2313,7 +2054,7 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
@@ -2323,32 +2064,45 @@
 
 
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler version" >&5
+$as_echo "$as_me:$LINENO: checking for Fortran compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
+{ (ac_try="$ac_compiler --version >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
 rm -f a.out
 
-cat > conftest.$ac_ext <<_ACEOF
+cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
@@ -2358,8 +2112,8 @@
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the Fortran compiler works" >&5
-$as_echo_n "checking whether the Fortran compiler works... " >&6; }
+{ $as_echo "$as_me:$LINENO: checking for Fortran compiler default output file name" >&5
+$as_echo_n "checking for Fortran compiler default output file name... " >&6; }
 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 
 # The possible output files:
@@ -2375,17 +2129,17 @@
 done
 rm -f $ac_rmfiles
 
-if { { ac_try="$ac_link_default"
+if { (ac_try="$ac_link_default"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
   (eval "$ac_link_default") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
   # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
@@ -2402,7 +2156,7 @@
 	# certainly right.
 	break;;
     *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
 	then :; else
 	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
 	fi
@@ -2421,41 +2175,84 @@
 else
   ac_file=''
 fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+if test -z "$ac_file"; then
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "Fortran compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+{ { $as_echo "$as_me:$LINENO: error: Fortran compiler cannot create executables
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: Fortran compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler default output file name" >&5
-$as_echo_n "checking for Fortran compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
+
 ac_exeext=$ac_cv_exeext
 
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether the Fortran compiler works" >&5
+$as_echo_n "checking whether the Fortran compiler works... " >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run Fortran compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot run Fortran compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
 $as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
   (eval "$ac_link") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
@@ -2470,93 +2267,44 @@
   esac
 done
 else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+
+rm -f conftest$ac_cv_exeext
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
 $as_echo "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-cat > conftest.$ac_ext <<_ACEOF
-      program main
-      open(unit=9,file='conftest.out')
-      close(unit=9)
-
-      end
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run Fortran compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
 $as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
+if test "${ac_cv_objext+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
 _ACEOF
 rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
   (eval "$ac_compile") 2>&5
   ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
   for ac_file in conftest.o conftest.obj conftest.*; do
   test -f "$ac_file" || continue;
   case $ac_file in
@@ -2569,14 +2317,18 @@
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 fi
+
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
 $as_echo "$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
@@ -2584,12 +2336,12 @@
 # input file.  (Note that this only needs to work for GNU compilers.)
 ac_save_ext=$ac_ext
 ac_ext=F
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran compiler" >&5
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Fortran compiler" >&5
 $as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; }
-if ${ac_cv_fc_compiler_gnu+:} false; then :
+if test "${ac_cv_fc_compiler_gnu+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       program main
 #ifndef __GNUC__
        choke me
@@ -2597,44 +2349,86 @@
 
       end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
 else
-  ac_compiler_gnu=no
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_fc_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_compiler_gnu" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_compiler_gnu" >&5
 $as_echo "$ac_cv_fc_compiler_gnu" >&6; }
 ac_ext=$ac_save_ext
-ac_test_FCFLAGS=${FCFLAGS+set}
-ac_save_FCFLAGS=$FCFLAGS
+ac_test_FFLAGS=${FCFLAGS+set}
+ac_save_FFLAGS=$FCFLAGS
 FCFLAGS=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $FC accepts -g" >&5
+{ $as_echo "$as_me:$LINENO: checking whether $FC accepts -g" >&5
 $as_echo_n "checking whether $FC accepts -g... " >&6; }
-if ${ac_cv_prog_fc_g+:} false; then :
+if test "${ac_cv_prog_fc_g+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   FCFLAGS=-g
-cat > conftest.$ac_ext <<_ACEOF
+cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_fc_g=yes
 else
-  ac_cv_prog_fc_g=no
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_prog_fc_g=no
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_g" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_fc_g" >&5
 $as_echo "$ac_cv_prog_fc_g" >&6; }
-if test "$ac_test_FCFLAGS" = set; then
-  FCFLAGS=$ac_save_FCFLAGS
+if test "$ac_test_FFLAGS" = set; then
+  FCFLAGS=$ac_save_FFLAGS
 elif test $ac_cv_prog_fc_g = yes; then
   if test "x$ac_cv_fc_compiler_gnu" = xyes; then
     FCFLAGS="-g -O2"
@@ -2649,11 +2443,6 @@
   fi
 fi
 
-if test $ac_compiler_gnu = yes; then
-  GFC=yes
-else
-  GFC=
-fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2668,132 +2457,52 @@
 
 
 flags_guess="$SHELL $srcdir/flags.guess"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: running $flags_guess" >&5
+{ $as_echo "$as_me:$LINENO: running $flags_guess" >&5
 $as_echo "$as_me: running $flags_guess" >&6;}
 flags=`$flags_guess` ||
-    as_fn_error $? "$flags_guess failed" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: $flags_guess failed" >&5
+$as_echo "$as_me: error: $flags_guess failed" >&2;}
+   { (exit 1); exit 1; }; }
 eval $flags
 
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
 
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
-else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-
 ac_ext=${ac_fc_srcext-f}
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to get verbose linking output from $FC" >&5
+{ $as_echo "$as_me:$LINENO: checking how to get verbose linking output from $FC" >&5
 $as_echo_n "checking how to get verbose linking output from $FC... " >&6; }
-if ${ac_cv_prog_fc_v+:} false; then :
+if test "${ac_cv_prog_fc_v+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_fc_v=
 # Try some options frequently used verbose output
 for ac_verb in -v -verbose --verbose -V -\#\#\#; do
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
@@ -2803,18 +2512,17 @@
 # 1 to this macro) to the Fortran compiler in order to get
 # "verbose" output that we can then parse for the Fortran linker
 # flags.
-ac_save_FCFLAGS=$FCFLAGS
+ac_save_FFLAGS=$FCFLAGS
 FCFLAGS="$FCFLAGS $ac_verb"
 eval "set x $ac_link"
 shift
-$as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5
+$as_echo "$as_me:$LINENO: $*" >&5
 # gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH,
 # LIBRARY_PATH; skip all such settings.
 ac_fc_v_output=`eval $ac_link 5>&1 2>&1 |
-  sed '/^Driving:/d; /^Configured with:/d;
-      '"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"`
+  grep -v 'Driving:' | grep -v "^[_$as_cr_Letters][_$as_cr_alnum]*="`
 $as_echo "$ac_fc_v_output" >&5
-FCFLAGS=$ac_save_FCFLAGS
+FCFLAGS=$ac_save_FFLAGS
 
 rm -rf conftest*
 
@@ -2829,16 +2537,9 @@
 #        that detects unbalanced quotes in FLIBS should be implemented
 #        and (ugh) tested at some point.
 case $ac_fc_v_output in
-  # With xlf replace commas with spaces,
-  # and remove "-link" and closing parenthesis.
+  # If we are using xlf then replace all the commas with spaces.
   *xlfentry*)
-    ac_fc_v_output=`echo $ac_fc_v_output |
-      sed '
-        s/,/ /g
-        s/ -link / /g
-        s/) *$//
-      '
-    ` ;;
+    ac_fc_v_output=`echo $ac_fc_v_output | sed 's/,/ /g'` ;;
 
   # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
   # $LIBS confuse us, and the libraries appear later in the output anyway).
@@ -2850,20 +2551,10 @@
   # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
   *-cmdline\ * | *-ignore\ * | *-def\ *)
     ac_fc_v_output=`echo $ac_fc_v_output | sed "\
-	s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
-	s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
-	s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
+        s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
+        s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
+        s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
 
-  # If we are using fort77 (the f2c wrapper) then filter output and delete quotes.
-  *fort77*f2c*gcc*)
-    ac_fc_v_output=`echo "$ac_fc_v_output" | sed -n '
-        /:[	 ]\+Running[	 ]\{1,\}"gcc"/{
-          /"-c"/d
-          /[.]c"*/d
-          s/^.*"gcc"/"gcc"/
-          s/"//gp
-        }'` ;;
-
   # If we are using Cray Fortran then delete quotes.
   *cft90*)
     ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"//g'` ;;
@@ -2873,35 +2564,39 @@
   # look for -l* and *.a constructs in the output
   for ac_arg in $ac_fc_v_output; do
      case $ac_arg in
-	[\\/]*.a | ?:[\\/]*.a | -[lLRu]*)
-	  ac_cv_prog_fc_v=$ac_verb
-	  break 2 ;;
+        [\\/]*.a | ?:[\\/]*.a | -[lLRu]*)
+          ac_cv_prog_fc_v=$ac_verb
+          break 2 ;;
      esac
   done
 done
 if test -z "$ac_cv_prog_fc_v"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine how to obtain linking information from $FC" >&5
+   { $as_echo "$as_me:$LINENO: WARNING: cannot determine how to obtain linking information from $FC" >&5
 $as_echo "$as_me: WARNING: cannot determine how to obtain linking information from $FC" >&2;}
 fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compilation failed" >&5
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ $as_echo "$as_me:$LINENO: WARNING: compilation failed" >&5
 $as_echo "$as_me: WARNING: compilation failed" >&2;}
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_v" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_fc_v" >&5
 $as_echo "$ac_cv_prog_fc_v" >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran libraries of $FC" >&5
+{ $as_echo "$as_me:$LINENO: checking for Fortran libraries of $FC" >&5
 $as_echo_n "checking for Fortran libraries of $FC... " >&6; }
-if ${ac_cv_fc_libs+:} false; then :
+if test "${ac_cv_fc_libs+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "x$FCLIBS" != "x"; then
   ac_cv_fc_libs="$FCLIBS" # Let the user override the test.
 else
 
-cat > conftest.$ac_ext <<_ACEOF
+cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
@@ -2911,18 +2606,17 @@
 # 1 to this macro) to the Fortran compiler in order to get
 # "verbose" output that we can then parse for the Fortran linker
 # flags.
-ac_save_FCFLAGS=$FCFLAGS
+ac_save_FFLAGS=$FCFLAGS
 FCFLAGS="$FCFLAGS $ac_cv_prog_fc_v"
 eval "set x $ac_link"
 shift
-$as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5
+$as_echo "$as_me:$LINENO: $*" >&5
 # gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH,
 # LIBRARY_PATH; skip all such settings.
 ac_fc_v_output=`eval $ac_link 5>&1 2>&1 |
-  sed '/^Driving:/d; /^Configured with:/d;
-      '"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"`
+  grep -v 'Driving:' | grep -v "^[_$as_cr_Letters][_$as_cr_alnum]*="`
 $as_echo "$ac_fc_v_output" >&5
-FCFLAGS=$ac_save_FCFLAGS
+FCFLAGS=$ac_save_FFLAGS
 
 rm -rf conftest*
 
@@ -2937,16 +2631,9 @@
 #        that detects unbalanced quotes in FLIBS should be implemented
 #        and (ugh) tested at some point.
 case $ac_fc_v_output in
-  # With xlf replace commas with spaces,
-  # and remove "-link" and closing parenthesis.
+  # If we are using xlf then replace all the commas with spaces.
   *xlfentry*)
-    ac_fc_v_output=`echo $ac_fc_v_output |
-      sed '
-        s/,/ /g
-        s/ -link / /g
-        s/) *$//
-      '
-    ` ;;
+    ac_fc_v_output=`echo $ac_fc_v_output | sed 's/,/ /g'` ;;
 
   # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
   # $LIBS confuse us, and the libraries appear later in the output anyway).
@@ -2958,20 +2645,10 @@
   # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
   *-cmdline\ * | *-ignore\ * | *-def\ *)
     ac_fc_v_output=`echo $ac_fc_v_output | sed "\
-	s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
-	s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
-	s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
+        s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
+        s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
+        s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
 
-  # If we are using fort77 (the f2c wrapper) then filter output and delete quotes.
-  *fort77*f2c*gcc*)
-    ac_fc_v_output=`echo "$ac_fc_v_output" | sed -n '
-        /:[	 ]\+Running[	 ]\{1,\}"gcc"/{
-          /"-c"/d
-          /[.]c"*/d
-          s/^.*"gcc"/"gcc"/
-          s/"//gp
-        }'` ;;
-
   # If we are using Cray Fortran then delete quotes.
   *cft90*)
     ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"//g'` ;;
@@ -2989,8 +2666,8 @@
   shift
   ac_arg=$1
   case $ac_arg in
-	[\\/]*.a | ?:[\\/]*.a)
-	    ac_exists=false
+        [\\/]*.a | ?:[\\/]*.a)
+            ac_exists=false
   for ac_i in $ac_cv_fc_libs; do
     if test x"$ac_arg" = x"$ac_i"; then
       ac_exists=true
@@ -2998,14 +2675,15 @@
     fi
   done
 
-  if test x"$ac_exists" = xtrue; then :
-
+  if test x"$ac_exists" = xtrue; then
+  :
 else
   ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
 fi
-	  ;;
-	-bI:*)
-	    ac_exists=false
+
+          ;;
+        -bI:*)
+            ac_exists=false
   for ac_i in $ac_cv_fc_libs; do
     if test x"$ac_arg" = x"$ac_i"; then
       ac_exists=true
@@ -3013,8 +2691,8 @@
     fi
   done
 
-  if test x"$ac_exists" = xtrue; then :
-
+  if test x"$ac_exists" = xtrue; then
+  :
 else
   if test "$ac_compiler_gnu" = yes; then
   for ac_link_opt in $ac_arg; do
@@ -3024,22 +2702,18 @@
   ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
 fi
 fi
-	  ;;
-	  # Ignore these flags.
-	-lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \
-	  |-LANG:=* | -LIST:* | -LNO:* | -link)
-	  ;;
-	-lkernel32)
-	  case $host_os in
-	  *cygwin*) ;;
-	  *) ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
-	    ;;
-	  esac
-	  ;;
-	-[LRuYz])
-	  # These flags, when seen by themselves, take an argument.
-	  # We remove the space between option and argument and re-iterate
-	  # unless we find an empty arg or a new option (starting with -)
+
+          ;;
+          # Ignore these flags.
+        -lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -LANG:=* | -LIST:* | -LNO:*)
+          ;;
+        -lkernel32)
+          test x"$CYGWIN" != xyes && ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
+          ;;
+        -[LRuYz])
+          # These flags, when seen by themselves, take an argument.
+          # We remove the space between option and argument and re-iterate
+          # unless we find an empty arg or a new option (starting with -)
 	  case $2 in
 	     "" | -*);;
 	     *)
@@ -3048,10 +2722,10 @@
 		set X $ac_arg "$@"
 		;;
 	  esac
-	  ;;
-	-YP,*)
-	  for ac_j in `$as_echo "$ac_arg" | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
-	      ac_exists=false
+          ;;
+        -YP,*)
+          for ac_j in `$as_echo "$ac_arg" | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
+              ac_exists=false
   for ac_i in $ac_cv_fc_libs; do
     if test x"$ac_j" = x"$ac_i"; then
       ac_exists=true
@@ -3059,16 +2733,17 @@
     fi
   done
 
-  if test x"$ac_exists" = xtrue; then :
-
+  if test x"$ac_exists" = xtrue; then
+  :
 else
   ac_arg="$ac_arg $ac_j"
-			       ac_cv_fc_libs="$ac_cv_fc_libs $ac_j"
+                               ac_cv_fc_libs="$ac_cv_fc_libs $ac_j"
 fi
-	  done
-	  ;;
-	-[lLR]*)
-	    ac_exists=false
+
+          done
+          ;;
+        -[lLR]*)
+            ac_exists=false
   for ac_i in $ac_cv_fc_libs; do
     if test x"$ac_arg" = x"$ac_i"; then
       ac_exists=true
@@ -3076,16 +2751,17 @@
     fi
   done
 
-  if test x"$ac_exists" = xtrue; then :
-
+  if test x"$ac_exists" = xtrue; then
+  :
 else
   ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
 fi
-	  ;;
+
+          ;;
 	-zallextract*| -zdefaultextract)
 	  ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
 	  ;;
-	  # Ignore everything else.
+          # Ignore everything else.
   esac
 done
 # restore positional arguments
@@ -3097,9 +2773,9 @@
 case `(uname -sr) 2>/dev/null` in
    "SunOS 5"*)
       ac_ld_run_path=`$as_echo "$ac_fc_v_output" |
-			sed -n 's,^.*LD_RUN_PATH *= *\(/[^ ]*\).*$,-R\1,p'`
+                        sed -n 's,^.*LD_RUN_PATH *= *\(/[^ ]*\).*$,-R\1,p'`
       test "x$ac_ld_run_path" != x &&
-	if test "$ac_compiler_gnu" = yes; then
+        if test "$ac_compiler_gnu" = yes; then
   for ac_link_opt in $ac_ld_run_path; do
     ac_cv_fc_libs="$ac_cv_fc_libs -Xlinker $ac_link_opt"
   done
@@ -3111,7 +2787,7 @@
 fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_libs" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_libs" >&5
 $as_echo "$ac_cv_fc_libs" >&6; }
 FCLIBS="$ac_cv_fc_libs"
 
@@ -3130,9 +2806,9 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3143,24 +2819,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3170,9 +2846,9 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3183,24 +2859,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 $as_echo "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3209,7 +2885,7 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
@@ -3223,9 +2899,9 @@
           if test -n "$ac_tool_prefix"; then
     # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3236,24 +2912,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3263,9 +2939,9 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3277,18 +2953,18 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 if test $ac_prog_rejected = yes; then
@@ -3307,10 +2983,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3322,9 +2998,9 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3335,24 +3011,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3366,9 +3042,9 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3379,24 +3055,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 $as_echo "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -3409,7 +3085,7 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
@@ -3420,42 +3096,62 @@
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
+{ (ac_try="$ac_compiler --version >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -3477,16 +3173,37 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
 else
-  ac_compiler_gnu=no
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
 if test $ac_compiler_gnu = yes; then
   GCC=yes
@@ -3495,16 +3212,20 @@
 fi
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
 $as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
+if test "${ac_cv_prog_cc_g+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
    CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -3523,11 +3244,35 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_g=yes
 else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -3546,12 +3291,36 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
+	ac_c_werror_flag=$ac_save_c_werror_flag
 	 CFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -3570,17 +3339,42 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_g=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    ac_c_werror_flag=$ac_save_c_werror_flag
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
 $as_echo "$ac_cv_prog_cc_g" >&6; }
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -3597,18 +3391,23 @@
     CFLAGS=
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
+if test "${ac_cv_prog_cc_c89+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-struct stat;
+#include <sys/types.h>
+#include <sys/stat.h>
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3668,9 +3467,32 @@
 	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_c89=$ac_arg
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext
   test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
@@ -3681,19 +3503,17 @@
 # AC_CACHE_VAL
 case "x$ac_cv_prog_cc_c89" in
   x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+    { $as_echo "$as_me:$LINENO: result: none needed" >&5
 $as_echo "none needed" >&6; } ;;
   xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+    { $as_echo "$as_me:$LINENO: result: unsupported" >&5
 $as_echo "unsupported" >&6; } ;;
   *)
     CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+    { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
 esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
 
-fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -3707,9 +3527,9 @@
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dummy main to link with Fortran libraries" >&5
+{ $as_echo "$as_me:$LINENO: checking for dummy main to link with Fortran libraries" >&5
 $as_echo_n "checking for dummy main to link with Fortran libraries... " >&6; }
-if ${ac_cv_fc_dummy_main+:} false; then :
+if test "${ac_cv_fc_dummy_main+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_fc_dm_save_LIBS=$LIBS
@@ -3722,7 +3542,11 @@
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
  # First, try linking without a dummy main:
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -3741,17 +3565,46 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_cv_fortran_dummy_main=none
 else
-  ac_cv_fortran_dummy_main=unknown
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_fortran_dummy_main=unknown
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
 
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+
  if test $ac_cv_fortran_dummy_main = unknown; then
    for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+     cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define $ac_fortran_dm_var $ac_func
 #ifdef FC_DUMMY_MAIN
@@ -3770,11 +3623,38 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_cv_fortran_dummy_main=$ac_func; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
    done
  fi
  ac_ext=${ac_fc_srcext-f}
@@ -3786,10 +3666,10 @@
  LIBS=$ac_fc_dm_save_LIBS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_dummy_main" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_dummy_main" >&5
 $as_echo "$ac_cv_fc_dummy_main" >&6; }
 FC_DUMMY_MAIN=$ac_cv_fc_dummy_main
-if test "$FC_DUMMY_MAIN" != unknown; then :
+if test "$FC_DUMMY_MAIN" != unknown; then
   if test $FC_DUMMY_MAIN != none; then
 
 cat >>confdefs.h <<_ACEOF
@@ -3798,17 +3678,23 @@
 
   if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then
 
-$as_echo "#define FC_DUMMY_MAIN_EQ_F77 1" >>confdefs.h
+cat >>confdefs.h <<\_ACEOF
+#define FC_DUMMY_MAIN_EQ_F77 1
+_ACEOF
 
   fi
 fi
 else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "linking to Fortran libraries from C fails
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: linking to Fortran libraries from C fails
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: linking to Fortran libraries from C fails
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 fi
 
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3819,12 +3705,12 @@
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran name-mangling scheme" >&5
+{ $as_echo "$as_me:$LINENO: checking for Fortran name-mangling scheme" >&5
 $as_echo_n "checking for Fortran name-mangling scheme... " >&6; }
-if ${ac_cv_fc_mangling+:} false; then :
+if test "${ac_cv_fc_mangling+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       subroutine foobar()
       return
       end
@@ -3832,7 +3718,24 @@
       return
       end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   mv conftest.$ac_objext cfortran_test.$ac_objext
 
   ac_save_LIBS=$LIBS
@@ -3847,7 +3750,11 @@
   for ac_foobar in foobar FOOBAR; do
     for ac_underscore in "" "_"; do
       ac_func="$ac_foobar$ac_underscore"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3873,11 +3780,38 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_success=yes; break 2
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
     done
   done
   ac_ext=${ac_fc_srcext-f}
@@ -3905,7 +3839,11 @@
      ac_success_extra=no
      for ac_extra in "" "_"; do
 	ac_func="$ac_foo_bar$ac_underscore$ac_extra"
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 /* Override any GCC internal prototype to avoid an error.
@@ -3931,11 +3869,38 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_success_extra=yes; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
      done
      ac_ext=${ac_fc_srcext-f}
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
@@ -3944,16 +3909,16 @@
 
      if test "$ac_success_extra" = "yes"; then
 	ac_cv_fc_mangling="$ac_case case"
-	if test -z "$ac_underscore"; then
-	   ac_cv_fc_mangling="$ac_cv_fc_mangling, no underscore"
+        if test -z "$ac_underscore"; then
+           ac_cv_fc_mangling="$ac_cv_fc_mangling, no underscore"
 	else
-	   ac_cv_fc_mangling="$ac_cv_fc_mangling, underscore"
-	fi
-	if test -z "$ac_extra"; then
-	   ac_cv_fc_mangling="$ac_cv_fc_mangling, no extra underscore"
+           ac_cv_fc_mangling="$ac_cv_fc_mangling, underscore"
+        fi
+        if test -z "$ac_extra"; then
+           ac_cv_fc_mangling="$ac_cv_fc_mangling, no extra underscore"
 	else
-	   ac_cv_fc_mangling="$ac_cv_fc_mangling, extra underscore"
-	fi
+           ac_cv_fc_mangling="$ac_cv_fc_mangling, extra underscore"
+        fi
       else
 	ac_cv_fc_mangling="unknown"
       fi
@@ -3965,15 +3930,22 @@
   rm -rf conftest*
   rm -f cfortran_test*
 else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compile a simple Fortran program
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot compile a simple Fortran program
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compile a simple Fortran program
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_mangling" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_mangling" >&5
 $as_echo "$ac_cv_fc_mangling" >&6; }
 
 ac_ext=c
@@ -3986,51 +3958,85 @@
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
 case $ac_cv_fc_mangling in
   "lower case, no underscore, no extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) name" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) name
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) name" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) name
+_ACEOF
  ;;
   "lower case, no underscore, extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) name" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) name
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) name ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) name ## _
+_ACEOF
  ;;
   "lower case, underscore, no extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) name ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) name ## _
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) name ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) name ## _
+_ACEOF
  ;;
   "lower case, underscore, extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) name ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) name ## _
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) name ## __" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) name ## __
+_ACEOF
  ;;
   "upper case, no underscore, no extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) NAME" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) NAME
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) NAME" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) NAME
+_ACEOF
  ;;
   "upper case, no underscore, extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) NAME" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) NAME
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) NAME ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) NAME ## _
+_ACEOF
  ;;
   "upper case, underscore, no extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) NAME ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) NAME ## _
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) NAME ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) NAME ## _
+_ACEOF
  ;;
   "upper case, underscore, extra underscore")
-	  $as_echo "#define FC_FUNC(name,NAME) NAME ## _" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC(name,NAME) NAME ## _
+_ACEOF
 
-	  $as_echo "#define FC_FUNC_(name,NAME) NAME ## __" >>confdefs.h
+          cat >>confdefs.h <<\_ACEOF
+#define FC_FUNC_(name,NAME) NAME ## __
+_ACEOF
  ;;
   *)
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unknown Fortran name-mangling scheme" >&5
+          { $as_echo "$as_me:$LINENO: WARNING: unknown Fortran name-mangling scheme" >&5
 $as_echo "$as_me: WARNING: unknown Fortran name-mangling scheme" >&2;}
-	  ;;
+          ;;
 esac
 
 ac_ext=c
@@ -4048,39 +4054,60 @@
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran flag to compile .f90 files" >&5
+{ $as_echo "$as_me:$LINENO: checking for Fortran flag to compile .f90 files" >&5
 $as_echo_n "checking for Fortran flag to compile .f90 files... " >&6; }
-if ${ac_cv_fc_srcext_f90+:} false; then :
+if test "${ac_cv_fc_srcext_f90+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_ext=f90
 ac_fcflags_srcext_save=$ac_fcflags_srcext
 ac_fcflags_srcext=
 ac_cv_fc_srcext_f90=unknown
-case $ac_ext in #(
-  [fF]77) ac_try=f77;; #(
-  *) ac_try=f95;;
-esac
-for ac_flag in none -qsuffix=f=f90 -Tf "-x $ac_try"; do
+for ac_flag in none -qsuffix=f=f90 -Tf; do
   test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_fc_srcext_f90=$ac_flag; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 rm -f conftest.$ac_objext conftest.f90
 ac_fcflags_srcext=$ac_fcflags_srcext_save
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_srcext_f90" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_srcext_f90" >&5
 $as_echo "$ac_cv_fc_srcext_f90" >&6; }
 if test "x$ac_cv_fc_srcext_f90" = xunknown; then
-  as_fn_error $? "Fortran could not compile .f90 files" "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: Fortran could not compile .f90 files" >&5
+$as_echo "$as_me: error: Fortran could not compile .f90 files" >&2;}
+   { (exit 1); exit 1; }; }
 else
   ac_fc_srcext=f90
   if test "x$ac_cv_fc_srcext_f90" = xnone; then
@@ -4102,38 +4129,63 @@
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran flag needed to accept free-form source" >&5
-$as_echo_n "checking for Fortran flag needed to accept free-form source... " >&6; }
-if ${ac_cv_fc_freeform+:} false; then :
+{ $as_echo "$as_me:$LINENO: checking for Fortran flag needed to allow free-form source" >&5
+$as_echo_n "checking for Fortran flag needed to allow free-form source... " >&6; }
+if test "${ac_cv_fc_freeform+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_cv_fc_freeform=unknown
 ac_fc_freeform_FCFLAGS_save=$FCFLAGS
 for ac_flag in none -ffree-form -FR -free -qfree -Mfree -Mfreeform \
-	       -freeform "-f free" -8 +source=free -nfix --nfix -Free
+               -freeform "-f free"
 do
   test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
-  cat > conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 
   program freeform
        ! FIXME: how to best confuse non-freeform compilers?
        print *, 'Hello ', &
-          'world.'
+           'world.'
        end
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_fc_freeform=$ac_flag; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 FCFLAGS=$ac_fc_freeform_FCFLAGS_save
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_freeform" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_freeform" >&5
 $as_echo "$ac_cv_fc_freeform" >&6; }
 if test "x$ac_cv_fc_freeform" = xunknown; then
-  as_fn_error 77 "Fortran does not accept free-form source" "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: Fortran does not accept free-form source" >&5
+$as_echo "$as_me: error: Fortran does not accept free-form source" >&2;}
+   { (exit 77); exit 77; }; }
 else
   if test "x$ac_cv_fc_freeform" != xnone; then
     FCFLAGS="$FCFLAGS $ac_cv_fc_freeform"
@@ -4154,9 +4206,9 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -4167,24 +4219,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4194,9 +4246,9 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -4207,24 +4259,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 $as_echo "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4233,7 +4285,7 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
@@ -4247,9 +4299,9 @@
           if test -n "$ac_tool_prefix"; then
     # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -4260,24 +4312,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4287,9 +4339,9 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -4301,18 +4353,18 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
      fi
     ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 if test $ac_prog_rejected = yes; then
@@ -4331,10 +4383,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4346,9 +4398,9 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if test "${ac_cv_prog_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -4359,24 +4411,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
 $as_echo "$CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4390,9 +4442,9 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -4403,24 +4455,24 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
 $as_echo "$ac_ct_CC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
@@ -4433,7 +4485,7 @@
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
@@ -4444,42 +4496,62 @@
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 
 # Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
+{ (ac_try="$ac_compiler --version >&5"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -4501,16 +4573,37 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
 else
-  ac_compiler_gnu=no
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_compiler_gnu=no
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
 if test $ac_compiler_gnu = yes; then
   GCC=yes
@@ -4519,16 +4612,20 @@
 fi
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
 $as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
+if test "${ac_cv_prog_cc_g+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_save_c_werror_flag=$ac_c_werror_flag
    ac_c_werror_flag=yes
    ac_cv_prog_cc_g=no
    CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+   cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -4547,11 +4644,35 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_g=yes
 else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -4570,12 +4691,36 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
+	ac_c_werror_flag=$ac_save_c_werror_flag
 	 CFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
 #ifdef FC_DUMMY_MAIN
@@ -4594,17 +4739,42 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_g=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    ac_c_werror_flag=$ac_save_c_werror_flag
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
 $as_echo "$ac_cv_prog_cc_g" >&6; }
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -4621,18 +4791,23 @@
     CFLAGS=
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
+if test "${ac_cv_prog_cc_c89+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-struct stat;
+#include <sys/types.h>
+#include <sys/stat.h>
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -4692,9 +4867,32 @@
 	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
+  rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_c89=$ac_arg
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
+
 rm -f core conftest.err conftest.$ac_objext
   test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
@@ -4705,19 +4903,17 @@
 # AC_CACHE_VAL
 case "x$ac_cv_prog_cc_c89" in
   x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+    { $as_echo "$as_me:$LINENO: result: none needed" >&5
 $as_echo "none needed" >&6; } ;;
   xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+    { $as_echo "$as_me:$LINENO: result: unsupported" >&5
 $as_echo "unsupported" >&6; } ;;
   *)
     CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+    { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
 esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
 
-fi
 
 ac_ext=${ac_fc_srcext-f}
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
@@ -4736,14 +4932,14 @@
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
 $as_echo_n "checking how to run the C preprocessor... " >&6; }
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
+  if test "${ac_cv_prog_CPP+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
@@ -4758,7 +4954,11 @@
   # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #ifdef __STDC__
 # include <limits.h>
@@ -4767,34 +4967,78 @@
 #endif
 		     Syntax error
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-else
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
+rm -f conftest.err conftest.$ac_ext
+
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   # Broken: success on invalid input.
 continue
 else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
+rm -f conftest.err conftest.$ac_ext
+
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
   break
 fi
 
@@ -4806,7 +5050,7 @@
 else
   ac_cv_prog_CPP=$CPP
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
 $as_echo "$CPP" >&6; }
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
@@ -4817,7 +5061,11 @@
   # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #ifdef __STDC__
 # include <limits.h>
@@ -4826,40 +5074,87 @@
 #endif
 		     Syntax error
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-else
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
+rm -f conftest.err conftest.$ac_ext
+
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   # Broken: success on invalid input.
 continue
 else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
+rm -f conftest.err conftest.$ac_ext
+
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
 else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 fi
 
 ac_ext=c
@@ -4869,9 +5164,9 @@
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
+if test "${ac_cv_path_GREP+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test -z "$GREP"; then
@@ -4882,10 +5177,10 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
+  for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -4902,7 +5197,7 @@
     $as_echo 'GREP' >> "conftest.nl"
     "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
     diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    ac_count=`expr $ac_count + 1`
     if test $ac_count -gt ${ac_path_GREP_max-0}; then
       # Best one so far, save it but keep looking for a better one
       ac_cv_path_GREP="$ac_path_GREP"
@@ -4917,24 +5212,26 @@
       $ac_path_GREP_found && break 3
     done
   done
-  done
+done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
   fi
 else
   ac_cv_path_GREP=$GREP
 fi
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
 $as_echo "$ac_cv_path_GREP" >&6; }
  GREP="$ac_cv_path_GREP"
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
 $as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
+if test "${ac_cv_path_EGREP+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
@@ -4948,10 +5245,10 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
+  for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -4968,7 +5265,7 @@
     $as_echo 'EGREP' >> "conftest.nl"
     "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
     diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    ac_count=`expr $ac_count + 1`
     if test $ac_count -gt ${ac_path_EGREP_max-0}; then
       # Best one so far, save it but keep looking for a better one
       ac_cv_path_EGREP="$ac_path_EGREP"
@@ -4983,10 +5280,12 @@
       $ac_path_EGREP_found && break 3
     done
   done
-  done
+done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
   fi
 else
   ac_cv_path_EGREP=$EGREP
@@ -4994,17 +5293,21 @@
 
    fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
 $as_echo "$ac_cv_path_EGREP" >&6; }
  EGREP="$ac_cv_path_EGREP"
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
+if test "${ac_cv_header_stdc+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <stdarg.h>
@@ -5027,23 +5330,48 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_header_stdc=yes
 else
-  ac_cv_header_stdc=no
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_header_stdc=no
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <string.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
 else
   ac_cv_header_stdc=no
 fi
@@ -5053,14 +5381,18 @@
 
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <stdlib.h>
 
 _ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
+  $EGREP "free" >/dev/null 2>&1; then
+  :
 else
   ac_cv_header_stdc=no
 fi
@@ -5070,10 +5402,14 @@
 
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
+  if test "$cross_compiling" = yes; then
   :
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ctype.h>
 #include <stdlib.h>
@@ -5100,33 +5436,118 @@
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-else
-  ac_cv_header_stdc=no
+( exit $ac_status )
+ac_cv_header_stdc=no
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
+
 fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
 $as_echo "$ac_cv_header_stdc" >&6; }
 if test $ac_cv_header_stdc = yes; then
 
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
 
 fi
 
 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
 		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -5136,22 +5557,288 @@
 done
 
 
-ac_fn_c_check_header_mongrel "$LINENO" "emmintrin.h" "ac_cv_header_emmintrin_h" "$ac_includes_default"
-if test "x$ac_cv_header_emmintrin_h" = xyes; then :
+if test "${ac_cv_header_emmintrin_h+set}" = set; then
+  { $as_echo "$as_me:$LINENO: checking for emmintrin.h" >&5
+$as_echo_n "checking for emmintrin.h... " >&6; }
+if test "${ac_cv_header_emmintrin_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_emmintrin_h" >&5
+$as_echo "$ac_cv_header_emmintrin_h" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking emmintrin.h usability" >&5
+$as_echo_n "checking emmintrin.h usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <emmintrin.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-$as_echo "#define HAVE_EMMINTRIN 1" >>confdefs.h
+	ac_header_compiler=no
+fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking emmintrin.h presence" >&5
+$as_echo_n "checking emmintrin.h presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <emmintrin.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
 fi
 
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
 
-ac_fn_c_check_header_mongrel "$LINENO" "xmmintrin.h" "ac_cv_header_xmmintrin_h" "$ac_includes_default"
-if test "x$ac_cv_header_xmmintrin_h" = xyes; then :
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: emmintrin.h:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: emmintrin.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: emmintrin.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: emmintrin.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## -------------------------------------- ##
+## Report this to jtromp AT princeton.edu ##
+## -------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for emmintrin.h" >&5
+$as_echo_n "checking for emmintrin.h... " >&6; }
+if test "${ac_cv_header_emmintrin_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_header_emmintrin_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_emmintrin_h" >&5
+$as_echo "$ac_cv_header_emmintrin_h" >&6; }
 
-$as_echo "#define HAVE_XMMINTRIN 1" >>confdefs.h
+fi
+if test "x$ac_cv_header_emmintrin_h" = x""yes; then
 
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EMMINTRIN 1
+_ACEOF
+
 fi
 
 
+if test "${ac_cv_header_xmmintrin_h+set}" = set; then
+  { $as_echo "$as_me:$LINENO: checking for xmmintrin.h" >&5
+$as_echo_n "checking for xmmintrin.h... " >&6; }
+if test "${ac_cv_header_xmmintrin_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_xmmintrin_h" >&5
+$as_echo "$ac_cv_header_xmmintrin_h" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking xmmintrin.h usability" >&5
+$as_echo_n "checking xmmintrin.h usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <xmmintrin.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking xmmintrin.h presence" >&5
+$as_echo_n "checking xmmintrin.h presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <xmmintrin.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: xmmintrin.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: xmmintrin.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## -------------------------------------- ##
+## Report this to jtromp AT princeton.edu ##
+## -------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for xmmintrin.h" >&5
+$as_echo_n "checking for xmmintrin.h... " >&6; }
+if test "${ac_cv_header_xmmintrin_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_header_xmmintrin_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_xmmintrin_h" >&5
+$as_echo "$ac_cv_header_xmmintrin_h" >&6; }
+
+fi
+if test "x$ac_cv_header_xmmintrin_h" = x""yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XMMINTRIN 1
+_ACEOF
+
+fi
+
+
 ac_ext=${ac_fc_srcext-f}
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
@@ -5171,6 +5858,13 @@
 
 
 
+
+
+
+
+
+
+
 if test x"$MPIFC" = x; then
     MPIFC=mpif90
 fi
@@ -5180,8 +5874,6 @@
     LOCAL_PATH_IS_ALSO_GLOBAL=true
 fi
 
-
-
 # Checks for libraries.
 
 
@@ -5205,9 +5897,9 @@
 FC=$MPIFC
 FCFLAGS="$FCFLAGS $FLAGS_NO_CHECK"
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mpif.h works" >&5
+{ $as_echo "$as_me:$LINENO: checking whether mpif.h works" >&5
 $as_echo_n "checking whether mpif.h works... " >&6; }
-cat > conftest.$ac_ext <<_ACEOF
+cat >conftest.$ac_ext <<_ACEOF
 
       program main
 
@@ -5221,14 +5913,34 @@
       end
 
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+    { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
 else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+    { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
     cit_mpif_h=unknown
     cit_mpifc_info=`$FC -compile_info 2>/dev/null`
@@ -5238,13 +5950,16 @@
         esac
     done
     if test "$cit_mpif_h" == "unknown"; then
-        { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+        { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compile a trivial MPI program using $MPIFC
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot compile a trivial MPI program using $MPIFC
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compile a trivial MPI program using $MPIFC
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
     fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ofile" >&5
+    { $as_echo "$as_me:$LINENO: creating $ofile" >&5
 $as_echo "$as_me: creating $ofile" >&6;}
     cat >"$cfgfile" <<END_OF_HEADER
 ! $ofile.  Generated from $cit_mpif_h by configure.
@@ -5254,9 +5969,9 @@
     mv -f "$cfgfile" "$ofile" || \
         (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether generated mpif.h works" >&5
+    { $as_echo "$as_me:$LINENO: checking whether generated mpif.h works" >&5
 $as_echo_n "checking whether generated mpif.h works... " >&6; }
-    cat > conftest.$ac_ext <<_ACEOF
+    cat >conftest.$ac_ext <<_ACEOF
 
       program main
 
@@ -5270,25 +5985,50 @@
       end
 
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 
 else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+        { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
-        { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+        { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compile a trivial MPI program using $MPIFC
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot compile a trivial MPI program using $MPIFC
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compile a trivial MPI program using $MPIFC
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
 
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
 fi
+
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 FC=$cit_fc_save_fc
@@ -5301,13 +6041,283 @@
 
 
 
+if test "$want_adios" = yes; then
+
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+  if test "${ac_cv_header_mxml_h+set}" = set; then
+  { $as_echo "$as_me:$LINENO: checking for mxml.h" >&5
+$as_echo_n "checking for mxml.h... " >&6; }
+if test "${ac_cv_header_mxml_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mxml_h" >&5
+$as_echo "$ac_cv_header_mxml_h" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking mxml.h usability" >&5
+$as_echo_n "checking mxml.h usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <mxml.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking mxml.h presence" >&5
+$as_echo_n "checking mxml.h presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <mxml.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: mxml.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: mxml.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: mxml.h: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: mxml.h:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: mxml.h: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: mxml.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: mxml.h: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: mxml.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: mxml.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## -------------------------------------- ##
+## Report this to jtromp AT princeton.edu ##
+## -------------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for mxml.h" >&5
+$as_echo_n "checking for mxml.h... " >&6; }
+if test "${ac_cv_header_mxml_h+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_header_mxml_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_mxml_h" >&5
+$as_echo "$ac_cv_header_mxml_h" >&6; }
+
+fi
+if test "x$ac_cv_header_mxml_h" = x""yes; then
+  :
+else
+
+    { { $as_echo "$as_me:$LINENO: error: mxml C header not found; try CPPFLAGS=\"-I<mxml include dir>\"" >&5
+$as_echo "$as_me: error: mxml C header not found; try CPPFLAGS=\"-I<mxml include dir>\"" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+
+
+
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+  { $as_echo "$as_me:$LINENO: checking for mxmlNewXML in -lmxml" >&5
+$as_echo_n "checking for mxmlNewXML in -lmxml... " >&6; }
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <mxml.h>
+#ifdef FC_DUMMY_MAIN
+#ifndef FC_DUMMY_MAIN_EQ_F77
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int FC_DUMMY_MAIN() { return 1; }
+#endif
+#endif
+int
+main ()
+{
+mxml_node_t *xml = mxmlNewXML("1.0");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+     { { $as_echo "$as_me:$LINENO: error: mxml library not found; try LDFLAGS=\"-L<mxml lib dir>\"" >&5
+$as_echo "$as_me: error: mxml library not found; try LDFLAGS=\"-L<mxml lib dir>\"" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+  ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+  { $as_echo "$as_me:$LINENO: checking for adios_init in -ladiosf" >&5
+$as_echo_n "checking for adios_init in -ladiosf... " >&6; }
+      FC_BCK=$FC
+  FC=$MPIFC
+  cat >conftest.$ac_ext <<_ACEOF
+      program main
+use adios_write_mod; call adios_init("par.xml", ierr)
+      end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+     { { $as_echo "$as_me:$LINENO: error: adiosf library not found; try LDFLAGS=\"-L<adios lib dir>\"
+					     and FCFLAGS=\"-I<adios inc dir>\"" >&5
+$as_echo "$as_me: error: adiosf library not found; try LDFLAGS=\"-L<adios lib dir>\"
+					     and FCFLAGS=\"-I<adios inc dir>\"" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext    FC=$FC_BCK
+
+fi
+
 if test "$want_cuda" = yes; then
 
   # Extract the first word of "nvcc", so it can be a program name with args.
 set dummy nvcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_NVCC+:} false; then :
+if test "${ac_cv_path_NVCC+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   case $NVCC in
@@ -5320,14 +6330,14 @@
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_NVCC="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
-  done
+done
 IFS=$as_save_IFS
 
   ;;
@@ -5335,24 +6345,34 @@
 fi
 NVCC=$ac_cv_path_NVCC
 if test -n "$NVCC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NVCC" >&5
+  { $as_echo "$as_me:$LINENO: result: $NVCC" >&5
 $as_echo "$NVCC" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
   if test -z "$NVCC" ; then
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+    { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot find 'nvcc' program.
-See \`config.log' for more details" "$LINENO" 5; }
+{ { $as_echo "$as_me:$LINENO: error: cannot find 'nvcc' program.
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot find 'nvcc' program.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }; }
     NVCC=`echo "Error: nvcc is not installed." ; false`
   fi
 
 fi
 
+#mpbl: adding flags to config.h.in through autoheader in order to save them into the adios file.
+configure_flags_str="FC=$FC"" FCFLAGS=""$FLAGS_NO_CHECK"""
+
+cat >>confdefs.h <<_ACEOF
+#define CONFIGURE_FLAGS "${configure_flags_str}"
+_ACEOF
+
 # Checks for typedefs, structures, and compiler characteristics.
 
 
@@ -5387,13 +6407,13 @@
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
+      *) $as_unset $ac_var ;;
       esac ;;
     esac
   done
@@ -5401,8 +6421,8 @@
   (set) 2>&1 |
     case $as_nl`(ac_space=' '; set) 2>&1` in #(
     *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
       sed -n \
 	"s/'/'\\\\''/g;
 	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
@@ -5424,23 +6444,12 @@
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
-    if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
 $as_echo "$as_me: updating cache $cache_file" >&6;}
-      if test ! -f "$cache_file" || test -h "$cache_file"; then
-	cat confcache >"$cache_file"
-      else
-        case $cache_file in #(
-        */* | ?:*)
-	  mv -f confcache "$cache_file"$$ &&
-	  mv -f "$cache_file"$$ "$cache_file" ;; #(
-        *)
-	  mv -f confcache "$cache_file" ;;
-	esac
-      fi
-    fi
+    cat confcache >$cache_file
   else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+    { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
@@ -5454,15 +6463,14 @@
 
 ac_libobjs=
 ac_ltlibobjs=
-U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
   ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
   # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
   #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
 done
 LIBOBJS=$ac_libobjs
 
@@ -5470,26 +6478,41 @@
 
 
 if test -z "${COND_CUDA_TRUE}" && test -z "${COND_CUDA_FALSE}"; then
-  as_fn_error $? "conditional \"COND_CUDA\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: conditional \"COND_CUDA\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"COND_CUDA\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
 fi
 if test -z "${COND_CUDA5_TRUE}" && test -z "${COND_CUDA5_FALSE}"; then
-  as_fn_error $? "conditional \"COND_CUDA5\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: conditional \"COND_CUDA5\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"COND_CUDA5\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
 fi
+if test -z "${COND_ADIOS_TRUE}" && test -z "${COND_ADIOS_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"COND_ADIOS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"COND_ADIOS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${COND_VTK_TRUE}" && test -z "${COND_VTK_FALSE}"; then
-  as_fn_error $? "conditional \"COND_VTK\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: conditional \"COND_VTK\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"COND_VTK\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-: "${CONFIG_STATUS=./config.status}"
+: ${CONFIG_STATUS=./config.status}
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #! $SHELL
 # Generated by $as_me.
 # Run this file to recreate the current configuration.
@@ -5499,18 +6522,17 @@
 debug=false
 ac_cs_recheck=false
 ac_cs_silent=false
-
 SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
+_ACEOF
 
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
 # Be more Bourne compatible
 DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
@@ -5518,15 +6540,23 @@
   alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
 else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
 esac
+
 fi
 
 
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
 as_nl='
 '
 export as_nl
@@ -5534,13 +6564,7 @@
 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
   as_echo='printf %s\n'
   as_echo_n='printf %s'
 else
@@ -5551,7 +6575,7 @@
     as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
     as_echo_n_body='eval
       arg=$1;
-      case $arg in #(
+      case $arg in
       *"$as_nl"*)
 	expr "X$arg" : "X\\(.*\\)$as_nl";
 	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
@@ -5574,7 +6598,14 @@
   }
 fi
 
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
 
+
 # IFS
 # We need space, tab and new line, in precisely that order.  Quoting is
 # there to prevent editors from complaining about space-tab.
@@ -5583,16 +6614,15 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
+case $0 in
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
 IFS=$as_save_IFS
 
      ;;
@@ -5604,16 +6634,12 @@
 fi
 if test ! -f "$as_myself"; then
   $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
+  { (exit 1); exit 1; }
 fi
 
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
 done
 PS1='$ '
 PS2='> '
@@ -5625,89 +6651,7 @@
 LANGUAGE=C
 export LANGUAGE
 
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
+# Required to use basename.
 if expr a : '\(a\)' >/dev/null 2>&1 &&
    test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
@@ -5721,12 +6665,8 @@
   as_basename=false
 fi
 
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
 
+# Name of the executable.
 as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
@@ -5746,25 +6686,76 @@
 	  }
 	  s/.*/./; q'`
 
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
+# CDPATH.
+$as_unset CDPATH
 
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
 ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
+case `echo -n x` in
 -n*)
-  case `echo 'xy\c'` in
+  case `echo 'x\c'` in
   *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
+  *)   ECHO_C='\c';;
   esac;;
 *)
   ECHO_N='-n';;
 esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
 
 rm -f conf$$ conf$$.exe conf$$.file
 if test -d conf$$.dir; then
@@ -5779,86 +6770,50 @@
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
 
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
 if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
+  as_mkdir_p=:
 else
   test -d ./-p && rmdir ./-p
   as_mkdir_p=false
 fi
 
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
 
@@ -5867,19 +6822,13 @@
 
 
 exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
+# Save the log message, to keep $[0] and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
 This file was extended by Specfem3D Globe $as_me 6.0.0, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -5910,15 +6859,13 @@
 
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
+\`$as_me' instantiates files from templates according to the
+current configuration.
 
-Usage: $0 [OPTION]... [TAG]...
+Usage: $0 [OPTION]... [FILE]...
 
   -h, --help       print this help, then exit
   -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
   -q, --quiet, --silent
                    do not print progress messages
   -d, --debug      don't remove temporary files
@@ -5934,17 +6881,16 @@
 Configuration headers:
 $config_headers
 
-Report bugs to <jtromp AT princeton.edu>."
+Report bugs to <bug-autoconf at gnu.org>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 Specfem3D Globe config.status 6.0.0
-configured by $0, generated by GNU Autoconf 2.69,
-  with options \\"\$ac_cs_config\\"
+configured by $0, generated by GNU Autoconf 2.63,
+  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2008 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -5959,16 +6905,11 @@
 while test $# != 0
 do
   case $1 in
-  --*=?*)
+  --*=*)
     ac_option=`expr "X$1" : 'X\([^=]*\)='`
     ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
     ac_shift=:
     ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
-    ac_shift=:
-    ;;
   *)
     ac_option=$1
     ac_optarg=$2
@@ -5982,29 +6923,27 @@
     ac_cs_recheck=: ;;
   --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
     $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
   --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
     case $ac_optarg in
     *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
     esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
     ac_need_defaults=false;;
   --header | --heade | --head | --hea )
     $ac_shift
     case $ac_optarg in
     *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
-    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
     ac_need_defaults=false;;
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
+    { $as_echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; };;
   --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
@@ -6012,10 +6951,11 @@
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
+  -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; } ;;
 
-  *) as_fn_append ac_config_targets " $1"
+  *) ac_config_targets="$ac_config_targets $1"
      ac_need_defaults=false ;;
 
   esac
@@ -6032,7 +6972,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
@@ -6070,7 +7010,9 @@
     "setup/constants.h") CONFIG_FILES="$CONFIG_FILES setup/constants.h" ;;
     "setup/precision.h") CONFIG_FILES="$CONFIG_FILES setup/precision.h" ;;
 
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
   esac
 done
 
@@ -6092,24 +7034,26 @@
 # after its creation but before its name has been assigned to `$tmp'.
 $debug ||
 {
-  tmp= ac_tmp=
+  tmp=
   trap 'exit_status=$?
-  : "${ac_tmp:=$tmp}"
-  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
 ' 0
-  trap 'as_fn_exit 1' 1 2 13 15
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
 }
 # Create a (secure) tmp directory for tmp files.
 
 {
   tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -d "$tmp"
+  test -n "$tmp" && test -d "$tmp"
 }  ||
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
+} ||
+{
+   $as_echo "$as_me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -6117,13 +7061,8 @@
 if test -n "$CONFIG_FILES"; then
 
 
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
+ac_cr='
+'
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
   ac_cs_awk_cr='\\r'
@@ -6131,7 +7070,7 @@
   ac_cs_awk_cr=$ac_cr
 fi
 
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
 _ACEOF
 
 
@@ -6140,18 +7079,24 @@
   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+  { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
   if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -6159,7 +7104,7 @@
 rm -f conf$$subs.sh
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
 _ACEOF
 sed -n '
 h
@@ -6173,7 +7118,7 @@
 t delim
 :nl
 h
-s/\(.\{148\}\)..*/\1/
+s/\(.\{148\}\).*/\1/
 t more1
 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
 p
@@ -6187,7 +7132,7 @@
 t nl
 :delim
 h
-s/\(.\{148\}\)..*/\1/
+s/\(.\{148\}\).*/\1/
 t more2
 s/["\\]/\\&/g; s/^/"/; s/$/"/
 p
@@ -6207,7 +7152,7 @@
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 _ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
   for (key in S) S_is_set[key] = 1
   FS = ""
 
@@ -6239,29 +7184,23 @@
   sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
 else
   cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+   { (exit 1); exit 1; }; }
 _ACEOF
 
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
 s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
 s/^[^=]*=[	 ]*$//
 }'
 fi
@@ -6273,7 +7212,7 @@
 # No need to generate them if there are no CONFIG_HEADERS.
 # This happens for instance with `./config.status Makefile'.
 if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+cat >"$tmp/defines.awk" <<\_ACAWK ||
 BEGIN {
 _ACEOF
 
@@ -6285,11 +7224,13 @@
 # handling of long lines.
 ac_delim='%!_!# '
 for ac_last_try in false false :; do
-  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_tt"; then
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
+   { (exit 1); exit 1; }; }
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -6374,7 +7315,9 @@
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
+$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
+   { (exit 1); exit 1; }; }
 fi # test -n "$CONFIG_HEADERS"
 
 
@@ -6387,7 +7330,9 @@
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
+   { (exit 1); exit 1; }; };;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
@@ -6406,7 +7351,7 @@
     for ac_f
     do
       case $ac_f in
-      -) ac_f="$ac_tmp/stdin";;
+      -) ac_f="$tmp/stdin";;
       *) # Look for the file first in the build tree, then in the source tree
 	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
 	 # because $ac_f cannot contain `:'.
@@ -6415,10 +7360,12 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+	   { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
+      ac_file_inputs="$ac_file_inputs '$ac_f'"
     done
 
     # Let's still pretend it is `configure' which instantiates (i.e., don't
@@ -6429,7 +7376,7 @@
 	`' by configure.'
     if test x"$ac_file" != x-; then
       configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+      { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
 $as_echo "$as_me: creating $ac_file" >&6;}
     fi
     # Neutralize special characters interpreted by sed in replacement strings.
@@ -6441,8 +7388,10 @@
     esac
 
     case $ac_tag in
-    *:-:* | *:-) cat >"$ac_tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; } ;;
     esac
     ;;
   esac
@@ -6470,7 +7419,47 @@
 	    q
 	  }
 	  s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
+   { (exit 1); exit 1; }; }; }
   ac_builddir=.
 
 case "$ac_dir" in
@@ -6518,6 +7507,7 @@
 # If the template does not know about datarootdir, expand it.
 # FIXME: This hack should be removed a few years after 2.60.
 ac_datarootdir_hack=; ac_datarootdir_seen=
+
 ac_sed_dataroot='
 /datarootdir/ {
   p
@@ -6527,11 +7517,12 @@
 /@docdir@/p
 /@infodir@/p
 /@localedir@/p
-/@mandir@/p'
+/@mandir@/p
+'
 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
@@ -6541,7 +7532,7 @@
   s&@infodir@&$infodir&g
   s&@localedir@&$localedir&g
   s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
+    s&\\\${datarootdir}&$datarootdir&g' ;;
 esac
 _ACEOF
 
@@ -6567,24 +7558,27 @@
 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
 $ac_datarootdir_hack
 "
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
-      "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
-  rm -f "$ac_tmp/stdin"
+  rm -f "$tmp/stdin"
   case $ac_file in
-  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
   esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
  ;;
   :H)
   #
@@ -6593,36 +7587,50 @@
   if test x"$ac_file" != x-; then
     {
       $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
-    } >"$ac_tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
-      mv "$ac_tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+      mv "$tmp/config.h" "$ac_file" \
+	|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
     fi
   else
     $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
+$as_echo "$as_me: error: could not create -" >&2;}
+   { (exit 1); exit 1; }; }
   fi
  ;;
 
 
   esac
 
+
+  case $ac_file$ac_mode in
+    "setup/config.h":H) sed 's/\/\*\(.*\)\*\//!\1/g' setup/config.h > setup/config.fh ;;
+
+  esac
 done # for ac_tag
 
 
-as_fn_exit 0
+{ (exit 0); exit 0; }
 _ACEOF
+chmod +x $CONFIG_STATUS
 ac_clean_files=$ac_clean_files_save
 
 test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
 
 
 # configure is writing to config.log, and then calls config.status.
@@ -6643,10 +7651,10 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
+  $ac_cs_success || { (exit 1); exit 1; }
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
@@ -6654,3 +7662,4 @@
 #daniel: adding custom lines to config.h.in through autoheader
 
 
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac	2013-06-30 12:40:04 UTC (rev 22453)
@@ -10,7 +10,9 @@
 AC_PREREQ(2.61)
 AC_INIT([Specfem3D Globe], [6.0.0], [jtromp AT princeton.edu], [Specfem3DGlobe])
 AC_CONFIG_SRCDIR([src/specfem3D/specfem3D.F90])
-AC_CONFIG_HEADER([setup/config.h])
+AC_CONFIG_HEADERS([setup/config.h],
+                  [sed 's/\/\*\(.*\)\*\//!\1/g' setup/config.h > setup/config.fh])
+dnl [awk '/\/\*/,/\*\//{sub(/^/,"!")};{print}' setup/config.h > setup/config.fh])
 AC_CONFIG_MACRO_DIR([m4])
 
 
@@ -40,6 +42,13 @@
 AM_CONDITIONAL([COND_CUDA], [test "$want_cuda" != no])
 AM_CONDITIONAL([COND_CUDA5], [test "$want_cuda" = cuda5])
 
+AC_ARG_WITH([adios],
+    [AC_HELP_STRING([--with-adios],
+        [build ADIOS enabled version @<:@default=no@:>@])],
+    [want_adios="$withval"],
+    [want_adios=no])
+AM_CONDITIONAL([COND_ADIOS], [test "$want_adios" != no])
+
 AC_ARG_WITH([vtk],
     [AC_HELP_STRING([--with-vtk],
         [build VTK enabled version @<:@default=no@:>@])],
@@ -71,6 +80,7 @@
     AC_MSG_ERROR([$flags_guess failed])
 eval $flags
 
+
 AC_FC_WRAPPERS
 AC_LANG(Fortran)
 AC_FC_SRCEXT(f90)
@@ -85,6 +95,11 @@
 
 # influential environment variables
 
+AC_ARG_VAR(ADIOS_INC, [Directory where ADIOS headers are installed])
+AC_ARG_VAR(ADIOS_LIB, [Directory where ADIOS libraries are installed])
+AC_ARG_VAR(MXML_INC, [Directory where MXML headers are installed])
+AC_ARG_VAR(MXML_LIB, [Directory where MXML libraries are installed])
+
 AC_ARG_VAR(MPIFC, [MPI Fortran compiler command])
 AC_ARG_VAR(MPILIBS, [extra libraries for linking MPI programs])
 AC_ARG_VAR(FLAGS_CHECK, [Fortran compiler flags for non-critical subroutines])
@@ -107,8 +122,6 @@
     LOCAL_PATH_IS_ALSO_GLOBAL=true
 fi
 
-
-
 # Checks for libraries.
 
 
@@ -116,10 +129,20 @@
 
 CIT_FC_MPI_HEADER([$MPIFC], [$FLAGS_NO_CHECK])
 
+if test "$want_adios" = yes; then
+  CIT_MXML_HEADER
+  CIT_MXML_LIB
+  CIT_ADIOS_LIB
+fi	
+
 if test "$want_cuda" = yes; then
     CIT_CUDA_COMPILER
 fi
 
+#mpbl: adding flags to config.h.in through autoheader in order to save them into the adios file.
+configure_flags_str="FC=$FC FCFLAGS=$FLAGS_NO_CHECK" 
+AC_DEFINE_UNQUOTED([CONFIGURE_FLAGS],["${configure_flags_str}"],
+          [configuration flags to be save in the adios output file.])
 # Checks for typedefs, structures, and compiler characteristics.
 
 
@@ -138,7 +161,7 @@
 AH_BOTTOM([
 /* Uncomment and define to select optimized file i/o for regional simulations */
 /* map fails when output files are > 4GB, which is often the case for GPU simulations */
-// #define USE_MAP_FUNCTION
+/* #define USE_MAP_FUNCTION */
 ])
 
 dnl end of configure.ac

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/doc/Doxyfile (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/doc/Doxyfile)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/doc/Doxyfile	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/doc/Doxyfile	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,1563 @@
+# Doxyfile 1.6.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = SPECFEM3D_GLOBE
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = SUNFLOWER_ADIOS
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = /data1/ml15/Workspace/SPECFEM3D_GLOBE/doc/doxygen
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = /Users/dimitri/doxygen/mail/1.5.7/doxywizard/
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = YES
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses. 
+# With this tag you can assign which parser to use for a given extension. 
+# Doxygen has a built-in mapping, but you can override or extend it using this tag. 
+# The format is ext=language, where ext is a file extension, and language is one of 
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, 
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat 
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), 
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set
+# FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen to replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penality. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will rougly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by 
+# doxygen. The layout file controls the global structure of the generated output files 
+# in an output format independent way. The create the layout file that represents 
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a 
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name 
+# of the layout file.
+
+LAYOUT_FILE            = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = /data1/ml15/Workspace/SPECFEM3D_GLOBE/src
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.f90 \
+                         *.f \
+                         *.vhd \
+                         *.vhdl \
+                         *.F90
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
+# link to the source code.  Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# If the HTML_TIMESTAMP tag is set to YES then the generated HTML
+# documentation will contain the timesstamp.
+
+HTML_TIMESTAMP         = NO
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER 
+# are set, an additional index file will be generated that can be used as input for 
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated 
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = 
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. 
+# For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value is set to YES, a side panel will be generated 
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = YES
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript 
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP) 
+# there is already a search function so this one should typically 
+# be disabled.
+
+SEARCHENGINE           = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links. 
+# Note that each tag file must have a unique name 
+# (where the name does NOT include the path) 
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = NO
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output 
+# directory and reference it in all dot files that doxygen generates. This 
+# font does not include all possible unicode characters however, so when you need 
+# these (or just want a differently looking font) you can specify the font name 
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font, 
+# which can be done by putting it in a standard location or by setting the 
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the 
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
+# different font using DOT_FONTNAME you can set the path where dot 
+# can find it using this tag.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include 
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif 
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. Warning: Depending on the platform used, 
+# enabling this option may lead to badly anti-aliased labels on the edges of 
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/flags.guess
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/flags.guess	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/flags.guess	2013-06-30 12:40:04 UTC (rev 22453)
@@ -27,10 +27,10 @@
         # check: http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/lin/compiler_f/index.htm
         #
         if test x"$FLAGS_CHECK" = x; then
-            FLAGS_CHECK="-O3 -xSSE4.2 -ftz -funroll-loops -unroll5 -ftz -align sequence -assume byterecl -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check nobounds" # -mcmodel=medium
+            FLAGS_CHECK="-O3 -ftz -funroll-loops -unroll5 -ftz -align sequence -assume byterecl -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check nobounds" # -mcmodel=medium
         fi
         if test x"$FLAGS_NO_CHECK" = x; then
-            FLAGS_NO_CHECK="-O3 -xSSE4.2 -ftz -funroll-loops -unroll5 -ftz -align sequence -assume byterecl -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check nobounds" # -mcmodel=medium
+            FLAGS_NO_CHECK="-O3 -ftz -funroll-loops -unroll5 -ftz -align sequence -assume byterecl -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check nobounds" # -mcmodel=medium
         fi
         # useful for debugging...
             # for debugging: change -check nobounds to -check all -debug -g -O0 -fp-stack-check -traceback -ftrapuv

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/setup/config.h.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/setup/config.h.in	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/setup/config.h.in	2013-06-30 12:40:04 UTC (rev 22453)
@@ -1,5 +1,8 @@
 /* setup/config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* configuration flags to be save in the adios output file. */
+#undef CONFIGURE_FLAGS
+
 /* Define to dummy `main' function (if any) required to link to the Fortran
    libraries. */
 #undef FC_DUMMY_MAIN
@@ -59,9 +62,6 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -71,5 +71,5 @@
 
 /* Uncomment and define to select optimized file i/o for regional simulations */
 /* map fails when output files are > 4GB, which is often the case for GPU simulations */
-// #define USE_MAP_FUNCTION
+/* #define USE_MAP_FUNCTION */
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in	2013-06-30 12:40:04 UTC (rev 22453)
@@ -194,7 +194,36 @@
 	$(EMPTY_MACRO)
 
 LIBSPECFEM_MESHER = $O/libspecfem_mesher.a
+#
+# using ADIOS files
+ADIOS_OBJECTS= \
+	$O/get_absorb_adios.adios.o  \
+	$O/adios_manager.shared_adios.o  \
+	$O/adios_helpers.shared_adios.o  \
+	$O/write_AVS_DX_global_data_adios.adios.o \
+	$O/write_AVS_DX_global_faces_data_adios.adios.o \
+	$O/write_AVS_DX_global_chunks_data_adios.adios.o \
+	$O/write_AVS_DX_surface_data_adios.adios.o \
+	$O/create_regions_mesh_adios.adios.o \
+	$O/save_arrays_solver_adios.adios.o
+ADIOS_STUBS = \
+	$O/adios_empty_stubs.noadios.o
 
+ at COND_ADIOS_FALSE@ADIOS_OBJECTS = $(ADIOS_STUBS)
+
+# ADIOS
+# with configure: ./configure --with-cuda ADIOS_LIB=.. ADIOS_INC=.. MPI_INC=..
+ at COND_ADIOS_TRUE@ADIOS_LIBS = -ladiosf -lmxml
+ at COND_ADIOS_FALSE@ADIOS_LIBS = 
+
+ADIOS_LIB_LOCATION = @ADIOS_LIB@ @MXML_LIB@
+ADIOS_LINK = $(ADIOS_LIB_LOCATION) $(ADIOS_LIBS)
+ADIOS_INC = @ADIOS_INC@ -I../../setup -I../../ 
+
+#@COND_ADIOS_TRUE at CPPFLAGS = -I../../setup @CPPFLAGS@
+ at COND_ADIOS_TRUE@MPIFCCOMPILE_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(ADIOS_INC) $(FLAGS_CHECK)
+ at COND_ADIOS_TRUE@MPIFCCOMPILE_NO_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(ADIOS_INC) $(FLAGS_NO_CHECK)
+
 #######################################
 
 ####
@@ -223,11 +252,11 @@
 ####
 
 # rules for the main programs
-XMESHFEM_OBJECTS = $(MESHER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_MESHER)
+XMESHFEM_OBJECTS = $(MESHER_ARRAY_OBJECTS) $(ADIOS_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_MESHER)
 
 xmeshfem3D: $(XMESHFEM_OBJECTS)
 ## use MPI here
-	${MPIFCCOMPILE_CHECK} -o ${E}/xmeshfem3D $(XMESHFEM_OBJECTS) $(MPILIBS)
+	${MPIFCCOMPILE_CHECK} -o ${E}/xmeshfem3D $(XMESHFEM_OBJECTS) $(MPILIBS) $(ADIOS_LINK)
 
 
 clean:
@@ -264,7 +293,29 @@
 $O/%.cc.o: ${SHARED}/%.c ${SETUP}/config.h
 	${CC} -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 
 
+#######################################
 
+###
+### ADIOS compilation
+###
+
+$O/%.adios.o: %.F90 ${SETUP}/config.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.adios.o: %.f90 ${SETUP}/config.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.noadios.o: %.F90 
+	${FC} -c -o $@ $<
+
+$O/%.noadios.o: %.f90 
+	${FC} -c -o $@ $<
+
+$O/%.shared_adios.o: ${SHARED}/%.f90 ${SETUP}/constants.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.shared_adios.o: ${SHARED}/%.F90 ${SETUP}/constants.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
 #######################################
 
 ###

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -39,12 +39,14 @@
   use meshfem3D_par,only: &
     ibool,idoubling,xstore,ystore,zstore, &
     IMAIN,volume_total,myrank,LOCAL_PATH, &
-    IREGION_CRUST_MANTLE,IREGION_OUTER_CORE,IREGION_INNER_CORE,IFLAG_IN_FICTITIOUS_CUBE, &
+    IREGION_CRUST_MANTLE,IREGION_OUTER_CORE,IREGION_INNER_CORE, &
+    IFLAG_IN_FICTITIOUS_CUBE, &
     NCHUNKS,SAVE_MESH_FILES,ABSORBING_CONDITIONS, &
     R_CENTRAL_CUBE,RICB,RCMB, &
     MAX_NUMBER_OF_MESH_LAYERS,MAX_NUM_REGIONS,NB_SQUARE_CORNERS, &
     NGLOB1D_RADIAL_CORNER, &
-    NGLOB2DMAX_XMIN_XMAX,NGLOB2DMAX_YMIN_YMAX
+    NGLOB2DMAX_XMIN_XMAX,NGLOB2DMAX_YMIN_YMAX, &
+    ADIOS_FOR_ARRAYS_SOLVER
 
   use meshfem3D_models_par,only: &
     SAVE_BOUNDARY_MESH,SUPPRESS_CRUSTAL_MESH,REGIONAL_MOHO_MESH, &
@@ -168,8 +170,9 @@
 
     ! sets up Stacey absorbing boundary indices
     if(NCHUNKS /= 6) then
-      call get_absorb(myrank,prname,iboun,nspec,nimin,nimax,njmin,njmax,nkmin_xi,nkmin_eta, &
-                         NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX,NSPEC2D_BOTTOM)
+      call get_absorb(myrank,prname,iregion_code, iboun,nspec,nimin,nimax,&
+          njmin,njmax, nkmin_xi,nkmin_eta, NSPEC2DMAX_XMIN_XMAX, &
+          NSPEC2DMAX_YMIN_YMAX, NSPEC2D_BOTTOM)
     endif
 
   ! only create mass matrix and save all the final arrays in the second pass
@@ -334,9 +337,15 @@
       call flush_IMAIN()
     endif
     ! saves mesh and model parameters
-    call save_arrays_solver(myrank,nspec,nglob,idoubling,ibool, &
-                           iregion_code,xstore,ystore,zstore, &
-                           NSPEC2D_TOP,NSPEC2D_BOTTOM)
+    if (ADIOS_FOR_ARRAYS_SOLVER) then
+      call save_arrays_solver_adios(myrank,nspec,nglob,idoubling,ibool, &
+          iregion_code,xstore,ystore,zstore,  &
+          NSPEC2DMAX_XMIN_XMAX, NSPEC2DMAX_YMIN_YMAX, &
+          NSPEC2D_TOP,NSPEC2D_BOTTOM)
+    else
+      call save_arrays_solver(myrank,nspec,nglob,idoubling,ibool, &
+          iregion_code,xstore,ystore,zstore, NSPEC2D_TOP,NSPEC2D_BOTTOM)
+    endif
 
     ! frees memory
     deallocate(rmassx,rmassy,rmassz)
@@ -360,21 +369,23 @@
         call flush_IMAIN()
       endif
       ! saves boundary file
-      call save_arrays_solver_boundary()
+      if (ADIOS_FOR_ARRAYS_SOLVER) then
+        call save_arrays_solver_boundary_adios()
+      else
+        call save_arrays_solver_boundary()
+      endif
 
     endif
 
     ! compute volume, bottom and top area of that part of the slice
     call compute_volumes(volume_local,area_local_bottom,area_local_top, &
-                            nspec,wxgll,wygll,wzgll,xixstore,xiystore,xizstore, &
-                            etaxstore,etaystore,etazstore,gammaxstore,gammaystore,gammazstore, &
-                            NSPEC2D_BOTTOM,jacobian2D_bottom,NSPEC2D_TOP,jacobian2D_top)
+        nspec,wxgll,wygll,wzgll,xixstore,xiystore,xizstore, &
+        etaxstore,etaystore,etazstore,gammaxstore,gammaystore,gammazstore, &
+        NSPEC2D_BOTTOM,jacobian2D_bottom,NSPEC2D_TOP,jacobian2D_top)
 
     ! computes total area and volume
-    call compute_area(myrank,NCHUNKS,iregion_code, &
-                              area_local_bottom,area_local_top,&
-                              volume_local,volume_total, &
-                              RCMB,RICB,R_CENTRAL_CUBE)
+    call compute_area(myrank,NCHUNKS,iregion_code, area_local_bottom, &
+        area_local_top, volume_local,volume_total, RCMB,RICB,R_CENTRAL_CUBE)
 
     ! create AVS or DX mesh data for the slices
     if(SAVE_MESH_FILES) then
@@ -1159,23 +1170,29 @@
 
 
 !
-!-------------------------------------------------------------------------------------------------
+!-------------------------------------------------------------------------------
 !
 
-  subroutine crm_save_mesh_files(nspec,npointot,iregion_code)
+subroutine crm_save_mesh_files(nspec,npointot,iregion_code)
 
   use meshfem3d_par,only: &
     ibool,idoubling, &
     xstore,ystore,zstore, &
     myrank,NGLLX,NGLLY,NGLLZ, &
     RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
-    RMIDDLE_CRUST,ROCEAN
+    RMIDDLE_CRUST,ROCEAN, &
+    ADIOS_FOR_AVS_DX
 
+
   use meshfem3D_models_par,only: &
     ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
     nspl,rspl,espl,espl2
 
   use create_regions_mesh_par2
+
+  ! Modules for temporary AVS/DX data
+  use AVS_DX_global_mod
+
   implicit none
 
   ! number of spectral elements in each block
@@ -1185,8 +1202,13 @@
   ! arrays used for AVS or DX files
   integer, dimension(:), allocatable :: num_ibool_AVS_DX
   logical, dimension(:), allocatable :: mask_ibool
-  integer :: ier
+  ! structures used for ADIOS AVS/DX files
+  type(avs_dx_global_t) :: avs_dx_global_vars
 
+  character(len=150) :: reg_name, outputname, group_name
+  integer :: comm, sizeprocs, ier
+  integer(kind=8) :: adios_group, group_size_inc, adios_totalsize, adios_handle
+
   ! arrays num_ibool_AVS_DX and mask_ibool used to save memory
   ! allocate memory for arrays
   allocate(num_ibool_AVS_DX(npointot), &
@@ -1194,15 +1216,19 @@
           stat=ier)
   if(ier /= 0) stop 'error in allocate 21'
 
-  call write_AVS_DX_global_data(myrank,prname,nspec,ibool,idoubling,xstore,ystore,zstore, &
-                                num_ibool_AVS_DX,mask_ibool,npointot)
+  if (ADIOS_FOR_AVS_DX) then 
+    call crm_save_mesh_files_adios(nspec,npointot,iregion_code, &
+        num_ibool_AVS_DX, mask_ibool)
+  else
+    call write_AVS_DX_global_data(myrank,prname,nspec,ibool,idoubling, &
+        xstore,ystore,zstore, num_ibool_AVS_DX,mask_ibool,npointot)
 
-  call write_AVS_DX_global_faces_data(myrank,prname,nspec,iMPIcut_xi,iMPIcut_eta,ibool, &
-          idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,npointot, &
-          rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
-          ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
-          RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
-          RMIDDLE_CRUST,ROCEAN,iregion_code)
+    call write_AVS_DX_global_faces_data(myrank,prname,nspec,iMPIcut_xi, &
+        iMPIcut_eta,ibool, idoubling,xstore,ystore,zstore,num_ibool_AVS_DX, &
+        mask_ibool,npointot, rhostore,kappavstore,muvstore,nspl,rspl, &
+        espl,espl2, ELLIPTICITY,ISOTROPIC_3D_MANTLE, RICB,RCMB, &
+        RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+        RMIDDLE_CRUST,ROCEAN,iregion_code)
 
   call write_AVS_DX_global_chunks_data(myrank,prname,nspec,iboun,ibool, &
           idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
@@ -1217,6 +1243,7 @@
           ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
           RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
           RMIDDLE_CRUST,ROCEAN,iregion_code)
+  endif
 
   ! Output material information for all GLL points
   ! Can be use to check the mesh
@@ -1224,7 +1251,7 @@
   !                rhostore,kappavstore,muvstore,Qmu_store,ATTENUATION)
   deallocate(num_ibool_AVS_DX,mask_ibool)
 
-  end subroutine crm_save_mesh_files
+end subroutine crm_save_mesh_files
 
 !
 !-------------------------------------------------------------------------------------------------

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/create_regions_mesh_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,175 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+subroutine crm_save_mesh_files_adios(nspec,npointot,iregion_code, &
+    num_ibool_AVS_DX, mask_ibool)
+  use mpi
+  use adios_write_mod
+
+  use meshfem3d_par,only: &
+    ibool,idoubling, &
+    xstore,ystore,zstore, &
+    myrank,NGLLX,NGLLY,NGLLZ, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN, &
+    ADIOS_FOR_AVS_DX, LOCAL_PATH
+
+
+  use meshfem3D_models_par,only: &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    nspl,rspl,espl,espl2
+
+  use create_regions_mesh_par2
+
+  ! Modules for temporary AVS/DX data
+  use AVS_DX_global_mod
+  use AVS_DX_global_faces_mod
+  use AVS_DX_global_chunks_mod
+  use AVS_DX_surface_mod
+
+  implicit none
+
+  ! number of spectral elements in each block
+  integer,intent(in) :: nspec,npointot,iregion_code
+
+  ! local parameters
+  ! arrays used for AVS or DX files
+  integer, dimension(npointot), intent(inout) :: num_ibool_AVS_DX
+  logical, dimension(npointot), intent(inout) :: mask_ibool
+  ! structures used for ADIOS AVS/DX files
+  type(avs_dx_global_t) :: avs_dx_global_vars
+  type(avs_dx_global_faces_t) :: avs_dx_global_faces_vars
+  type(avs_dx_global_chunks_t) :: avs_dx_global_chunks_vars
+  type(avs_dx_surface_t) :: avs_dx_surface_vars
+
+  character(len=150) :: reg_name, outputname, group_name
+  integer :: comm, sizeprocs, ier
+  integer(kind=8) :: adios_group, group_size_inc, adios_totalsize, adios_handle
+
+  ! create a prefix for the file name such as LOCAL_PATH/regX_
+  call create_name_database_adios(reg_name,iregion_code,LOCAL_PATH)
+  outputname = trim(reg_name) // "AVS_DX.bp" 
+  write(group_name,"('SPECFEM3D_GLOBE_AVS_DX_reg',i1)") iregion_code
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  ! Alias COMM_WORLD to use ADIOS
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ier)
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, ier)
+  ! We set the transport method to 'MPI'. This seems to be the correct choice
+  ! for now. We might want to move this to the constant.h file later on.
+  call adios_select_method(adios_group, "MPI", "", "", ier)
+
+  !--- Define ADIOS variables -----------------------------
+  call define_AVS_DX_global_data_adios(adios_group, myrank, nspec, ibool, &
+      npointot, mask_ibool, group_size_inc, avs_dx_global_vars)
+    
+  call define_AVS_DX_global_faces_data_adios (adios_group, &
+      myrank, prname, nspec, iMPIcut_xi,iMPIcut_eta, &
+      ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+      npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      group_size_inc, avs_dx_global_faces_vars)
+
+  call define_AVS_DX_global_chunks_data(adios_group, &
+      myrank,prname,nspec,iboun,ibool, &
+      idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+      npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      group_size_inc, avs_dx_global_chunks_vars)
+
+  call define_AVS_DX_surfaces_data_adios(adios_group, &
+      myrank,prname,nspec,iboun, &
+      ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,npointot,&
+      rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      group_size_inc, avs_dx_surface_vars)
+
+  !--- Open an ADIOS handler to the AVS_DX file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, ier);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, ier)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  call prepare_AVS_DX_global_data_adios(adios_handle, myrank, &
+      nspec, ibool, idoubling, xstore, ystore, zstore, num_ibool_AVS_DX, &
+      mask_ibool, npointot, avs_dx_global_vars)
+  call write_AVS_DX_global_data_adios(adios_handle, myrank, &
+      sizeprocs, avs_dx_global_vars)
+
+  call prepare_AVS_DX_global_faces_data_adios (myrank, prname, nspec, &
+      iMPIcut_xi,iMPIcut_eta, &
+      ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+      npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      avs_dx_global_faces_vars)
+  call write_AVS_DX_global_faces_data_adios(adios_handle, myrank, &
+      sizeprocs, avs_dx_global_faces_vars, ISOTROPIC_3D_MANTLE)
+
+  call prepare_AVS_DX_global_chunks_data_adios(myrank,prname,nspec, &
+      iboun,ibool, idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,&
+      npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      avs_dx_global_chunks_vars)
+  call write_AVS_DX_global_chunks_data_adios(adios_handle, myrank, &
+      sizeprocs, avs_dx_global_chunks_vars, ISOTROPIC_3D_MANTLE)
+
+  call prepare_AVS_DX_surfaces_data_adios(myrank,prname,nspec,iboun, &
+      ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,npointot,&
+      rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+      ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+      RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+      RMIDDLE_CRUST,ROCEAN,iregion_code, &
+      avs_dx_surface_vars)
+  call write_AVS_DX_surfaces_data_adios(adios_handle, myrank, &
+      sizeprocs, avs_dx_surface_vars, ISOTROPIC_3D_MANTLE)
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", ier)
+  call adios_close(adios_handle, ier)
+
+  !--- Clean up temporary arrays -------------------------
+  call free_AVS_DX_global_data_adios(myrank, avs_dx_global_vars)
+  call free_AVS_DX_global_faces_data_adios(myrank, avs_dx_global_faces_vars, &
+      ISOTROPIC_3D_MANTLE)
+  call free_AVS_DX_global_chunks_data_adios(myrank, avs_dx_global_chunks_vars, &
+      ISOTROPIC_3D_MANTLE)
+  call free_AVS_DX_surfaces_data_adios(myrank, avs_dx_surface_vars, &
+      ISOTROPIC_3D_MANTLE)
+end subroutine crm_save_mesh_files_adios

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/finalize_mesher.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/finalize_mesher.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/finalize_mesher.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -170,5 +170,9 @@
   ! synchronize all the processes to make sure everybody has finished
   call sync_all()
 
+  if (ADIOS_ENABLED) then
+    call adios_cleanup()
+  endif
+
   end subroutine finalize_mesher
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -25,17 +25,18 @@
 !
 !=====================================================================
 
-  subroutine get_absorb(myrank,prname,iboun,nspec, &
+  subroutine get_absorb(myrank,prname,iregion, iboun,nspec, &
                         nimin,nimax,njmin,njmax,nkmin_xi,nkmin_eta, &
                         NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX,NSPEC2D_BOTTOM)
 
 ! Stacey, define flags for absorbing boundaries
+  use meshfem3D_par, only: ADIOS_FOR_ARRAYS_SOLVER
 
   implicit none
 
   include "constants.h"
 
-  integer :: nspec,myrank
+  integer :: nspec,myrank, iregion
 
   integer :: NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX,NSPEC2D_BOTTOM
 
@@ -134,18 +135,25 @@
     call exit_MPI(myrank,'ispecb5 should equal NSPEC2D_BOTTOM in absorbing boundary detection')
 
   ! save these temporary arrays for the solver for Stacey conditions
-  open(unit=27,file=prname(1:len_trim(prname))//'stacey.bin', &
-        status='unknown',form='unformatted',action='write',iostat=ier)
-  if( ier /= 0 ) call exit_MPI(myrank,'error opening stacey.bin file')
+  ! This files will be saved with the help of ADIOS if the 
+  ! ADIOS_FOR_ARRAYS_SOLVER flag is set to true in the Par_file
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call get_absorb_adios(myrank, iregion, nimin, nimax, njmin, njmax, &
+        nkmin_xi, nkmin_eta, NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX)
+  else  
+    open(unit=27,file=prname(1:len_trim(prname))//'stacey.bin', &
+          status='unknown',form='unformatted',action='write',iostat=ier)
+    if( ier /= 0 ) call exit_MPI(myrank,'error opening stacey.bin file')
 
-  write(27) nimin
-  write(27) nimax
-  write(27) njmin
-  write(27) njmax
-  write(27) nkmin_xi
-  write(27) nkmin_eta
+    write(27) nimin
+    write(27) nimax
+    write(27) njmin
+    write(27) njmax
+    write(27) nkmin_xi
+    write(27) nkmin_eta
 
-  close(27)
+    close(27)
+  endif
 
   end subroutine get_absorb
 

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/get_absorb_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/get_absorb_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,161 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file get_absorb_adios.f90
+!! \brief Function to write stacey boundary condition to disk with ADIOS.
+!! \author MPBL      
+!-------------------------------------------------------------------------------
+
+!===============================================================================
+!> \brief Write stacey boundary conditions to a single file using ADIOS 
+!!
+!! \param myrank The MPI rank of the current process
+!! \param iregion The region the absorbing conditon is written for. Check
+!!                constant.h files to see what these regions are.
+!! \param nimin An array to be written
+!! \param nimax An array to be written
+!! \param njmin An array to be written
+!! \param njmax An array to be written
+!! \param nkmin_xi An array to be written
+!! \param nkmin_eta An array to be written
+!! \param NSPEC2DMAX_XMIN_XMAX Integer to compute the size of the arrays
+!!                             in argument
+!! \param NSPEC2DMAX_YMIN_YMAX Integer to compute the size of the arrays
+!!                             in argument
+!! 
+!! \note This routine only call adios to write the file to disk, Note that he
+!!       necessary data preparation is done by the get_absorb() routine.
+subroutine get_absorb_adios(myrank, iregion, nimin, nimax, njmin, njmax, &
+  nkmin_xi, nkmin_eta, NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX)
+
+  use mpi
+  use adios_write_mod
+  use meshfem3D_par, only: LOCAL_PATH
+
+  ! Stacey, define flags for absorbing boundaries
+  implicit none
+
+  include "constants.h"
+
+  integer :: myrank
+  integer :: NSPEC2DMAX_XMIN_XMAX,NSPEC2DMAX_YMIN_YMAX
+
+  integer,dimension(2,NSPEC2DMAX_YMIN_YMAX) :: nimin,nimax
+  integer,dimension(2,NSPEC2DMAX_XMIN_XMAX) :: njmin,njmax
+  integer,dimension(2,NSPEC2DMAX_XMIN_XMAX) :: nkmin_xi
+  integer,dimension(2,NSPEC2DMAX_YMIN_YMAX) :: nkmin_eta
+
+  character(len=150) :: reg_name, outputname, group_name
+  integer :: sizeprocs, comm, local_dim, ierr, iregion
+  integer(kind=8) :: group_size_inc
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  ! create a prefix for the file name such as LOCAL_PATH/regX_
+  call create_name_database_adios(reg_name,iregion,LOCAL_PATH)
+
+  ! Postpend the actual file name.
+  outputname = trim(reg_name) // "stacey.bp" 
+
+  ! save these temporary arrays for the solver for Stacey conditions
+  write(group_name,"('SPECFEM3D_GLOBE_STACEY_reg',i1)") iregion
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  ! Alias COMM_WORLD to use ADIOS
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  ! set the adios group size to 0 before incremented by calls to 
+  ! helpers functions.
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  ! We set the transport method to 'MPI'. This seems to be the correct choice
+  ! for now. We might want to move this to the constant.h file later on.
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  local_dim = 2*NSPEC2DMAX_XMIN_XMAX 
+  call define_adios_global_integer_1d_array(adios_group, "njmin", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "njmax", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "nkmin_xi", &
+      local_dim, group_size_inc)
+  local_dim = 2*NSPEC2DMAX_YMIN_YMAX
+  call define_adios_global_integer_1d_array(adios_group, "nimin", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "nimax", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "nkmin_eta", &
+      local_dim, group_size_inc)
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  local_dim = 2*NSPEC2DMAX_XMIN_XMAX 
+  call adios_set_path (adios_handle, "njmin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", njmin, adios_err)
+
+  call adios_set_path (adios_handle, "njmax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", njmax, adios_err)
+
+  call adios_set_path (adios_handle, "nkmin_xi", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", nkmin_xi, adios_err)
+
+  local_dim = 2*NSPEC2DMAX_YMIN_YMAX 
+  call adios_set_path (adios_handle, "nimin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", nimin, adios_err)
+
+  call adios_set_path (adios_handle, "nimax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", nimax, adios_err)
+
+  call adios_set_path (adios_handle, "nkmin_eta", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", nkmin_eta, adios_err)
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", adios_err)
+  call adios_close(adios_handle, adios_err)
+
+end subroutine get_absorb_adios
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/initialize_mesher.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/initialize_mesher.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/initialize_mesher.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -102,6 +102,11 @@
     if(err_occurred() /= 0) &
       call exit_MPI(myrank,'an error occurred while reading the parameter file')
 
+    ! ADIOS_ENABLED: parameter is optional, may not be in the Par_file
+    call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, &
+        ADIOS_FOR_MPI_ARRAYS, ADIOS_FOR_ARRAYS_SOLVER, &
+        ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX)
+
   endif
 
   ! distributes parameters from master to all processes
@@ -137,6 +142,10 @@
                 HONOR_1D_SPHERICAL_MOHO,CRUSTAL,ONE_CRUST,CASE_3D,TRANSVERSE_ISOTROPY, &
                 ISOTROPIC_3D_MANTLE,ANISOTROPIC_3D_MANTLE,HETEROGEN_3D_MANTLE, &
                 ATTENUATION,ATTENUATION_NEW,ATTENUATION_3D,ANISOTROPIC_INNER_CORE,NOISE_TOMOGRAPHY)
+  ! broadcasts optional ADIOS_ENABLED 
+  call broadcast_adios_parameters(myrank,ADIOS_ENABLED, &
+      ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, ADIOS_FOR_ARRAYS_SOLVER, &
+      ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX)
 
   ! check that the code is running with the requested number of processes
   if(sizeprocs /= NPROCTOT) call exit_MPI(myrank,'wrong number of MPI processes')
@@ -147,4 +156,8 @@
 
   if(NCHUNKS /= 6) call euler_angles(rotation_matrix,CENTER_LONGITUDE_IN_DEGREES,CENTER_LATITUDE_IN_DEGREES,GAMMA_ROTATION_AZIMUTH)
 
+  if (ADIOS_ENABLED) then
+    call adios_setup()
+  endif
+
   end subroutine initialize_mesher

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/meshfem3D_par.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/meshfem3D_par.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/meshfem3D_par.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -264,7 +264,14 @@
 
   ! this for non blocking MPI
   logical, dimension(:), allocatable :: is_on_a_slice_edge
+  !-----------------------------------------------------------------
+  ! ADIOS
+  !-----------------------------------------------------------------
 
+  logical :: ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, &
+      ADIOS_FOR_ARRAYS_SOLVER, ADIOS_FOR_SOLVER_MESHFILES, &
+      ADIOS_FOR_AVS_DX
+
   end module meshfem3D_par
 
 !
@@ -392,7 +399,7 @@
   logical, dimension(:), allocatable :: ispec_is_tiso
 
   ! name of the database file
-  character(len=150) :: prname
+  character(len=150) :: prname, prname_adios
 
   end module create_regions_mesh_par2
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -474,7 +474,8 @@
 
   use meshfem3D_par,only: &
     myrank,LOCAL_PATH, &
-    IREGION_CRUST_MANTLE,IREGION_OUTER_CORE,IREGION_INNER_CORE
+    IREGION_CRUST_MANTLE,IREGION_OUTER_CORE,IREGION_INNER_CORE, &
+    ADIOS_FOR_MPI_ARRAYS
 
 !  use create_MPI_interfaces_par
 
@@ -489,38 +490,69 @@
   select case( iregion_code )
   case( IREGION_CRUST_MANTLE )
     ! crust mantle
-    call save_MPI_arrays(myrank,IREGION_CRUST_MANTLE,LOCAL_PATH, &
-                             num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
-                             my_neighbours_crust_mantle,nibool_interfaces_crust_mantle, &
-                             ibool_interfaces_crust_mantle, &
-                             nspec_inner_crust_mantle,nspec_outer_crust_mantle, &
-                             num_phase_ispec_crust_mantle,phase_ispec_inner_crust_mantle, &
-                             num_colors_outer_crust_mantle,num_colors_inner_crust_mantle, &
-                             num_elem_colors_crust_mantle)
+    if (ADIOS_FOR_MPI_ARRAYS) then
+      call save_MPI_arrays_adios(myrank,IREGION_CRUST_MANTLE,LOCAL_PATH, &
+          num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
+          my_neighbours_crust_mantle,nibool_interfaces_crust_mantle, &
+          ibool_interfaces_crust_mantle, &
+          nspec_inner_crust_mantle,nspec_outer_crust_mantle, &
+          num_phase_ispec_crust_mantle,phase_ispec_inner_crust_mantle, &
+          num_colors_outer_crust_mantle,num_colors_inner_crust_mantle, &
+          num_elem_colors_crust_mantle)
+    else
+      call save_MPI_arrays(myrank,IREGION_CRUST_MANTLE,LOCAL_PATH, &
+          num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
+          my_neighbours_crust_mantle,nibool_interfaces_crust_mantle, &
+          ibool_interfaces_crust_mantle, &
+          nspec_inner_crust_mantle,nspec_outer_crust_mantle, &
+          num_phase_ispec_crust_mantle,phase_ispec_inner_crust_mantle, &
+          num_colors_outer_crust_mantle,num_colors_inner_crust_mantle, &
+          num_elem_colors_crust_mantle)
+    endif
 
-
   case( IREGION_OUTER_CORE )
     ! outer core
-    call save_MPI_arrays(myrank,IREGION_OUTER_CORE,LOCAL_PATH, &
-                             num_interfaces_outer_core,max_nibool_interfaces_oc, &
-                             my_neighbours_outer_core,nibool_interfaces_outer_core, &
-                             ibool_interfaces_outer_core, &
-                             nspec_inner_outer_core,nspec_outer_outer_core, &
-                             num_phase_ispec_outer_core,phase_ispec_inner_outer_core, &
-                             num_colors_outer_outer_core,num_colors_inner_outer_core, &
-                             num_elem_colors_outer_core)
+    if (ADIOS_FOR_MPI_ARRAYS) then
+      call save_MPI_arrays_adios(myrank,IREGION_OUTER_CORE,LOCAL_PATH, &
+          num_interfaces_outer_core,max_nibool_interfaces_oc, &
+          my_neighbours_outer_core,nibool_interfaces_outer_core, &
+          ibool_interfaces_outer_core, &
+          nspec_inner_outer_core,nspec_outer_outer_core, &
+          num_phase_ispec_outer_core,phase_ispec_inner_outer_core, &
+          num_colors_outer_outer_core,num_colors_inner_outer_core, &
+          num_elem_colors_outer_core)
+    else
+      call save_MPI_arrays(myrank,IREGION_OUTER_CORE,LOCAL_PATH, &
+          num_interfaces_outer_core,max_nibool_interfaces_oc, &
+          my_neighbours_outer_core,nibool_interfaces_outer_core, &
+          ibool_interfaces_outer_core, &
+          nspec_inner_outer_core,nspec_outer_outer_core, &
+          num_phase_ispec_outer_core,phase_ispec_inner_outer_core, &
+          num_colors_outer_outer_core,num_colors_inner_outer_core, &
+          num_elem_colors_outer_core)
+    endif
 
   case( IREGION_INNER_CORE )
     ! inner core
-    call save_MPI_arrays(myrank,IREGION_INNER_CORE,LOCAL_PATH, &
-                             num_interfaces_inner_core,max_nibool_interfaces_ic, &
-                             my_neighbours_inner_core,nibool_interfaces_inner_core, &
-                             ibool_interfaces_inner_core, &
-                             nspec_inner_inner_core,nspec_outer_inner_core, &
-                             num_phase_ispec_inner_core,phase_ispec_inner_inner_core, &
-                             num_colors_outer_inner_core,num_colors_inner_inner_core, &
-                             num_elem_colors_inner_core)
-
+    if (ADIOS_FOR_MPI_ARRAYS) then
+      call save_MPI_arrays_adios(myrank,IREGION_INNER_CORE,LOCAL_PATH, &
+          num_interfaces_inner_core,max_nibool_interfaces_ic, &
+          my_neighbours_inner_core,nibool_interfaces_inner_core, &
+          ibool_interfaces_inner_core, &
+          nspec_inner_inner_core,nspec_outer_inner_core, &
+          num_phase_ispec_inner_core,phase_ispec_inner_inner_core, &
+          num_colors_outer_inner_core,num_colors_inner_inner_core, &
+          num_elem_colors_inner_core)
+    else
+      call save_MPI_arrays(myrank,IREGION_INNER_CORE,LOCAL_PATH, &
+          num_interfaces_inner_core,max_nibool_interfaces_ic, &
+          my_neighbours_inner_core,nibool_interfaces_inner_core, &
+          ibool_interfaces_inner_core, &
+          nspec_inner_inner_core,nspec_outer_inner_core, &
+          num_phase_ispec_inner_core,phase_ispec_inner_inner_core, &
+          num_colors_outer_inner_core,num_colors_inner_inner_core, &
+          num_elem_colors_inner_core)
+    endif
   end select
 
   end subroutine save_arrays_solver_MPI

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver_adios.F90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/save_arrays_solver_adios.F90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver_adios.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver_adios.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,1603 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file get_absorb_adios.f90
+!! \brief Function to write stacey boundary condition to disk with ADIOS.
+!! \author MPBL      
+!-------------------------------------------------------------------------------
+
+!===============================================================================
+!> \brief Main routine to save the arrays from the mesher to the solver with the
+!!        help of ADIOS
+!! \param myrank The MPI rank of the current process
+!! \param nspec Number of GLL points per element
+!! \param nglob Number of mesh points
+!! \param idoubling Array of information on every mesh point
+!! \param ibool Array of information on every mesh point
+!! \param iregion_code The region the absorbing conditon is written for. Check
+!!                     constant.h files to see what these regions are.
+!! \param xstore Array with the x coordinates of the mesh points 
+!! \param ystore Array with the y coordinates of the mesh points 
+!! \param zstore Array with the z coordinates of the mesh points 
+!! \param NSPEC2DMAX_XMIN_XMAX Integer to compute the size of the arrays
+!!                             in argument
+!! \param NSPEC2DMAX_YMIN_YMAX Integer to compute the size of the arrays
+!!                             in argument
+!! \param NSPEC2D_TOP Integer to compute the size of the arrays
+!!                    in argument
+!! \param NSPEC2D_BOTTOM Integer to compute the size of the arrays
+!!                       in argument
+subroutine save_arrays_solver_adios(myrank,nspec,nglob,idoubling,ibool, &
+                    iregion_code,xstore,ystore,zstore, &
+                    NSPEC2DMAX_XMIN_XMAX, NSPEC2DMAX_YMIN_YMAX, &
+                    NSPEC2D_TOP,NSPEC2D_BOTTOM)
+
+  use mpi
+  use adios_write_mod
+
+  use constants
+
+  use meshfem3D_models_par,only: &
+    OCEANS,TRANSVERSE_ISOTROPY,HETEROGEN_3D_MANTLE,ANISOTROPIC_3D_MANTLE, &
+    ANISOTROPIC_INNER_CORE,ATTENUATION
+
+  use meshfem3D_par,only: &
+    NCHUNKS,ABSORBING_CONDITIONS,SAVE_MESH_FILES, LOCAL_PATH, &
+    ADIOS_FOR_SOLVER_MESHFILES
+
+  use create_regions_mesh_par2,only: &
+    xixstore,xiystore,xizstore,etaxstore,etaystore,etazstore, &
+    gammaxstore,gammaystore,gammazstore, &
+    rhostore,dvpstore,kappavstore,kappahstore,muvstore,muhstore,eta_anisostore,&
+    c11store,c12store,c13store,c14store,c15store,c16store,c22store, &
+    c23store,c24store,c25store,c26store,c33store,c34store,c35store, &
+    c36store,c44store,c45store,c46store,c55store,c56store,c66store, &
+    rmassx,rmassy,rmassz,rmass_ocean_load, &
+    ibelm_xmin,ibelm_xmax,ibelm_ymin,ibelm_ymax,ibelm_bottom,ibelm_top, &
+    normal_xmin,normal_xmax,normal_ymin,normal_ymax,normal_bottom,normal_top, &
+    jacobian2D_xmin,jacobian2D_xmax,jacobian2D_ymin,jacobian2D_ymax, &
+    jacobian2D_bottom,jacobian2D_top, &
+    rho_vp,rho_vs, &
+    nspec2D_xmin,nspec2D_xmax,nspec2D_ymin,nspec2D_ymax, &
+    ispec_is_tiso,tau_s,T_c_source,tau_e_store,Qmu_store, &
+    prname, nspec_actually, nspec_ani, nspec_stacey, nglob_xy, nglob_oceans
+
+  implicit none
+
+  integer :: myrank
+  integer :: nspec,nglob
+
+  ! doubling mesh flag
+  integer, dimension(nspec) :: idoubling
+  integer,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
+
+  integer :: iregion_code
+
+  ! arrays with the mesh in double precision
+  double precision,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: xstore,ystore,zstore
+
+  ! boundary parameters locator
+  integer :: NSPEC2D_TOP,NSPEC2D_BOTTOM, &
+      NSPEC2DMAX_XMIN_XMAX, NSPEC2DMAX_YMIN_YMAX
+
+  ! local parameters
+  integer :: i,j,k,ispec,iglob,ier
+  real(kind=CUSTOM_REAL),dimension(:),allocatable :: tmp_array_x, &
+      tmp_array_y, tmp_array_z
+
+  ! local parameters
+  character(len=150) :: reg_name, outputname, group_name
+  integer :: ierr, sizeprocs, comm, local_dim
+  integer(kind=8) :: group_size_inc
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  ! create a prefix for the file name such as LOCAL_PATH/regX_
+  call create_name_database_adios(reg_name,iregion_code,LOCAL_PATH)
+
+  !---------------------------------------------------------
+  !--- Solver data arrays ----------------------------------
+  !---------------------------------------------------------
+
+  ! create the name for the database of the current slide and region
+  outputname = trim(reg_name) // "solver_data.bp" 
+
+  ! save arrays for the solver to run.
+  write(group_name,"('SPECFEM3D_GLOBE_ARRAYS_SOLVER_reg',i1)") iregion_code
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  ! Alias COMM_WORLD to use ADIOS
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  ! set the adios group size to 0 before incremented by calls to 
+  ! helpers functions.
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  ! We set the transport method to 'MPI'. This seems to be the correct choice
+  ! for now. We might want to move this to the constant.h file later on.
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  ! save nspec and nglob, to be used in combine_paraview_data
+  call define_adios_integer_scalar (adios_group, "nspec", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "nglob", "", &
+      group_size_inc)
+
+  local_dim = nglob 
+  call define_adios_global_real_1d_array(adios_group, "xstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "ystore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "zstore", &
+      local_dim, group_size_inc)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec
+  call define_adios_global_real_1d_array(adios_group, "rhostore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "kappavstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibool", &
+      local_dim, group_size_inc)
+  if(iregion_code /= IREGION_OUTER_CORE) then
+    if(.not. (ANISOTROPIC_3D_MANTLE .and. &
+        iregion_code == IREGION_CRUST_MANTLE)) then
+      call define_adios_global_real_1d_array(adios_group, "muvstore", &
+          local_dim, group_size_inc)
+    endif
+    if(TRANSVERSE_ISOTROPY) then
+      if(iregion_code == IREGION_CRUST_MANTLE .and. &
+          .not. ANISOTROPIC_3D_MANTLE) then
+        call define_adios_global_real_1d_array(adios_group, "kappahstore", &
+            local_dim, group_size_inc)
+        call define_adios_global_real_1d_array(adios_group, "muhstore", &
+            local_dim, group_size_inc)
+        call define_adios_global_real_1d_array(adios_group, "eta_anisostore", &
+            local_dim, group_size_inc)
+      endif
+    endif
+  endif
+
+  local_dim = nspec
+  call define_adios_global_integer_1d_array(adios_group, "idoubling", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ispec_is_tiso", &
+      local_dim, group_size_inc)
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_actually
+  call define_adios_global_real_1d_array(adios_group, "xixstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "xiystore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "xizstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "etaxstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "etaystore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "etazstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "gammaxstore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "gammaystore", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "gammazstore", &
+      local_dim, group_size_inc)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_ani 
+  if(iregion_code /= IREGION_OUTER_CORE) then
+    !   save anisotropy in the inner core only
+    if(ANISOTROPIC_INNER_CORE .and. iregion_code == IREGION_INNER_CORE) then
+      call define_adios_global_real_1d_array(adios_group, "c11store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c33store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c12store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c13store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c44store", &
+          local_dim, group_size_inc)
+    endif
+    if(ANISOTROPIC_3D_MANTLE .and. iregion_code == IREGION_CRUST_MANTLE) then
+      call define_adios_global_real_1d_array(adios_group, "c11store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c12store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c13store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c14store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c15store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c16store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c22store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c23store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c24store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c25store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c26store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c33store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c34store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c35store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c36store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c44store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c45store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c46store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c55store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c56store", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "c66store", &
+          local_dim, group_size_inc)
+    endif
+  endif
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_stacey
+  if(ABSORBING_CONDITIONS) then
+    if(iregion_code == IREGION_CRUST_MANTLE) then
+      call define_adios_global_real_1d_array(adios_group, "rho_vp", &
+          local_dim, group_size_inc)
+      call define_adios_global_real_1d_array(adios_group, "rho_vs", &
+          local_dim, group_size_inc)
+    else if(iregion_code == IREGION_OUTER_CORE) then
+      call define_adios_global_real_1d_array(adios_group, "rho_vp", &
+          local_dim, group_size_inc)
+    endif
+  endif
+
+  local_dim = nglob_xy
+  if(NCHUNKS /= 6 .and. ABSORBING_CONDITIONS .and. &
+      iregion_code == IREGION_CRUST_MANTLE) then
+    call define_adios_global_real_1d_array(adios_group, "rmassx", &
+        local_dim, group_size_inc)
+    call define_adios_global_real_1d_array(adios_group, "rmassy", &
+        local_dim, group_size_inc)
+  endif
+  local_dim = nglob
+  call define_adios_global_real_1d_array(adios_group, "rmassz", &
+      local_dim, group_size_inc)
+
+  local_dim = nglob_oceans
+  if(OCEANS .and. iregion_code == IREGION_CRUST_MANTLE) then
+    call define_adios_global_real_1d_array(adios_group, "rmass_ocean_load", &
+        local_dim, group_size_inc)
+  endif
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  ! mesh topology
+
+  ! mesh arrays used in the solver to locate source and receivers
+  ! and for anisotropy and gravity, save in single precision
+  ! use tmp_array for temporary storage to perform conversion
+  allocate(tmp_array_x(nglob),stat=ier)
+  if( ier /=0 ) call exit_MPI(myrank,&
+      'error allocating temporary array for mesh topology')
+  allocate(tmp_array_y(nglob),stat=ier)
+  if( ier /=0 ) call exit_MPI(myrank,&
+      'error allocating temporary array for mesh topology')
+  allocate(tmp_array_z(nglob),stat=ier)
+  if( ier /=0 ) call exit_MPI(myrank,&
+      'error allocating temporary array for mesh topology')
+
+  !--- x coordinate
+  tmp_array_x(:) = 0._CUSTOM_REAL
+  do ispec = 1,nspec
+    do k = 1,NGLLZ
+      do j = 1,NGLLY
+        do i = 1,NGLLX
+          iglob = ibool(i,j,k,ispec)
+          ! distinguish between single and double precision for reals
+          if(CUSTOM_REAL == SIZE_REAL) then
+            tmp_array_x(iglob) = sngl(xstore(i,j,k,ispec))
+          else
+            tmp_array_x(iglob) = xstore(i,j,k,ispec)
+          endif
+        enddo
+      enddo
+    enddo
+  enddo
+  !--- y coordinate
+  tmp_array_y(:) = 0._CUSTOM_REAL
+  do ispec = 1,nspec
+    do k = 1,NGLLZ
+      do j = 1,NGLLY
+        do i = 1,NGLLX
+          iglob = ibool(i,j,k,ispec)
+          ! distinguish between single and double precision for reals
+          if(CUSTOM_REAL == SIZE_REAL) then
+            tmp_array_y(iglob) = sngl(ystore(i,j,k,ispec))
+          else
+            tmp_array_y(iglob) = ystore(i,j,k,ispec)
+          endif
+        enddo
+      enddo
+    enddo
+  enddo
+  !--- z coordinate
+  tmp_array_z(:) = 0._CUSTOM_REAL
+  do ispec = 1,nspec
+    do k = 1,NGLLZ
+      do j = 1,NGLLY
+        do i = 1,NGLLX
+          iglob = ibool(i,j,k,ispec)
+          ! distinguish between single and double precision for reals
+          if(CUSTOM_REAL == SIZE_REAL) then
+            tmp_array_z(iglob) = sngl(zstore(i,j,k,ispec))
+          else
+            tmp_array_z(iglob) = zstore(i,j,k,ispec)
+          endif
+        enddo
+      enddo
+    enddo
+  enddo
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  ! save nspec and nglob, to be used in combine_paraview_data
+  call adios_write(adios_handle, "nspec", nspec, adios_err)
+  call adios_write(adios_handle, "nglob", nglob, adios_err)
+
+  local_dim = nglob 
+  call adios_set_path (adios_handle, "xstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", tmp_array_x, adios_err)
+
+  call adios_set_path (adios_handle, "ystore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", tmp_array_y, adios_err)
+  
+  call adios_set_path (adios_handle, "zstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", tmp_array_z, adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec
+  call adios_set_path (adios_handle, "rhostore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", rhostore, adios_err)
+
+  call adios_set_path (adios_handle, "kappavstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", kappavstore, adios_err)
+
+  call adios_set_path (adios_handle, "ibool", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibool, adios_err)
+
+  if(iregion_code /= IREGION_OUTER_CORE) then
+    if(.not. (ANISOTROPIC_3D_MANTLE .and. &
+        iregion_code == IREGION_CRUST_MANTLE)) then
+      call adios_set_path (adios_handle, "muvstore", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", muvstore, adios_err)
+    endif
+    if(TRANSVERSE_ISOTROPY) then
+      if(iregion_code == IREGION_CRUST_MANTLE .and. &
+          .not. ANISOTROPIC_3D_MANTLE) then
+        call adios_set_path (adios_handle, "kappahstore", adios_err)
+        call write_1D_global_array_adios_dims(adios_handle, myrank, &
+            local_dim, sizeprocs)
+        call adios_write(adios_handle, "array", kappahstore, adios_err)
+
+        call adios_set_path (adios_handle, "muhstore", adios_err)
+        call write_1D_global_array_adios_dims(adios_handle, myrank, &
+            local_dim, sizeprocs)
+        call adios_write(adios_handle, "array", muhstore, adios_err)
+
+        call adios_set_path (adios_handle, "eta_anisostore", adios_err)
+        call write_1D_global_array_adios_dims(adios_handle, myrank, &
+            local_dim, sizeprocs)
+        call adios_write(adios_handle, "array", eta_anisostore, adios_err)
+      endif
+    endif
+  endif
+
+  local_dim = nspec
+  call adios_set_path (adios_handle, "idoubling", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", idoubling, adios_err)
+
+  call adios_set_path (adios_handle, "ispec_is_tiso", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ispec_is_tiso, adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_actually
+  call adios_set_path (adios_handle, "xixstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", xixstore, adios_err)
+
+  call adios_set_path (adios_handle, "xiystore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", xiystore, adios_err)
+
+  call adios_set_path (adios_handle, "xizstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", xizstore, adios_err)
+
+  call adios_set_path (adios_handle, "etaxstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", etaxstore, adios_err)
+
+  call adios_set_path (adios_handle, "etaystore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", etaystore, adios_err)
+
+  call adios_set_path (adios_handle, "etazstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", etazstore, adios_err)
+
+  call adios_set_path (adios_handle, "gammaxstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", gammaxstore, adios_err)
+
+  call adios_set_path (adios_handle, "gammaystore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", gammaystore, adios_err)
+
+  call adios_set_path (adios_handle, "gammazstore", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", gammazstore, adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_ani 
+  if(iregion_code /= IREGION_OUTER_CORE) then
+    !   save anisotropy in the inner core only
+    if(ANISOTROPIC_INNER_CORE .and. iregion_code == IREGION_INNER_CORE) then
+      call adios_set_path (adios_handle, "c11store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c11store, adios_err)
+
+      call adios_set_path (adios_handle, "c33store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c33store, adios_err)
+
+      call adios_set_path (adios_handle, "c12store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c12store, adios_err)
+
+      call adios_set_path (adios_handle, "c13store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c13store, adios_err)
+
+      call adios_set_path (adios_handle, "c44store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c44store, adios_err)
+    endif
+    if(ANISOTROPIC_3D_MANTLE .and. iregion_code == IREGION_CRUST_MANTLE) then
+      call adios_set_path (adios_handle, "c11store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c11store, adios_err)
+
+      call adios_set_path (adios_handle, "c12store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c12store, adios_err)
+
+      call adios_set_path (adios_handle, "c13store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c13store, adios_err)
+
+      call adios_set_path (adios_handle, "c14store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c14store, adios_err)
+
+      call adios_set_path (adios_handle, "c15store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c15store, adios_err)
+
+      call adios_set_path (adios_handle, "c16store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c16store, adios_err)
+
+      call adios_set_path (adios_handle, "c22store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c22store, adios_err)
+
+      call adios_set_path (adios_handle, "c23store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c23store, adios_err)
+
+      call adios_set_path (adios_handle, "c24store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c24store, adios_err)
+
+      call adios_set_path (adios_handle, "c25store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c25store, adios_err)
+
+      call adios_set_path (adios_handle, "c26store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c26store, adios_err)
+
+      call adios_set_path (adios_handle, "c33store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c33store, adios_err)
+
+      call adios_set_path (adios_handle, "c34store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c34store, adios_err)
+
+      call adios_set_path (adios_handle, "c35store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c35store, adios_err)
+
+      call adios_set_path (adios_handle, "c36store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c36store, adios_err)
+
+      call adios_set_path (adios_handle, "c44store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c44store, adios_err)
+
+      call adios_set_path (adios_handle, "c45store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c45store, adios_err)
+
+      call adios_set_path (adios_handle, "c46store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c46store, adios_err)
+
+      call adios_set_path (adios_handle, "c55store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c55store, adios_err)
+
+      call adios_set_path (adios_handle, "c56store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c56store, adios_err)
+
+      call adios_set_path (adios_handle, "c66store", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", c66store, adios_err)
+    endif
+  endif
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_stacey
+  if(ABSORBING_CONDITIONS) then
+    if(iregion_code == IREGION_CRUST_MANTLE) then
+      call adios_set_path (adios_handle, "rho_vp", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", rho_vp, adios_err)
+
+      call adios_set_path (adios_handle, "rho_vs", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", rho_vs, adios_err)
+
+    else if(iregion_code == IREGION_OUTER_CORE) then
+      call adios_set_path (adios_handle, "rho_vp", adios_err)
+      call write_1D_global_array_adios_dims(adios_handle, myrank, &
+          local_dim, sizeprocs)
+      call adios_write(adios_handle, "array", rho_vp, adios_err)
+    endif
+  endif
+
+  local_dim = nglob_xy
+  if(NCHUNKS /= 6 .and. ABSORBING_CONDITIONS .and. &
+      iregion_code == IREGION_CRUST_MANTLE) then
+    call adios_set_path (adios_handle, "rmassx", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", rmassx, adios_err)
+
+    call adios_set_path (adios_handle, "rmassy", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", rmassy, adios_err)
+  endif
+
+  local_dim = nglob
+  call adios_set_path (adios_handle, "rmassz", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", rmassz, adios_err)
+
+  local_dim = nglob_oceans
+  if(OCEANS .and. iregion_code == IREGION_CRUST_MANTLE) then
+    call adios_set_path (adios_handle, "rmass_ocean_load", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", rmass_ocean_load, adios_err)
+    if(minval(rmass_ocean_load) <= 0._CUSTOM_REAL) &
+        call exit_MPI(myrank,'negative mass matrix term for the oceans')
+  endif
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", adios_err)
+  call adios_close(adios_handle, adios_err)
+
+  ! Clean the temporary arrays containing the node information
+  deallocate(tmp_array_x)
+  deallocate(tmp_array_y)
+  deallocate(tmp_array_z)
+
+  !---------------------------------------------------------
+  !--- Boundary arrays -------------------------------------
+  !---------------------------------------------------------
+
+  ! Postpend the actual file name.
+  outputname = trim(reg_name) // "boundary.bp" 
+
+  ! save boundary arrays in ADIOS files 
+  write(group_name,"('SPECFEM3D_GLOBE_BOUNDARY_reg',i1)") iregion_code
+  ! set the adios group size to 0 before incremented by calls to 
+  ! helpers functions.
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  call define_adios_integer_scalar (adios_group, "nspec2D_xmin", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "nspec2D_xmax", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "nspec2D_ymin", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "nspec2D_ymax", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NSPEC2D_BOTTOM", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NSPEC2D_TOP", "", &
+      group_size_inc)
+  
+  !local_dim = NSPEC2DMAX_XMIN_YMAX
+  local_dim = size (ibelm_xmin) 
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_xmin", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_xmax", &
+      local_dim, group_size_inc)
+
+  !local_dim = NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (ibelm_ymin) 
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_ymin", &
+      local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_ymax", &
+      local_dim, group_size_inc)
+
+  !local_dim = NSPEC2D_BOTTOM
+  local_dim = size (ibelm_bottom) 
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_bottom", &
+      local_dim, group_size_inc)
+
+  !local_dim = NSPEC2D_TOP
+  local_dim = size (ibelm_top) 
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_top", &
+      local_dim, group_size_inc)
+
+  !local_dim = NDIM*NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX
+  local_dim = size (normal_xmin) 
+  call define_adios_global_real_1d_array(adios_group, "normal_xmin", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "normal_xmax", &
+      local_dim, group_size_inc)
+
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (normal_ymin) 
+  call define_adios_global_real_1d_array(adios_group, "normal_ymin", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "normal_ymax", &
+      local_dim, group_size_inc)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM
+  local_dim = size (normal_bottom) 
+  call define_adios_global_real_1d_array(adios_group, "normal_bottom", &
+      local_dim, group_size_inc)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP
+  local_dim = size (normal_top) 
+  call define_adios_global_real_1d_array(adios_group, "normal_top", &
+      local_dim, group_size_inc)
+
+  !local_dim = NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX
+  local_dim = size (jacobian2D_xmin) 
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_xmin", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_xmax", &
+      local_dim, group_size_inc)
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (jacobian2D_ymin) 
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_ymin", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_ymax", &
+      local_dim, group_size_inc)
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM
+  local_dim = size (jacobian2D_bottom) 
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_bottom", &
+      local_dim, group_size_inc)
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP
+  local_dim = size (jacobian2D_top) 
+  call define_adios_global_real_1d_array(adios_group, "jacobian2D_top", &
+      local_dim, group_size_inc)
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  call adios_write(adios_handle, "nspec2D_xmin", nspec2D_xmin, adios_err)
+  call adios_write(adios_handle, "nspec2D_xmax", nspec2D_xmax, adios_err)
+  call adios_write(adios_handle, "nspec2D_ymin", nspec2D_ymin, adios_err)
+  call adios_write(adios_handle, "nspec2D_ymax", nspec2D_ymax, adios_err)
+  call adios_write(adios_handle, "NSPEC2D_BOTTOM", NSPEC2D_BOTTOM, adios_err)
+  call adios_write(adios_handle, "NSPEC2D_TOP", NSPEC2D_TOP, adios_err)
+  
+  !local_dim = NSPEC2DMAX_XMIN_XMAX
+  local_dim = size (ibelm_xmin) 
+  call adios_set_path (adios_handle, "ibelm_xmin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_xmin, adios_err)
+  call adios_set_path (adios_handle, "ibelm_xmax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_xmax, adios_err)
+
+  !local_dim = NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (ibelm_ymin) 
+  call adios_set_path (adios_handle, "ibelm_ymin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_ymin, adios_err)
+  call adios_set_path (adios_handle, "ibelm_ymax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_ymax, adios_err)
+
+  !local_dim = NSPEC2D_BOTTOM
+  local_dim = size (ibelm_bottom) 
+  call adios_set_path (adios_handle, "ibelm_bottom", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_bottom, adios_err)
+
+  !local_dim = NSPEC2D_TOP
+  local_dim = size (ibelm_top) 
+  call adios_set_path (adios_handle, "ibelm_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_top, adios_err)
+
+  !local_dim = NDIM*NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX
+  local_dim = size (normal_xmin) 
+  call adios_set_path (adios_handle, "normal_xmin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_xmin, adios_err)
+  call adios_set_path (adios_handle, "normal_xmax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_xmax, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (normal_ymin) 
+  call adios_set_path (adios_handle, "normal_ymin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_ymin, adios_err)
+  call adios_set_path (adios_handle, "normal_ymax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_ymax, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM
+  local_dim = size (normal_bottom) 
+  call adios_set_path (adios_handle, "normal_bottom", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_bottom, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP
+  local_dim = size (normal_top) 
+  call adios_set_path (adios_handle, "normal_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_top, adios_err)
+
+  !local_dim = NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX
+  local_dim = size (jacobian2D_xmin) 
+  call adios_set_path (adios_handle, "jacobian2D_xmin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_xmin, adios_err)
+  call adios_set_path (adios_handle, "jacobian2D_xmax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_xmax, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX
+  local_dim = size (jacobian2D_ymin) 
+  call adios_set_path (adios_handle, "jacobian2D_ymin", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_ymin, adios_err)
+  call adios_set_path (adios_handle, "jacobian2D_ymax", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_ymax, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM
+  local_dim = size (jacobian2D_bottom) 
+  call adios_set_path (adios_handle, "jacobian2D_bottom", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_bottom, adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP
+  local_dim = size (jacobian2D_top) 
+  call adios_set_path (adios_handle, "jacobian2D_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", jacobian2D_top, adios_err)
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", adios_err)
+  call adios_close(adios_handle, adios_err)
+
+  !---------------------------------------------------------
+  !--- Attenuation arrays ----------------------------------
+  !---------------------------------------------------------
+  if(ATTENUATION) then
+    outputname = trim(reg_name) // "attenuation.bp" 
+    write(group_name,"('SPECFEM3D_GLOBE_ATTENUATION_reg',i1)") iregion_code
+    group_size_inc = 0
+    call adios_declare_group(adios_group, group_name, &
+        "", 0, adios_err)
+    call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+    !--- Define ADIOS variables -----------------------------
+    call define_adios_double_scalar(adios_group, "T_c_source", "", &
+        group_size_inc)
+
+    local_dim = size(tau_s)
+    call define_adios_global_double_1d_array(adios_group, "tau_s", &
+        local_dim, group_size_inc)
+    local_dim = size(tau_e_store)
+    call define_adios_global_double_1d_array(adios_group, "tau_e_store", &
+        local_dim, group_size_inc)
+    local_dim = size(Qmu_store)
+    call define_adios_global_double_1d_array(adios_group, "Qmu_store", &
+        local_dim, group_size_inc)
+
+    !--- Open an ADIOS handler to the restart file. ---------
+    call adios_open (adios_handle, group_name, &
+        outputname, "w", comm, adios_err);
+    call adios_group_size (adios_handle, group_size_inc, &
+                           adios_totalsize, adios_err)
+
+    !--- Schedule writes for the previously defined ADIOS variables
+    call adios_write(adios_handle, "T_c_source", T_c_source, adios_err)
+
+    local_dim = size (tau_s) 
+    call adios_set_path (adios_handle, "tau_s", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", tau_s, adios_err)
+    local_dim = size (tau_e_store) 
+    call adios_set_path (adios_handle, "tau_e_store", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", tau_e_store, adios_err)
+    local_dim = size (Qmu_store) 
+    call adios_set_path (adios_handle, "Qmu_store", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", Qmu_store, adios_err)
+
+    !--- Reset the path to zero and perform the actual write to disk
+    call adios_set_path (adios_handle, "", adios_err)
+    call adios_close(adios_handle, adios_err)
+  endif
+
+  !---------------------------------------------------------
+  !--- dvp arrays ------------------------------------------
+  !---------------------------------------------------------
+  if(HETEROGEN_3D_MANTLE .and. iregion_code == IREGION_CRUST_MANTLE) then
+    outputname = trim(reg_name) // "dvp.bp" 
+    write(group_name,"('SPECFEM3D_GLOBE_DVP_reg',i1)") iregion_code
+    group_size_inc = 0
+    call adios_declare_group(adios_group, group_name, &
+        "", 0, adios_err)
+    call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+    !--- Define ADIOS variables -----------------------------
+    local_dim = size (dvpstore) 
+    call define_adios_global_real_1d_array(adios_group, "dvp", &
+        local_dim, group_size_inc)
+    !--- Open an ADIOS handler to the restart file. ---------
+    call adios_open (adios_handle, group_name, &
+        outputname, "w", comm, adios_err);
+    call adios_group_size (adios_handle, group_size_inc, &
+                           adios_totalsize, adios_err)
+    call adios_set_path (adios_handle, "dvp", adios_err)
+    !--- Schedule writes for the previously defined ADIOS variables
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", dvpstore, adios_err)
+
+    !--- Reset the path to zero and perform the actual write to disk
+    call adios_set_path (adios_handle, "", adios_err)
+    call adios_close(adios_handle, adios_err)
+  endif
+
+  !---------------------------------------------------------
+  !--- mehsfiles arrays ------------------------------------
+  !---------------------------------------------------------
+  ! uncomment for vp & vs model storage
+  if( SAVE_MESH_FILES ) then
+    ! outputs model files in binary format
+    if (ADIOS_FOR_SOLVER_MESHFILES) then
+      call save_arrays_solver_meshfiles_adios(myrank,iregion_code, &
+          reg_name, nspec)
+    else
+      call save_arrays_solver_meshfiles(myrank,nspec)
+    endif
+  endif
+
+end subroutine save_arrays_solver_adios
+
+
+!===============================================================================
+!> \brief Save the meshfiles that will be used by the solver in an ADIOS format.
+!! 
+!! \param myrank The MPI rank of the current process.
+!! \param iregion_code Code of the region considered. See constant.h for details
+!! \param reg_name Output file prefix with the name of the region included
+!! \param nspec Number of GLL points per spectral elements
+subroutine save_arrays_solver_meshfiles_adios(myrank, iregion_code, &
+    reg_name, nspec)
+
+  ! outputs model files in binary format
+  use mpi
+  use adios_write_mod
+  use constants
+
+  use meshfem3D_models_par,only: &
+    TRANSVERSE_ISOTROPY,ATTENUATION
+
+  use create_regions_mesh_par2,only: &
+    rhostore,kappavstore,kappahstore,muvstore,muhstore,eta_anisostore, &
+    Qmu_store, &
+    prname
+
+  implicit none
+
+  integer :: myrank, nspec, iregion_code
+  character(len=150) :: reg_name
+
+  ! local parameters
+  integer :: i,j,k,ispec,ier
+  real(kind=CUSTOM_REAL) :: scaleval1,scaleval2
+  real(kind=CUSTOM_REAL),dimension(:,:,:,:),allocatable :: temp_store
+
+  ! local parameters
+  character(len=150) :: outputname, group_name
+  integer :: ierr, sizeprocs, comm, local_dim
+  integer(kind=8) :: group_size_inc
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  ! scaling factors to re-dimensionalize units
+  scaleval1 = sngl( sqrt(PI*GRAV*RHOAV)*(R_EARTH/1000.0d0) )
+  scaleval2 = sngl( RHOAV/1000.0d0 )
+
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  ! isotropic model
+  outputname = trim(reg_name) // "solver_meshfiles.bp" 
+  write(group_name,"('SPECFEM3D_GLOBE_solver_meshfiles_reg',i1)") iregion_code
+
+  group_size_inc = 0
+
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  !--- vp arrays -------------------------------------------
+  local_dim = size (kappavstore) 
+  call define_adios_global_real_1d_array(adios_group, "vp", &
+      local_dim, group_size_inc)
+  !--- vs arrays -------------------------------------------
+  local_dim = size (rhostore) 
+  call define_adios_global_real_1d_array(adios_group, "vs", &
+      local_dim, group_size_inc)
+  !--- rho arrays ------------------------------------------
+  local_dim = size (rhostore) 
+  call define_adios_global_real_1d_array(adios_group, "rho", &
+      local_dim, group_size_inc)
+  ! transverse isotropic model
+  if( TRANSVERSE_ISOTROPY ) then
+    !--- vpv arrays ----------------------------------------
+    local_dim = size (kappavstore) 
+    call define_adios_global_real_1d_array(adios_group, "vpv", &
+        local_dim, group_size_inc)
+    !--- vph arrays ----------------------------------------
+    local_dim = size (kappavstore) 
+    call define_adios_global_real_1d_array(adios_group, "vph", &
+        local_dim, group_size_inc)
+    !--- vsv arrays ----------------------------------------
+    local_dim = size (rhostore) 
+    call define_adios_global_real_1d_array(adios_group, "vsv", &
+        local_dim, group_size_inc)
+    !--- vsh arrays ----------------------------------------
+    local_dim = size (rhostore) 
+    call define_adios_global_real_1d_array(adios_group, "vsh", &
+        local_dim, group_size_inc)
+    !--- eta arrays ----------------------------------------
+    local_dim = size (eta_anisostore) 
+    call define_adios_global_real_1d_array(adios_group, "eta", &
+        local_dim, group_size_inc)
+  endif
+  if( ATTENUATION ) then
+    !--- Qmu arrays ----------------------------------------
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec
+    call define_adios_global_real_1d_array(adios_group, "qmu", &
+        local_dim, group_size_inc)
+  endif
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  !--- vp arrays -------------------------------------------
+  local_dim = size (kappavstore) 
+  call adios_set_path (adios_handle, "vp", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", &
+      sqrt( (kappavstore+4.*muvstore/3.)/rhostore )*scaleval1, &
+      adios_err)
+  !--- vs arrays -------------------------------------------
+  local_dim = size (rhostore) 
+  call adios_set_path (adios_handle, "vs", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", &
+      sqrt( muvstore/rhostore )*scaleval1, &
+      adios_err)
+  !--- rho arrays ------------------------------------------
+  local_dim = size (rhostore) 
+  call adios_set_path (adios_handle, "rho", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", &
+      rhostore *scaleval2, &
+      adios_err)
+
+  ! transverse isotropic model
+  if( TRANSVERSE_ISOTROPY ) then
+    !--- vpv arrays ----------------------------------------
+    local_dim = size (kappavstore) 
+    call adios_set_path (adios_handle, "vpv", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        sqrt( (kappavstore+4.*muvstore/3.)/rhostore )*scaleval1, &
+        adios_err)
+    !--- vph arrays ----------------------------------------
+    local_dim = size (kappavstore) 
+    call adios_set_path (adios_handle, "vph", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        sqrt( (kappahstore+4.*muhstore/3.)/rhostore )*scaleval1, &
+        adios_err)
+    !--- vsv arrays ----------------------------------------
+    local_dim = size (rhostore) 
+    call adios_set_path (adios_handle, "vsv", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        sqrt( muvstore/rhostore )*scaleval1, &
+        adios_err)
+    !--- vsh arrays ----------------------------------------
+    local_dim = size (rhostore) 
+    call adios_set_path (adios_handle, "vsh", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        sqrt( muhstore/rhostore )*scaleval1, &
+        adios_err)
+    !--- eta arrays ----------------------------------------
+    local_dim = size (eta_anisostore) 
+    call adios_set_path (adios_handle, "eta", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        eta_anisostore, &
+        adios_err)
+  endif ! TRANSVERSE_ISOTROPY
+
+  ! shear attenuation
+  if( ATTENUATION ) then
+    !-------------------------------------------------------
+    !--- Qmu arrays ----------------------------------------
+    !-------------------------------------------------------
+    ! saves Qmu_store to full custom_real array
+    ! uses temporary array
+    allocate(temp_store(NGLLX,NGLLY,NGLLZ,nspec))
+    if (USE_3D_ATTENUATION_ARRAYS) then
+      ! attenuation arrays are fully 3D
+      if(CUSTOM_REAL == SIZE_REAL) then
+        temp_store(:,:,:,:) = sngl(Qmu_store(:,:,:,:))
+      else
+        temp_store(:,:,:,:) = Qmu_store(:,:,:,:)
+      endif
+    else
+      ! attenuation array dimensions: Q_mustore(1,1,1,nspec)
+      do ispec = 1,nspec
+        do k = 1,NGLLZ
+          do j = 1,NGLLY
+            do i = 1,NGLLX
+              ! distinguish between single and double precision for reals
+              if(CUSTOM_REAL == SIZE_REAL) then
+                temp_store(i,j,k,ispec) = sngl(Qmu_store(1,1,1,ispec))
+              else
+                temp_store(i,j,k,ispec) = Qmu_store(1,1,1,ispec)
+              endif
+            enddo
+          enddo
+        enddo
+      enddo
+    endif
+
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec
+    call adios_set_path (adios_handle, "qmu", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        temp_store, &
+        adios_err)
+
+    ! frees temporary memory
+    deallocate(temp_store)
+  endif ! ATTENUATION
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", adios_err)
+  call adios_close(adios_handle, adios_err)
+
+end subroutine save_arrays_solver_meshfiles_adios
+
+
+!===============================================================================
+!> \brief Save the arrays use by the solver for MPI communications.
+!! 
+!! \param myrank The MPI rank of the current process.
+!! \param iregion_code Code of the region considered. See constant.h for details
+!! \param LOCAL_PATH The full path to the output directory
+!! \param num_interfaces The number of interfaces between processors
+!! \param max_nibool_interfaces
+!! \param my_neighbours
+!! \param nibool_interfaces
+!! \param ibool_interfaces
+!! \param nspec_inner Number of spectral elements in the inner core
+!! \param nspec_outer Number of spectral elemetns in the outer core
+!! \param num_phase_ispec
+!! \param phase_ispec_inner
+!! \param num_colors_inner Number of colors for GPU computing in the inner core.
+!! \param num_colors_outer Number of colors for GPU computing in the outer core.
+subroutine save_MPI_arrays_adios(myrank,iregion_code,LOCAL_PATH, &
+   num_interfaces,max_nibool_interfaces, my_neighbours,nibool_interfaces, &
+   ibool_interfaces, nspec_inner,nspec_outer, num_phase_ispec, &
+   phase_ispec_inner, num_colors_outer,num_colors_inner, num_elem_colors)
+
+  use mpi
+  use adios_write_mod
+  implicit none
+
+  include "constants.h"
+
+  integer :: iregion_code,myrank
+  character(len=150) :: LOCAL_PATH
+  ! MPI interfaces
+  integer :: num_interfaces,max_nibool_interfaces
+  integer, dimension(num_interfaces) :: my_neighbours
+  integer, dimension(num_interfaces) :: nibool_interfaces
+  integer, dimension(max_nibool_interfaces,num_interfaces) :: &
+      ibool_interfaces
+  ! inner/outer elements
+  integer :: nspec_inner,nspec_outer
+  integer :: num_phase_ispec
+  integer,dimension(num_phase_ispec,2) :: phase_ispec_inner
+  ! mesh coloring
+  integer :: num_colors_outer,num_colors_inner
+  integer, dimension(num_colors_outer + num_colors_inner) :: &
+    num_elem_colors
+
+  ! local parameters
+  character(len=150) :: prname, outputname, group_name
+  integer :: ierr, sizeprocs, comm, local_dim
+  integer(kind=8) :: group_size_inc
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  ! create the name for the database of the current slide and region
+  call create_name_database_adios(prname,iregion_code,LOCAL_PATH)
+
+  outputname = trim(prname) // "solver_data_mpi.bp" 
+  write(group_name,"('SPECFEM3D_GLOBE_MPI_ARRAYS_reg',i1)") iregion_code
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  !! MPI interfaces
+  call define_adios_integer_scalar (adios_group, "num_interfaces", "", &
+      group_size_inc)
+  if( num_interfaces > 0 ) then
+    call define_adios_integer_scalar(adios_group, "max_nibool_interfaces", &
+        "", group_size_inc)
+    call define_adios_global_integer_1d_array(adios_group, "my_neighbours", &
+        num_interfaces, group_size_inc)
+    call define_adios_global_integer_1d_array(adios_group, "nibool_interfaces",&
+        num_interfaces, group_size_inc)
+    local_dim = max_nibool_interfaces*num_interfaces
+    call define_adios_global_integer_1d_array(adios_group, "ibool_interfaces", &
+        local_dim, group_size_inc)
+  endif
+
+  ! inner/outer elements
+  call define_adios_integer_scalar (adios_group, "nspec_inner", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "nspec_outer", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "num_phase_ispec", "", &
+      group_size_inc)
+  if(num_phase_ispec > 0 ) then
+    local_dim = num_phase_ispec * 2
+    call define_adios_global_integer_1d_array(adios_group, "phase_ispec_inner", &
+        local_dim, group_size_inc)
+  endif
+
+  ! mesh coloring
+  if( USE_MESH_COLORING_GPU ) then
+    call define_adios_integer_scalar (adios_group, "num_colors_outer", "", &
+        group_size_inc)
+    call define_adios_integer_scalar (adios_group, "num_colors_inner", "", &
+        group_size_inc)
+    call define_adios_global_integer_1d_array(adios_group, "num_elem_colors", &
+        num_colors_outer + num_colors_inner, group_size_inc)
+  endif
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  ! MPI interfaces
+  call adios_write(adios_handle, "num_interfaces", num_interfaces, adios_err)
+  if( num_interfaces > 0 ) then
+    call adios_write(adios_handle, "max_nibool_interfaces", &
+        max_nibool_interfaces, adios_err)
+
+    local_dim = num_interfaces
+
+    call adios_set_path (adios_handle, "my_neighbours", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", my_neighbours, adios_err)
+
+    call adios_set_path (adios_handle, "nibool_interfaces", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", nibool_interfaces, adios_err)
+
+    local_dim = max_nibool_interfaces * num_interfaces
+
+    call adios_set_path (adios_handle, "ibool_interfaces", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        ibool_interfaces, adios_err)
+    call adios_set_path (adios_handle, "", adios_err)
+  endif
+
+  ! inner/outer elements
+  call adios_write(adios_handle, "nspec_inner", nspec_inner, adios_err)
+  call adios_write(adios_handle, "nspec_outer", nspec_outer, adios_err)
+  call adios_write(adios_handle, "num_phase_ispec", num_phase_ispec, adios_err)
+
+  if(num_phase_ispec > 0 ) then
+    local_dim = num_phase_ispec * 2
+    call adios_set_path (adios_handle, "phase_ispec_inner", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        phase_ispec_inner, adios_err)
+    call adios_set_path (adios_handle, "", adios_err)
+  endif
+
+  ! mesh coloring
+  if( USE_MESH_COLORING_GPU ) then
+    call adios_write(adios_handle, "num_colors_outer", nspec_inner, adios_err)
+    call adios_write(adios_handle, "num_colors_inner", nspec_inner, adios_err)
+    local_dim = num_colors_outer + num_colors_inner
+    call adios_set_path (adios_handle, "num_elem_colors", adios_err)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        local_dim, sizeprocs)
+    call adios_write(adios_handle, "array", &
+        num_elem_colors, adios_err)
+    call adios_set_path (adios_handle, "", adios_err)
+  endif
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_close(adios_handle, adios_err)
+
+end subroutine save_MPI_arrays_adios
+
+
+!===============================================================================
+!> \brief Write boundary conditions (MOHO, 400, 600) to a single ADIOS file.
+subroutine save_arrays_solver_boundary_adios()
+
+! saves arrays for boundaries such as MOHO, 400 and 670 discontinuities
+  use mpi
+  
+  use meshfem3d_par,only: &
+    myrank, LOCAL_PATH
+
+  use meshfem3D_models_par,only: &
+    HONOR_1D_SPHERICAL_MOHO
+    !SAVE_BOUNDARY_MESH,HONOR_1D_SPHERICAL_MOHO,SUPPRESS_CRUSTAL_MESH
+
+  use create_regions_mesh_par2, only: &
+    NSPEC2D_MOHO, NSPEC2D_400, NSPEC2D_670, &
+    ibelm_moho_top,ibelm_moho_bot,ibelm_400_top,ibelm_400_bot, &
+    ibelm_670_top,ibelm_670_bot,normal_moho,normal_400,normal_670, &
+    ispec2D_moho_top,ispec2D_moho_bot,ispec2D_400_top,ispec2D_400_bot, &
+    ispec2D_670_top,ispec2D_670_bot, &
+    prname
+
+  implicit none
+  include "constants.h"
+
+  ! local parameters
+  ! local parameters
+  character(len=150) :: outputname, group_name
+  integer :: ierr, sizeprocs, comm, local_dim
+  integer(kind=8) :: group_size_inc
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  ! first check the number of surface elements are the same for Moho, 400, 670
+  if (.not. SUPPRESS_CRUSTAL_MESH .and. HONOR_1D_SPHERICAL_MOHO) then
+    if (ispec2D_moho_top /= NSPEC2D_MOHO .or. ispec2D_moho_bot /= NSPEC2D_MOHO) &
+           call exit_mpi(myrank, 'Not the same number of Moho surface elements')
+  endif
+  if (ispec2D_400_top /= NSPEC2D_400 .or. ispec2D_400_bot /= NSPEC2D_400) &
+           call exit_mpi(myrank,'Not the same number of 400 surface elements')
+  if (ispec2D_670_top /= NSPEC2D_670 .or. ispec2D_670_bot /= NSPEC2D_670) &
+           call exit_mpi(myrank,'Not the same number of 670 surface elements')
+
+  outputname = trim(LOCAL_PATH) // "/boundary_disc.bp" 
+  group_name = "SPECFEM3D_GLOBE_BOUNDARY_DISC"
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  group_size_inc = 0
+  call adios_declare_group(adios_group, group_name, &
+      "", 0, adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+
+  !--- Define ADIOS variables -----------------------------
+  call define_adios_integer_scalar (adios_group, "NSPEC2D_MOHO", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NSPEC2D_400", "", &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NSPEC2D_670", "", &
+      group_size_inc)
+
+  local_dim = NSPEC2D_MOHO
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_moho_top", &
+        local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_moho_bot", &
+        local_dim, group_size_inc)
+  local_dim = NSPEC2D_400
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_400_top", &
+        local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_400_bot", &
+        local_dim, group_size_inc)
+  local_dim = NSPEC2D_670 
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_670_top", &
+        local_dim, group_size_inc)
+  call define_adios_global_integer_1d_array(adios_group, "ibelm_670_bot", &
+        local_dim, group_size_inc)
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_MOHO
+  call define_adios_global_real_1d_array(adios_group, "normal_moho", &
+        local_dim, group_size_inc)
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_400
+  call define_adios_global_real_1d_array(adios_group, "normal_400", &
+        local_dim, group_size_inc)
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_670
+  call define_adios_global_real_1d_array(adios_group, "normal_670", &
+        local_dim, group_size_inc)
+
+  !--- Open an ADIOS handler to the restart file. ---------
+  call adios_open (adios_handle, group_name, &
+      outputname, "w", comm, adios_err);
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+
+  !--- Schedule writes for the previously defined ADIOS variables
+  call adios_write(adios_handle, "NSPEC2D_MOHO", NSPEC2D_MOHO, adios_err)
+  call adios_write(adios_handle, "NSPEC2D_400", NSPEC2D_400, adios_err)
+  call adios_write(adios_handle, "NSPEC2D_670", NSPEC2D_670, adios_err)
+
+  local_dim = NSPEC2D_MOHO
+  call adios_set_path (adios_handle, "ibelm_moho_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_moho_top, adios_err)
+  call adios_set_path (adios_handle, "ibelm_moho_bot", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_moho_bot, adios_err)
+
+  local_dim = NSPEC2D_400 
+  call adios_set_path (adios_handle, "ibelm_400_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_400_top, adios_err)
+  call adios_set_path (adios_handle, "ibelm_400_bot", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_400_bot, adios_err)
+
+  local_dim = NSPEC2D_670
+  call adios_set_path (adios_handle, "ibelm_670_top", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_670_top, adios_err)
+  call adios_set_path (adios_handle, "ibelm_670_bot", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", ibelm_670_bot, adios_err)
+
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_MOHO
+  call adios_set_path (adios_handle, "normal_moho", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_moho, adios_err)
+
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_400
+  call adios_set_path (adios_handle, "normal_400", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_400, adios_err)
+
+  local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_670
+  call adios_set_path (adios_handle, "normal_670", adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", normal_670, adios_err)
+
+  !--- Reset the path to zero and perform the actual write to disk
+  call adios_set_path (adios_handle, "", adios_err)
+  call adios_close(adios_handle, adios_err)
+end subroutine save_arrays_solver_boundary_adios
+
+!-------------------------------------------------------------------------------
+!> Write local, global and offset dimensions to ADIOS 
+!! \param adios_handle Handle to the adios file
+!! \param local_dim Number of elements to be written by one process
+!! \param sizeprocs Number of MPI processes
+subroutine write_1D_global_array_adios_dims(adios_handle, myrank, &
+    local_dim, sizeprocs)
+  use adios_write_mod
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: sizeprocs, local_dim, myrank
+
+  integer :: adios_err
+
+  call adios_write(adios_handle, "local_dim", local_dim, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_write(adios_handle, "global_dim", local_dim*sizeprocs, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_write(adios_handle, "offset", local_dim*myrank, adios_err)
+  call check_adios_err(myrank,adios_err)
+end subroutine write_1D_global_array_adios_dims
+

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_chunks_data_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/write_AVS_DX_global_chunks_data_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_chunks_data_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_chunks_data_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,1145 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+! create AVS or DX 2D data for the faces of the global chunks,
+! to be recombined in postprocessing
+
+module AVS_DX_global_chunks_mod
+
+  implicit none
+
+  type avs_dx_global_chunks_t
+    integer(kind=4) :: npoin, nspecface
+    real(kind=4), dimension(:), allocatable :: x_adios, y_adios, z_adios
+    integer(kind=4), dimension(:), allocatable :: idoubling, iglob1, iglob2, &
+        iglob3, iglob4
+    real, dimension(:), allocatable :: vmin, vmax 
+    real, dimension(:), allocatable :: dvp, dvs
+  endtype
+
+contains
+
+
+subroutine define_AVS_DX_global_chunks_data(adios_group, &
+    myrank,prname,nspec,iboun,ibool, &
+    idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+    npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN,iregion_code, &
+    group_size_inc, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+
+  implicit none
+
+  include "constants.h"
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer :: myrank
+
+  ! processor identification
+  character(len=150) :: prname
+
+  integer :: nspec
+
+  logical iboun(6,nspec)
+
+  integer,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
+  integer idoubling(nspec)
+
+  double precision,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: xstore,ystore,zstore
+
+  integer :: npointot
+  ! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+  ! logical mask used to output global points only once
+  logical mask_ibool(npointot)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  ! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+    R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  integer iregion_code
+
+  ! local parameters
+  integer ispec
+  integer i,j,k,np
+  integer, dimension(8) :: iglobval
+  integer npoin,numpoin,nspecface,ispecface
+
+  real(kind=CUSTOM_REAL) vmin,vmax
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+  type(avs_dx_global_chunks_t), intent(inout) :: avs_dx_adios
+
+  integer :: ierr
+
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+  ! only if on face
+    if(iboun(1,ispec) .or. iboun(2,ispec) .or. &
+                iboun(3,ispec) .or. iboun(4,ispec)) then
+      iglobval(1)=ibool(1,1,1,ispec)
+      iglobval(2)=ibool(NGLLX,1,1,ispec)
+      iglobval(3)=ibool(NGLLX,NGLLY,1,ispec)
+      iglobval(4)=ibool(1,NGLLY,1,ispec)
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iboun(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face xi = xi_max
+      if(iboun(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+      endif
+
+      ! face eta = eta_min
+      if(iboun(3,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face eta = eta_max
+      if(iboun(4,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+      endif
+
+    endif
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  avs_dx_adios%npoin = npoin
+  avs_dx_adios%nspecface = nspecface
+
+  allocate(avs_dx_adios%x_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating x_adios.")
+  allocate(avs_dx_adios%y_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating y_adios.")
+  allocate(avs_dx_adios%z_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating z_adios.")
+  
+  allocate(avs_dx_adios%vmin(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating vmin.")
+  allocate(avs_dx_adios%vmax(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating vmax.")
+
+  ! Allocate temporary arrays for AVS/DX elements.
+  allocate(avs_dx_adios%idoubling(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating idoubling.")
+  allocate(avs_dx_adios%iglob1(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob1.")
+  allocate(avs_dx_adios%iglob2(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob2.")
+  allocate(avs_dx_adios%iglob3(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob3.")
+  allocate(avs_dx_adios%iglob4(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob4.")
+
+  !--- Variables for '...AVS_DXpointschunk.txt'
+  call define_adios_global_real_1d_array(adios_group, "points_chunks/x_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points_chunks/y_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points_chunks/z_value", &
+      npoin, group_size_inc)
+  !--- Variables for '...AVS_DXpointschunk_stability.txt'
+  call define_adios_global_real_1d_array(adios_group, &
+      "points_chunks_stability/vmin", npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "points_chunks_stability/vmax", npoin, group_size_inc)
+  !--- Variables for AVS_DXelementschunks.txt
+  call define_adios_global_real_1d_array(adios_group, & 
+      "elements_chunks/idoubling", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_chunks/num_ibool_AVS_DX_iglob1", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_chunks/num_ibool_AVS_DX_iglob2", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_chunks/num_ibool_AVS_DX_iglob3", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_chunks/num_ibool_AVS_DX_iglob4", nspecface, group_size_inc)
+
+  !--- Variables for AVS_DXelementschunks_dvp_dvs.txt
+  if(ISOTROPIC_3D_MANTLE) then 
+    allocate(avs_dx_adios%dvp(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvp.")
+    allocate(avs_dx_adios%dvs(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvs.")
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_chunks/dvp", dvp, group_size_inc)
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_chunks/dvp", dvs, group_size_inc)
+  endif
+
+end subroutine define_AVS_DX_global_chunks_data
+
+!===============================================================================
+subroutine prepare_AVS_DX_global_chunks_data_adios(myrank,prname,nspec, &
+    iboun,ibool, idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+    npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN,iregion_code, &
+    avs_dx_adios)
+
+  implicit none
+
+  include "constants.h"
+
+  integer :: myrank
+
+  ! processor identification
+  character(len=150) :: prname
+
+  integer :: nspec
+
+  logical iboun(6,nspec)
+
+  integer,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
+  integer idoubling(nspec)
+
+  double precision,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: xstore,ystore,zstore
+
+  integer :: npointot
+  ! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+  ! logical mask used to output global points only once
+  logical mask_ibool(npointot)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  ! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+    R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  integer iregion_code
+
+  ! local parameters
+  integer ispec
+  integer i,j,k,np
+  integer, dimension(8) :: iglobval
+  integer npoin,numpoin,nspecface,ispecface
+
+  real(kind=CUSTOM_REAL) vmin,vmax
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+  type(avs_dx_global_chunks_t), intent(inout) :: avs_dx_adios ! out for adios_write
+
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+  ! only if on face
+    if(iboun(1,ispec) .or. iboun(2,ispec) .or. &
+                iboun(3,ispec) .or. iboun(4,ispec)) then
+      iglobval(1)=ibool(1,1,1,ispec)
+      iglobval(2)=ibool(NGLLX,1,1,ispec)
+      iglobval(3)=ibool(NGLLX,NGLLY,1,ispec)
+      iglobval(4)=ibool(1,NGLLY,1,ispec)
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iboun(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face xi = xi_max
+      if(iboun(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+      endif
+
+      ! face eta = eta_min
+      if(iboun(3,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face eta = eta_max
+      if(iboun(4,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+      endif
+
+    endif
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  ! number of points in AVS or DX file
+  write(10,*) npoin
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  ! output global AVS or DX points
+  numpoin = 0
+  do ispec=1,nspec
+  ! only if on face
+    if(iboun(1,ispec) .or. iboun(2,ispec) .or. &
+                iboun(3,ispec) .or. iboun(4,ispec)) then
+      iglobval(1)=ibool(1,1,1,ispec)
+      iglobval(2)=ibool(NGLLX,1,1,ispec)
+      iglobval(3)=ibool(NGLLX,NGLLY,1,ispec)
+      iglobval(4)=ibool(1,NGLLY,1,ispec)
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iboun(1,ispec)) then
+
+        if(.not. mask_ibool(iglobval(1))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(1)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,1,ispec))
+
+          vmax = sqrt((kappavstore(1,1,1,ispec) &
+              + 4.*muvstore(1,1,1,ispec)/3.)/rhostore(1,1,1,ispec))
+          vmin = sqrt(muvstore(1,1,1,ispec)/rhostore(1,1,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,1,1,ispec)**2 + ystore(1,1,1,ispec)**2 &
+                + zstore(1,1,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(4))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(4)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,1,ispec)) 
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,1,ispec))
+
+          vmax = sqrt((kappavstore(1,NGLLY,1,ispec) &
+              +4.*muvstore(1,NGLLY,1,ispec)/3.)/rhostore(1,NGLLY,1,ispec))
+          vmin = sqrt(muvstore(1,NGLLY,1,ispec)/rhostore(1,NGLLY,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,NGLLY,1,ispec)**2 + ystore(1,NGLLY,1,ispec)**2 &
+                + zstore(1,NGLLY,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(8))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(8)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(1,NGLLY,NGLLZ,ispec) &
+              +4.*muvstore(1,NGLLY,NGLLZ,ispec)/3.) &
+              / rhostore(1,NGLLY,NGLLZ,ispec))
+          vmin = sqrt(muvstore(1,NGLLY,NGLLZ,ispec) &
+              / rhostore(1,NGLLY,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,NGLLY,NGLLZ,ispec)**2 &
+                + ystore(1,NGLLY,NGLLZ,ispec)**2 &
+                + zstore(1,NGLLY,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(5))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(5)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(1,1,NGLLZ,ispec) &
+              +4.*muvstore(1,1,NGLLZ,ispec)/3.)/rhostore(1,1,NGLLZ,ispec))
+          vmin = sqrt(muvstore(1,1,NGLLZ,ispec)/rhostore(1,1,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,1,NGLLZ,ispec)**2 + ystore(1,1,NGLLZ,ispec)**2 &
+                + zstore(1,1,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face xi = xi_max
+      if(iboun(2,ispec)) then
+
+        if(.not. mask_ibool(iglobval(2))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(2)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,1,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,1,1,ispec) & 
+              +4.*muvstore(NGLLX,1,1,ispec)/3.)/rhostore(NGLLX,1,1,ispec))
+          vmin = sqrt(muvstore(NGLLX,1,1,ispec)/rhostore(NGLLX,1,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,1,1,ispec)**2 + ystore(NGLLX,1,1,ispec)**2 &
+                + zstore(NGLLX,1,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(3))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(3)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,1,ispec)) 
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,1,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,NGLLY,1,ispec) &
+              + 4.*muvstore(NGLLX,NGLLY,1,ispec)/3.) &
+              / rhostore(NGLLX,NGLLY,1,ispec))
+          vmin = sqrt(muvstore(NGLLX,NGLLY,1,ispec) &
+              / rhostore(NGLLX,NGLLY,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,NGLLY,1,ispec)**2 &
+                + ystore(NGLLX,NGLLY,1,ispec)**2 &
+                + zstore(NGLLX,NGLLY,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(7))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(7)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,NGLLY,NGLLZ,ispec) &
+              + 4.*muvstore(NGLLX,NGLLY,NGLLZ,ispec)/3.) &
+              / rhostore(NGLLX,NGLLY,NGLLZ,ispec))
+          vmin = sqrt(muvstore(NGLLX,NGLLY,NGLLZ,ispec) &
+              / rhostore(NGLLX,NGLLY,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,NGLLY,NGLLZ,ispec)**2 &
+                + ystore(NGLLX,NGLLY,NGLLZ,ispec)**2 &
+                + zstore(NGLLX,NGLLY,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(6))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(6)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,1,NGLLZ,ispec) &
+              + 4.*muvstore(NGLLX,1,NGLLZ,ispec)/3.) &
+              / rhostore(NGLLX,1,NGLLZ,ispec))
+          vmin = sqrt(muvstore(NGLLX,1,NGLLZ,ispec) &
+              / rhostore(NGLLX,1,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,1,NGLLZ,ispec)**2 &
+                + ystore(NGLLX,1,NGLLZ,ispec)**2 &
+                + zstore(NGLLX,1,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+      endif
+
+      ! face eta = eta_min
+      if(iboun(3,ispec)) then
+
+        if(.not. mask_ibool(iglobval(1))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(1)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,1,ispec))
+
+          vmax = sqrt((kappavstore(1,1,1,ispec) &
+              + 4.*muvstore(1,1,1,ispec)/3.)/rhostore(1,1,1,ispec))
+          vmin = sqrt(muvstore(1,1,1,ispec)/rhostore(1,1,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,1,1,ispec)**2 &
+                + ystore(1,1,1,ispec)**2 + zstore(1,1,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(2))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(2)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,1,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,1,1,ispec) &
+              +4.*muvstore(NGLLX,1,1,ispec)/3.)/rhostore(NGLLX,1,1,ispec))
+          vmin = sqrt(muvstore(NGLLX,1,1,ispec)/rhostore(NGLLX,1,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,1,1,ispec)**2 &
+                + ystore(NGLLX,1,1,ispec)**2 + zstore(NGLLX,1,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin = vmin
+          avs_dx_adios%vmax = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(6))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(6)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,1,NGLLZ,ispec) &
+              + 4.*muvstore(NGLLX,1,NGLLZ,ispec)/3.) &
+              / rhostore(NGLLX,1,NGLLZ,ispec))
+          vmin = sqrt(muvstore(NGLLX,1,NGLLZ,ispec) &
+              / rhostore(NGLLX,1,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,1,NGLLZ,ispec)**2 &
+                + ystore(NGLLX,1,NGLLZ,ispec)**2 &
+                + zstore(NGLLX,1,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(5))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(5)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(1,1,NGLLZ,ispec) &
+              + 4.*muvstore(1,1,NGLLZ,ispec)/3.) &
+              / rhostore(1,1,NGLLZ,ispec))
+          vmin = sqrt(muvstore(1,1,NGLLZ,ispec)/rhostore(1,1,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,1,NGLLZ,ispec)**2 &
+                + ystore(1,1,NGLLZ,ispec)**2 + zstore(1,1,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        mask_ibool(iglobval(1)) = .true.
+        mask_ibool(iglobval(2)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+        mask_ibool(iglobval(5)) = .true.
+      endif
+
+      ! face eta = eta_max
+      if(iboun(4,ispec)) then
+
+        if(.not. mask_ibool(iglobval(4))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(4)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,1,ispec))
+
+          vmax = sqrt((kappavstore(1,NGLLY,1,ispec) &
+              + 4.*muvstore(1,NGLLY,1,ispec)/3.)/rhostore(1,NGLLY,1,ispec))
+          vmin = sqrt(muvstore(1,NGLLY,1,ispec)/rhostore(1,NGLLY,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,NGLLY,1,ispec)**2 &
+                + ystore(1,NGLLY,1,ispec)**2 + zstore(1,NGLLY,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(3))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(3)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,1,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,NGLLY,1,ispec) &
+              + 4.*muvstore(NGLLX,NGLLY,1,ispec)/3.) &
+              / rhostore(NGLLX,NGLLY,1,ispec))
+          vmin = sqrt(muvstore(NGLLX,NGLLY,1,ispec) &
+              / rhostore(NGLLX,NGLLY,1,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,NGLLY,1,ispec)**2 &
+                + ystore(NGLLX,NGLLY,1,ispec)**2 &
+                + zstore(NGLLX,NGLLY,1,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+
+          if(vmin == 0.0) vmin=vmax
+
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(7))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(7)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(NGLLX,NGLLY,NGLLZ,ispec) &
+              + 4.*muvstore(NGLLX,NGLLY,NGLLZ,ispec)/3.) &
+              / rhostore(NGLLX,NGLLY,NGLLZ,ispec))
+          vmin = sqrt(muvstore(NGLLX,NGLLY,NGLLZ,ispec) &
+              / rhostore(NGLLX,NGLLY,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(NGLLX,NGLLY,NGLLZ,ispec)**2 &
+                + ystore(NGLLX,NGLLY,NGLLZ,ispec)**2 &
+                + zstore(NGLLX,NGLLY,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+          vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        if(.not. mask_ibool(iglobval(8))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(8)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+
+          vmax = sqrt((kappavstore(1,NGLLY,NGLLZ,ispec) &
+              + 4.*muvstore(1,NGLLY,NGLLZ,ispec)/3.) &
+              / rhostore(1,NGLLY,NGLLZ,ispec))
+          vmin = sqrt(muvstore(1,NGLLY,NGLLZ,ispec) & 
+              / rhostore(1,NGLLY,NGLLZ,ispec))
+          ! particular case of the outer core (muvstore contains 1/rho)
+          if(idoubling(ispec) == IFLAG_OUTER_CORE_NORMAL) then
+            r = dsqrt(xstore(1,NGLLY,NGLLZ,ispec)**2 &
+                + ystore(1,NGLLY,NGLLZ,ispec)**2 &
+                + zstore(1,NGLLY,NGLLZ,ispec)**2)
+            call prem_display_outer_core(myrank,r,rho,vp,vs, &
+                Qkappa,Qmu,idoubling(ispec))
+            vmax = vp
+            vmin = vp
+          endif
+          if(vmin == 0.0) vmin=vmax
+
+          avs_dx_adios%vmin(numpoin) = vmin
+          avs_dx_adios%vmax(numpoin) = vmax
+        endif
+
+        mask_ibool(iglobval(4)) = .true.
+        mask_ibool(iglobval(3)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+      endif
+
+    endif
+  enddo
+
+! check that number of global points output is okay
+  if(numpoin /= npoin) &
+    call exit_MPI(myrank,&
+        'incorrect number of global points in AVS or DX file creation')
+
+  ! output global AVS or DX elements
+  ispecface = 0
+  do ispec=1,nspec
+    ! only if on face
+    if(iboun(1,ispec) .or. iboun(2,ispec) .or. &
+        iboun(3,ispec) .or. iboun(4,ispec)) then
+      iglobval(1)=ibool(1,1,1,ispec)
+      iglobval(2)=ibool(NGLLX,1,1,ispec)
+      iglobval(3)=ibool(NGLLX,NGLLY,1,ispec)
+      iglobval(4)=ibool(1,NGLLY,1,ispec)
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! include lateral variations if needed
+
+      if(ISOTROPIC_3D_MANTLE) then
+        !   pick a point within the element and get its radius
+        r=dsqrt(xstore(2,2,2,ispec)**2+ystore(2,2,2,ispec)**2 &
+            +zstore(2,2,2,ispec)**2)
+
+        if(r > RCMB/R_EARTH .and. r < R_UNIT_SPHERE) then
+          !     average over the element
+          dvp = 0.0
+          dvs = 0.0
+          np =0
+          do k=2,NGLLZ-1
+            do j=2,NGLLY-1
+              do i=2,NGLLX-1
+                np=np+1
+                x=xstore(i,j,k,ispec)
+                y=ystore(i,j,k,ispec)
+                z=zstore(i,j,k,ispec)
+                r=dsqrt(x*x+y*y+z*z)
+                ! take out ellipticity
+                if(ELLIPTICITY) then
+                  call xyz_2_rthetaphi_dble(x,y,z,r,theta,phi_dummy)
+                  cost=dcos(theta)
+                  p20=0.5d0*(3.0d0*cost*cost-1.0d0)
+                  call spline_evaluation(rspl,espl,espl2,nspl,r,ell)
+                  factor=ONE-(TWO/3.0d0)*ell*p20
+                  r=r/factor
+                endif
+
+
+                ! get reference model values: rho,vpv,vph,vsv,vsh and eta_aniso
+                call meshfem3D_models_get1D_val(myrank,iregion_code, &
+                    idoubling(ispec), &
+                    r,rho,vpv,vph,vsv,vsh,eta_aniso, &
+                    Qkappa,Qmu,RICB,RCMB, &
+                    RTOPDDOUBLEPRIME,R80,R120,R220,R400,R600,R670,R771, &
+                    RMOHO,RMIDDLE_CRUST,ROCEAN)
+
+                ! calculates isotropic values
+                vp = sqrt(((8.d0+4.d0*eta_aniso)*vph*vph + 3.d0*vpv*vpv &
+                        + (8.d0 - 8.d0*eta_aniso)*vsv*vsv)/15.d0)
+                vs = sqrt(((1.d0-2.d0*eta_aniso)*vph*vph + vpv*vpv &
+                        + 5.d0*vsh*vsh + (6.d0+4.d0*eta_aniso)*vsv*vsv)/15.d0)
+
+                if( abs(rhostore(i,j,k,ispec))< 1.e-20 ) then
+                  print*,' attention: rhostore close to zero', &
+                      rhostore(i,j,k,ispec),r,i,j,k,ispec
+                  dvp = 0.0
+                  dvs = 0.0
+                else if( abs(sngl(vp))< 1.e-20 ) then
+                  print*,' attention: vp close to zero', &
+                      sngl(vp),r,i,j,k,ispec
+                  dvp = 0.0
+                else if( abs(sngl(vs))< 1.e-20 ) then
+                  print*,' attention: vs close to zero', &
+                      sngl(vs),r,i,j,k,ispec
+                  dvs = 0.0
+                else
+                  dvp = dvp + (sqrt((kappavstore(i,j,k,ispec) &
+                      +4.*muvstore(i,j,k,ispec)/3.)/rhostore(i,j,k,ispec)) &
+                      - sngl(vp))/sngl(vp)
+                  dvs = dvs + (sqrt(muvstore(i,j,k,ispec)/rhostore(i,j,k,ispec)) &
+                      - sngl(vs))/sngl(vs)
+                endif
+
+              enddo
+            enddo
+          enddo
+          dvp = dvp / np
+          dvs = dvs / np
+        else
+          dvp = 0.0
+          dvs = 0.0
+        endif
+      endif
+
+      ! face xi = xi_min
+      if(iboun(1,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglobval(1))
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglobval(4))
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglobval(8))
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglobval(5))
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+      ! face xi = xi_max
+      if(iboun(2,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface)= num_ibool_AVS_DX(iglobval(2))
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglobval(3))
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglobval(7))
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglobval(6))
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+    ! face eta = eta_min
+      if(iboun(3,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglobval(1))
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglobval(2))
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglobval(6))
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglobval(5))
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+      ! face eta = eta_max
+      if(iboun(4,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglobval(4))
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglobval(3))
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglobval(7))
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglobval(8))
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+    endif
+  enddo
+
+  ! check that number of surface elements output is okay
+  if(ispecface /= nspecface) &
+    call exit_MPI(myrank, &
+        'incorrect number of surface elements in AVS or DX file creation')
+
+end subroutine prepare_AVS_DX_global_chunks_data_adios
+
+!===============================================================================
+subroutine write_AVS_DX_global_chunks_data_adios(adios_handle, myrank, &
+    sizeprocs, avs_dx_adios, ISOTROPIC_3D_MANTLE)
+  use mpi
+  use adios_write_mod
+  implicit none
+  !--- Arguments
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: myrank, sizeprocs
+  type(avs_dx_global_chunks_t), intent(inout) :: avs_dx_adios ! out for adios_write
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  integer :: npoin, nspec
+  integer :: ierr
+  
+  npoin = avs_dx_adios%npoin
+  nspec = avs_dx_adios%nspecface
+
+  call adios_set_path(adios_handle, "points_chunks/x_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%x_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_chunks/y_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%y_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_chunks/z_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%z_adios, ierr)
+
+
+  call adios_set_path(adios_handle, "points_chunks/vmin", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%vmin, ierr)
+
+  call adios_set_path(adios_handle, "points_chunks/vmax", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%vmax, ierr)
+
+
+  call adios_set_path(adios_handle, "elements_chunks/idoubling", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%idoubling, ierr)
+
+
+  call adios_set_path(adios_handle, &
+      "elements_chunks/num_ibool_AVS_DX_iglob1", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob1, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_chunks/num_ibool_AVS_DX_iglob2", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob2, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_chunks/num_ibool_AVS_DX_iglob3", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob3, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_chunks/num_ibool_AVS_DX_iglob4", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob4, ierr)
+  
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    call adios_set_path(adios_handle, "elements_chunks/dvp", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvp, ierr)
+    call adios_set_path(adios_handle, "elements_chunks/dvs", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvs, ierr)
+  endif
+
+end subroutine write_AVS_DX_global_chunks_data_adios
+
+!===============================================================================
+subroutine free_AVS_DX_global_chunks_data_adios(myrank, avs_dx_adios, &
+    ISOTROPIC_3D_MANTLE)
+  implicit none
+  !--- Arguments
+  integer, intent(in) :: myrank
+  type(avs_dx_global_chunks_t), intent(inout) :: avs_dx_adios
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  !--- Variables
+  integer :: ierr
+
+  deallocate(avs_dx_adios%x_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating x_adios.")
+  deallocate(avs_dx_adios%y_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating y_adios.")
+  deallocate(avs_dx_adios%z_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating z_adios.")
+
+  deallocate(avs_dx_adios%vmin, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating vmin.")
+  deallocate(avs_dx_adios%vmax, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating vmax.")
+
+  deallocate(avs_dx_adios%idoubling, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob1, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob2, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob2.")
+  deallocate(avs_dx_adios%iglob3, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob3.")
+  deallocate(avs_dx_adios%iglob4, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob4.")
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    deallocate(avs_dx_adios%dvp, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvp.")
+    deallocate(avs_dx_adios%dvs, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvs.")
+  endif
+
+  avs_dx_adios%npoin = 0 
+  avs_dx_adios%nspecface = 0
+end subroutine free_AVS_DX_global_chunks_data_adios
+
+end module

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_data_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/write_AVS_DX_global_data_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_data_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_data_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,470 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file write_AVS_DX_global_adios.f90
+!! \brief Define a module to hold global AVS/DX data (points and elements) and
+!!        provides function to deal with them.
+!! \author MPBL      
+!-------------------------------------------------------------------------------
+
+!===============================================================================
+!> AVS_DX_global_mod module. Hold and write to ADIOS file global data (points
+!! and elements).
+module AVS_DX_global_mod
+
+  implicit none
+
+  ! ADIOS Arrays to write down
+  type avs_dx_global_t
+    integer(kind=4) :: npoin, nspec
+    real(kind=4), dimension(:), allocatable :: x_adios, y_adios, z_adios
+    integer(kind=4), dimension(:), allocatable :: idoubling, iglob1, iglob2, &
+        iglob3, iglob4, iglob5, iglob6, iglob7, iglob8
+  endtype
+
+contains
+
+!===============================================================================
+!> Allocate the structure that hold data to be written; initialize adios vars.
+!! \param adios_group ADIOS group where the variables belong
+!! \param group_size_inc The size of the ADIOS group to increment
+!! \param avs_dx_adios The structure holding the data to be allocated
+subroutine define_AVS_DX_global_data_adios(adios_group, myrank, nspec, ibool, &
+    npointot, mask_ibool, group_size_inc, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+  implicit none
+  include "constants.h"
+  !--- Arguments -------------------------------------------
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=4), intent(in) :: nspec, npointot, myrank
+  integer(kind=4), intent(in) :: ibool(NGLLX,NGLLY,NGLLZ,nspec)
+  logical, intent(inout) :: mask_ibool(npointot)
+  integer(kind=8), intent(inout) :: group_size_inc
+  type(avs_dx_global_t), intent(inout) :: avs_dx_adios
+  !--- Variables -------------------------------------------
+  integer ispec, npoin, ierr
+  integer iglob1,iglob2,iglob3,iglob4,iglob5,iglob6,iglob7,iglob8
+
+  mask_ibool(:) = .false.
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+    iglob1=ibool(1,1,1,ispec)
+    iglob2=ibool(NGLLX,1,1,ispec)
+    iglob3=ibool(NGLLX,NGLLY,1,ispec)
+    iglob4=ibool(1,NGLLY,1,ispec)
+    iglob5=ibool(1,1,NGLLZ,ispec)
+    iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+    iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+    iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+    mask_ibool(iglob1) = .true.
+    mask_ibool(iglob2) = .true.
+    mask_ibool(iglob3) = .true.
+    mask_ibool(iglob4) = .true.
+    mask_ibool(iglob5) = .true.
+    mask_ibool(iglob6) = .true.
+    mask_ibool(iglob7) = .true.
+    mask_ibool(iglob8) = .true.
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  avs_dx_adios%npoin = npoin
+  avs_dx_adios%nspec = nspec
+  ! Allocate temporary arrays for AVS/DX points
+  allocate(avs_dx_adios%x_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating x_adios.")
+  allocate(avs_dx_adios%y_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating y_adios.")
+  allocate(avs_dx_adios%z_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating z_adios.")
+
+  ! Allocate temporary arrays for AVS/DX elements.
+  allocate(avs_dx_adios%idoubling(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating idoubling.")
+  allocate(avs_dx_adios%iglob1(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob1.")
+  allocate(avs_dx_adios%iglob2(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob2.")
+  allocate(avs_dx_adios%iglob3(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob3.")
+  allocate(avs_dx_adios%iglob4(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob4.")
+  allocate(avs_dx_adios%iglob5(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob5.")
+  allocate(avs_dx_adios%iglob6(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob6.")
+  allocate(avs_dx_adios%iglob7(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob7.")
+  allocate(avs_dx_adios%iglob8(nspec), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob8.")
+
+  !--- Variables for '...AVS_DXpoints.txt'
+  call define_adios_global_real_1d_array(adios_group, "points/x_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points/y_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points/z_value", &
+      npoin, group_size_inc)
+  !--- Variables for AVS_DXelements.txt
+  call define_adios_global_real_1d_array(adios_group, "elements/idoubling", &
+      nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob1", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob2", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob3", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob4", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob5", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob6", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob7", nspec, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements/num_ibool_AVS_DX_iglob8", nspec, group_size_inc)
+
+end subroutine define_AVS_DX_global_data_adios
+
+
+!===============================================================================
+!> Prepare the global AVS/DX data to be written; fill the structure.
+!! \param adios_handle The handle to the ADIOS file to be written.
+!! \param myrank The MPI rank of the current process.
+!! \param avs_dx_adios The structure to be filled.
+!!
+!! Create AVS or DX 3D data for the slice, to be recombined in postprocessing.
+subroutine prepare_AVS_DX_global_data_adios(adios_handle, myrank, &
+    nspec, ibool, idoubling, xstore, ystore, zstore, num_ibool_AVS_DX, &
+    mask_ibool, npointot, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+
+  implicit none
+
+  include "constants.h"
+
+  integer(kind=8), intent(in)    :: adios_handle
+  integer nspec,myrank
+  integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
+
+  integer idoubling(nspec)
+
+  double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  ! logical mask used to output global points only once
+  integer npointot
+  logical mask_ibool(npointot)
+
+  ! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+
+  integer ispec
+  integer iglob1,iglob2,iglob3,iglob4,iglob5,iglob6,iglob7,iglob8
+  integer npoin,numpoin
+  
+  type(avs_dx_global_t), intent(inout) :: avs_dx_adios
+
+  integer :: ierr
+
+! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+! mark global AVS or DX points
+  do ispec=1,nspec
+    iglob1=ibool(1,1,1,ispec)
+    iglob2=ibool(NGLLX,1,1,ispec)
+    iglob3=ibool(NGLLX,NGLLY,1,ispec)
+    iglob4=ibool(1,NGLLY,1,ispec)
+    iglob5=ibool(1,1,NGLLZ,ispec)
+    iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+    iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+    iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+    mask_ibool(iglob1) = .true.
+    mask_ibool(iglob2) = .true.
+    mask_ibool(iglob3) = .true.
+    mask_ibool(iglob4) = .true.
+    mask_ibool(iglob5) = .true.
+    mask_ibool(iglob6) = .true.
+    mask_ibool(iglob7) = .true.
+    mask_ibool(iglob8) = .true.
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  ! fill the structure with global AVS or DX points
+  numpoin = 0
+  do ispec=1,nspec
+    iglob1=ibool(1,1,1,ispec)
+    iglob2=ibool(NGLLX,1,1,ispec)
+    iglob3=ibool(NGLLX,NGLLY,1,ispec)
+    iglob4=ibool(1,NGLLY,1,ispec)
+    iglob5=ibool(1,1,NGLLZ,ispec)
+    iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+    iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+    iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+    if(.not. mask_ibool(iglob1)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob1) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,1,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,1,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,1,ispec))
+    endif
+    if(.not. mask_ibool(iglob2)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob2) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,1,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,1,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,1,ispec))
+    endif
+    if(.not. mask_ibool(iglob3)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob3) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,1,ispec)) 
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,1,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,1,ispec))
+    endif
+    if(.not. mask_ibool(iglob4)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob4) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,1,ispec)) 
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,1,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,1,ispec))
+    endif
+    if(.not. mask_ibool(iglob5)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob5) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+    endif
+    if(.not. mask_ibool(iglob6)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob6) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+    endif
+    if(.not. mask_ibool(iglob7)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob7) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+    endif
+    if(.not. mask_ibool(iglob8)) then
+      numpoin = numpoin + 1
+      num_ibool_AVS_DX(iglob8) = numpoin
+      avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+      avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+      avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+    endif
+    mask_ibool(iglob1) = .true.
+    mask_ibool(iglob2) = .true.
+    mask_ibool(iglob3) = .true.
+    mask_ibool(iglob4) = .true.
+    mask_ibool(iglob5) = .true.
+    mask_ibool(iglob6) = .true.
+    mask_ibool(iglob7) = .true.
+    mask_ibool(iglob8) = .true.
+  enddo
+
+  ! check that number of global points output is okay
+  if(numpoin /= npoin) &
+    call exit_MPI(myrank, &
+        'incorrect number of global points in AVS or DX file creation')
+
+  ! AVS or DX elements
+  do ispec=1,nspec
+    iglob1=ibool(1,1,1,ispec)
+    iglob2=ibool(NGLLX,1,1,ispec)
+    iglob3=ibool(NGLLX,NGLLY,1,ispec)
+    iglob4=ibool(1,NGLLY,1,ispec)
+    iglob5=ibool(1,1,NGLLZ,ispec)
+    iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+    iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+    iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+
+    avs_dx_adios%iglob1 = num_ibool_AVS_DX(iglob1)
+    avs_dx_adios%iglob2 = num_ibool_AVS_DX(iglob2)
+    avs_dx_adios%iglob3 = num_ibool_AVS_DX(iglob3)
+    avs_dx_adios%iglob4 = num_ibool_AVS_DX(iglob4)
+    avs_dx_adios%iglob5 = num_ibool_AVS_DX(iglob5)
+    avs_dx_adios%iglob6 = num_ibool_AVS_DX(iglob6)
+    avs_dx_adios%iglob7 = num_ibool_AVS_DX(iglob7)
+    avs_dx_adios%iglob8 = num_ibool_AVS_DX(iglob8)
+  enddo
+  avs_dx_adios%idoubling = idoubling
+end subroutine prepare_AVS_DX_global_data_adios
+
+!===============================================================================
+!> Schedule write to ADIOS file for global AVS/DX data
+!! \param adios_handle The handle to the ADIOS file we want to write into
+!! \param nspec Number of spectral elements
+!! \avs_dx_adios Structure with the data that have to be wrtten
+subroutine write_AVS_DX_global_data_adios(adios_handle, myrank, &
+    sizeprocs, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+  implicit none
+  !--- Arguments
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: myrank, sizeprocs
+  type(avs_dx_global_t), intent(inout) :: avs_dx_adios ! out for adios_write
+  !--- Variables
+  integer :: npoin, nspec
+  integer :: ierr
+  
+  npoin = avs_dx_adios%npoin
+  nspec = avs_dx_adios%nspec
+
+  call adios_set_path(adios_handle, "points/x_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%x_adios, ierr)
+
+  call adios_set_path(adios_handle, "points/y_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%y_adios, ierr)
+
+  call adios_set_path(adios_handle, "points/z_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%z_adios, ierr)
+
+
+  call adios_set_path(adios_handle, "elements/idoubling", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%idoubling, ierr)
+
+
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob1", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob1, ierr)
+  
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob2", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob2, ierr)
+  
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob3", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob3, ierr)
+  
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob4", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob4, ierr)
+  
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob5", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob5, ierr)
+  
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob6", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob6, ierr)
+
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob7", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob7, ierr)
+
+  call adios_set_path(adios_handle, "elements/num_ibool_AVS_DX_iglob1", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob8, ierr)
+end subroutine write_AVS_DX_global_data_adios
+
+!===============================================================================
+!> Free temporary structure filled to write AVS/DX global variable to file.
+!! \param myrank The MPI rank of the process
+!! \param avs_dx_adios The structure holding AVS/DX information
+subroutine free_AVS_DX_global_data_adios(myrank, avs_dx_adios)
+  implicit none
+  !--- Arguments
+  integer, intent(in) :: myrank
+  type(avs_dx_global_t), intent(inout) :: avs_dx_adios
+  !--- Variables
+  integer :: ierr
+
+  deallocate(avs_dx_adios%x_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating x_adios.")
+  deallocate(avs_dx_adios%y_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating y_adios.")
+  deallocate(avs_dx_adios%z_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating z_adios.")
+
+  deallocate(avs_dx_adios%idoubling, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob1, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob2, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob2.")
+  deallocate(avs_dx_adios%iglob3, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob3.")
+  deallocate(avs_dx_adios%iglob4, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob4.")
+  deallocate(avs_dx_adios%iglob5, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob5.")
+  deallocate(avs_dx_adios%iglob6, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob6.")
+  deallocate(avs_dx_adios%iglob7, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob7.")
+  deallocate(avs_dx_adios%iglob8, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob8.")
+
+  avs_dx_adios%npoin = 0 
+  avs_dx_adios%nspec = 0
+end subroutine free_AVS_DX_global_data_adios
+
+end module AVS_DX_global_mod

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_faces_data_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/write_AVS_DX_global_faces_data_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_faces_data_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_global_faces_data_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,825 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file write_AVS_DX_global_faces_data_adios.f90
+!! \brief create AVS or DX 2D data for the faces of the slice,
+!!        to be recombined in postprocessing
+!! \author MPBL
+!-------------------------------------------------------------------------------
+
+!===============================================================================
+module AVS_DX_global_faces_mod
+
+  implicit none
+
+  type avs_dx_global_faces_t
+    integer(kind=4) :: npoin, nspecface
+    real(kind=4), dimension(:), allocatable :: x_adios, y_adios, z_adios
+    integer(kind=4), dimension(:), allocatable :: idoubling, iglob1, iglob2, &
+        iglob3, iglob4
+    real, dimension(:), allocatable :: dvp, dvs
+  endtype
+
+contains
+
+!===============================================================================
+subroutine define_AVS_DX_global_faces_data_adios (adios_group, &
+    myrank, prname, nspec, iMPIcut_xi,iMPIcut_eta, &
+    ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+    npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN,iregion_code, &
+    group_size_inc, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+
+  implicit none
+  include "constants.h"
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer nspec,myrank
+  integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
+
+  integer idoubling(nspec)
+
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  logical iMPIcut_xi(2,nspec)
+  logical iMPIcut_eta(2,nspec)
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+      R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+! logical mask used to output global points only once
+  integer npointot
+  logical mask_ibool(npointot)
+
+! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+
+  integer ispec
+  integer i,j,k,np
+  integer iglob1,iglob2,iglob3,iglob4,iglob5,iglob6,iglob7,iglob8
+  integer npoin,numpoin,nspecface,ispecface
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+! processor identification
+  character(len=150) prname
+
+  integer iregion_code
+
+  type(avs_dx_global_faces_t), intent(inout) :: avs_dx_adios
+
+  integer :: ierr
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+    ! only if on face
+    if(iMPIcut_xi(1,ispec) .or. iMPIcut_xi(2,ispec) .or. &
+        iMPIcut_eta(1,ispec) .or. iMPIcut_eta(2,ispec)) then
+      iglob1=ibool(1,1,1,ispec)
+      iglob2=ibool(NGLLX,1,1,ispec)
+      iglob3=ibool(NGLLX,NGLLY,1,ispec)
+      iglob4=ibool(1,NGLLY,1,ispec)
+      iglob5=ibool(1,1,NGLLZ,ispec)
+      iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+      iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iMPIcut_xi(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob8) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+    ! face xi = xi_max
+      if(iMPIcut_xi(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob6) = .true.
+      endif
+
+    ! face eta = eta_min
+      if(iMPIcut_eta(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob6) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+    ! face eta = eta_max
+      if(iMPIcut_eta(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob8) = .true.
+      endif
+    endif
+  enddo
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+  
+  avs_dx_adios%npoin = npoin
+  avs_dx_adios%nspecface = nspecface
+
+  allocate(avs_dx_adios%x_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating x_adios.")
+  allocate(avs_dx_adios%y_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating y_adios.")
+  allocate(avs_dx_adios%z_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating z_adios.")
+
+  ! Allocate temporary arrays for AVS/DX elements.
+  allocate(avs_dx_adios%idoubling(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating idoubling.")
+  allocate(avs_dx_adios%iglob1(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob1.")
+  allocate(avs_dx_adios%iglob2(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob2.")
+  allocate(avs_dx_adios%iglob3(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob3.")
+  allocate(avs_dx_adios%iglob4(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob4.")
+
+  !--- Variables for '...AVS_DXpointsfaces.txt'
+  call define_adios_global_real_1d_array(adios_group, "points_faces/x_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points_faces/y_value", &
+      npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "points_faces/z_value", &
+      npoin, group_size_inc)
+  !--- Variables for AVS_DXelementsfaces.txt
+  call define_adios_global_real_1d_array(adios_group, & 
+      "elements_faces/idoubling", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_faces/num_ibool_AVS_DX_iglob1", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_faces/num_ibool_AVS_DX_iglob2", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_faces/num_ibool_AVS_DX_iglob3", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_faces/num_ibool_AVS_DX_iglob4", nspecface, group_size_inc)
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    allocate(avs_dx_adios%dvp(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvp.")
+    allocate(avs_dx_adios%dvs(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvs.")
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_faces/dvp", dvp, group_size_inc)
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_faces/dvp", dvs, group_size_inc)
+  endif
+
+end subroutine define_AVS_DX_global_faces_data_adios
+
+!===============================================================================
+subroutine prepare_AVS_DX_global_faces_data_adios (myrank, prname, nspec, &
+        iMPIcut_xi,iMPIcut_eta, &
+        ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool, &
+        npointot,rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+        ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+        RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+        RMIDDLE_CRUST,ROCEAN,iregion_code, &
+        avs_dx_adios)
+
+  implicit none
+
+  include "constants.h"
+
+  integer nspec,myrank
+  integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
+
+  integer idoubling(nspec)
+
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  logical iMPIcut_xi(2,nspec)
+  logical iMPIcut_eta(2,nspec)
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+    R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+! logical mask used to output global points only once
+  integer npointot
+  logical mask_ibool(npointot)
+
+! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+
+  integer ispec
+  integer i,j,k,np
+  integer iglob1,iglob2,iglob3,iglob4,iglob5,iglob6,iglob7,iglob8
+  integer npoin,numpoin,nspecface,ispecface
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+! processor identification
+  character(len=150) prname
+
+  integer iregion_code
+
+  type(avs_dx_global_faces_t), intent(inout) :: avs_dx_adios
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+! mark global AVS or DX points
+  do ispec=1,nspec
+  ! only if on face
+    if(iMPIcut_xi(1,ispec) .or. iMPIcut_xi(2,ispec) .or. &
+                iMPIcut_eta(1,ispec) .or. iMPIcut_eta(2,ispec)) then
+      iglob1=ibool(1,1,1,ispec)
+      iglob2=ibool(NGLLX,1,1,ispec)
+      iglob3=ibool(NGLLX,NGLLY,1,ispec)
+      iglob4=ibool(1,NGLLY,1,ispec)
+      iglob5=ibool(1,1,NGLLZ,ispec)
+      iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+      iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iMPIcut_xi(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob8) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+      ! face xi = xi_max
+      if(iMPIcut_xi(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob6) = .true.
+      endif
+
+      ! face eta = eta_min
+      if(iMPIcut_eta(1,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob6) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+      ! face eta = eta_max
+      if(iMPIcut_eta(2,ispec)) then
+        nspecface = nspecface + 1
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob8) = .true.
+      endif
+
+    endif
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  ! output global AVS or DX points
+  numpoin = 0
+  do ispec=1,nspec
+    ! only if on face
+    if(iMPIcut_xi(1,ispec) .or. iMPIcut_xi(2,ispec) .or. &
+                iMPIcut_eta(1,ispec) .or. iMPIcut_eta(2,ispec)) then
+      iglob1=ibool(1,1,1,ispec)
+      iglob2=ibool(NGLLX,1,1,ispec)
+      iglob3=ibool(NGLLX,NGLLY,1,ispec)
+      iglob4=ibool(1,NGLLY,1,ispec)
+      iglob5=ibool(1,1,NGLLZ,ispec)
+      iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+      iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! face xi = xi_min
+      if(iMPIcut_xi(1,ispec)) then
+        if(.not. mask_ibool(iglob1)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob1) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob4)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob4) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,1,ispec)) 
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob8)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob8) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+        endif
+        if(.not. mask_ibool(iglob5)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob5) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+        endif
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob8) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+      ! face xi = xi_max
+      if(iMPIcut_xi(2,ispec)) then
+        if(.not. mask_ibool(iglob2)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob2) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob3)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob3) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,1,ispec)) 
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob7)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob7) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+        endif
+        if(.not. mask_ibool(iglob6)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob6) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+        endif
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob6) = .true.
+      endif
+
+      ! face eta = eta_min
+      if(iMPIcut_eta(1,ispec)) then
+        if(.not. mask_ibool(iglob1)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob1) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob2)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob2) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob6)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob6) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+        endif
+        if(.not. mask_ibool(iglob5)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob5) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+        endif
+        mask_ibool(iglob1) = .true.
+        mask_ibool(iglob2) = .true.
+        mask_ibool(iglob6) = .true.
+        mask_ibool(iglob5) = .true.
+      endif
+
+      ! face eta = eta_max
+      if(iMPIcut_eta(2,ispec)) then
+        if(.not. mask_ibool(iglob4)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob4) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob3)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob3) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,1,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,1,ispec))
+        endif
+        if(.not. mask_ibool(iglob7)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob7) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+        endif
+        if(.not. mask_ibool(iglob8)) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglob8) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+        endif
+        mask_ibool(iglob4) = .true.
+        mask_ibool(iglob3) = .true.
+        mask_ibool(iglob7) = .true.
+        mask_ibool(iglob8) = .true.
+      endif
+
+    endif
+  enddo
+
+  ! check that number of global points output is okay
+  if(numpoin /= npoin) &
+    call exit_MPI(myrank, &
+        'incorrect number of global points in AVS or DX file creation')
+
+  ! output global AVS or DX elements
+
+  ispecface = 0
+  do ispec=1,nspec
+!    print *, ispecface, nspecface
+    ! only if on face
+    if(iMPIcut_xi(1,ispec) .or. iMPIcut_xi(2,ispec) .or. &
+                iMPIcut_eta(1,ispec) .or. iMPIcut_eta(2,ispec)) then
+      iglob1=ibool(1,1,1,ispec)
+      iglob2=ibool(NGLLX,1,1,ispec)
+      iglob3=ibool(NGLLX,NGLLY,1,ispec)
+      iglob4=ibool(1,NGLLY,1,ispec)
+      iglob5=ibool(1,1,NGLLZ,ispec)
+      iglob6=ibool(NGLLX,1,NGLLZ,ispec)
+      iglob7=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglob8=ibool(1,NGLLY,NGLLZ,ispec)
+if (iglob1 > npointot) print *, myrank, "problem with iglob1", iglob1, npointot
+if (iglob2 > npointot) print *, myrank, "problem with iglob2", iglob2, npointot
+if (iglob3 > npointot) print *, myrank, "problem with iglob3", iglob3, npointot
+if (iglob4 > npointot) print *, myrank, "problem with iglob4", iglob4, npointot
+if (iglob5 > npointot) print *, myrank, "problem with iglob5", iglob5, npointot
+if (iglob6 > npointot) print *, myrank, "problem with iglob6", iglob6, npointot
+if (iglob7 > npointot) print *, myrank, "problem with iglob7", iglob7, npointot
+if (iglob8 > npointot) print *, myrank, "problem with iglob8", iglob8, npointot
+
+if (iglob1 < 0) print *, myrank, "problem with iglob1", iglob1, npointot
+if (iglob2 < 0) print *, myrank, "problem with iglob2", iglob2, npointot
+if (iglob3 < 0) print *, myrank, "problem with iglob3", iglob3, npointot
+if (iglob4 < 0) print *, myrank, "problem with iglob4", iglob4, npointot
+if (iglob5 < 0) print *, myrank, "problem with iglob5", iglob5, npointot
+if (iglob6 < 0) print *, myrank, "problem with iglob6", iglob6, npointot
+if (iglob7 < 0) print *, myrank, "problem with iglob7", iglob7, npointot
+if (iglob8 < 0) print *, myrank, "problem with iglob8", iglob8, npointot
+
+      ! include lateral variations if needed
+      if(ISOTROPIC_3D_MANTLE) then
+        ! pick a point within the element and get its radius
+        r = dsqrt(xstore(2,2,2,ispec)**2 &
+            + ystore(2,2,2,ispec)**2 &
+            + zstore(2,2,2,ispec)**2)
+
+        if(r > RCMB/R_EARTH .and. r < R_UNIT_SPHERE) then
+          ! average over the element
+          dvp = 0.0
+          dvs = 0.0
+          np =0
+          do k=2,NGLLZ-1
+            do j=2,NGLLY-1
+              do i=2,NGLLX-1
+                np=np+1
+                x=xstore(i,j,k,ispec)
+                y=ystore(i,j,k,ispec)
+                z=zstore(i,j,k,ispec)
+                r=dsqrt(x*x+y*y+z*z)
+                ! take out ellipticity
+                if(ELLIPTICITY) then
+                  call xyz_2_rthetaphi_dble(x,y,z,r,theta,phi_dummy)
+                  cost=dcos(theta)
+                  p20=0.5d0*(3.0d0*cost*cost-1.0d0)
+                  call spline_evaluation(rspl,espl,espl2,nspl,r,ell)
+                  factor=ONE-(TWO/3.0d0)*ell*p20
+                  r=r/factor
+                endif
+
+                ! gets reference model values:rho,vpv,vph,vsv,vsh and eta_aniso
+                call meshfem3D_models_get1D_val(myrank, iregion_code, &
+                    idoubling(ispec), r, rho, vpv, vph, vsv, vsh, eta_aniso, &
+                    Qkappa, Qmu, RICB, RCMB, RTOPDDOUBLEPRIME, R80, R120, & 
+                    R220, R400, R600, R670, R771, RMOHO, RMIDDLE_CRUST, ROCEAN)
+
+                 ! calculates isotropic values
+                vp = sqrt(((8.d0+4.d0*eta_aniso)*vph*vph + 3.d0*vpv*vpv &
+                        + (8.d0 - 8.d0*eta_aniso)*vsv*vsv)/15.d0)
+                vs = sqrt(((1.d0-2.d0*eta_aniso)*vph*vph + vpv*vpv &
+                        + 5.d0*vsh*vsh + (6.d0+4.d0*eta_aniso)*vsv*vsv)/15.d0)
+
+                if( abs(rhostore(i,j,k,ispec))< 1.e-20 ) then
+                  print*,'attention: rhostore close to zero', &
+                      rhostore(i,j,k,ispec),r,i,j,k,ispec
+                  dvp = 0.0
+                  dvs = 0.0
+                else if( abs(sngl(vp))< 1.e-20 ) then
+                  print*,' attention: vp close to zero',sngl(vp),r,i,j,k,ispec
+                  dvp = 0.0
+                else if( abs(sngl(vs))< 1.e-20 ) then
+                  print*,' attention: vs close to zero',sngl(vs),r,i,j,k,ispec
+                  dvs = 0.0
+                else
+                  dvp = dvp + (sqrt((kappavstore(i,j,k,ispec) &
+                      +4.*muvstore(i,j,k,ispec)/3.)/rhostore(i,j,k,ispec)) &
+                      - sngl(vp))/sngl(vp)
+                  dvs = dvs &
+                      + (sqrt(muvstore(i,j,k,ispec)/rhostore(i,j,k,ispec)) &
+                      - sngl(vs))/sngl(vs)
+                endif
+
+              enddo
+            enddo
+          enddo
+          dvp = dvp / np
+          dvs = dvs / np
+        else
+          dvp = 0.0
+          dvs = 0.0
+        endif
+      endif
+
+      ! face xi = xi_min
+      if(iMPIcut_xi(1,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglob1)
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglob4)
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglob8)
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglob5)
+        if(ISOTROPIC_3D_MANTLE)  then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+      ! face xi = xi_max
+      if(iMPIcut_xi(2,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface)= num_ibool_AVS_DX(iglob2)
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglob3)
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglob7)
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglob6)
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+      ! face eta = eta_min
+      if(iMPIcut_eta(1,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglob1)
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglob2)
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglob6)
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglob5)
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+      ! face eta = eta_max
+      if(iMPIcut_eta(2,ispec)) then
+        ispecface = ispecface + 1
+        avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+        avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglob4)
+        avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglob3)
+        avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglob7)
+        avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglob8)
+        if(ISOTROPIC_3D_MANTLE) then
+          avs_dx_adios%dvp(ispecface) = dvp
+          avs_dx_adios%dvs(ispecface) = dvs
+        endif
+      endif
+
+    endif
+  enddo
+
+  ! check that number of surface elements output is okay
+  if(ispecface /= nspecface) &
+    call exit_MPI(myrank,&
+        'incorrect number of surface elements in AVS or DX file creation')
+
+end subroutine prepare_AVS_DX_global_faces_data_adios
+
+!===============================================================================
+subroutine write_AVS_DX_global_faces_data_adios(adios_handle, myrank, &
+    sizeprocs, avs_dx_adios, ISOTROPIC_3D_MANTLE)
+  use mpi
+  use adios_write_mod
+  implicit none
+  !--- Arguments
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: myrank, sizeprocs
+  type(avs_dx_global_faces_t), intent(inout) :: avs_dx_adios ! out for adios_write
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  integer :: npoin, nspec
+  integer :: ierr
+  
+  npoin = avs_dx_adios%npoin
+  nspec = avs_dx_adios%nspecface
+
+  call adios_set_path(adios_handle, "points_faces/x_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%x_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_faces/y_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%y_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_faces/z_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%z_adios, ierr)
+
+
+  call adios_set_path(adios_handle, "elements_faces/idoubling", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%idoubling, ierr)
+
+
+  call adios_set_path(adios_handle, &
+      "elements_faces/num_ibool_AVS_DX_iglob1", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob1, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_faces/num_ibool_AVS_DX_iglob2", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob2, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_faces/num_ibool_AVS_DX_iglob3", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob3, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_faces/num_ibool_AVS_DX_iglob4", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob4, ierr)
+  
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    call adios_set_path(adios_handle, "elements_faces/dvp", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvp, ierr)
+    call adios_set_path(adios_handle, "elements_faces/dvs", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvs, ierr)
+  endif
+
+end subroutine write_AVS_DX_global_faces_data_adios
+
+!===============================================================================
+subroutine free_AVS_DX_global_faces_data_adios(myrank, avs_dx_adios, &
+    ISOTROPIC_3D_MANTLE)
+  implicit none
+  !--- Arguments
+  integer, intent(in) :: myrank
+  type(avs_dx_global_faces_t), intent(inout) :: avs_dx_adios
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  !--- Variables
+  integer :: ierr
+
+  deallocate(avs_dx_adios%x_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating x_adios.")
+  deallocate(avs_dx_adios%y_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating y_adios.")
+  deallocate(avs_dx_adios%z_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating z_adios.")
+
+  deallocate(avs_dx_adios%idoubling, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob1, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob2, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob2.")
+  deallocate(avs_dx_adios%iglob3, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob3.")
+  deallocate(avs_dx_adios%iglob4, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob4.")
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    deallocate(avs_dx_adios%dvp, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvp.")
+    deallocate(avs_dx_adios%dvs, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvs.")
+  endif
+
+  avs_dx_adios%npoin = 0 
+  avs_dx_adios%nspecface = 0
+end subroutine free_AVS_DX_global_faces_data_adios
+
+end module

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_surface_data_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/meshfem3D/write_AVS_DX_surface_data_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_surface_data_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/write_AVS_DX_surface_data_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,577 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+! create AVS or DX 2D data for the surface of the model
+! to be recombined in postprocessing
+
+module AVS_DX_surface_mod
+
+  implicit none
+
+  type avs_dx_surface_t
+    integer(kind=4) :: npoin, nspecface
+    real(kind=4), dimension(:), allocatable :: x_adios, y_adios, z_adios
+    integer(kind=4), dimension(:), allocatable :: idoubling, iglob1, iglob2, &
+        iglob3, iglob4
+    real, dimension(:), allocatable :: dvp, dvs
+  endtype
+
+contains
+
+subroutine define_AVS_DX_surfaces_data_adios(adios_group, &
+    myrank,prname,nspec,iboun, &
+    ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,npointot,&
+    rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN,iregion_code, &
+    group_size_inc, avs_dx_adios)
+  use mpi
+  use adios_write_mod
+
+  implicit none
+
+  include "constants.h"
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer nspec,myrank
+  integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
+
+  integer idoubling(nspec)
+
+  logical iboun(6,nspec)
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+       R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+  double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+! logical mask used to output global points only once
+  integer npointot
+  logical mask_ibool(npointot)
+
+! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+
+  integer ispec
+  integer i,j,k,np
+  integer, dimension(8) :: iglobval
+  integer npoin,numpoin,nspecface,ispecface
+
+! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+! processor identification
+  character(len=150) prname
+
+  integer iregion_code
+
+  type(avs_dx_surface_t), intent(inout) :: avs_dx_adios
+
+  integer :: ierr
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+  ! only if at the surface (top plane)
+    if(iboun(6,ispec)) then
+
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! element is at the surface
+      nspecface = nspecface + 1
+      mask_ibool(iglobval(5)) = .true.
+      mask_ibool(iglobval(6)) = .true.
+      mask_ibool(iglobval(7)) = .true.
+      mask_ibool(iglobval(8)) = .true.
+    endif
+  enddo
+
+! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  avs_dx_adios%npoin = npoin
+  avs_dx_adios%nspecface = nspecface
+
+  allocate(avs_dx_adios%x_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating x_adios.")
+  allocate(avs_dx_adios%y_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating y_adios.")
+  allocate(avs_dx_adios%z_adios(npoin), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating z_adios.")
+  
+  ! Allocate temporary arrays for AVS/DX elements.
+  allocate(avs_dx_adios%idoubling(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating idoubling.")
+  allocate(avs_dx_adios%iglob1(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob1.")
+  allocate(avs_dx_adios%iglob2(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob2.")
+  allocate(avs_dx_adios%iglob3(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob3.")
+  allocate(avs_dx_adios%iglob4(nspecface), stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error allocating iglob4.")
+
+  !--- Variables for '...AVS_DXpointschunk.txt'
+  call define_adios_global_real_1d_array(adios_group, &
+      "points_surfaces/x_value", npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "points_surfaces/y_value", npoin, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "points_surfaces/z_value", npoin, group_size_inc)
+  !--- Variables for AVS_DXelementschunks.txt
+  call define_adios_global_real_1d_array(adios_group, & 
+      "elements_surfaces/idoubling", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob1", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob2", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob3", nspecface, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob4", nspecface, group_size_inc)
+
+  !--- Variables for AVS_DXelementschunks_dvp_dvs.txt
+  if(ISOTROPIC_3D_MANTLE) then 
+    allocate(avs_dx_adios%dvp(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvp.")
+    allocate(avs_dx_adios%dvs(nspecface), stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, "Error allocating dvs.")
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_surfaces/dvp", dvp, group_size_inc)
+    call define_adios_global_real_1d_array(adios_group, &
+        "elements_surfaces/dvp", dvs, group_size_inc)
+  endif
+
+end subroutine define_AVS_DX_surfaces_data_adios
+
+!===============================================================================
+subroutine prepare_AVS_DX_surfaces_data_adios(myrank,prname,nspec,iboun, &
+    ibool,idoubling,xstore,ystore,zstore,num_ibool_AVS_DX,mask_ibool,npointot,&
+    rhostore,kappavstore,muvstore,nspl,rspl,espl,espl2, &
+    ELLIPTICITY,ISOTROPIC_3D_MANTLE, &
+    RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771,R400,R120,R80,RMOHO, &
+    RMIDDLE_CRUST,ROCEAN,iregion_code, &
+    avs_dx_adios)
+
+  implicit none
+
+  include "constants.h"
+
+  integer nspec,myrank
+  integer ibool(NGLLX,NGLLY,NGLLZ,nspec)
+
+  integer idoubling(nspec)
+
+  logical iboun(6,nspec)
+  logical ELLIPTICITY,ISOTROPIC_3D_MANTLE
+
+  double precision RICB,RCMB,RTOPDDOUBLEPRIME,R600,R670,R220,R771, &
+       R400,R120,R80,RMOHO,RMIDDLE_CRUST,ROCEAN
+
+  double precision r,rho,vp,vs,Qkappa,Qmu
+  double precision vpv,vph,vsv,vsh,eta_aniso
+  double precision x,y,z,theta,phi_dummy,cost,p20,ell,factor
+  real(kind=CUSTOM_REAL) dvp,dvs
+
+  double precision xstore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision ystore(NGLLX,NGLLY,NGLLZ,nspec)
+  double precision zstore(NGLLX,NGLLY,NGLLZ,nspec)
+
+  real(kind=CUSTOM_REAL) kappavstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) muvstore(NGLLX,NGLLY,NGLLZ,nspec)
+  real(kind=CUSTOM_REAL) rhostore(NGLLX,NGLLY,NGLLZ,nspec)
+
+! logical mask used to output global points only once
+  integer npointot
+  logical mask_ibool(npointot)
+
+! numbering of global AVS or DX points
+  integer num_ibool_AVS_DX(npointot)
+
+  integer ispec
+  integer i,j,k,np
+  integer, dimension(8) :: iglobval
+  integer npoin,numpoin,nspecface,ispecface
+
+! for ellipticity
+  integer nspl
+  double precision rspl(NR),espl(NR),espl2(NR)
+
+! processor identification
+  character(len=150) prname
+
+  integer iregion_code
+
+  type(avs_dx_surface_t), intent(inout) :: avs_dx_adios
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  nspecface = 0
+
+  ! mark global AVS or DX points
+  do ispec=1,nspec
+    ! only if at the surface (top plane)
+    if(iboun(6,ispec)) then
+
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+  ! element is at the surface
+      nspecface = nspecface + 1
+      mask_ibool(iglobval(5)) = .true.
+      mask_ibool(iglobval(6)) = .true.
+      mask_ibool(iglobval(7)) = .true.
+      mask_ibool(iglobval(8)) = .true.
+
+    endif
+  enddo
+
+  ! count global number of AVS or DX points
+  npoin = count(mask_ibool(:))
+
+  ! erase the logical mask used to mark points already found
+  mask_ibool(:) = .false.
+
+  ! output global AVS or DX points
+  numpoin = 0
+  do ispec=1,nspec
+  ! only if at the surface
+    if(iboun(6,ispec)) then
+
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      ! top face
+      if(iboun(6,ispec)) then
+
+        if(.not. mask_ibool(iglobval(5))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(5)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,1,NGLLZ,ispec))
+        endif
+
+        if(.not. mask_ibool(iglobval(6))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(6)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,1,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,1,NGLLZ,ispec))
+        endif
+
+        if(.not. mask_ibool(iglobval(7))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(7)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(NGLLX,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(NGLLX,NGLLY,NGLLZ,ispec))
+        endif
+
+        if(.not. mask_ibool(iglobval(8))) then
+          numpoin = numpoin + 1
+          num_ibool_AVS_DX(iglobval(8)) = numpoin
+          avs_dx_adios%x_adios(numpoin) = sngl(xstore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%y_adios(numpoin) = sngl(ystore(1,NGLLY,NGLLZ,ispec))
+          avs_dx_adios%z_adios(numpoin) = sngl(zstore(1,NGLLY,NGLLZ,ispec))
+        endif
+
+        mask_ibool(iglobval(5)) = .true.
+        mask_ibool(iglobval(6)) = .true.
+        mask_ibool(iglobval(7)) = .true.
+        mask_ibool(iglobval(8)) = .true.
+      endif
+
+    endif
+  enddo
+
+  ! check that number of global points output is okay
+  if(numpoin /= npoin) &
+      call exit_MPI(myrank, &
+          'incorrect number of global points in AVS or DX file creation')
+
+  ! output global AVS or DX elements
+  ispecface = 0
+  do ispec=1,nspec
+    ! only if at the surface
+    if(iboun(6,ispec)) then
+
+      iglobval(5)=ibool(1,1,NGLLZ,ispec)
+      iglobval(6)=ibool(NGLLX,1,NGLLZ,ispec)
+      iglobval(7)=ibool(NGLLX,NGLLY,NGLLZ,ispec)
+      iglobval(8)=ibool(1,NGLLY,NGLLZ,ispec)
+
+      if(ISOTROPIC_3D_MANTLE) then
+        !   pick a point within the element and get its radius
+        r=dsqrt(xstore(2,2,2,ispec)**2 &
+            + ystore(2,2,2,ispec)**2+zstore(2,2,2,ispec)**2)
+
+        if(r > RCMB/R_EARTH .and. r < R_UNIT_SPHERE) then
+          !     average over the element
+          dvp = 0.0
+          dvs = 0.0
+          np =0
+          do k=2,NGLLZ-1
+            do j=2,NGLLY-1
+              do i=2,NGLLX-1
+                np=np+1
+                x=xstore(i,j,k,ispec)
+                y=ystore(i,j,k,ispec)
+                z=zstore(i,j,k,ispec)
+                r=dsqrt(x*x+y*y+z*z)
+                ! take out ellipticity
+                if(ELLIPTICITY) then
+                  call xyz_2_rthetaphi_dble(x,y,z,r,theta,phi_dummy)
+                  cost=dcos(theta)
+                  p20=0.5d0*(3.0d0*cost*cost-1.0d0)
+                  call spline_evaluation(rspl,espl,espl2,nspl,r,ell)
+                  factor=ONE-(TWO/3.0d0)*ell*p20
+                  r=r/factor
+                endif
+
+                ! gets reference model values: rho,vpv,vph,vsv,vsh and eta_aniso
+                call meshfem3D_models_get1D_val(myrank,iregion_code, &
+                            idoubling(ispec), &
+                            r,rho,vpv,vph,vsv,vsh,eta_aniso, &
+                            Qkappa,Qmu,RICB,RCMB, &
+                            RTOPDDOUBLEPRIME,R80,R120,R220,R400,R600,R670,R771, &
+                            RMOHO,RMIDDLE_CRUST,ROCEAN)
+
+                ! calculates isotropic values
+                vp = sqrt(((8.d0+4.d0*eta_aniso)*vph*vph + 3.d0*vpv*vpv &
+                    + (8.d0 - 8.d0*eta_aniso)*vsv*vsv)/15.d0)
+                vs = sqrt(((1.d0-2.d0*eta_aniso)*vph*vph + vpv*vpv &
+                    + 5.d0*vsh*vsh + (6.d0+4.d0*eta_aniso)*vsv*vsv)/15.d0)
+
+                if( abs(rhostore(i,j,k,ispec))< 1.e-20 ) then
+                  print*,' attention: rhostore close to zero', &
+                      rhostore(i,j,k,ispec),r,i,j,k,ispec
+                  dvp = 0.0
+                  dvs = 0.0
+                else if( abs(sngl(vp))< 1.e-20 ) then
+                  print*,' attention: vp close to zero',sngl(vp),r,i,j,k,ispec
+                  dvp = 0.0
+                else if( abs(sngl(vs))< 1.e-20 ) then
+                  print*,' attention: vs close to zero',sngl(vs),r,i,j,k,ispec
+                  dvs = 0.0
+                else
+                  dvp = dvp + (sqrt((kappavstore(i,j,k,ispec) &
+                      + 4.*muvstore(i,j,k,ispec)/3.) &
+                      / rhostore(i,j,k,ispec)) - sngl(vp))/sngl(vp)
+                  dvs = dvs &
+                      + (sqrt(muvstore(i,j,k,ispec)/rhostore(i,j,k,ispec)) &
+                      - sngl(vs))/sngl(vs)
+                endif
+
+              enddo
+            enddo
+          enddo
+          dvp = dvp / np
+          dvs = dvs / np
+        else
+          dvp = 0.0
+          dvs = 0.0
+        endif
+      endif
+
+      ! top face
+      ispecface = ispecface + 1
+      avs_dx_adios%idoubling(ispecface) = idoubling(ispec)
+      avs_dx_adios%iglob1(ispecface) = num_ibool_AVS_DX(iglobval(5))
+      avs_dx_adios%iglob2(ispecface) = num_ibool_AVS_DX(iglobval(6))
+      avs_dx_adios%iglob3(ispecface) = num_ibool_AVS_DX(iglobval(7))
+      avs_dx_adios%iglob4(ispecface) = num_ibool_AVS_DX(iglobval(8))
+      if(ISOTROPIC_3D_MANTLE) then
+        avs_dx_adios%dvp(ispecface) = dvp
+        avs_dx_adios%dvs(ispecface) = dvs
+      endif
+
+    endif
+  enddo
+
+  ! check that number of surface elements output is okay
+  if(ispecface /= nspecface) &
+      call exit_MPI(myrank,'&
+          incorrect number of surface elements in AVS or DX file creation')
+
+end subroutine prepare_AVS_DX_surfaces_data_adios 
+
+!===============================================================================
+subroutine write_AVS_DX_surfaces_data_adios(adios_handle, myrank, &
+    sizeprocs, avs_dx_adios, ISOTROPIC_3D_MANTLE)
+  use mpi
+  use adios_write_mod
+  implicit none
+  !--- Arguments
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: myrank, sizeprocs
+  type(avs_dx_surface_t), intent(inout) :: avs_dx_adios ! out for adios_write
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  integer :: npoin, nspec
+  integer :: ierr
+  
+  npoin = avs_dx_adios%npoin
+  nspec = avs_dx_adios%nspecface
+
+  call adios_set_path(adios_handle, "points_surfaces/x_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%x_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_surfaces/y_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%y_adios, ierr)
+
+  call adios_set_path(adios_handle, "points_surfaces/z_value", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      npoin, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%z_adios, ierr)
+
+
+  call adios_set_path(adios_handle, "elements_surfaces/idoubling", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%idoubling, ierr)
+
+
+  call adios_set_path(adios_handle, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob1", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob1, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob2", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob2, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob3", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob3, ierr)
+  
+  call adios_set_path(adios_handle, &
+      "elements_surfaces/num_ibool_AVS_DX_iglob4", ierr)
+  call write_1D_global_array_adios_dims(adios_handle, myrank, &
+      nspec, sizeprocs)
+  call adios_write(adios_handle, "array", avs_dx_adios%iglob4, ierr)
+  
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    call adios_set_path(adios_handle, "elements_surfaces/dvp", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvp, ierr)
+    call adios_set_path(adios_handle, "elements_surfaces/dvs", ierr)
+    call write_1D_global_array_adios_dims(adios_handle, myrank, &
+        nspec, sizeprocs)
+    call adios_write(adios_handle, "array", avs_dx_adios%dvs, ierr)
+  endif
+end subroutine write_AVS_DX_surfaces_data_adios
+
+!===============================================================================
+subroutine free_AVS_DX_surfaces_data_adios(myrank, avs_dx_adios, &
+    ISOTROPIC_3D_MANTLE)
+  implicit none
+  !--- Arguments
+  integer, intent(in) :: myrank
+  type(avs_dx_surface_t), intent(inout) :: avs_dx_adios
+  logical ISOTROPIC_3D_MANTLE
+  !--- Variables
+  !--- Variables
+  integer :: ierr
+
+  deallocate(avs_dx_adios%x_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating x_adios.")
+  deallocate(avs_dx_adios%y_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating y_adios.")
+  deallocate(avs_dx_adios%z_adios, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, "Error deallocating z_adios.")
+
+  deallocate(avs_dx_adios%idoubling, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob1, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob1.")
+  deallocate(avs_dx_adios%iglob2, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob2.")
+  deallocate(avs_dx_adios%iglob3, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob3.")
+  deallocate(avs_dx_adios%iglob4, stat=ierr)
+  if (ierr /= 0) call exit_MPI(myrank, &
+      "Error deallocating num_ibool_AVS_DX_iglob4.")
+
+  if(ISOTROPIC_3D_MANTLE) then 
+    deallocate(avs_dx_adios%dvp, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvp.")
+    deallocate(avs_dx_adios%dvs, stat=ierr)
+    if (ierr /= 0) call exit_MPI(myrank, &
+        "Error deallocating dvs.")
+  endif
+
+  avs_dx_adios%npoin = 0 
+  avs_dx_adios%nspecface = 0
+end subroutine free_AVS_DX_surfaces_data_adios
+
+
+end module

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_helpers.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/shared/adios_helpers.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_helpers.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_helpers.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,356 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+!-------------------------------------------------------------------------------
+!> \file adios_helpers.f90
+!! \brief Helpers to set up adios features.
+!! \author MPBL      
+!-------------------------------------------------------------------------------
+
+!===============================================================================
+!> Get the ADIOS error message from an adios error number if there is an error.
+!! \param adios_err The error code considered.
+subroutine check_adios_err(myrank, adios_err)
+  use adios_read_mod
+  implicit none
+  integer, intent(in) :: myrank, adios_err
+  character(len=1024) :: msg
+
+  if (adios_err /= 0) then
+    call adios_errmsg(msg)
+    print *, "process: ", myrank, ", error: ", msg
+    stop
+  endif
+end subroutine check_adios_err
+
+
+!===============================================================================
+!> Define an ADIOS scalar double precision variable and autoincrement 
+!! the adios group size by (8).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_adios_double_scalar (adios_group, name, path, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+
+  ! adios: 6 == real(kind=8) 
+  call adios_define_var (adios_group, name, path, 6,  "", "", "", varid)
+  group_size_inc = group_size_inc + 8
+end subroutine define_adios_double_scalar
+
+!===============================================================================
+!> Define an ADIOS scalar integer variable and autoincrement the adios
+!! group size by (4).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_adios_integer_scalar (adios_group, name, path, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+
+  ! adios: 2 == integer(kind=4) 
+  call adios_define_var (adios_group, name, path, adios_integer,  "", "", "", varid)
+  group_size_inc = group_size_inc + 4
+end subroutine define_adios_integer_scalar
+
+!===============================================================================
+!> Define an ADIOS scalar byte variable and autoincrement the adios
+!! group size by (1).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_adios_byte_scalar (adios_group, name, path, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+
+  ! adios: 0 == byte == any_data_type(kind=1) 
+  call adios_define_var (adios_group, name, path, 0,  "", "", "", varid)
+  group_size_inc = group_size_inc + 1
+end subroutine define_adios_byte_scalar
+
+!===============================================================================
+!> Define a local ADIOS array of integers and autoincrement the adios
+!! group size by (4 * number of elements).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param dim The number of elements in the 1D array. Required to
+!!            correctly increment adios group size.
+!! \param dim_str The "stringified" version of dim. Needed by adios
+!!                to define variables
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_adios_integer_local_array1D (adios_group, name, path, dim, dim_str, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path, dim_str
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  integer, intent(in)              :: dim
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+
+  ! adios: 2 == integer 
+  call adios_define_var (adios_group, name, path, 2,  dim_str, "", "", varid)
+  group_size_inc = group_size_inc + 4*dim
+end subroutine define_adios_integer_local_array1D
+
+!===============================================================================
+!> Define a local ADIOS array of doubles and autoincrement the adios
+!! group size by (8 * number of elements).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param dim The number of elements in the 1D array. Required to
+!!            correctly increment adios group size.
+!! \param dim_str The "stringified" version of dim. Needed by adios
+!!                to define variables
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_adios_double_local_array1D (adios_group, name, path, dim, dim_str, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path, dim_str
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  integer, intent(in)              :: dim
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+
+  ! adios: 6 == real(kind=8) 
+  call adios_define_var (adios_group, name, path, 6, dim_str, "", "", varid)
+  group_size_inc = group_size_inc + 8*dim
+end subroutine define_adios_double_local_array1D
+
+!===============================================================================
+!> Define a local ADIOS string and autoincrement the adios
+!! group size by (1 * string's length).
+!! \param adios_group The adios group where the variables belongs
+!! \param name The variable to be defined
+!! \param path The logical path structuring the data and containing
+!!             the variable 
+!! \param len The length of the string(number of character. in Fortran
+!!            it does not include a final '\0' -- null -- character)
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+!! \note Adios string are scalar values counting for (1) byte. It is
+!!       mandatory to increase the group size by the length of the
+!!       string in order not to overlap 'data regions'.
+subroutine define_adios_string (adios_group, name, path, length, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Arguments
+  integer(kind=8),  intent(in)     :: adios_group
+  character(len=*), intent(in)     :: name, path
+  integer(kind=8),  intent(inout)  :: group_size_inc
+  integer                          :: length
+  ! Local Variables
+  integer(kind=8)                  :: varid ! dummy variable, adios use var name
+  
+  ! adios: 9 == string 
+  call adios_define_var (adios_group, name, path, 9,  "", "", "", varid)
+  group_size_inc = group_size_inc + 1*length 
+end subroutine define_adios_string
+
+!===============================================================================
+!> Define a global ADIOS 1D real array and autoincrement the adios
+!! group size.
+!! \param adios_group The adios group where the variables belongs
+!! \param array_name The variable to be defined. This is actually the path for
+!!                   ADIOS. The values are stored in array_name/array
+!! \param len The local dimension of the array.
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+!! \note This function define local, global and offset sizes as well as the
+!!       array to store the values in.
+subroutine define_adios_global_real_1d_array(adios_group, array_name, &
+    local_dim, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_group
+  character(len=*), intent(in) :: array_name
+  integer, intent(in) :: local_dim
+  integer(kind=8), intent(inout) :: group_size_inc
+  ! Variables
+  integer(kind=8) :: var_id
+
+  call define_adios_integer_scalar (adios_group, "local_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "global_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "offset", array_name, &
+      group_size_inc)
+!  call adios_define_var(adios_group, "array", array_name, 6, &
+!      "local_dim", "global_dim", "offset", var_id)
+  call adios_define_var(adios_group, "array", array_name, 5, &
+      array_name // "/local_dim", array_name // "/global_dim", &
+      array_name // "/offset", var_id)
+  group_size_inc = group_size_inc + local_dim*4
+end subroutine define_adios_global_real_1d_array
+
+!===============================================================================
+!> Define a global ADIOS 1D integer array and autoincrement the adios
+!! group size.
+!! \param adios_group The adios group where the variables belongs
+!! \param array_name The variable to be defined. This is actually the path for
+!!                   ADIOS. The values are stored in array_name/array
+!! \param len The local dimension of the array.
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+!! \note This function define local, global and offset sizes as well as the
+!!       array to store the values in.
+subroutine define_adios_global_integer_1d_array(adios_group, array_name, &
+    local_dim, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_group
+  character(len=*), intent(in) :: array_name
+  integer, intent(in) :: local_dim
+  integer(kind=8), intent(inout) :: group_size_inc
+  ! Variables
+  integer(kind=8) :: var_id
+
+  call define_adios_integer_scalar (adios_group, "local_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "global_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "offset", array_name, &
+      group_size_inc)
+!  call adios_define_var(adios_group, "array", array_name, 6, &
+!      "local_dim", "global_dim", "offset", var_id)
+  call adios_define_var(adios_group, "array", array_name, 2, &
+      array_name // "/local_dim", array_name // "/global_dim", &
+      array_name // "/offset", var_id)
+  group_size_inc = group_size_inc + local_dim*4
+end subroutine define_adios_global_integer_1d_array
+
+!===============================================================================
+!> Define a global ADIOS 1D logical array and autoincrement the adios
+!! group size.
+!! \param adios_group The adios group where the variables belongs
+!! \param array_name The variable to be defined. This is actually the path for
+!!                   ADIOS. The values are stored in array_name/array
+!! \param len The local dimension of the array.
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+!! \note This function define local, global and offset sizes as well as the
+!!       array to store the values in.
+subroutine define_adios_global_logical_1d_array(adios_group, array_name, &
+    local_dim, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_group
+  character(len=*), intent(in) :: array_name
+  integer, intent(in) :: local_dim
+  integer(kind=8), intent(inout) :: group_size_inc
+  ! Variables
+  integer(kind=8) :: var_id
+
+  call define_adios_integer_scalar (adios_group, "local_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "global_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "offset", array_name, &
+      group_size_inc)
+!  call adios_define_var(adios_group, "array", array_name, 6, &
+!      "local_dim", "global_dim", "offset", var_id)
+  call adios_define_var(adios_group, "array", array_name, 1, &
+      array_name // "/local_dim", array_name // "/global_dim", &
+      array_name // "/offset", var_id)
+  group_size_inc = group_size_inc + local_dim*1
+end subroutine define_adios_global_logical_1d_array
+
+!===============================================================================
+!> Define a global ADIOS 1D real array and autoincrement the adios
+!! group size.
+!! \param adios_group The adios group where the variables belongs
+!! \param array_name The variable to be defined. This is actually the path for
+!!                   ADIOS. The values are stored in array_name/array
+!! \param len The local dimension of the array.
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+!! \note This function define local, global and offset sizes as well as the
+!!       array to store the values in.
+subroutine define_adios_global_double_1d_array(adios_group, array_name, &
+    local_dim, group_size_inc)
+  use adios_write_mod
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_group
+  character(len=*), intent(in) :: array_name
+  integer, intent(in) :: local_dim
+  integer(kind=8), intent(inout) :: group_size_inc
+  ! Variables
+  integer(kind=8) :: var_id
+
+  call define_adios_integer_scalar (adios_group, "local_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "global_dim", array_name, &
+      group_size_inc)
+  call define_adios_integer_scalar (adios_group, "offset", array_name, &
+      group_size_inc)
+  call adios_define_var(adios_group, "array", array_name, 6, &
+      array_name // "/local_dim", array_name // "/global_dim", &
+      array_name // "/offset", var_id)
+  group_size_inc = group_size_inc + local_dim*8
+end subroutine define_adios_global_double_1d_array

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_manager.F90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/shared/adios_manager.F90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_manager.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/adios_manager.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,51 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!> @brief Initialize ADIOS and setup the xml output file
+subroutine adios_setup()
+  use adios_write_mod, only: adios_init
+
+  implicit none
+  integer :: adios_err, sizeMB
+
+  call adios_init_noxml (adios_err);
+  sizeMB = 200 ! TODO 200MB is surely not the right size for the adios buffer
+  call adios_allocate_buffer (sizeMB , adios_err)
+end subroutine adios_setup
+
+!> @brief Finalize ADIOS. Must be called once everything is written down.
+subroutine adios_cleanup()
+  use mpi
+  use adios_write_mod, only: adios_finalize
+
+  implicit none
+  integer :: myrank
+  integer :: adios_err, ierr
+
+  call MPI_Comm_rank(MPI_COMM_WORLD, myrank, ierr)
+  call adios_finalize (myrank, adios_err)
+end subroutine adios_cleanup

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/broadcast_compute_parameters.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/broadcast_compute_parameters.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/broadcast_compute_parameters.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -320,10 +320,11 @@
 
   end subroutine broadcast_compute_parameters
 
-!
+
 !-------------------------------------------------------------------------------------------------
-!
-
+!> Broadcast the parameters relative to GPU computing settings.
+!! \param myrank The rank of the MPI process in COMM_WORLD
+!! \param GPU_MODE Flag to indicate that GPU computing is ON or OFF.
   subroutine broadcast_gpu_parameters(myrank,GPU_MODE)
 
   implicit none
@@ -342,3 +343,46 @@
   if( ier /= 0 ) call exit_MPI(myrank,'error broadcasting GPU_MODE')
 
   end subroutine broadcast_gpu_parameters
+
+!-------------------------------------------------------------------------------------------------
+!> Broadcast the parameters relative to ADIOS output settings.
+!! \param myrank The rank of the MPI process in COMM_WORLD
+!! \param ADIOS_ENABLED Flag to indicate ADIOS output for seismograms.
+!! \param ADIOS_FOR_FORWARD_ARRAYS Flag to indicate that intermediate and 
+!1        forward arrays are stored with the help of ADIOS.
+subroutine broadcast_adios_parameters(myrank,ADIOS_ENABLED,  &
+    ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, &
+    ADIOS_FOR_ARRAYS_SOLVER, ADIOS_FOR_SOLVER_MESHFILES, &
+    ADIOS_FOR_AVS_DX)
+
+  implicit none
+
+  ! standard include of the MPI library
+  include 'mpif.h'
+  include "constants.h"
+  include "precision.h"
+  
+  integer:: myrank
+  logical:: ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, &
+      ADIOS_FOR_ARRAYS_SOLVER, ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX
+  ! local parameters
+  integer :: ier
+  call MPI_BCAST(ADIOS_ENABLED,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank,'error broadcasting ADIOS_ENABLED')
+  call MPI_BCAST(ADIOS_FOR_FORWARD_ARRAYS,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank, &
+      'error broadcasting ADIOS_FOR_FORWARD_ARRAYS')
+  call MPI_BCAST(ADIOS_FOR_MPI_ARRAYS,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank, &
+      'error broadcasting ADIOS_FOR_MPI_ARRAYS')
+  call MPI_BCAST(ADIOS_FOR_ARRAYS_SOLVER,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank, &
+      'error broadcasting ADIOS_FOR_ARRAYS_SOLVER')
+  call MPI_BCAST(ADIOS_FOR_SOLVER_MESHFILES,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank, &
+      'error broadcasting ADIOS_FOR_SOLVER_MESHFILES')
+  call MPI_BCAST(ADIOS_FOR_AVS_DX,1,MPI_LOGICAL,0,MPI_COMM_WORLD,ier)
+  if( ier /= 0 ) call exit_MPI(myrank, &
+      'error broadcasting ADIOS_FOR_AVS_DX')
+
+end subroutine broadcast_adios_parameters

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/create_name_database.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/create_name_database.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/create_name_database.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -25,12 +25,11 @@
 !
 !=====================================================================
 
-  subroutine create_name_database(prname,iproc,iregion_code,LOCAL_PATH)
+subroutine create_name_database(prname,iproc,iregion_code,LOCAL_PATH)
 
 ! create the name of the database for the mesher and the solver
 
   implicit none
-
   integer iproc,iregion_code
 
 ! name of the database file
@@ -38,9 +37,26 @@
 
 ! create the name for the database of the current slide and region
   write(procname,"('/proc',i6.6,'_reg',i1,'_')") iproc,iregion_code
+! create full name with path
+  prname = trim(LOCAL_PATH) // procname
 
+end subroutine create_name_database
+
+subroutine create_name_database_adios(prname,iregion_code,LOCAL_PATH)
+
+  ! create the name of the database for the mesher and the solver
+
+  implicit none
+
+  integer iregion_code
+
+! name of the database file
+  character(len=150) prname,procname,LOCAL_PATH
+
+! create the name for the database of the current slide and region
+  write(procname,"('/reg',i1,'_')") iregion_code
+
 ! create full name with path
   prname = trim(LOCAL_PATH) // procname
 
-  end subroutine create_name_database
-
+end subroutine create_name_database_adios

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_parameter_file.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_parameter_file.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_parameter_file.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -48,7 +48,7 @@
 
   include "constants.h"
 
-! parameters read from parameter file
+  ! parameters read from parameter file
   integer NTSTEP_BETWEEN_OUTPUT_SEISMOS,NTSTEP_BETWEEN_READ_ADJSRC,NTSTEP_BETWEEN_FRAMES, &
           NTSTEP_BETWEEN_OUTPUT_INFO,NUMBER_OF_RUNS,NUMBER_OF_THIS_RUN,NCHUNKS,SIMULATION_TYPE, &
           MOVIE_VOLUME_TYPE,MOVIE_START,MOVIE_STOP, &
@@ -232,3 +232,43 @@
   call close_parameter_file()
 
   end subroutine read_gpu_mode
+
+
+!-------------------------------------------------------------------------------------------------
+!
+  subroutine read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, &
+      ADIOS_FOR_MPI_ARRAYS, ADIOS_FOR_ARRAYS_SOLVER, &
+      ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX)
+
+  implicit none
+  include "constants.h"
+
+  logical :: ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, &
+      ADIOS_FOR_ARRAYS_SOLVER, ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX
+
+  ! initializes flags
+  ADIOS_ENABLED = .false.
+  ADIOS_FOR_FORWARD_ARRAYS = .false.
+  ADIOS_FOR_MPI_ARRAYS = .false.
+  ADIOS_FOR_ARRAYS_SOLVER = .false.
+  ADIOS_FOR_SOLVER_MESHFILES = .false.
+  ADIOS_FOR_AVS_DX = .false.
+  ! opens file Par_file
+  call open_parameter_file()
+  call read_value_logical(ADIOS_ENABLED, 'solver.ADIOS_ENABLED')
+  if (ADIOS_ENABLED) then
+    call read_value_logical(ADIOS_FOR_FORWARD_ARRAYS, &
+        'solver.ADIOS_FOR_FORWARD_ARRAYS')
+    call read_value_logical(ADIOS_FOR_MPI_ARRAYS, &
+        'solver.ADIOS_FOR_MPI_ARRAYS')
+    call read_value_logical(ADIOS_FOR_ARRAYS_SOLVER, &
+        'solver.ADIOS_FOR_ARRAYS_SOLVER')
+    call read_value_logical(ADIOS_FOR_SOLVER_MESHFILES, &
+        'solver.ADIOS_FOR_ARRAYS_SOLVER')
+    call read_value_logical(ADIOS_FOR_AVS_DX, &
+        'solver.ADIOS_FOR_AVS_DX')
+  endif
+  call close_parameter_file()
+
+  end subroutine read_adios_parameters
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in	2013-06-30 12:40:04 UTC (rev 22453)
@@ -91,6 +91,8 @@
 CFLAGS = @CFLAGS@
 CPPFLAGS = -I../../setup @CPPFLAGS@
 
+LDFLAGS = @LDFLAGS@
+
 #AR = ar
 #ARFLAGS = cru
 #RANLIB = ranlib
@@ -245,7 +247,36 @@
 @COND_CUDA_TRUE at XSPECFEM_OBJECTS_PRE = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_OBJECTS)
 @COND_CUDA_FALSE at XSPECFEM_OBJECTS_PRE = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_STUBS)
 
+# using ADIOS files
+ADIOS_OBJECTS= \
+	$O/read_attenuation_adios.adios.o \
+	$O/read_mesh_databases_adios.adios.o \
+	$O/read_arrays_solver_adios.adios.o \
+	$O/save_forward_arrays_adios.adios.o \
+	$O/read_forward_arrays_adios.adios.o \
+	$O/write_specfem_adios_header.adios.o \
+	$O/adios_manager.shared_adios.o  \
+	$O/adios_helpers.shared_adios.o
+ADIOS_STUBS = \
+	$O/adios_empty_stubs.noadios.o
 
+ at COND_ADIOS_TRUE@XSPECFEM_OBJECTS_ADIOS = $(XSPECFEM_OBJECTS_PRE) $(ADIOS_OBJECTS)
+ at COND_ADIOS_FALSE@XSPECFEM_OBJECTS_ADIOS = $(XSPECFEM_OBJECTS_PRE) $(ADIOS_STUBS)
+
+# ADIOS
+# with configure: ./configure --with-cuda ADIOS_LIB=.. ADIOS_INC=.. MPI_INC=..
+ at COND_ADIOS_TRUE@ADIOS_LIBS = -ladiosf -lmxml
+ at COND_ADIOS_FALSE@ADIOS_LIBS = 
+
+ADIOS_LIB_LOCATION = @ADIOS_LIB@ @MXML_LIB@
+ADIOS_LINK = $(ADIOS_LIB_LOCATION) $(ADIOS_LIBS)
+ADIOS_INC = @ADIOS_INC@ -I../../setup -I../../ 
+
+#@COND_ADIOS_TRUE at CPPFLAGS = -I../../setup @CPPFLAGS@
+ at COND_ADIOS_TRUE@MPIFCCOMPILE_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(ADIOS_INC) $(FLAGS_CHECK)
+ at COND_ADIOS_TRUE@MPIFCCOMPILE_NO_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(ADIOS_INC) $(FLAGS_NO_CHECK)
+
+
 # vtk visualization
 VTK_OBJECTS = \
 	$O/visual_vtk.visualcc.o
@@ -253,8 +284,8 @@
 VTK_STUBS = \
 	$O/visual_vtk_stubs.visualc.o
 
- at COND_VTK_TRUE@XSPECFEM_OBJECTS = $(XSPECFEM_OBJECTS_PRE) $(VTK_OBJECTS)
- at COND_VTK_FALSE@XSPECFEM_OBJECTS = $(XSPECFEM_OBJECTS_PRE) $(VTK_STUBS)
+ at COND_VTK_TRUE@XSPECFEM_OBJECTS = $(XSPECFEM_OBJECTS_ADIOS) $(VTK_OBJECTS)
+ at COND_VTK_FALSE@XSPECFEM_OBJECTS = $(XSPECFEM_OBJECTS_ADIOS) $(VTK_STUBS)
 
 @COND_VTK_TRUE at CPPFLAGS = -I../../setup @CPPFLAGS@ -DWITH_VTK
 @COND_VTK_TRUE at FCCOMPILE_CHECK =@FCENV@ ${FC} ${FCFLAGS} $(FLAGS_CHECK) -DWITH_VTK
@@ -291,9 +322,9 @@
 
 xspecfem3D: $(XSPECFEM_OBJECTS)
 @COND_CUDA_TRUE@@COND_CUDA5_TRUE@	${NVCCLINK} -o $(CUDA_DEVICE_OBJ) $(CUDA_OBJECTS)
- at COND_CUDA_TRUE@@COND_CUDA5_TRUE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(CUDA_DEVICE_OBJ) $(MPILIBS) $(CUDA_LINK)
- at COND_CUDA_TRUE@@COND_CUDA5_FALSE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS) $(CUDA_LINK)
- at COND_CUDA_FALSE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS) $(CUDA_LINK)
+ at COND_CUDA_TRUE@@COND_CUDA5_TRUE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(CUDA_DEVICE_OBJ) $(MPILIBS) $(CUDA_LINK) $(ADIOS_LINK) $(LDFLAGS)
+ at COND_CUDA_TRUE@@COND_CUDA5_FALSE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS) $(CUDA_LINK) $(ADIOS_LINK) $(LDFLAGS)
+ at COND_CUDA_FALSE@	${FCLINK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS) $(CUDA_LINK) $(ADIOS_LINK) $(LDFLAGS)
 
 reqheader:
 	(cd ../create_header_file; make)
@@ -386,6 +417,29 @@
 #######################################
 
 ###
+### ADIOS compilation
+###
+
+$O/%.adios.o: %.F90 ${SETUP}/config.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.adios.o: %.f90 ${SETUP}/config.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.noadios.o: %.F90 
+	${FC} -c -o $@ $<
+
+$O/%.noadios.o: %.f90 
+	${FC} -c -o $@ $<
+
+$O/%.shared_adios.o: ${SHARED}/%.f90 ${SETUP}/constants.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.shared_adios.o: ${SHARED}/%.F90 ${SETUP}/constants.h
+	${MPIFC} -c $(ADIOS_INC) $(FCFLAGS) $(MPI_INC) -o $@ $<
+#######################################
+
+###
 ### VTK compilation
 ###
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/finalize_simulation.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/finalize_simulation.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/finalize_simulation.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -268,4 +268,7 @@
   ! synchronize all the processes to make sure everybody has finished
   call sync_all()
 
+  if (ADIOS_ENABLED) then
+    call adios_cleanup()
+  endif
   end subroutine finalize_simulation

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/get_attenuation.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/get_attenuation.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/get_attenuation.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -32,7 +32,7 @@
                                            scale_factor, tau_s, &
                                            vx, vy, vz, vnspec)
 
-  use specfem_par,only: ATTENUATION_VAL
+  use specfem_par,only: ATTENUATION_VAL, ADIOS_FOR_ARRAYS_SOLVER
 
   implicit none
 
@@ -57,15 +57,20 @@
 
   ! All of the following reads use the output parameters as their temporary arrays
   ! use the filename to determine the actual contents of the read
-  open(unit=27, file=prname(1:len_trim(prname))//'attenuation.bin', &
-        status='old',action='read',form='unformatted',iostat=ier)
-  if( ier /= 0 ) call exit_MPI(myrank,'error opening file attenuation.bin')
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call read_attenuation_adios(myrank, prname, & 
+       factor_common, scale_factor, tau_s, vx, vy, vz, vnspec, T_c_source)
+  else
+    open(unit=27, file=prname(1:len_trim(prname))//'attenuation.bin', &
+          status='old',action='read',form='unformatted',iostat=ier)
+    if( ier /= 0 ) call exit_MPI(myrank,'error opening file attenuation.bin')
 
-  read(27) tau_s
-  read(27) factor_common ! tau_e_store
-  read(27) scale_factor  ! Qmu_store
-  read(27) T_c_source
-  close(27)
+    read(27) tau_s
+    read(27) factor_common ! tau_e_store
+    read(27) scale_factor  ! Qmu_store
+    read(27) T_c_source
+    close(27)
+  endif
 
   scale_t = ONE/dsqrt(PI*GRAV*RHOAV)
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/initialize_simulation.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/initialize_simulation.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/initialize_simulation.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -107,7 +107,10 @@
 
     ! GPU_MODE: parameter is optional, may not be in the Par_file
     call read_gpu_mode(GPU_MODE)
-
+    ! ADIOS_ENABLED: parameter is optional, may not be in the Par_file
+    call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, &
+        ADIOS_FOR_MPI_ARRAYS, ADIOS_FOR_ARRAYS_SOLVER, &
+        ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX)
   endif
 
   ! distributes parameters from master to all processes
@@ -147,7 +150,10 @@
 
   ! broadcasts optional GPU_MODE
   call broadcast_gpu_parameters(myrank,GPU_MODE)
-
+  ! broadcasts optional ADIOS_ENABLED 
+  call broadcast_adios_parameters(myrank,ADIOS_ENABLED, &
+      ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, ADIOS_FOR_ARRAYS_SOLVER, &
+      ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX)
   ! get the base pathname for output files
   call get_value_string(OUTPUT_FILES, 'OUTPUT_FILES', 'OUTPUT_FILES')
 
@@ -315,6 +321,17 @@
     if(myrank == 0 ) call initialize_vtkwindow(GPU_MODE)
   endif
 
+  if (ADIOS_ENABLED) then
+    call adios_setup()
+  endif
+  !if (ADIOS_ENABLED) then
+    ! TODO use only one ADIOS group to write simulation parameters
+    !      i.e. merge write_solver... write_par_... into
+    !      write_specfem3D_globe_adios_header()
+    !call write_solver_info_header_ADIOS()
+    !call write_specfem_header_adios()
+  !endif
+
   end subroutine initialize_simulation
 
 !

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/prepare_timerun.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/prepare_timerun.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/prepare_timerun.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -745,7 +745,11 @@
   tau_sigma_dble(:) = 0.d0
 
   ! reads in attenuation values
-  call create_name_database(prnamel, myrank, IREGION_CRUST_MANTLE, LOCAL_PATH)
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call create_name_database_adios(prnamel, IREGION_CRUST_MANTLE, LOCAL_PATH)
+  else 
+    call create_name_database(prnamel, myrank, IREGION_CRUST_MANTLE, LOCAL_PATH)
+  endif
   call get_attenuation_model_3D_or_1D(myrank, prnamel, &
                                      omsb_crust_mantle_dble, &
                                      factor_common_crust_mantle_dble, &
@@ -760,7 +764,11 @@
   tau_sigma_dble = 0.d0
 
   ! reads in attenuation values
-  call create_name_database(prnamel, myrank, IREGION_INNER_CORE, LOCAL_PATH)
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call create_name_database_adios(prnamel, IREGION_INNER_CORE, LOCAL_PATH)
+  else
+    call create_name_database(prnamel, myrank, IREGION_INNER_CORE, LOCAL_PATH)
+  endif
   call get_attenuation_model_3D_or_1D(myrank, prnamel, &
                                      omsb_inner_core_dble, &
                                      factor_common_inner_core_dble, &

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_arrays_solver_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/read_arrays_solver_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_arrays_solver_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_arrays_solver_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,455 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!===============================================================================
+!> \brief Read adios arrays created by the mesher (file: regX_solver_data.bp)
+subroutine read_arrays_solver_adios(iregion_code,myrank, &
+              nspec,nglob,nglob_xy, &
+              nspec_iso,nspec_tiso,nspec_ani, &
+              rho_vp,rho_vs,xstore,ystore,zstore, &
+              xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz, &
+              rhostore, kappavstore,muvstore,kappahstore,muhstore,eta_anisostore, &
+              c11store,c12store,c13store,c14store,c15store,c16store,c22store, &
+              c23store,c24store,c25store,c26store,c33store,c34store,c35store, &
+              c36store,c44store,c45store,c46store,c55store,c56store,c66store, &
+              ibool,idoubling,ispec_is_tiso, &
+              rmassx,rmassy,rmassz,rmass_ocean_load, &
+              READ_KAPPA_MU,READ_TISO, &
+              ABSORBING_CONDITIONS,LOCAL_PATH)
+
+  use mpi 
+  use adios_read_mod
+  implicit none
+
+  include "constants.h"
+  include "OUTPUT_FILES/values_from_mesher.h"
+
+  integer :: iregion_code,myrank
+  integer :: nspec,nglob,nglob_xy
+  integer :: nspec_iso,nspec_tiso,nspec_ani
+
+  ! Stacey
+  real(kind=CUSTOM_REAL),dimension(NGLLX,NGLLY,NGLLZ,nspec):: rho_vp,rho_vs
+
+  real(kind=CUSTOM_REAL), dimension(nglob) :: xstore,ystore,zstore
+
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,nspec) :: &
+    xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz
+
+  ! material properties
+  real(kind=CUSTOM_REAL),dimension(NGLLX,NGLLY,NGLLZ,nspec_iso) :: &
+    rhostore,kappavstore,muvstore
+
+  ! additional arrays for anisotropy stored only where needed to save memory
+  real(kind=CUSTOM_REAL),dimension(NGLLX,NGLLY,NGLLZ,nspec_tiso) :: &
+    kappahstore,muhstore,eta_anisostore
+
+  ! additional arrays for full anisotropy
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,nspec_ani) :: &
+    c11store,c12store,c13store,c14store,c15store,c16store, &
+    c22store,c23store,c24store,c25store,c26store,c33store,c34store, &
+    c35store,c36store,c44store,c45store,c46store,c55store,c56store,c66store
+
+  ! global addressing
+  integer,dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
+  integer, dimension(nspec) :: idoubling
+  logical, dimension(nspec) :: ispec_is_tiso
+
+  ! mass matrices and additional ocean load mass matrix
+  real(kind=CUSTOM_REAL), dimension(nglob_xy) :: rmassx,rmassy
+  real(kind=CUSTOM_REAL), dimension(nglob)    :: rmassz
+  real(kind=CUSTOM_REAL), dimension(NGLOB_CRUST_MANTLE_OCEANS) :: rmass_ocean_load
+
+  ! flags to know if we should read Vs and anisotropy arrays
+  logical :: READ_KAPPA_MU,READ_TISO,ABSORBING_CONDITIONS
+
+  character(len=150) :: LOCAL_PATH, file_name
+
+  ! local parameters
+  integer :: ierr, comm, lnspec, lnglob, local_dim
+  ! processor identification
+  character(len=150) :: prname
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  integer(kind=8), dimension(256),target :: selections
+  integer :: sel_num, i
+  integer(kind=8), pointer :: sel => null()
+
+  sel_num = 0
+
+  ! create a prefix for the file name such as LOCAL_PATH/regX_
+  call create_name_database_adios(prname, iregion_code, LOCAL_PATH)
+
+  ! Postpend the actual file name.
+  file_name= trim(prname) // "solver_data.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  ! Setup the ADIOS library to read the file
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  ! read coordinates of the mesh
+  sel_num = sel_num+1
+  sel => selections(sel_num)
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec", 0, 1, &
+     lnspec, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nglob", 0, 1, &
+     lnglob, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec", lnspec, adios_err)
+  !call adios_get_scalar(adios_handle, "nglob", lnglob, adios_err)
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+
+  ! mesh coordinates
+  local_dim = nglob 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  sel_num = sel_num+1
+  sel => selections(sel_num)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "xstore/array", 0, 1, &
+      xstore, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ystore/array", 0, 1, &
+      ystore, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "zstore/array", 0, 1, &
+      zstore, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "rmassz/array", 0, 1, &
+      rmassz, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec_iso
+  start(1) = local_dim*myrank; count(1) = local_dim
+  sel_num = sel_num+1
+  sel => selections(sel_num)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "rhostore/array", 0, 1, &
+      rhostore, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "kappavstore/array", 0, 1, &
+      kappavstore, adios_err)
+  call check_adios_err(myrank,adios_err)
+  if(READ_KAPPA_MU) then 
+    call adios_schedule_read(adios_handle, sel, "muvstore/array", 0, 1, &
+        muvstore, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  if(TRANSVERSE_ISOTROPY_VAL .and. READ_TISO) then
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec_tiso
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "kappahstore/array", 0, 1, &
+        kappahstore, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "muhstore/array", 0, 1, &
+        muhstore, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "eta_anisostore/array", 0, 1, &
+        eta_anisostore, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  local_dim = nspec
+  start(1) = local_dim*myrank; count(1) = local_dim
+  sel_num = sel_num+1
+  sel => selections(sel_num)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "idoubling/array", 0, 1, &
+      idoubling, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ispec_is_tiso/array", 0, 1, &
+      ispec_is_tiso, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * nspec
+  start(1) = local_dim*myrank; count(1) = local_dim
+  sel_num = sel_num+1
+  sel => selections(sel_num)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibool/array", 0, 1, &
+      ibool, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "xixstore/array", 0, 1, &
+      xix, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "xiystore/array", 0, 1, &
+      xiy, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "xizstore/array", 0, 1, &
+      xiz, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "etaxstore/array", 0, 1, &
+      etax, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "etaystore/array", 0, 1, &
+      etay, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "etazstore/array", 0, 1, &
+      etaz, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "gammaxstore/array", 0, 1, &
+      gammax, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "gammaystore/array", 0, 1, &
+      gammay, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "gammazstore/array", 0, 1, &
+      gammaz, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+
+  if(ANISOTROPIC_INNER_CORE_VAL .and. iregion_code == IREGION_INNER_CORE) then
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec_ani 
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+
+    call adios_schedule_read(adios_handle, sel, "c11store/array", 0, 1, &
+        c11store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c12store/array", 0, 1, &
+        c12store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c13store/array", 0, 1, &
+        c13store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c33store/array", 0, 1, &
+        c33store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c44store/array", 0, 1, &
+        c44store, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  if(ANISOTROPIC_3D_MANTLE_VAL .and. iregion_code == IREGION_CRUST_MANTLE) then
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec_ani 
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+
+    call adios_schedule_read(adios_handle, sel, "c11store/array", 0, 1, &
+        c11store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c12store/array", 0, 1, &
+        c12store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c13store/array", 0, 1, &
+        c13store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c14store/array", 0, 1, &
+        c14store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c15store/array", 0, 1, &
+        c15store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c16store/array", 0, 1, &
+        c16store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c22store/array", 0, 1, &
+        c22store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c23store/array", 0, 1, &
+        c23store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c24store/array", 0, 1, &
+        c24store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c25store/array", 0, 1, &
+        c25store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c26store/array", 0, 1, &
+        c26store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c33store/array", 0, 1, &
+        c33store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c34store/array", 0, 1, &
+        c34store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c35store/array", 0, 1, &
+        c35store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c36store/array", 0, 1, &
+        c36store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c44store/array", 0, 1, &
+        c44store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c45store/array", 0, 1, &
+        c45store, adios_err)
+    call adios_schedule_read(adios_handle, sel, "c46store/array", 0, 1, &
+        c46store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c55store/array", 0, 1, &
+        c55store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c56store/array", 0, 1, &
+        c56store, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "c66store/array", 0, 1, &
+        c66store, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  ! Stacey
+  if(ABSORBING_CONDITIONS) then
+    local_dim = NGLLX * NGLLY * NGLLZ * nspec ! nspec_stacey in meshfem3D
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+
+    if(iregion_code == IREGION_CRUST_MANTLE) then
+      call adios_schedule_read(adios_handle, sel, "rho_vp/array", 0, 1, &
+          rho_vp, adios_err)
+      call check_adios_err(myrank,adios_err)
+      call adios_schedule_read(adios_handle, sel, "rho_vs/array", 0, 1, &
+          rho_vs, adios_err)
+      call check_adios_err(myrank,adios_err)
+    else if(iregion_code == IREGION_OUTER_CORE) then
+      call adios_schedule_read(adios_handle, sel, "rho_vp/array", 0, 1, &
+          rho_vp, adios_err)
+      call check_adios_err(myrank,adios_err)
+    endif
+
+  endif
+
+  ! mass matrices
+  !
+  ! in the case of stacey boundary conditions, add C*deltat/2 contribution to
+  ! the mass matrix on Stacey edges for the crust_mantle and outer_core regions
+  ! but not for the inner_core region thus the mass matrix must be replaced by
+  ! three mass matrices including the "C" damping matrix 
+  !
+  ! if absorbing_conditions are not set or if NCHUNKS=6, only one mass matrix
+  ! is needed for the sake of performance, only "rmassz" array will be filled
+  ! and "rmassx" & "rmassy" will be obsolete
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  if(NCHUNKS_VAL /= 6 .and. ABSORBING_CONDITIONS .and. &
+      iregion_code == IREGION_CRUST_MANTLE) then
+
+    local_dim = nglob_xy
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+
+    call adios_schedule_read(adios_handle, sel, "rmassx/array", 0, 1, &
+        rmassx, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "rmassy/array", 0, 1, &
+        rmassy, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  !call adios_perform_reads(adios_handle, adios_err)
+  !call check_adios_err(myrank,adios_err)
+
+  ! read additional ocean load mass matrix
+  if(OCEANS_VAL .and. iregion_code == IREGION_CRUST_MANTLE) then
+    local_dim = NGLOB_CRUST_MANTLE_OCEANS ! nglob_oceans
+    start(1) = local_dim*myrank; count(1) = local_dim
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count)
+
+    call adios_schedule_read(adios_handle, sel, "rmass_ocean_load/array", &
+        0, 1, rmass_ocean_load, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    !call adios_perform_reads(adios_handle, adios_err)
+    !call check_adios_err(myrank,adios_err)
+  endif
+
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+
+  ! Clean everything and close the ADIOS file
+  do i = 1, sel_num
+    sel => selections(i)
+    call adios_selection_delete(sel)
+  enddo
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+  ! checks dimensions
+  if( lnspec /= nspec ) then
+    print*,'error file dimension: nspec in file = ',lnspec, &
+        ' but nspec desired:',nspec
+    print*,'please check file ', file_name
+    call exit_mpi(myrank,'error dimensions in solver_data.bp')
+  endif
+  if( lnglob /= nglob ) then
+    print*,'error file dimension: nglob in file = ',lnglob, &
+        ' but nglob desired:',nglob
+    print*,'please check file ', file_name
+    call exit_mpi(myrank,'error dimensions in solver_data.bp')
+  endif
+
+end subroutine read_arrays_solver_adios

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_attenuation_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/read_attenuation_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_attenuation_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_attenuation_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,127 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+!===============================================================================
+!> \brief Read adios attenuation arrays created by the mesher
+!         (regX_attenuation.bp)
+subroutine read_attenuation_adios(myrank, prname, &
+   factor_common, scale_factor, tau_s, vx, vy, vz, vnspec, T_c_source)
+
+  use adios_read_mod
+  use specfem_par,only: ATTENUATION_VAL
+
+  implicit none
+
+  include 'constants.h'
+  include 'mpif.h'
+
+  integer :: myrank
+
+  integer :: vx,vy,vz,vnspec
+  double precision, dimension(vx,vy,vz,vnspec)       :: scale_factor
+  double precision, dimension(N_SLS,vx,vy,vz,vnspec) :: factor_common
+  double precision, dimension(N_SLS)                 :: tau_s
+
+  character(len=150) :: prname
+
+  ! local parameters
+  integer :: i,j,k,ispec,ier
+  double precision, dimension(N_SLS) :: tau_e, fc
+  double precision :: omsb, Q_mu, sf, T_c_source, scale_t
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  ! checks if attenuation is on and anything to do
+  if( .not. ATTENUATION_VAL) return
+
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  ! All of the following reads use the output parameters as their temporary arrays
+  ! use the filename to determine the actual contents of the read
+  file_name= trim(prname) // "attenuation.bp" 
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "T_c_source", 0, 1, &
+     T_c_source, adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = size (tau_s) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "tau_s/array", 0, 1, &
+    tau_s, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = size (factor_common) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "tau_e_store/array", 0, 1, &
+    factor_common, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = size (scale_factor) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "Qmu_store/array", 0, 1, &
+    scale_factor, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+end subroutine read_attenuation_adios

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -71,47 +71,51 @@
 
   ! read files back from local disk or MT tape system if restart file
   if(NUMBER_OF_THIS_RUN > 1) then
-    write(outputname,"('dump_all_arrays',i6.6)") myrank
-    open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname,status='old',action='read',form='unformatted')
+    if (ADIOS_FOR_FORWARD_ARRAYS) then
+      call read_intermediate_forward_arrays_adios()
+    else
+      write(outputname,"('dump_all_arrays',i6.6)") myrank
+      open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname,status='old',action='read',form='unformatted')
 
-    read(55) displ_crust_mantle
-    read(55) veloc_crust_mantle
-    read(55) accel_crust_mantle
-    read(55) displ_inner_core
-    read(55) veloc_inner_core
-    read(55) accel_inner_core
-    read(55) displ_outer_core
-    read(55) veloc_outer_core
-    read(55) accel_outer_core
+      read(55) displ_crust_mantle
+      read(55) veloc_crust_mantle
+      read(55) accel_crust_mantle
+      read(55) displ_inner_core
+      read(55) veloc_inner_core
+      read(55) accel_inner_core
+      read(55) displ_outer_core
+      read(55) veloc_outer_core
+      read(55) accel_outer_core
 
-    read(55) epsilondev_xx_crust_mantle
-    read(55) epsilondev_yy_crust_mantle
-    read(55) epsilondev_xy_crust_mantle
-    read(55) epsilondev_xz_crust_mantle
-    read(55) epsilondev_yz_crust_mantle
+      read(55) epsilondev_xx_crust_mantle
+      read(55) epsilondev_yy_crust_mantle
+      read(55) epsilondev_xy_crust_mantle
+      read(55) epsilondev_xz_crust_mantle
+      read(55) epsilondev_yz_crust_mantle
 
-    read(55) epsilondev_xx_inner_core
-    read(55) epsilondev_yy_inner_core
-    read(55) epsilondev_xy_inner_core
-    read(55) epsilondev_xz_inner_core
-    read(55) epsilondev_yz_inner_core
+      read(55) epsilondev_xx_inner_core
+      read(55) epsilondev_yy_inner_core
+      read(55) epsilondev_xy_inner_core
+      read(55) epsilondev_xz_inner_core
+      read(55) epsilondev_yz_inner_core
 
-    read(55) A_array_rotation
-    read(55) B_array_rotation
+      read(55) A_array_rotation
+      read(55) B_array_rotation
 
-    read(55) R_xx_crust_mantle
-    read(55) R_yy_crust_mantle
-    read(55) R_xy_crust_mantle
-    read(55) R_xz_crust_mantle
-    read(55) R_yz_crust_mantle
+      read(55) R_xx_crust_mantle
+      read(55) R_yy_crust_mantle
+      read(55) R_xy_crust_mantle
+      read(55) R_xz_crust_mantle
+      read(55) R_yz_crust_mantle
 
-    read(55) R_xx_inner_core
-    read(55) R_yy_inner_core
-    read(55) R_xy_inner_core
-    read(55) R_xz_inner_core
-    read(55) R_yz_inner_core
+      read(55) R_xx_inner_core
+      read(55) R_yy_inner_core
+      read(55) R_xy_inner_core
+      read(55) R_xz_inner_core
+      read(55) R_yz_inner_core
 
-    close(55)
+      close(55)
+    endif
   endif
 
   ! initializes backward/reconstructed arrays
@@ -146,7 +150,7 @@
       b_B_array_rotation = 0._CUSTOM_REAL
     endif
 
-    if (ATTENUATION_VAL) then
+    if(ATTENUATION_VAL) then
       b_R_xx_crust_mantle = 0._CUSTOM_REAL
       b_R_yy_crust_mantle = 0._CUSTOM_REAL
       b_R_xy_crust_mantle = 0._CUSTOM_REAL
@@ -181,39 +185,63 @@
   integer :: ier
   character(len=150) outputname
 
-  write(outputname,'(a,i6.6,a)') 'proc',myrank,'_save_forward_arrays.bin'
-  open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname, &
-        status='old',action='read',form='unformatted',iostat=ier)
-  if( ier /= 0 ) then
-    print*,'error: opening proc_****_save_forward_arrays.bin'
-    print*,'path: ',trim(LOCAL_TMP_PATH)//'/'//outputname
-    call exit_mpi(myrank,'error open file save_forward_arrays.bin')
-  endif
+  if (ADIOS_FOR_FORWARD_ARRAYS) then
+    call read_forward_arrays_adios()
+  else
+    write(outputname,'(a,i6.6,a)') 'proc',myrank,'_save_forward_arrays.bin'
+    open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname, &
+          status='old',action='read',form='unformatted',iostat=ier)
+    if( ier /= 0 ) then
+      print*,'error: opening proc_****_save_forward_arrays.bin'
+      print*,'path: ',trim(LOCAL_TMP_PATH)//'/'//outputname
+      call exit_mpi(myrank,'error open file save_forward_arrays.bin')
+    endif
 
-  read(55) b_displ_crust_mantle
-  read(55) b_veloc_crust_mantle
-  read(55) b_accel_crust_mantle
+    read(55) b_displ_crust_mantle
+    read(55) b_veloc_crust_mantle
+    read(55) b_accel_crust_mantle
 
-  read(55) b_displ_inner_core
-  read(55) b_veloc_inner_core
-  read(55) b_accel_inner_core
+    read(55) b_displ_inner_core
+    read(55) b_veloc_inner_core
+    read(55) b_accel_inner_core
 
-  read(55) b_displ_outer_core
-  read(55) b_veloc_outer_core
-  read(55) b_accel_outer_core
+    read(55) b_displ_outer_core
+    read(55) b_veloc_outer_core
+    read(55) b_accel_outer_core
 
-  read(55) b_epsilondev_xx_crust_mantle
-  read(55) b_epsilondev_yy_crust_mantle
-  read(55) b_epsilondev_xy_crust_mantle
-  read(55) b_epsilondev_xz_crust_mantle
-  read(55) b_epsilondev_yz_crust_mantle
+    read(55) b_epsilondev_xx_crust_mantle
+    read(55) b_epsilondev_yy_crust_mantle
+    read(55) b_epsilondev_xy_crust_mantle
+    read(55) b_epsilondev_xz_crust_mantle
+    read(55) b_epsilondev_yz_crust_mantle
 
-  read(55) b_epsilondev_xx_inner_core
-  read(55) b_epsilondev_yy_inner_core
-  read(55) b_epsilondev_xy_inner_core
-  read(55) b_epsilondev_xz_inner_core
-  read(55) b_epsilondev_yz_inner_core
+    read(55) b_epsilondev_xx_inner_core
+    read(55) b_epsilondev_yy_inner_core
+    read(55) b_epsilondev_xy_inner_core
+    read(55) b_epsilondev_xz_inner_core
+    read(55) b_epsilondev_yz_inner_core
 
+    if (ROTATION_VAL) then
+      read(55) b_A_array_rotation
+      read(55) b_B_array_rotation
+    endif
+
+    if (ATTENUATION_VAL) then
+       read(55) b_R_xx_crust_mantle
+       read(55) b_R_yy_crust_mantle
+       read(55) b_R_xy_crust_mantle
+       read(55) b_R_xz_crust_mantle
+       read(55) b_R_yz_crust_mantle
+
+       read(55) b_R_xx_inner_core
+       read(55) b_R_yy_inner_core
+       read(55) b_R_xy_inner_core
+       read(55) b_R_xz_inner_core
+       read(55) b_R_yz_inner_core
+    endif
+    close(55)
+  endif ! ADIOS_FOR_FORWARD_ARRAYS
+
   ! transfers fields onto GPU
   if(GPU_MODE) then
     call transfer_b_fields_cm_to_device(NDIM*NGLOB_CRUST_MANTLE, &
@@ -237,37 +265,11 @@
                                     b_epsilondev_xx_inner_core,b_epsilondev_yy_inner_core, &
                                     b_epsilondev_xy_inner_core,b_epsilondev_xz_inner_core, &
                                     b_epsilondev_yz_inner_core)
-  endif
-
-
-  if (ROTATION_VAL) then
-    read(55) b_A_array_rotation
-    read(55) b_B_array_rotation
-    ! transfers to GPU
-    if(GPU_MODE) then
+    if (ROTATION_VAL) then
       call transfer_b_rotation_to_device(Mesh_pointer,b_A_array_rotation,b_B_array_rotation)
     endif
-  endif
 
-  if (ATTENUATION_VAL) then
-     read(55) b_R_xx_crust_mantle
-     read(55) b_R_yy_crust_mantle
-     read(55) b_R_xy_crust_mantle
-     read(55) b_R_xz_crust_mantle
-     read(55) b_R_yz_crust_mantle
-
-     read(55) b_R_xx_inner_core
-     read(55) b_R_yy_inner_core
-     read(55) b_R_xy_inner_core
-     read(55) b_R_xz_inner_core
-     read(55) b_R_yz_inner_core
-
-     ! note: for kernel simulations (SIMULATION_TYPE == 3), attenuation is by default
-     !          only mimicking effects on phase shifts, but not on amplitudes.
-     !          flag USE_ATTENUATION_MIMIC will have to be set to true in this case.
-     !
-     ! arrays b_R_xx, ... are not used when USE_ATTENUATION_MIMIC is set
-     if(GPU_MODE) then
+    if (ATTENUATION_VAL) then
       call transfer_b_rmemory_cm_to_device(Mesh_pointer, &
                                     b_R_xx_crust_mantle,b_R_yy_crust_mantle, &
                                     b_R_xy_crust_mantle,b_R_xz_crust_mantle, &
@@ -276,9 +278,7 @@
                                     b_R_xx_inner_core,b_R_yy_inner_core, &
                                     b_R_xy_inner_core,b_R_xz_inner_core, &
                                     b_R_yz_inner_core)
-     endif
-
+    endif
   endif
-  close(55)
 
-  end subroutine read_forward_arrays
+end subroutine read_forward_arrays

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays_adios.F90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/read_forward_arrays_adios.F90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays_adios.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays_adios.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,442 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file read_forward_arrays_adios.F90
+!! \brief Read saved forward arrays with the help of the ADIOS library.
+!-------------------------------------------------------------------------------
+
+!-------------------------------------------------------------------------------
+!> \brief Read forward arrays from an ADIOS file.
+!> \note read_intermediate_forward_arrays_adios() 
+!!       and read_forward_arrays_adios() are not factorized, because
+!>       the latest read the bp file in "b_" prefixed arrays
+subroutine read_intermediate_forward_arrays_adios()
+  ! External imports
+  use mpi
+  use adios_read_mod
+  ! Internal imports
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+  ! Local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+!  integer, parameter :: num_arrays = 9 ! TODO correct number 
+!  character(len=256), dimension(num_arrays) :: local_dims1, local_dims2, &
+!      global_dims1, global_dims2, offsets1, offsets2, array_name
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+
+  file_name = trim(LOCAL_TMP_PATH) // "/dump_all_arrays_adios.bp" 
+  call world_size(sizeprocs)
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+  
+
+  local_dim = NDIM * NGLOB_CRUST_MANTLE 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_crust_mantle/array", 0, 1, &
+      displ_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_crust_mantle/array", 0, 1, &
+      veloc_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_crust_mantle/array", 0, 1, &
+      accel_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! NOTE: perform reads before changing selection, otherwise it will segfault
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  
+  local_dim = NDIM * NGLOB_INNER_CORE
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_inner_core/array", 0, 1, &
+      displ_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_inner_core/array", 0, 1, &
+      veloc_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_inner_core/array", 0, 1, &
+      accel_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLOB_OUTER_CORE
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_outer_core/array", 0, 1, &
+      displ_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_outer_core/array", 0, 1, &
+      veloc_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_outer_core/array", 0, 1, &
+      accel_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_CRUST_MANTLE_STR_OR_ATT
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xx_crust_mantle/array",&
+      0, 1, epsilondev_xx_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yy_crust_mantle/array",&
+      0, 1, epsilondev_yy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xy_crust_mantle/array",&
+      0, 1, epsilondev_xy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xz_crust_mantle/array",&
+      0, 1, epsilondev_xz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yz_crust_mantle/array",&
+      0, 1, epsilondev_yz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_INNER_CORE_STR_OR_ATT
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xx_inner_core/array",&
+      0, 1, epsilondev_xx_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yy_inner_core/array",&
+      0, 1, epsilondev_yy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xy_inner_core/array",&
+      0, 1, epsilondev_xy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xz_inner_core/array",&
+      0, 1, epsilondev_xz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yz_inner_core/array",&
+      0, 1, epsilondev_yz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_OUTER_CORE_ROTATION
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "A_array_rotation/array", 0, 1, &
+      A_array_rotation, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "B_array_rotation/array", 0, 1, &
+      B_array_rotation, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_CRUST_MANTLE_ATTENUAT
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "R_xx_crust_mantle/array", 0, 1, &
+      R_xx_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_yy_crust_mantle/array", 0, 1, &
+      R_yy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_xy_crust_mantle/array", 0, 1, &
+      R_xy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_xz_crust_mantle/array", 0, 1, &
+      R_xz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_yz_crust_mantle/array", 0, 1, &
+      R_yz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_INNER_CORE_ATTENUATION
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "R_xx_inner_core/array", 0, 1, &
+      R_xx_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_yy_inner_core/array", 0, 1, &
+      R_yy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_xy_inner_core/array", 0, 1, &
+      R_xy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_xz_inner_core/array", 0, 1, &
+      R_xz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "R_yz_inner_core/array", 0, 1, &
+      R_yz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+
+end subroutine read_intermediate_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> \brief Read forward arrays from an ADIOS file.
+!> \note read_intermediate_forward_arrays_adios() 
+!!       and read_forward_arrays_adios() are not factorized, because
+!>       the latest read the bp file in "b_" prefixed arrays
+subroutine read_forward_arrays_adios()
+  ! External imports
+  use mpi
+  use adios_read_mod
+  ! Internal imports
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+  ! Local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+
+  file_name = trim(LOCAL_TMP_PATH) // "/save_forward_arrays.bp" 
+  call world_size(sizeprocs)
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+  
+
+  local_dim = NDIM * NGLOB_CRUST_MANTLE 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_crust_mantle/array", 0, 1, &
+      b_displ_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_crust_mantle/array", 0, 1, &
+      b_veloc_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_crust_mantle/array", 0, 1, &
+      b_accel_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! NOTE: perform reads before changing selection, otherwise it will segfault
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  
+  local_dim = NDIM * NGLOB_INNER_CORE
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_inner_core/array", 0, 1, &
+      b_displ_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_inner_core/array", 0, 1, &
+      b_veloc_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_inner_core/array", 0, 1, &
+      b_accel_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLOB_OUTER_CORE
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "displ_outer_core/array", 0, 1, &
+      b_displ_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "veloc_outer_core/array", 0, 1, &
+      b_veloc_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "accel_outer_core/array", 0, 1, &
+      b_accel_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_CRUST_MANTLE_STR_OR_ATT
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xx_crust_mantle/array",&
+      0, 1, b_epsilondev_xx_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yy_crust_mantle/array",&
+      0, 1, b_epsilondev_yy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xy_crust_mantle/array",&
+      0, 1, b_epsilondev_xy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xz_crust_mantle/array",&
+      0, 1, b_epsilondev_xz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yz_crust_mantle/array",&
+      0, 1, b_epsilondev_yz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_INNER_CORE_STR_OR_ATT
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xx_inner_core/array",&
+      0, 1, b_epsilondev_xx_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yy_inner_core/array",&
+      0, 1, b_epsilondev_yy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xy_inner_core/array",&
+      0, 1, b_epsilondev_xy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_xz_inner_core/array",&
+      0, 1, b_epsilondev_xz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "epsilondev_yz_inner_core/array",&
+      0, 1, b_epsilondev_yz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  if (ROTATION_VAL) then
+    local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_OUTER_CORE_ROTATION
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "A_array_rotation/array", 0, 1, &
+        b_A_array_rotation, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "B_array_rotation/array", 0, 1, &
+        b_B_array_rotation, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  if (ATTENUATION_VAL) then
+    local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_CRUST_MANTLE_ATTENUAT
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "R_xx_crust_mantle/array", 0, 1, &
+        b_R_xx_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_yy_crust_mantle/array", 0, 1, &
+        b_R_yy_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_xy_crust_mantle/array", 0, 1, &
+        b_R_xy_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_xz_crust_mantle/array", 0, 1, &
+        b_R_xz_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_yz_crust_mantle/array", 0, 1, &
+        b_R_yz_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_INNER_CORE_ATTENUATION
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "R_xx_inner_core/array", 0, 1, &
+        b_R_xx_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_yy_inner_core/array", 0, 1, &
+        b_R_yy_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_xy_inner_core/array", 0, 1, &
+        b_R_xy_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_xz_inner_core/array", 0, 1, &
+        b_R_xz_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "R_yz_inner_core/array", 0, 1, &
+        b_R_yz_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+
+end subroutine read_forward_arrays_adios

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -54,7 +54,11 @@
   call read_mesh_databases_IC()
 
   ! reads "boundary.bin" files to couple mantle with outer core and inner core boundaries
-  call read_mesh_databases_coupling()
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call read_mesh_databases_coupling_adios()
+  else
+    call read_mesh_databases_coupling()
+  endif
 
   ! reads "addressing.txt" 2-D addressing (needed for stacey boundaries)
   call read_mesh_databases_addressing()
@@ -65,7 +69,11 @@
   ! absorbing boundaries
   if(ABSORBING_CONDITIONS) then
     ! reads "stacey.bin" files
-    call read_mesh_databases_stacey()
+    if (ADIOS_FOR_ARRAYS_SOLVER) then
+      call read_mesh_databases_stacey_adios()
+    else
+      call read_mesh_databases_stacey()
+    endif
   endif
 
   ! user output
@@ -148,31 +156,56 @@
   if(ier /= 0) stop 'error allocating rmassz in crust_mantle'
 
   ! reads databases file
-  call read_arrays_solver(IREGION_CRUST_MANTLE,myrank, &
-            NSPEC_CRUST_MANTLE,NGLOB_CRUST_MANTLE,NGLOB_XY_CM, &
-            nspec_iso,nspec_tiso,nspec_ani, &
-            rho_vp_crust_mantle,rho_vs_crust_mantle, &
-            xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
-            xix_crust_mantle,xiy_crust_mantle,xiz_crust_mantle, &
-            etax_crust_mantle,etay_crust_mantle,etaz_crust_mantle, &
-            gammax_crust_mantle,gammay_crust_mantle,gammaz_crust_mantle, &
-            rhostore_crust_mantle,kappavstore_crust_mantle,muvstore_crust_mantle, &
-            kappahstore_crust_mantle,muhstore_crust_mantle,eta_anisostore_crust_mantle, &
-            c11store_crust_mantle,c12store_crust_mantle,c13store_crust_mantle, &
-            c14store_crust_mantle,c15store_crust_mantle,c16store_crust_mantle, &
-            c22store_crust_mantle,c23store_crust_mantle,c24store_crust_mantle, &
-            c25store_crust_mantle,c26store_crust_mantle,c33store_crust_mantle, &
-            c34store_crust_mantle,c35store_crust_mantle,c36store_crust_mantle, &
-            c44store_crust_mantle,c45store_crust_mantle,c46store_crust_mantle, &
-            c55store_crust_mantle,c56store_crust_mantle,c66store_crust_mantle, &
-            ibool_crust_mantle,dummy_idoubling,ispec_is_tiso_crust_mantle, &
-            rmassx_crust_mantle,rmassy_crust_mantle,rmassz_crust_mantle,rmass_ocean_load, &
-            READ_KAPPA_MU,READ_TISO, &
-            ABSORBING_CONDITIONS,LOCAL_PATH)
+  if(ADIOS_FOR_ARRAYS_SOLVER) then
+    call read_arrays_solver_adios(IREGION_CRUST_MANTLE,myrank, &
+        NSPEC_CRUST_MANTLE,NGLOB_CRUST_MANTLE,NGLOB_XY_CM, &
+        nspec_iso,nspec_tiso,nspec_ani, &
+        rho_vp_crust_mantle,rho_vs_crust_mantle, &
+        xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
+        xix_crust_mantle,xiy_crust_mantle,xiz_crust_mantle, &
+        etax_crust_mantle,etay_crust_mantle,etaz_crust_mantle, &
+        gammax_crust_mantle,gammay_crust_mantle,gammaz_crust_mantle, &
+        rhostore_crust_mantle,kappavstore_crust_mantle,muvstore_crust_mantle, &
+        kappahstore_crust_mantle,muhstore_crust_mantle,eta_anisostore_crust_mantle, &
+        c11store_crust_mantle,c12store_crust_mantle,c13store_crust_mantle, &
+        c14store_crust_mantle,c15store_crust_mantle,c16store_crust_mantle, &
+        c22store_crust_mantle,c23store_crust_mantle,c24store_crust_mantle, &
+        c25store_crust_mantle,c26store_crust_mantle,c33store_crust_mantle, &
+        c34store_crust_mantle,c35store_crust_mantle,c36store_crust_mantle, &
+        c44store_crust_mantle,c45store_crust_mantle,c46store_crust_mantle, &
+        c55store_crust_mantle,c56store_crust_mantle,c66store_crust_mantle, &
+        ibool_crust_mantle,dummy_idoubling,ispec_is_tiso_crust_mantle, &
+        rmassx_crust_mantle,rmassy_crust_mantle,rmassz_crust_mantle,rmass_ocean_load, &
+        READ_KAPPA_MU,READ_TISO, &
+        ABSORBING_CONDITIONS,LOCAL_PATH)
+  else
+    call read_arrays_solver(IREGION_CRUST_MANTLE,myrank, &
+        NSPEC_CRUST_MANTLE,NGLOB_CRUST_MANTLE,NGLOB_XY_CM, &
+        nspec_iso,nspec_tiso,nspec_ani, &
+        rho_vp_crust_mantle,rho_vs_crust_mantle, &
+        xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
+        xix_crust_mantle,xiy_crust_mantle,xiz_crust_mantle, &
+        etax_crust_mantle,etay_crust_mantle,etaz_crust_mantle, &
+        gammax_crust_mantle,gammay_crust_mantle,gammaz_crust_mantle, &
+        rhostore_crust_mantle,kappavstore_crust_mantle,muvstore_crust_mantle, &
+        kappahstore_crust_mantle,muhstore_crust_mantle,eta_anisostore_crust_mantle, &
+        c11store_crust_mantle,c12store_crust_mantle,c13store_crust_mantle, &
+        c14store_crust_mantle,c15store_crust_mantle,c16store_crust_mantle, &
+        c22store_crust_mantle,c23store_crust_mantle,c24store_crust_mantle, &
+        c25store_crust_mantle,c26store_crust_mantle,c33store_crust_mantle, &
+        c34store_crust_mantle,c35store_crust_mantle,c36store_crust_mantle, &
+        c44store_crust_mantle,c45store_crust_mantle,c46store_crust_mantle, &
+        c55store_crust_mantle,c56store_crust_mantle,c66store_crust_mantle, &
+        ibool_crust_mantle,dummy_idoubling,ispec_is_tiso_crust_mantle, &
+        rmassx_crust_mantle,rmassy_crust_mantle,rmassz_crust_mantle,rmass_ocean_load, &
+        READ_KAPPA_MU,READ_TISO, &
+        ABSORBING_CONDITIONS,LOCAL_PATH)
+  endif
 
   ! check that the number of points in this slice is correct
-  if(minval(ibool_crust_mantle(:,:,:,:)) /= 1 .or. &
-    maxval(ibool_crust_mantle(:,:,:,:)) /= NGLOB_CRUST_MANTLE) &
+  if(minval(ibool_crust_mantle(:,:,:,:)) /= 1) &
+      call exit_MPI(myrank,'incorrect global numbering: iboolmin is not equal to 1 in crust and mantle')
+  if(maxval(ibool_crust_mantle(:,:,:,:)) /= NGLOB_CRUST_MANTLE) &
       call exit_MPI(myrank,'incorrect global numbering: iboolmax does not equal nglob in crust and mantle')
 
   deallocate(dummy_idoubling)
@@ -231,34 +264,62 @@
   allocate(rmass_outer_core(NGLOB_OUTER_CORE),stat=ier)
   if(ier /= 0) stop 'error allocating rmass in outer core'
 
-  call read_arrays_solver(IREGION_OUTER_CORE,myrank, &
-            NSPEC_OUTER_CORE,NGLOB_OUTER_CORE,NGLOB_XY_dummy, &
-            nspec_iso,nspec_tiso,nspec_ani, &
-            vp_outer_core,dummy_array, &
-            xstore_outer_core,ystore_outer_core,zstore_outer_core, &
-            xix_outer_core,xiy_outer_core,xiz_outer_core, &
-            etax_outer_core,etay_outer_core,etaz_outer_core, &
-            gammax_outer_core,gammay_outer_core,gammaz_outer_core, &
-            rhostore_outer_core,kappavstore_outer_core,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            ibool_outer_core,dummy_idoubling_outer_core,dummy_ispec_is_tiso, &
-            dummy_rmass,dummy_rmass,rmass_outer_core,rmass_ocean_load, &
-            READ_KAPPA_MU,READ_TISO, &
-            ABSORBING_CONDITIONS,LOCAL_PATH)
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call read_arrays_solver_adios(IREGION_OUTER_CORE,myrank, &
+              NSPEC_OUTER_CORE,NGLOB_OUTER_CORE,NGLOB_XY_dummy, &
+              nspec_iso,nspec_tiso,nspec_ani, &
+              vp_outer_core,dummy_array, &
+              xstore_outer_core,ystore_outer_core,zstore_outer_core, &
+              xix_outer_core,xiy_outer_core,xiz_outer_core, &
+              etax_outer_core,etay_outer_core,etaz_outer_core, &
+              gammax_outer_core,gammay_outer_core,gammaz_outer_core, &
+              rhostore_outer_core,kappavstore_outer_core,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              ibool_outer_core,dummy_idoubling_outer_core,dummy_ispec_is_tiso, &
+              dummy_rmass,dummy_rmass,rmass_outer_core,rmass_ocean_load, &
+              READ_KAPPA_MU,READ_TISO, &
+              ABSORBING_CONDITIONS,LOCAL_PATH)
+  else
+    call read_arrays_solver(IREGION_OUTER_CORE,myrank, &
+              NSPEC_OUTER_CORE,NGLOB_OUTER_CORE,NGLOB_XY_dummy, &
+              nspec_iso,nspec_tiso,nspec_ani, &
+              vp_outer_core,dummy_array, &
+              xstore_outer_core,ystore_outer_core,zstore_outer_core, &
+              xix_outer_core,xiy_outer_core,xiz_outer_core, &
+              etax_outer_core,etay_outer_core,etaz_outer_core, &
+              gammax_outer_core,gammay_outer_core,gammaz_outer_core, &
+              rhostore_outer_core,kappavstore_outer_core,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              ibool_outer_core,dummy_idoubling_outer_core,dummy_ispec_is_tiso, &
+              dummy_rmass,dummy_rmass,rmass_outer_core,rmass_ocean_load, &
+              READ_KAPPA_MU,READ_TISO, &
+              ABSORBING_CONDITIONS,LOCAL_PATH)
+  endif
 
   deallocate(dummy_idoubling_outer_core,dummy_ispec_is_tiso,dummy_rmass)
 
   ! check that the number of points in this slice is correct
-  if(minval(ibool_outer_core(:,:,:,:)) /= 1 .or. &
-     maxval(ibool_outer_core(:,:,:,:)) /= NGLOB_OUTER_CORE) &
-    call exit_MPI(myrank,'incorrect global numbering: iboolmax does not equal nglob in outer core')
+  ! check that the number of points in this slice is correct
+  if(minval(ibool_outer_core(:,:,:,:)) /= 1) &
+      call exit_MPI(myrank,'incorrect global numbering: iboolmin is not equal to 1 in outer core')
+  if(maxval(ibool_outer_core(:,:,:,:)) /= NGLOB_OUTER_CORE) then
+    call exit_MPI(myrank, 'incorrect global numbering: &
+        & iboolmax does not equal nglob in outer core')
+  endif
 
   end subroutine read_mesh_databases_OC
 
@@ -315,27 +376,51 @@
   allocate(rmass_inner_core(NGLOB_INNER_CORE),stat=ier)
   if(ier /= 0) stop 'error allocating rmass in inner core'
 
-  call read_arrays_solver(IREGION_INNER_CORE,myrank, &
-            NSPEC_INNER_CORE,NGLOB_INNER_CORE,NGLOB_XY_dummy, &
-            nspec_iso,nspec_tiso,nspec_ani, &
-            dummy_array,dummy_array, &
-            xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-            xix_inner_core,xiy_inner_core,xiz_inner_core, &
-            etax_inner_core,etay_inner_core,etaz_inner_core, &
-            gammax_inner_core,gammay_inner_core,gammaz_inner_core, &
-            rhostore_inner_core,kappavstore_inner_core,muvstore_inner_core, &
-            dummy_array,dummy_array,dummy_array, &
-            c11store_inner_core,c12store_inner_core,c13store_inner_core, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            dummy_array,dummy_array,c33store_inner_core, &
-            dummy_array,dummy_array,dummy_array, &
-            c44store_inner_core,dummy_array,dummy_array, &
-            dummy_array,dummy_array,dummy_array, &
-            ibool_inner_core,idoubling_inner_core,dummy_ispec_is_tiso, &
-            dummy_rmass,dummy_rmass,rmass_inner_core,rmass_ocean_load, &
-            READ_KAPPA_MU,READ_TISO, &
-            ABSORBING_CONDITIONS,LOCAL_PATH)
+  if (ADIOS_FOR_ARRAYS_SOLVER) then
+    call read_arrays_solver_adios(IREGION_INNER_CORE,myrank, &
+              NSPEC_INNER_CORE,NGLOB_INNER_CORE,NGLOB_XY_dummy, &
+              nspec_iso,nspec_tiso,nspec_ani, &
+              dummy_array,dummy_array, &
+              xstore_inner_core,ystore_inner_core,zstore_inner_core, &
+              xix_inner_core,xiy_inner_core,xiz_inner_core, &
+              etax_inner_core,etay_inner_core,etaz_inner_core, &
+              gammax_inner_core,gammay_inner_core,gammaz_inner_core, &
+              rhostore_inner_core,kappavstore_inner_core,muvstore_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              c11store_inner_core,c12store_inner_core,c13store_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,c33store_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              c44store_inner_core,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              ibool_inner_core,idoubling_inner_core,dummy_ispec_is_tiso, &
+              dummy_rmass,dummy_rmass,rmass_inner_core,rmass_ocean_load, &
+              READ_KAPPA_MU,READ_TISO, &
+              ABSORBING_CONDITIONS,LOCAL_PATH)
+  else
+    call read_arrays_solver(IREGION_INNER_CORE,myrank, &
+              NSPEC_INNER_CORE,NGLOB_INNER_CORE,NGLOB_XY_dummy, &
+              nspec_iso,nspec_tiso,nspec_ani, &
+              dummy_array,dummy_array, &
+              xstore_inner_core,ystore_inner_core,zstore_inner_core, &
+              xix_inner_core,xiy_inner_core,xiz_inner_core, &
+              etax_inner_core,etay_inner_core,etaz_inner_core, &
+              gammax_inner_core,gammay_inner_core,gammaz_inner_core, &
+              rhostore_inner_core,kappavstore_inner_core,muvstore_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              c11store_inner_core,c12store_inner_core,c13store_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              dummy_array,dummy_array,c33store_inner_core, &
+              dummy_array,dummy_array,dummy_array, &
+              c44store_inner_core,dummy_array,dummy_array, &
+              dummy_array,dummy_array,dummy_array, &
+              ibool_inner_core,idoubling_inner_core,dummy_ispec_is_tiso, &
+              dummy_rmass,dummy_rmass,rmass_inner_core,rmass_ocean_load, &
+              READ_KAPPA_MU,READ_TISO, &
+              ABSORBING_CONDITIONS,LOCAL_PATH)
+  endif
 
   deallocate(dummy_ispec_is_tiso,dummy_rmass)
 
@@ -636,7 +721,11 @@
   ! read MPI interfaces from file
 
   ! crust mantle
-  call read_mesh_databases_MPI_CM()
+  if (ADIOS_FOR_MPI_ARRAYS) then
+    call read_mesh_databases_MPI_CM_adios()
+  else
+    call read_mesh_databases_MPI_CM()
+  endif
 
   allocate(buffer_send_vector_crust_mantle(NDIM,max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
           buffer_recv_vector_crust_mantle(NDIM,max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
@@ -655,7 +744,11 @@
   endif
 
   ! outer core
-  call read_mesh_databases_MPI_OC()
+  if (ADIOS_FOR_MPI_ARRAYS) then
+    call read_mesh_databases_MPI_OC_adios()
+  else
+    call read_mesh_databases_MPI_OC()
+  endif
 
   allocate(buffer_send_scalar_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
           buffer_recv_scalar_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
@@ -674,7 +767,11 @@
   endif
 
   ! inner core
-  call read_mesh_databases_MPI_IC()
+  if (ADIOS_FOR_MPI_ARRAYS) then
+    call read_mesh_databases_MPI_IC_adios()
+  else
+    call read_mesh_databases_MPI_IC()
+  endif
 
   allocate(buffer_send_vector_inner_core(NDIM,max_nibool_interfaces_ic,num_interfaces_inner_core), &
           buffer_recv_vector_inner_core(NDIM,max_nibool_interfaces_ic,num_interfaces_inner_core), &

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases_adios.f90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/read_mesh_databases_adios.f90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases_adios.f90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases_adios.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,1438 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+!===============================================================================
+!> \brief Read adios boundary arrays created by the mesher
+!!        (file: regX_boundary.bp)
+subroutine read_mesh_databases_coupling_adios()
+  use adios_read_mod
+
+! to couple mantle with outer core
+
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  include 'mpif.h'
+
+  ! local parameters
+  integer :: njunk1,njunk2,njunk3
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  ! crust and mantle
+  ! create name of database
+  call create_name_database_adios(prname, IREGION_CRUST_MANTLE, LOCAL_PATH)
+  file_name= trim(prname) // "boundary.bp" 
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmin", 0, 1, &
+     nspec2D_xmin_crust_mantle, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmax", 0, 1, &
+     nspec2D_xmax_crust_mantle, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymin", 0, 1, &
+     nspec2D_ymin_crust_mantle, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymax", 0, 1, &
+     nspec2D_ymax_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmin", &
+      !nspec2D_xmin_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmax", &
+      !nspec2D_xmax_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymin", &
+      !nspec2D_ymin_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymax", &
+      !nspec2D_ymax_crust_mantle, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2DMAX_XMIN_XMAX_CM
+  local_dim = size (ibelm_xmin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmin/array", 0, 1, &
+    ibelm_xmin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmax/array", 0, 1, &
+    ibelm_xmax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2DMAX_YMIN_YMAX_CM
+  local_dim = size (ibelm_ymin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymin/array", 0, 1, &
+    ibelm_ymin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymax/array", 0, 1, &
+    ibelm_ymax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_BOTTOM_CM
+  local_dim = size (ibelm_bottom_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_bottom/array", 0, 1, &
+    ibelm_bottom_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_TOP_CM
+  local_dim = size (ibelm_top_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_top/array", 0, 1, &
+    ibelm_top_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX_CM
+  local_dim = size (normal_xmin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_xmin/array", 0, 1, &
+    normal_xmin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "normal_xmax/array", 0, 1, &
+    normal_xmax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX_CM
+  local_dim = size (normal_ymin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_ymin/array", 0, 1, &
+    normal_ymin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "normal_ymax/array", 0, 1, &
+    normal_ymax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM_CM
+  local_dim = size (ibelm_bottom_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_bottom/array", 0, 1, &
+    normal_bottom_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP_CM
+  local_dim = size (ibelm_top_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_top/array", 0, 1, &
+    normal_top_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX_CM
+  local_dim = size (jacobian2D_xmin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_xmin/array", 0, 1, &
+    jacobian2D_xmin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_xmax/array", 0, 1, &
+    jacobian2D_xmax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX_CM
+  local_dim = size (jacobian2D_ymin_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_ymin/array", 0, 1, &
+    jacobian2D_ymin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_ymax/array", 0, 1, &
+    jacobian2D_ymax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLX*NGLLY*NSPEC2D_BOTTOM_CM
+  local_dim = size (jacobian2D_bottom_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_bottom/array", 0, 1, &
+    jacobian2D_bottom_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLX*NGLLY*NSPEC2D_TOP_CM
+  local_dim = size (jacobian2D_top_crust_mantle) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_top/array", 0, 1, &
+    jacobian2D_top_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+! boundary parameters
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! read parameters to couple fluid and solid regions
+  !
+  ! outer core
+
+  ! create name of database
+  call create_name_database_adios(prname, IREGION_OUTER_CORE, LOCAL_PATH)
+  file_name= trim(prname) // "boundary.bp" 
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmin", 0, 1, &
+     nspec2D_xmin_outer_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmax", 0, 1, &
+     nspec2D_xmax_outer_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymin", 0, 1, &
+     nspec2D_ymin_outer_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymax", 0, 1, &
+     nspec2D_ymax_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmin", &
+      !nspec2D_xmin_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmax", &
+      !nspec2D_xmax_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymin", &
+      !nspec2D_ymin_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymax", &
+      !nspec2D_ymax_outer_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  nspec2D_zmin_outer_core = NSPEC2D_BOTTOM(IREGION_OUTER_CORE)
+
+  !local_dim = NSPEC2DMAX_XMIN_XMAX_OC
+  local_dim = size (ibelm_xmin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmin/array", 0, 1, &
+    ibelm_xmin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmax/array", 0, 1, &
+    ibelm_xmax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2DMAX_YMIN_YMAX_OC
+  local_dim = size (ibelm_ymin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymin/array", 0, 1, &
+    ibelm_ymin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymax/array", 0, 1, &
+    ibelm_ymax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_BOTTOM_OC
+  local_dim = size (ibelm_bottom_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_bottom/array", 0, 1, &
+    ibelm_bottom_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_TOP_OC
+  local_dim = size (ibelm_top_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_top/array", 0, 1, &
+    ibelm_top_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX_OC
+  local_dim = size (normal_xmin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_xmin/array", 0, 1, &
+    normal_xmin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "normal_xmax/array", 0, 1, &
+    normal_xmax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX_OC
+  local_dim = size (normal_ymin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_ymin/array", 0, 1, &
+    normal_ymin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "normal_ymax/array", 0, 1, &
+    normal_ymax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_BOTTOM_OC
+  local_dim = size (normal_bottom_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_bottom/array", 0, 1, &
+    normal_bottom_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_TOP_OC
+  local_dim = size (normal_top_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "normal_top/array", 0, 1, &
+    normal_top_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLY*NGLLZ*NSPEC2DMAX_XMIN_XMAX_OC
+  local_dim = size (jacobian2D_xmin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_xmin/array", 0, 1, &
+    jacobian2D_xmin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_xmax/array", 0, 1, &
+    jacobian2D_xmax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLX*NGLLZ*NSPEC2DMAX_YMIN_YMAX_OC
+  local_dim = size (jacobian2D_ymin_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_ymin/array", 0, 1, &
+    jacobian2D_ymin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_ymax/array", 0, 1, &
+    jacobian2D_ymax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+
+  !local_dim = NGLLX*NGLLY*NSPEC2D_BOTTOM_OC
+  local_dim = size (jacobian2D_bottom_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_bottom/array", 0, 1, &
+    jacobian2D_bottom_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NGLLX*NGLLY*NSPEC2D_TOP_OC
+  local_dim = size (jacobian2D_top_outer_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "jacobian2D_top/array", 0, 1, &
+    jacobian2D_top_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  ! boundary parameters
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+
+  ! inner core
+
+  ! create name of database
+  call create_name_database_adios(prname, IREGION_INNER_CORE, LOCAL_PATH)
+  file_name= trim(prname) // "boundary.bp" 
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmin", 0, 1, &
+     nspec2D_xmin_inner_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_xmax", 0, 1, &
+     nspec2D_xmax_inner_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymin", 0, 1, &
+     nspec2D_ymin_inner_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec2D_ymax", 0, 1, &
+     nspec2D_ymax_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmin", &
+      !nspec2D_xmin_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_xmax", &
+      !nspec2D_xmax_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymin", &
+      !nspec2D_ymin_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec2D_ymax", &
+      !nspec2D_ymax_inner_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2DMAX_XMIN_XMAX_IC
+  local_dim = size (ibelm_xmin_inner_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmin/array", 0, 1, &
+    ibelm_xmin_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_xmax/array", 0, 1, &
+    ibelm_xmax_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2DMAX_YMIN_YMAX_IC
+  local_dim = size (ibelm_ymin_inner_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymin/array", 0, 1, &
+    ibelm_ymin_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_schedule_read(adios_handle, sel, "ibelm_ymax/array", 0, 1, &
+    ibelm_ymax_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_BOTTOM_IC
+  local_dim = size (ibelm_bottom_inner_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_bottom/array", 0, 1, &
+    ibelm_bottom_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  !local_dim = NSPEC2D_TOP_IC
+  local_dim = size (ibelm_top_inner_core) 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "ibelm_top/array", 0, 1, &
+    ibelm_top_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! -- Boundary Mesh for crust and mantle ---
+  if (SAVE_BOUNDARY_MESH .and. SIMULATION_TYPE == 3) then
+    file_name = LOCAL_PATH // "boundary_disc.bp" 
+    call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+        "verbose=1", adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "NSPEC2D_MOHO", 0, 1, &
+       njunk1, adios_err)
+    call adios_schedule_read(adios_handle, sel, "NSPEC2D_400", 0, 1, &
+       njunk2, adios_err)
+    call adios_schedule_read(adios_handle, sel, "NSPEC2D_670", 0, 1, &
+       njunk3, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    if (njunk1 /= NSPEC2D_MOHO .and. njunk2 /= NSPEC2D_400 .and. &
+        njunk3 /= NSPEC2D_670) &
+        call exit_mpi(myrank, 'Error reading boundary_disc.bp file')
+
+    local_dim = NSPEC2D_MOHO
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "ibelm_moho_top/array", 0, 1, &
+      ibelm_moho_bot, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "ibelm_moho_bot/array", 0, 1, &
+      ibelm_moho_top, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = NSPEC2D_400
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "ibelm_400_top/array", 0, 1, &
+      ibelm_400_bot, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "ibelm_400_bot/array", 0, 1, &
+      ibelm_400_top, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = NSPEC2D_670
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "ibelm_670_top/array", 0, 1, &
+      ibelm_670_bot, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "ibelm_670_bot/array", 0, 1, &
+      ibelm_670_top, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_MOHO
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "normal_moho/array", 0, 1, &
+      normal_moho, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_400
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "normal_400/array", 0, 1, &
+      normal_400, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = NDIM*NGLLX*NGLLY*NSPEC2D_670
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "normal_670/array", 0, 1, &
+      normal_670, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    ! Close ADIOS handler to the restart file.
+    call adios_selection_delete(sel)
+    call adios_read_close(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    k_top = 1
+    k_bot = NGLLZ
+
+    ! initialization
+    moho_kl = 0.; d400_kl = 0.; d670_kl = 0.; cmb_kl = 0.; icb_kl = 0.
+  endif
+
+end subroutine read_mesh_databases_coupling_adios
+
+subroutine read_mesh_databases_addressing_adios()
+
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  include 'mpif.h'
+
+  ! local parameters
+  integer, dimension(NCHUNKS_VAL,0:NPROC_XI_VAL-1,0:NPROC_ETA_VAL-1) :: addressing
+  integer, dimension(0:NPROCTOT_VAL-1) :: ichunk_slice,iproc_xi_slice,iproc_eta_slice
+  integer :: ierr,iproc,iproc_read,iproc_xi,iproc_eta
+
+  ! open file with global slice number addressing
+  if(myrank == 0) then
+    open(unit=IIN,file=trim(OUTPUT_FILES)//'/addressing.txt',status='old',action='read',iostat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank,'error opening addressing.txt')
+
+    do iproc = 0,NPROCTOT_VAL-1
+      read(IIN,*) iproc_read,ichunk,iproc_xi,iproc_eta
+
+      if(iproc_read /= iproc) call exit_MPI(myrank,'incorrect slice number read')
+
+      addressing(ichunk,iproc_xi,iproc_eta) = iproc
+      ichunk_slice(iproc) = ichunk
+      iproc_xi_slice(iproc) = iproc_xi
+      iproc_eta_slice(iproc) = iproc_eta
+    enddo
+    close(IIN)
+  endif
+
+  ! broadcast the information read on the master to the nodes
+  call MPI_BCAST(addressing,NCHUNKS_VAL*NPROC_XI_VAL*NPROC_ETA_VAL,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
+  call MPI_BCAST(ichunk_slice,NPROCTOT_VAL,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
+  call MPI_BCAST(iproc_xi_slice,NPROCTOT_VAL,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
+  call MPI_BCAST(iproc_eta_slice,NPROCTOT_VAL,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
+
+  ! output a topology map of slices - fix 20x by nproc
+  if (myrank == 0 ) then
+    if( NCHUNKS_VAL == 6 .and. NPROCTOT_VAL < 1000 ) then
+      write(IMAIN,*) 'Spatial distribution of the slices'
+      do iproc_xi = NPROC_XI_VAL-1, 0, -1
+        write(IMAIN,'(20x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_AB
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(1x)',advance='yes')
+      enddo
+      write(IMAIN, *) ' '
+      do iproc_xi = NPROC_XI_VAL-1, 0, -1
+        write(IMAIN,'(1x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_BC
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(3x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_AC
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(3x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_BC_ANTIPODE
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(1x)',advance='yes')
+      enddo
+      write(IMAIN, *) ' '
+      do iproc_xi = NPROC_XI_VAL-1, 0, -1
+        write(IMAIN,'(20x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_AB_ANTIPODE
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(1x)',advance='yes')
+      enddo
+      write(IMAIN, *) ' '
+      do iproc_xi = NPROC_XI_VAL-1, 0, -1
+        write(IMAIN,'(20x)',advance='no')
+        do iproc_eta = NPROC_ETA_VAL -1, 0, -1
+          ichunk = CHUNK_AC_ANTIPODE
+          write(IMAIN,'(i5)',advance='no') addressing(ichunk,iproc_xi,iproc_eta)
+        enddo
+        write(IMAIN,'(1x)',advance='yes')
+      enddo
+      write(IMAIN, *) ' '
+    endif
+  endif
+
+  ! determine chunk number and local slice coordinates using addressing
+  ! (needed for stacey conditions)
+  ichunk = ichunk_slice(myrank)
+
+end subroutine read_mesh_databases_addressing_adios
+
+
+!===============================================================================
+!> \brief Read crust mantle MPI arrays from an ADIOS file.
+subroutine read_mesh_databases_MPI_CM_adios()
+  ! External imports
+  use mpi
+  use adios_read_mod
+  ! Internal imports
+  use specfem_par
+  use specfem_par_crustmantle
+  implicit none
+
+  ! local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  ! create the name for the database of the current slide and region
+  call create_name_database_adios(prname, IREGION_CRUST_MANTLE, LOCAL_PATH)
+
+  file_name= trim(prname) // "solver_data_mpi.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  ! MPI interfaces
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "num_interfaces", 0, 1, &
+     num_interfaces_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "num_interfaces", &
+      !num_interfaces_crust_mantle, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  allocate(my_neighbours_crust_mantle(num_interfaces_crust_mantle), &
+          nibool_interfaces_crust_mantle(num_interfaces_crust_mantle), &
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array my_neighbours_crust_mantle etc.')
+
+  if( num_interfaces_crust_mantle > 0 ) then
+    call adios_selection_writeblock(sel, myrank)
+    !call adios_get_scalar(adios_handle, "max_nibool_interfaces", &
+      !max_nibool_interfaces_cm, adios_err)
+    call adios_schedule_read(adios_handle, sel, "max_nibool_interfaces", 0, 1, &
+       max_nibool_interfaces_cm, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_cm, &
+        num_interfaces_crust_mantle), stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array ibool_interfaces_crust_mantle')
+
+    local_dim = num_interfaces_crust_mantle
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "my_neighbours/array", 0, 1, &
+      my_neighbours_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "nibool_interfaces/array", &
+      0, 1, nibool_interfaces_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = max_nibool_interfaces_cm * num_interfaces_crust_mantle
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "ibool_interfaces/array", 0, 1, &
+      ibool_interfaces_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! dummy array
+    max_nibool_interfaces_cm = 0
+    allocate(ibool_interfaces_crust_mantle(0,0),stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array dummy ibool_interfaces_crust_mantle')
+  endif
+
+  ! inner / outer elements
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec_inner", &
+    0, 1, nspec_inner_crust_mantle, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec_outer", &
+    0, 1, nspec_outer_crust_mantle, adios_err)
+  call adios_schedule_read(adios_handle, sel, "num_phase_ispec", &
+    0, 1, num_phase_ispec_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_inner", &
+      !nspec_inner_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_outer", &
+      !nspec_outer_crust_mantle, adios_err)
+  !call adios_get_scalar(adios_handle, "num_phase_ispec", &
+      !num_phase_ispec_crust_mantle, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  if( num_phase_ispec_crust_mantle < 0 ) &
+      call exit_mpi(myrank,'error num_phase_ispec_crust_mantle is < zero')
+
+  allocate(phase_ispec_inner_crust_mantle(num_phase_ispec_crust_mantle,2),&
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array phase_ispec_inner_crust_mantle')
+
+  if(num_phase_ispec_crust_mantle > 0 ) then
+    local_dim = num_phase_ispec_crust_mantle * 2
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "phase_ispec_inner/array", 0, 1, &
+      phase_ispec_inner_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  ! mesh coloring for GPUs
+  if( USE_MESH_COLORING_GPU ) then
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "num_colors_outer", &
+      0, 1, num_colors_outer_crust_mantle, adios_err)
+    call adios_schedule_read(adios_handle, sel, "num_colors_inner", &
+      0, 1, num_colors_inner_crust_mantle, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_outer", &
+        !num_colors_outer_crust_mantle, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_inner", &
+        !num_colors_inner_crust_mantle, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    ! colors
+
+    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle +&
+        num_colors_inner_crust_mantle), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank,'error allocating num_elem_colors_crust_mantle array')
+
+    local_dim = num_colors_outer_crust_mantle + num_colors_inner_crust_mantle 
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "num_elem_colors/array", 0, 1, &
+      num_elem_colors_crust_mantle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! allocates dummy arrays
+    num_colors_outer_crust_mantle = 0
+    num_colors_inner_crust_mantle = 0
+    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle + &
+        num_colors_inner_crust_mantle), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank, &
+          'error allocating num_elem_colors_crust_mantle array')
+  endif
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+
+end subroutine read_mesh_databases_MPI_CM_adios
+
+!===============================================================================
+!> \brief Read outer core MPI arrays from an ADIOS file.
+subroutine read_mesh_databases_MPI_OC_adios()
+  use mpi
+  use adios_read_mod
+  use specfem_par
+  use specfem_par_outercore
+  implicit none
+
+  ! local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  ! create the name for the database of the current slide and region
+  call create_name_database_adios(prname, IREGION_OUTER_CORE, LOCAL_PATH)
+
+  file_name= trim(prname) // "solver_data_mpi.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  ! MPI interfaces
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "num_interfaces", &
+    0, 1, num_interfaces_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "num_interfaces", &
+      !num_interfaces_outer_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  allocate(my_neighbours_outer_core(num_interfaces_outer_core), &
+          nibool_interfaces_outer_core(num_interfaces_outer_core), &
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array my_neighbours_outer_coreetc.')
+
+  if( num_interfaces_outer_core> 0 ) then
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "max_nibool_interfaces", &
+      0, 1, max_nibool_interfaces_oc, adios_err)
+    !call adios_get_scalar(adios_handle, "max_nibool_interfaces", &
+      !max_nibool_interfaces_oc, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_oc, &
+        num_interfaces_outer_core), stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array ibool_interfaces_outer_core')
+
+    local_dim = num_interfaces_outer_core
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "my_neighbours/array", 0, 1, &
+      my_neighbours_outer_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "nibool_interfaces/array", &
+      0, 1, nibool_interfaces_outer_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = max_nibool_interfaces_oc * num_interfaces_outer_core
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "ibool_interfaces/array", 0, 1, &
+      ibool_interfaces_outer_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! dummy array
+    max_nibool_interfaces_oc = 0
+    allocate(ibool_interfaces_outer_core(0,0),stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array dummy ibool_interfaces_outer_core')
+  endif
+
+  ! inner / outer elements
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec_inner", &
+  0, 1, nspec_inner_outer_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec_outer", &
+    0, 1, nspec_outer_outer_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "num_phase_ispec", &
+    0, 1, num_phase_ispec_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_inner", &
+      !nspec_inner_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_outer", &
+      !nspec_outer_outer_core, adios_err)
+  !call adios_get_scalar(adios_handle, "num_phase_ispec", &
+      !num_phase_ispec_outer_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  if( num_phase_ispec_outer_core< 0 ) &
+      call exit_mpi(myrank,'error num_phase_ispec_outer_core is < zero')
+
+  allocate(phase_ispec_inner_outer_core(num_phase_ispec_outer_core,2),&
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array phase_ispec_inner_outer_core')
+
+  if(num_phase_ispec_outer_core> 0 ) then
+    local_dim = num_phase_ispec_outer_core * 2
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "phase_ispec_inner/array", 0, 1, &
+      phase_ispec_inner_outer_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  ! mesh coloring for GPUs
+  if( USE_MESH_COLORING_GPU ) then
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "num_colors_outer", &
+      0, 1, num_colors_outer_outer_core, adios_err)
+    call adios_schedule_read(adios_handle, sel, "num_colors_inner", &
+      0, 1, num_colors_inner_outer_core, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_outer", &
+        !num_colors_outer_outer_core, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_inner", &
+        !num_colors_inner_outer_core, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    ! colors
+
+    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+&
+        num_colors_inner_outer_core), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank,'error allocating num_elem_colors_outer_core array')
+
+    local_dim = num_colors_outer_outer_core+ num_colors_inner_outer_core
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "num_elem_colors/array", 0, 1, &
+      num_elem_colors_outer_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! allocates dummy arrays
+    num_colors_outer_outer_core = 0
+    num_colors_inner_outer_core = 0
+    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+ &
+        num_colors_inner_outer_core), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank, &
+          'error allocating num_elem_colors_outer_core array')
+  endif
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+
+end subroutine read_mesh_databases_MPI_OC_adios
+
+
+!===============================================================================
+!> \brief Read outer core MPI arrays from an ADIOS file.
+subroutine read_mesh_databases_MPI_IC_adios()
+  use mpi
+  use adios_read_mod
+
+  use specfem_par
+  use specfem_par_innercore
+  implicit none
+
+  ! local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: file_name
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  ! create the name for the database of the current slide and region
+  call create_name_database_adios(prname, IREGION_INNER_CORE, LOCAL_PATH)
+
+  file_name= trim(prname) // "solver_data_mpi.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+
+  ! MPI interfaces
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "num_interfaces", &
+    0, 1, num_interfaces_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "num_interfaces", &
+      !num_interfaces_inner_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  allocate(my_neighbours_inner_core(num_interfaces_inner_core), &
+          nibool_interfaces_inner_core(num_interfaces_inner_core), &
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array my_neighbours_inner_core etc.')
+
+  if( num_interfaces_inner_core > 0 ) then
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "max_nibool_interfaces", &
+      0, 1, max_nibool_interfaces_ic, adios_err)
+    !call adios_get_scalar(adios_handle, "max_nibool_interfaces", &
+      !max_nibool_interfaces_ic, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_ic, &
+        num_interfaces_inner_core), stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array ibool_interfaces_inner_core')
+
+    local_dim = num_interfaces_inner_core
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, "my_neighbours/array", 0, 1, &
+      my_neighbours_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+    call adios_schedule_read(adios_handle, sel, "nibool_interfaces/array", &
+      0, 1, nibool_interfaces_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    local_dim = max_nibool_interfaces_ic * num_interfaces_inner_core
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "ibool_interfaces/array", 0, 1, &
+      ibool_interfaces_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! dummy array
+    max_nibool_interfaces_ic = 0
+    allocate(ibool_interfaces_inner_core(0,0),stat=ierr)
+    if( ierr /= 0 ) call exit_mpi(myrank, &
+        'error allocating array dummy ibool_interfaces_inner_core')
+  endif
+
+  ! inner / outer elements
+  call adios_selection_writeblock(sel, myrank)
+  call adios_schedule_read(adios_handle, sel, "nspec_inner", &
+    0, 1, nspec_inner_inner_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "nspec_outer", &
+    0, 1, nspec_outer_inner_core, adios_err)
+  call adios_schedule_read(adios_handle, sel, "num_phase_ispec", &
+    0, 1, num_phase_ispec_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_inner", &
+      !nspec_inner_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "nspec_outer", &
+      !nspec_outer_inner_core, adios_err)
+  !call adios_get_scalar(adios_handle, "num_phase_ispec", &
+      !num_phase_ispec_inner_core, adios_err)
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  if( num_phase_ispec_inner_core < 0 ) &
+      call exit_mpi(myrank,'error num_phase_ispec_inner_core is < zero')
+
+  allocate(phase_ispec_inner_inner_core(num_phase_ispec_inner_core,2),&
+          stat=ierr)
+  if( ierr /= 0 ) call exit_mpi(myrank, &
+      'error allocating array phase_ispec_inner_inner_core')
+
+  if(num_phase_ispec_inner_core > 0 ) then
+    local_dim = num_phase_ispec_inner_core * 2
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "phase_ispec_inner/array", 0, 1, &
+      phase_ispec_inner_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  endif
+
+  ! mesh coloring for GPUs
+  if( USE_MESH_COLORING_GPU ) then
+    call adios_selection_writeblock(sel, myrank)
+    call adios_schedule_read(adios_handle, sel, "num_colors_outer", &
+      0, 1, num_colors_outer_inner_core, adios_err)
+    call adios_schedule_read(adios_handle, sel, "num_colors_inner", &
+      0, 1, num_colors_inner_inner_core, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_outer", &
+        !num_colors_outer_inner_core, adios_err)
+    !call adios_get_scalar(adios_handle, "num_colors_inner", &
+        !num_colors_inner_inner_core, adios_err)
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+    ! colors
+
+    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core +&
+        num_colors_inner_inner_core), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank,'error allocating num_elem_colors_inner_core array')
+
+    local_dim = num_colors_outer_inner_core + num_colors_inner_inner_core 
+    start(1) = local_dim*myrank; count(1) = local_dim
+    call adios_selection_boundingbox (sel , 1, start, count)
+    call adios_schedule_read(adios_handle, sel, &
+      "num_elem_colors/array", 0, 1, &
+      num_elem_colors_inner_core, adios_err)
+    call check_adios_err(myrank,adios_err)
+
+    call adios_perform_reads(adios_handle, adios_err)
+    call check_adios_err(myrank,adios_err)
+  else
+    ! allocates dummy arrays
+    num_colors_outer_inner_core = 0
+    num_colors_inner_inner_core = 0
+    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core + &
+        num_colors_inner_inner_core), stat=ierr)
+    if( ierr /= 0 ) &
+      call exit_mpi(myrank, &
+          'error allocating num_elem_colors_inner_core array')
+  endif
+  ! Close ADIOS handler to the restart file.
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call MPI_Barrier(comm, ierr)
+
+end subroutine read_mesh_databases_MPI_IC_adios
+
+
+!===============================================================================
+!> \brief Read Stacey BC arrays from an ADIOS file.
+subroutine read_mesh_databases_stacey_adios()
+
+  use mpi
+  use adios_read_mod
+
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  ! local parameters
+  integer :: ierr, comm, lnspec, lnglob, local_dim
+  ! processor identification
+  character(len=150) :: reg_name, file_name
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid, sel
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  integer :: vars_count, attrs_count, current_step, last_step, vsteps
+  character(len=128), dimension(:), allocatable :: adios_names 
+  integer(kind=8), dimension(1) :: start, count
+
+  ! crust and mantle
+
+  ! create name of database
+  call create_name_database_adios(reg_name, IREGION_CRUST_MANTLE, LOCAL_PATH)
+
+  file_name= trim(reg_name) // "stacey.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+  ! read arrays for Stacey conditions
+
+  local_dim = 2*NSPEC2DMAX_XMIN_XMAX_CM 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "njmin/array", 0, 1, &
+      njmin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "njmax/array", 0, 1, &
+      njmax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nkmin_xi/array", 0, 1, &
+      nkmin_xi_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = 2*NSPEC2DMAX_YMIN_YMAX_CM 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nimin/array", 0, 1, &
+      nimin_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nimax/array", 0, 1, &
+      nimax_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nkmin_eta/array", 0, 1, &
+      nkmin_eta_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  ! outer core
+
+  ! create name of database
+  call create_name_database_adios(reg_name, IREGION_OUTER_CORE, LOCAL_PATH)
+
+  file_name= trim(reg_name) // "stacey.bp" 
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, comm, &
+      "verbose=1", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_open_file (adios_handle, file_name, 0, comm, ierr)
+  call check_adios_err(myrank,adios_err)
+  ! read arrays for Stacey conditions
+
+  local_dim = 2*NSPEC2DMAX_XMIN_XMAX_OC 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "njmin/array", 0, 1, &
+      njmin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "njmax/array", 0, 1, &
+      njmax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nkmin_xi/array", 0, 1, &
+      nkmin_xi_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = 2*NSPEC2DMAX_YMIN_YMAX_OC 
+  start(1) = local_dim*myrank; count(1) = local_dim
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nimin/array", 0, 1, &
+      nimin_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nimax/array", 0, 1, &
+      nimax_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_selection_boundingbox (sel , 1, start, count)
+  call adios_schedule_read(adios_handle, sel, "nkmin_eta/array", 0, 1, &
+      nkmin_eta_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_perform_reads(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_selection_delete(sel)
+  call adios_read_close(adios_handle, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+end subroutine read_mesh_databases_stacey_adios
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays.f90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays.f90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -25,7 +25,16 @@
 !
 !=====================================================================
 
-  subroutine save_forward_arrays()
+!> Save the values of the arrays used for forward simulations.
+!!
+!! Two different options allow to save arrays used for forward simulations.
+!!   - setting SAVE_FORWARD to true. That save the last frame.
+!!   - setting NUMBERS_OF_RUNS to 2 or 3. This save intermadiate frame to
+!!     restart the remaining of the simulation later.
+!! Moreover, one can choose to save these arrays with the help of the ADIOS
+!! library. Set ADIOS_FOR_FORWARD_ARRAYS to true in the Par_file for this
+!! feature.
+subroutine save_forward_arrays()
 
   use specfem_par
   use specfem_par_crustmantle
@@ -39,98 +48,108 @@
 
   ! save files to local disk or tape system if restart file
   if(NUMBER_OF_RUNS > 1 .and. NUMBER_OF_THIS_RUN < NUMBER_OF_RUNS) then
-    write(outputname,"('dump_all_arrays',i6.6)") myrank
-    open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname,status='unknown',form='unformatted',action='write')
+    if (ADIOS_FOR_FORWARD_ARRAYS) then
+      call save_intermediate_forward_arrays_adios()
+    else
+      write(outputname,"('dump_all_arrays',i6.6)") myrank
+      open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname, &
+      status='unknown',form='unformatted',action='write')
 
-    write(55) displ_crust_mantle
-    write(55) veloc_crust_mantle
-    write(55) accel_crust_mantle
-    write(55) displ_inner_core
-    write(55) veloc_inner_core
-    write(55) accel_inner_core
-    write(55) displ_outer_core
-    write(55) veloc_outer_core
-    write(55) accel_outer_core
+      write(55) displ_crust_mantle
+      write(55) veloc_crust_mantle
+      write(55) accel_crust_mantle
+      write(55) displ_inner_core
+      write(55) veloc_inner_core
+      write(55) accel_inner_core
+      write(55) displ_outer_core
+      write(55) veloc_outer_core
+      write(55) accel_outer_core
 
-    write(55) epsilondev_xx_crust_mantle
-    write(55) epsilondev_yy_crust_mantle
-    write(55) epsilondev_xy_crust_mantle
-    write(55) epsilondev_xz_crust_mantle
-    write(55) epsilondev_yz_crust_mantle
+      write(55) epsilondev_xx_crust_mantle
+      write(55) epsilondev_yy_crust_mantle
+      write(55) epsilondev_xy_crust_mantle
+      write(55) epsilondev_xz_crust_mantle
+      write(55) epsilondev_yz_crust_mantle
 
-    write(55) epsilondev_xx_inner_core
-    write(55) epsilondev_yy_inner_core
-    write(55) epsilondev_xy_inner_core
-    write(55) epsilondev_xz_inner_core
-    write(55) epsilondev_yz_inner_core
+      write(55) epsilondev_xx_inner_core
+      write(55) epsilondev_yy_inner_core
+      write(55) epsilondev_xy_inner_core
+      write(55) epsilondev_xz_inner_core
+      write(55) epsilondev_yz_inner_core
 
-    write(55) A_array_rotation
-    write(55) B_array_rotation
+      write(55) A_array_rotation
+      write(55) B_array_rotation
 
-    write(55) R_xx_crust_mantle
-    write(55) R_yy_crust_mantle
-    write(55) R_xy_crust_mantle
-    write(55) R_xz_crust_mantle
-    write(55) R_yz_crust_mantle
+      write(55) R_xx_crust_mantle
+      write(55) R_yy_crust_mantle
+      write(55) R_xy_crust_mantle
+      write(55) R_xz_crust_mantle
+      write(55) R_yz_crust_mantle
 
-    write(55) R_xx_inner_core
-    write(55) R_yy_inner_core
-    write(55) R_xy_inner_core
-    write(55) R_xz_inner_core
-    write(55) R_yz_inner_core
+      write(55) R_xx_inner_core
+      write(55) R_yy_inner_core
+      write(55) R_xy_inner_core
+      write(55) R_xz_inner_core
+      write(55) R_yz_inner_core
 
-    close(55)
+      close(55)
+    endif
   endif
 
   ! save last frame of the forward simulation
   if (SIMULATION_TYPE == 1 .and. SAVE_FORWARD) then
-    write(outputname,'(a,i6.6,a)') 'proc',myrank,'_save_forward_arrays.bin'
-    open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname,status='unknown',form='unformatted',action='write')
+    if (ADIOS_FOR_FORWARD_ARRAYS) then
+      call save_forward_arrays_adios()
+    else
+      write(outputname,'(a,i6.6,a)') 'proc',myrank,'_save_forward_arrays.bin'
+      open(unit=55,file=trim(LOCAL_TMP_PATH)//'/'//outputname,status='unknown', &
+          form='unformatted',action='write')
 
-    write(55) displ_crust_mantle
-    write(55) veloc_crust_mantle
-    write(55) accel_crust_mantle
+      write(55) displ_crust_mantle
+      write(55) veloc_crust_mantle
+      write(55) accel_crust_mantle
 
-    write(55) displ_inner_core
-    write(55) veloc_inner_core
-    write(55) accel_inner_core
+      write(55) displ_inner_core
+      write(55) veloc_inner_core
+      write(55) accel_inner_core
 
-    write(55) displ_outer_core
-    write(55) veloc_outer_core
-    write(55) accel_outer_core
+      write(55) displ_outer_core
+      write(55) veloc_outer_core
+      write(55) accel_outer_core
 
-    write(55) epsilondev_xx_crust_mantle
-    write(55) epsilondev_yy_crust_mantle
-    write(55) epsilondev_xy_crust_mantle
-    write(55) epsilondev_xz_crust_mantle
-    write(55) epsilondev_yz_crust_mantle
+      write(55) epsilondev_xx_crust_mantle
+      write(55) epsilondev_yy_crust_mantle
+      write(55) epsilondev_xy_crust_mantle
+      write(55) epsilondev_xz_crust_mantle
+      write(55) epsilondev_yz_crust_mantle
 
-    write(55) epsilondev_xx_inner_core
-    write(55) epsilondev_yy_inner_core
-    write(55) epsilondev_xy_inner_core
-    write(55) epsilondev_xz_inner_core
-    write(55) epsilondev_yz_inner_core
+      write(55) epsilondev_xx_inner_core
+      write(55) epsilondev_yy_inner_core
+      write(55) epsilondev_xy_inner_core
+      write(55) epsilondev_xz_inner_core
+      write(55) epsilondev_yz_inner_core
 
-    if (ROTATION_VAL) then
-      write(55) A_array_rotation
-      write(55) B_array_rotation
-    endif
+      if (ROTATION_VAL) then
+        write(55) A_array_rotation
+        write(55) B_array_rotation
+      endif
 
-    if (ATTENUATION_VAL) then
-       write(55) R_xx_crust_mantle
-       write(55) R_yy_crust_mantle
-       write(55) R_xy_crust_mantle
-       write(55) R_xz_crust_mantle
-       write(55) R_yz_crust_mantle
+      if (ATTENUATION_VAL) then
+         write(55) R_xx_crust_mantle
+         write(55) R_yy_crust_mantle
+         write(55) R_xy_crust_mantle
+         write(55) R_xz_crust_mantle
+         write(55) R_yz_crust_mantle
 
-       write(55) R_xx_inner_core
-       write(55) R_yy_inner_core
-       write(55) R_xy_inner_core
-       write(55) R_xz_inner_core
-       write(55) R_yz_inner_core
+         write(55) R_xx_inner_core
+         write(55) R_yy_inner_core
+         write(55) R_xy_inner_core
+         write(55) R_xz_inner_core
+         write(55) R_yz_inner_core
+      endif
+
+      close(55)
     endif
-
-    close(55)
   endif
 
-  end subroutine save_forward_arrays
+end subroutine save_forward_arrays

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays_adios.F90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/save_forward_arrays_adios.F90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays_adios.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays_adios.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,592 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!-------------------------------------------------------------------------------
+!> \file save_forward_arrays_adios.F90
+!! \brief Save forward arrays with the help of the ADIOS library.
+!! \author MPBL
+!-------------------------------------------------------------------------------
+
+!-------------------------------------------------------------------------------
+!> \brief Write intermediate forward arrays in an ADIOS file.
+!! 
+!! This subroutine is only used when NUMBER_OF_RUNS > 1 and
+!! NUMBER_OF_THIS_RUN < NUMBER_OF_RUNS.
+subroutine save_intermediate_forward_arrays_adios()
+  ! External imports
+  use mpi
+  use adios_write_mod
+  ! Internal imports
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+  ! Local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: outputname
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  outputname = trim(LOCAL_TMP_PATH) // "/dump_all_arrays_adios.bp" 
+  call world_size(sizeprocs) ! TODO keep it in parameters
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  group_size_inc = 0
+  call adios_declare_group(adios_group, "SPECFEM3D_GLOBE_FORWARD_ARRAYS", &
+      "", 1, adios_err)
+!  call check_adios_err(myrank,adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Define ADIOS variables
+  call define_common_forward_arrays_adios(adios_group, group_size_inc)
+  call define_rotation_forward_arrays_adios(adios_group, group_size_inc)
+  call define_attenuation_forward_arrays_adios(adios_group, group_size_inc)
+
+  ! Open an ADIOS handler to the restart file.
+  call adios_open (adios_handle, "SPECFEM3D_GLOBE_FORWARD_ARRAYS", &
+      outputname, "w", comm, adios_err);
+!  call check_adios_err(myrank,adios_err)
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Issue the order to write the previously defined variable to the ADIOS file
+  call write_common_forward_arrays_adios(adios_handle, sizeprocs)
+  call write_rotation_forward_arrays_adios(adios_handle, sizeprocs)
+  call write_attenuation_forward_arrays_adios(adios_handle, sizeprocs)
+  ! Reset the path to its original value to avoid bugs.
+  call adios_set_path (adios_handle, "", adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Close ADIOS handler to the restart file.
+  call adios_close(adios_handle, adios_err)
+!  call check_adios_err(myrank,adios_err)
+end subroutine save_intermediate_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> \brief Write selected forward arrays in an ADIOS file.
+!! 
+!! This subroutine is only used for forward simualtions when
+!! SAVE_FORWARD is set to .true. It dumps the same arrays than 
+!! save_intermediate_forward_arrays_adios() execpt than some arrays
+!! are only dumped if ROTATION and ATTENUATION are set to .true.
+subroutine save_forward_arrays_adios()
+  ! External imports
+  use mpi
+  use adios_write_mod
+  ! Internal imports
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+  ! Local parameters
+  integer :: sizeprocs, comm, ierr
+  character(len=150) :: outputname
+  integer(kind=8) :: group_size_inc
+  integer :: local_dim, global_dim, offset
+!  integer, parameter :: num_arrays = 9 ! TODO correct number 
+!  character(len=256), dimension(num_arrays) :: local_dims1, local_dims2, &
+!      global_dims1, global_dims2, offsets1, offsets2, array_name
+  ! ADIOS variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+
+  outputname = trim(LOCAL_TMP_PATH) // "/save_forward_arrays.bp" 
+  call world_size(sizeprocs)
+  call MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)
+  group_size_inc = 0
+
+  call adios_declare_group(adios_group, "SPECFEM3D_GLOBE_FORWARD_ARRAYS", &
+      "", 1, adios_err)
+!  call check_adios_err(myrank,adios_err)
+  call adios_select_method(adios_group, "MPI", "", "", adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Define ADIOS variables
+  call define_common_forward_arrays_adios(adios_group, group_size_inc)
+  ! conditional definition of vars seem to mess with the group size, 
+  ! even if the variables are conditionnaly written.
+!  if (ROTATION_VAL) then
+    call define_rotation_forward_arrays_adios(adios_group, group_size_inc)
+!  endif
+!  if (ATTENUATION_VAL) then
+    call define_attenuation_forward_arrays_adios(adios_group, group_size_inc)
+!  endif
+
+  ! Open an ADIOS handler to the restart file.
+  call adios_open (adios_handle, "SPECFEM3D_GLOBE_FORWARD_ARRAYS", &
+      outputname, "w", comm, adios_err);
+!  call check_adios_err(myrank,adios_err)
+  call adios_group_size (adios_handle, group_size_inc, &
+                         adios_totalsize, adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Issue the order to write the previously defined variable to the ADIOS file
+  call write_common_forward_arrays_adios(adios_handle, sizeprocs)
+  if (ROTATION_VAL) then
+      call write_rotation_forward_arrays_adios(adios_handle, sizeprocs)
+  endif
+  if (ATTENUATION_VAL) then
+    call write_attenuation_forward_arrays_adios(adios_handle, sizeprocs)
+  endif
+  ! Reset the path to its original value to avoid bugs.
+  call adios_set_path (adios_handle, "", adios_err)
+!  call check_adios_err(myrank,adios_err)
+
+  ! Close ADIOS handler to the restart file.
+  call adios_close(adios_handle, adios_err)
+!  call check_adios_err(myrank,adios_err)
+end subroutine save_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> Define ADIOS forward arrays that are always dumped.
+!! \param adios_group The adios group where the variables belongs
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_common_forward_arrays_adios(adios_group, group_size_inc)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer :: local_dim
+
+  local_dim = NDIM * NGLOB_CRUST_MANTLE 
+  call define_adios_global_real_1d_array(adios_group, "displ_crust_mantle", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "veloc_crust_mantle", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "accel_crust_mantle", &
+      local_dim, group_size_inc)
+
+  local_dim = NDIM * NGLOB_INNER_CORE
+  call define_adios_global_real_1d_array(adios_group, "displ_inner_core", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "veloc_inner_core", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "accel_inner_core", &
+      local_dim, group_size_inc)
+
+  local_dim = NGLOB_OUTER_CORE
+  call define_adios_global_real_1d_array(adios_group, "displ_outer_core", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "veloc_outer_core", &
+      local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, "accel_outer_core", &
+      local_dim, group_size_inc)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_CRUST_MANTLE_STR_OR_ATT
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xx_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_yy_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xy_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xz_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_yz_crust_mantle", local_dim, group_size_inc)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_INNER_CORE_STR_OR_ATT
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xx_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_yy_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xy_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_xz_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "epsilondev_yz_inner_core", local_dim, group_size_inc)
+end subroutine define_common_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> Define ADIOS forward arrays that are dumped if ROTATION is true.
+!! \param adios_group The adios group where the variables belongs
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_rotation_forward_arrays_adios(adios_group, group_size_inc)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer :: local_dim
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_OUTER_CORE_ROTATION
+  call define_adios_global_real_1d_array(adios_group, &
+      "A_array_rotation", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "B_array_rotation", local_dim, group_size_inc)
+end subroutine define_rotation_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> Define ADIOS forward arrays that are dumped if ATTENUATION is true.
+!! \param adios_group The adios group where the variables belongs
+!! \param group_size_inc The inout adios group size to increment
+!!                       with the size of the variable
+subroutine define_attenuation_forward_arrays_adios(adios_group, group_size_inc)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+
+  integer :: local_dim
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_CRUST_MANTLE_ATTENUAT
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xx_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_yy_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xy_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xz_crust_mantle", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_yz_crust_mantle", local_dim, group_size_inc)
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_INNER_CORE_ATTENUATION
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xx_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_yy_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xy_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_xz_inner_core", local_dim, group_size_inc)
+  call define_adios_global_real_1d_array(adios_group, &
+      "R_yz_inner_core", local_dim, group_size_inc)
+end subroutine define_attenuation_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!>  Schedule writes of ADIOS forward arrays that are always dumped.
+!! \param adios_handle The handle to the adios bp file
+!! \param group_size_inc The number of MPI processes involved in the writting 
+subroutine write_common_forward_arrays_adios(adios_handle, sizeprocs)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: sizeprocs 
+
+  integer :: local_dim, adios_err
+
+  local_dim = NDIM * NGLOB_CRUST_MANTLE 
+  call adios_set_path (adios_handle, "displ_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", displ_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "veloc_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", veloc_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "accel_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", accel_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NDIM * NGLOB_INNER_CORE
+  call adios_set_path (adios_handle, "displ_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", displ_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "veloc_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", veloc_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "accel_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", accel_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_set_path (adios_handle, "", adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLOB_OUTER_CORE
+  call adios_set_path (adios_handle, "displ_outer_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", displ_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "veloc_outer_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", veloc_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "accel_outer_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", accel_outer_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_CRUST_MANTLE_STR_OR_ATT
+  call adios_set_path (adios_handle, "epsilondev_xx_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xx_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_yy_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_yy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_xy_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_xz_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_yz_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_yz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_INNER_CORE_STR_OR_ATT
+  call adios_set_path (adios_handle, "epsilondev_xx_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xx_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_yy_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_yy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_xy_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_xz_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_xz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "epsilondev_yz_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", epsilondev_yz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+end subroutine write_common_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!>  Schedule writes of ADIOS forward arrays that are dumped if ROTATION is true.
+!! \param adios_handle The handle to the adios bp file
+!! \param group_size_inc The number of MPI processes involved in the writting 
+subroutine write_rotation_forward_arrays_adios(adios_handle, sizeprocs)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: sizeprocs 
+
+  integer :: local_dim, adios_err
+
+  local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_OUTER_CORE_ROTATION
+  call adios_set_path (adios_handle, "A_array_rotation", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", A_array_rotation, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "B_array_rotation", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", B_array_rotation, adios_err)
+  call check_adios_err(myrank,adios_err)
+end subroutine write_rotation_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!>  Schedule writes of ADIOS forward arrays that are dumped if ATTENUATION 
+!!  is true.
+!! \param adios_handle The handle to the adios bp file
+!! \param group_size_inc The number of MPI processes involved in the writting 
+subroutine write_attenuation_forward_arrays_adios(adios_handle, sizeprocs)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: sizeprocs 
+
+  integer :: local_dim, adios_err
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_CRUST_MANTLE_ATTENUAT
+  call adios_set_path (adios_handle, "R_xx_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xx_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_yy_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_yy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_xy_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xy_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_xz_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_yz_crust_mantle", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_yz_crust_mantle, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  local_dim = N_SLS*NGLLX*NGLLY*NGLLZ*NSPEC_INNER_CORE_ATTENUATION
+  call adios_set_path (adios_handle, "R_xx_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xx_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_yy_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_yy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_xy_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xy_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_xz_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_xz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+
+  call adios_set_path (adios_handle, "R_yz_inner_core", adios_err)
+  call check_adios_err(myrank,adios_err)
+  call write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  call adios_write(adios_handle, "array", R_yz_inner_core, adios_err)
+  call check_adios_err(myrank,adios_err)
+end subroutine write_attenuation_forward_arrays_adios
+
+!-------------------------------------------------------------------------------
+!> Write local, global and offset dimensions to ADIOS 
+!! \param adios_handle Handle to the adios file
+!! \param local_dim Number of elements to be written by one process
+!! \param sizeprocs Number of MPI processes
+subroutine write_1D_global_array_adios_dims(adios_handle, local_dim, sizeprocs)
+  use adios_write_mod
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_innercore
+  use specfem_par_outercore
+
+  implicit none
+
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: sizeprocs, local_dim
+
+  integer :: adios_err
+
+  call adios_write(adios_handle, "local_dim", local_dim, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_write(adios_handle, "global_dim", local_dim*sizeprocs, adios_err)
+  call check_adios_err(myrank,adios_err)
+  call adios_write(adios_handle, "offset", local_dim*myrank, adios_err)
+  call check_adios_err(myrank,adios_err)
+end subroutine write_1D_global_array_adios_dims
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D.F90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -447,7 +447,6 @@
 
   ! starts reading the databases
   call read_mesh_databases()
-
   ! sets up reference element GLL points/weights/derivatives
   call setup_GLL_points()
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D_par.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D_par.F90	2013-06-30 12:30:23 UTC (rev 22452)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D_par.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -304,6 +304,13 @@
   logical :: GPU_MODE
 
   !-----------------------------------------------------------------
+  ! ADIOS
+  !-----------------------------------------------------------------
+
+  logical :: ADIOS_ENABLED, ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MPI_ARRAYS, &
+      ADIOS_FOR_ARRAYS_SOLVER, ADIOS_FOR_SOLVER_MESHFILES, ADIOS_FOR_AVS_DX
+
+  !-----------------------------------------------------------------
   ! time scheme
   !-----------------------------------------------------------------
 

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_specfem_adios_header.F90 (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/src/specfem3D/write_specfem_adios_header.F90)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_specfem_adios_header.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_specfem_adios_header.F90	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,761 @@
+!=====================================================================
+!
+!          S p e c f e m 3 D  G l o b e  V e r s i o n  5 . 1
+!          --------------------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!                        Princeton University, USA
+!             and University of Pau / CNRS / INRIA, France
+! (c) Princeton University / California Institute of Technology and University of Pau / CNRS / INRIA
+!                            April 2011
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+!> \file write_par_header_ADIOS.F90
+!! \brief Write in the adios file a group with all the parameters that insure
+!!        reproductibility
+
+#include "config.fh"
+
+!
+!-------------------------------------------------------------------------------
+!
+
+!> @brief Write simulation parameters into ADIOS result file header.
+!!
+!! Write the ADIOS header containing values to ensure reproductibility of
+!! the simulation. These values come form the following files :
+!! DATA/Par_file, DATA/CMTSOLUTION, DATA/STATIONS
+subroutine write_specfem_header_adios()
+  use mpi
+  use adios_write_mod
+  use specfem_par, only : myrank, NSOURCES
+
+  implicit none
+  include "constants.h"
+
+  !-------------------------------------------------------------------
+  ! local parameters
+  !-------------------------------------------------------------------
+  ! parameters read from parameter file (cf. DATA/Par_file)
+  integer  :: NTSTEP_BETWEEN_OUTPUT_SEISMOS,NTSTEP_BETWEEN_READ_ADJSRC,        &
+      NTSTEP_BETWEEN_FRAMES, NTSTEP_BETWEEN_OUTPUT_INFO,NUMBER_OF_RUNS,        &
+      NUMBER_OF_THIS_RUN,NCHUNKS,SIMULATION_TYPE, MOVIE_VOLUME_TYPE,           &
+      MOVIE_START,MOVIE_STOP, NEX_XI,NEX_ETA,NPROC_XI,NPROC_ETA,               &
+      NOISE_TOMOGRAPHY
+
+  double precision :: ANGULAR_WIDTH_XI_IN_DEGREES,ANGULAR_WIDTH_ETA_IN_DEGREES,&
+      CENTER_LONGITUDE_IN_DEGREES,CENTER_LATITUDE_IN_DEGREES,                  &
+      GAMMA_ROTATION_AZIMUTH, HDUR_MOVIE,MOVIE_TOP_KM,MOVIE_BOTTOM_KM,         &
+      MOVIE_EAST_DEG,MOVIE_WEST_DEG,MOVIE_NORTH_DEG,MOVIE_SOUTH_DEG,           &
+      RECORD_LENGTH_IN_MINUTES
+
+  logical :: ELLIPTICITY,GRAVITY,ROTATION,TOPOGRAPHY,OCEANS, MOVIE_SURFACE,    &
+      MOVIE_VOLUME,MOVIE_COARSE, RECEIVERS_CAN_BE_BURIED,                      &
+      PRINT_SOURCE_TIME_FUNCTION, SAVE_MESH_FILES,ATTENUATION,ATTENUATION_NEW, &
+      ABSORBING_CONDITIONS,SAVE_FORWARD, OUTPUT_SEISMOS_ASCII_TEXT,            &
+      OUTPUT_SEISMOS_SAC_ALPHANUM,OUTPUT_SEISMOS_SAC_BINARY,                   &
+      ROTATE_SEISMOGRAMS_RT,WRITE_SEISMOGRAMS_BY_MASTER,                       &
+      SAVE_ALL_SEISMOS_IN_ONE_FILE,USE_BINARY_FOR_LARGE_FILE
+
+  ! values from CMTSOLUTION -------------------------------
+  ! integer          :: NSOURCES -> in specfem_par module
+  integer,           dimension(NSOURCES) :: yr, mo, da, ho, mi
+  double precision,  dimension(NSOURCES) :: sec, t_shift, hdur, lat, long, depth
+  double precision,  dimension(NSOURCES) :: mrr, mtt, mpp, mrt, mrp, mtp 
+  integer :: event_name_length, datasource_length
+  character(len=16):: event_name
+  character(len=:), allocatable  :: datasource  ! F03 feature
+
+  ! values from STATIONS ----------------------------------
+  integer :: NSTATIONS
+  integer :: station_name_length, network_name_length ! for later reading
+  character(len=:),   allocatable :: station_name, network_name 
+  double precision, allocatable, dimension(:) :: stlat, stlon, stele, stbur
+
+  character(len=150) :: OUTPUT_FILES,LOCAL_PATH,LOCAL_TMP_PATH,MODEL
+
+  ! Adios variables
+  integer                 :: adios_err
+  integer(kind=8)         :: adios_group, adios_handle, varid
+  integer(kind=8)         :: adios_groupsize, adios_totalsize
+  ! TODO: find a better name once the use of ADIOS is more completely
+  !       implemented
+  character(len=256):: filename = "OUTPUT_FILES/header_specfem3d_globe.bp" 
+  integer(kind=8)   :: group_size_inc
+  integer           :: model_length ! for later reading of MODEL
+  integer           :: isource, irec, ier
+
+
+  ! only the master needs to read the values to be written 
+  if(myrank == 0) then
+    call adios_declare_group (adios_group, "SPECFEM3D_GLOBE_HEADER",           &
+                              "", 0, adios_err)
+    call adios_select_method (adios_group, "MPI", "", "", adios_err)
+
+    group_size_inc = 0 ! Adios group size. Incremented by adios_helpers
+
+    !-- *** Define variables used to configure specfem
+    call define_solver_info_variables (adios_group, group_size_inc)
+
+    !--*** Values read from DATA/Par_file ***
+    ! extract all unmodified values from the Par_file
+    call read_parameter_file(OUTPUT_FILES,                                     & 
+        LOCAL_PATH, LOCAL_TMP_PATH, MODEL,                                     & 
+        NTSTEP_BETWEEN_OUTPUT_SEISMOS, NTSTEP_BETWEEN_READ_ADJSRC,             &
+        NTSTEP_BETWEEN_FRAMES, NTSTEP_BETWEEN_OUTPUT_INFO, NUMBER_OF_RUNS,     & 
+        NUMBER_OF_THIS_RUN, NCHUNKS, SIMULATION_TYPE, MOVIE_VOLUME_TYPE,       &
+        MOVIE_START, MOVIE_STOP, NEX_XI, NEX_ETA, NPROC_XI, NPROC_ETA,         & 
+        ANGULAR_WIDTH_XI_IN_DEGREES, ANGULAR_WIDTH_ETA_IN_DEGREES,             & 
+        CENTER_LONGITUDE_IN_DEGREES, CENTER_LATITUDE_IN_DEGREES,               &
+        GAMMA_ROTATION_AZIMUTH, HDUR_MOVIE, MOVIE_TOP_KM, MOVIE_BOTTOM_KM,     &
+        RECORD_LENGTH_IN_MINUTES, MOVIE_EAST_DEG, MOVIE_WEST_DEG,              &
+        MOVIE_NORTH_DEG, MOVIE_SOUTH_DEG, ELLIPTICITY, GRAVITY, ROTATION,      &
+        TOPOGRAPHY, OCEANS, MOVIE_SURFACE, MOVIE_VOLUME, MOVIE_COARSE,         & 
+        RECEIVERS_CAN_BE_BURIED, PRINT_SOURCE_TIME_FUNCTION, SAVE_MESH_FILES,  &
+        ATTENUATION, ATTENUATION_NEW, ABSORBING_CONDITIONS, SAVE_FORWARD,      & 
+        OUTPUT_SEISMOS_ASCII_TEXT, OUTPUT_SEISMOS_SAC_ALPHANUM,                &
+        OUTPUT_SEISMOS_SAC_BINARY, ROTATE_SEISMOGRAMS_RT,                      &
+        WRITE_SEISMOGRAMS_BY_MASTER, SAVE_ALL_SEISMOS_IN_ONE_FILE,             &
+        USE_BINARY_FOR_LARGE_FILE, NOISE_TOMOGRAPHY)
+
+    model_length = len(MODEL)
+    ! define adios variables for the Par_file
+    call define_par_file_variables (adios_group, group_size_inc, model_length)
+
+    !--*** Values read from DATA/CMTSOLUTION ***--
+    call read_raw_cmtsolution (yr, mo, da, ho, mi, sec, t_shift, hdur, lat,    &
+        long, depth, mrr, mtt, mpp, mrt, mrp, mtp, event_name_length,          &
+        event_name, datasource_length,  datasource)
+    call define_cmtsolution_variables (adios_group, group_size_inc, NSOURCES,  &
+        event_name_length, datasource_length)
+
+    !--*** Values read from DATA/STATIONS
+    call read_raw_stations (NSTATIONS, stlat, stlon, stele, stbur,             &
+        station_name_length, station_name, network_name_length, network_name)
+    call define_stations_variables (adios_group, group_size_inc, NSTATIONS,    &
+        station_name_length, network_name_length)
+
+    ! open the file where the headers have to be written
+    call adios_open (adios_handle, "SPECFEM3D_GLOBE_HEADER", filename, "w",    &
+                     MPI_COMM_SELF, adios_err);
+    ! The group size have been auto-incremented
+    adios_groupsize = group_size_inc
+    call adios_group_size (adios_handle, adios_groupsize,                      &
+                           adios_totalsize, adios_err)
+
+    ! Write variables from 'config.h'
+    call write_adios_solver_info_variables (adios_handle)
+
+    ! Write variables from 'Par_file'
+    call write_adios_par_file_variables (adios_handle,                         &
+        ANGULAR_WIDTH_XI_IN_DEGREES, ANGULAR_WIDTH_ETA_IN_DEGREES,             &
+        CENTER_LONGITUDE_IN_DEGREES, CENTER_LATITUDE_IN_DEGREES,               &
+        GAMMA_ROTATION_AZIMUTH, HDUR_MOVIE, MOVIE_TOP_KM, MOVIE_BOTTOM_KM,     &
+        MOVIE_EAST_DEG, MOVIE_WEST_DEG, MOVIE_NORTH_DEG, MOVIE_SOUTH_DEG,      &
+        RECORD_LENGTH_IN_MINUTES, NTSTEP_BETWEEN_OUTPUT_SEISMOS,               &
+        NTSTEP_BETWEEN_READ_ADJSRC, NTSTEP_BETWEEN_FRAMES,                     &
+        NTSTEP_BETWEEN_OUTPUT_INFO, NUMBER_OF_RUNS, NUMBER_OF_THIS_RUN,NCHUNKS,&
+        SIMULATION_TYPE, MOVIE_VOLUME_TYPE, MOVIE_START, MOVIE_STOP, NEX_XI,   &
+        NEX_ETA, NPROC_XI, NPROC_ETA, NOISE_TOMOGRAPHY, ELLIPTICITY, GRAVITY,  &
+        ROTATION, TOPOGRAPHY, OCEANS, MOVIE_SURFACE, MOVIE_VOLUME,MOVIE_COARSE,&
+        RECEIVERS_CAN_BE_BURIED, PRINT_SOURCE_TIME_FUNCTION, SAVE_MESH_FILES,  &
+        ATTENUATION, ATTENUATION_NEW, ABSORBING_CONDITIONS, SAVE_FORWARD,      &
+        OUTPUT_SEISMOS_ASCII_TEXT, OUTPUT_SEISMOS_SAC_ALPHANUM,                &
+        OUTPUT_SEISMOS_SAC_BINARY, ROTATE_SEISMOGRAMS_RT,                      &
+        WRITE_SEISMOGRAMS_BY_MASTER, SAVE_ALL_SEISMOS_IN_ONE_FILE,             &
+        USE_BINARY_FOR_LARGE_FILE, model_length, MODEL)
+
+    ! Write variables from 'CMTSOLUTION'
+    call write_adios_cmtsolution_variables (adios_handle,                      &
+        NSOURCES, yr, mo, da, ho, mi, sec, t_shift, hdur, lat, long, depth,    &
+        mrr, mtt, mpp, mrt, mrp, mtp, event_name_length, event_name,           &
+        datasource_length, datasource)
+
+    ! Write variables from 'STATIONS' 
+    call write_adios_stations_variables (adios_handle,                         &
+       NSTATIONS, stlat, stlon, stele, stbur, station_name_length,             &
+       station_name, network_name_length, network_name)
+
+    call adios_close (adios_handle, adios_err)
+
+    deallocate(datasource)
+    deallocate(station_name)
+    deallocate(network_name)
+    deallocate(stlat)
+    deallocate(stlon)
+    deallocate(stele)
+    deallocate(stbur)
+  endif
+
+! Imbricated/contained subroutines. The initial thougth was to do a module with
+! public access to the write_specfem_header_adios routine and private access to
+! the other routines. The problem then is the files compilation order that 
+! should be done very carefully. This require modifications of the Makefile
+! which is not currently designed to do that.
+contains
+
+!> \brief Define ADIOS variable to store values from 'setup/config.h'. Store
+!!        configuration parameters to insure reproductibility
+!! \param adios_group The ADIOS entity grouping variables for data transferts
+!! \param group_size_inc The group size to increment wrt. the variable size
+subroutine define_solver_info_variables (adios_group, group_size_inc)
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in)    :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+  ! Variables
+  integer :: pkg_str_len, conf_flags_len
+ 
+  pkg_str_len    = len_trim(PACKAGE_STRING)
+  conf_flags_len = len_trim(CONFIGURE_FLAGS)
+  call define_adios_integer_scalar (adios_group, "package_string_length", &
+      "/solver_info", group_size_inc)
+  call define_adios_string (adios_group, "package_name", "/solver_info", &
+      pkg_str_len, group_size_inc)
+  call define_adios_integer_scalar (adios_group, "conf_flags_len", &
+      "/solver_info", group_size_inc)
+  call define_adios_string (adios_group, "conf_flags", "/solver_info", &
+      conf_flags_len, group_size_inc)
+end subroutine define_solver_info_variables
+
+!> \brief Define ADIOS variable to store values from the Par_file
+!! \param adios_group The ADIOS entity grouping variables for data transferts
+!! \param group_size_inc The group size to increment wrt. the variable size
+!! \param model_length The number of character of the MODEL string.
+!!                     Usefull for reading back the MODEL
+subroutine define_par_file_variables (adios_group, group_size_inc, model_length)
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in)    :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+  integer, intent(in)            :: model_length ! for later reading of MODEL
+
+  !-- double precision variables
+  call define_adios_double_scalar (adios_group, "ANGULAR_WIDTH_XI_IN_DEGREES", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "ANGULAR_WIDTH_ETA_IN_DEGREES", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "CENTER_LONGITUDE_IN_DEGREES", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "CENTER_LATITUDE_IN_DEGREES", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "GAMMA_ROTATION_AZIMUTH", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "HDUR_MOVIE", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_TOP_KM", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_BOTTOM_KM", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_EAST_DEG", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_WEST_DEG", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_NORTH_DEG", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "MOVIE_SOUTH_DEG", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_double_scalar (adios_group, "RECORD_LENGTH_IN_MINUTES", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  !-- integer variables 
+  call define_adios_integer_scalar (adios_group, "NTSTEP_BETWEEN_OUTPUT_SEISMOS", &
+      "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NTSTEP_BETWEEN_READ_ADJSRC", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NTSTEP_BETWEEN_FRAMES", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NTSTEP_BETWEEN_OUTPUT_INFO", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NUMBER_OF_RUNS", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NUMBER_OF_THIS_RUN", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NCHUNKS", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "SIMULATION_TYPE", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "MOVIE_VOLUME_TYPE", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "MOVIE_START", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "MOVIE_STOP", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NEX_XI", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NEX_ETA", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NPROC_XI", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NPROC_ETA", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "NOISE_TOMOGRAPHY", "/specfem3D_globe_parameter_file", group_size_inc)
+  !-- logical variables
+  call define_adios_byte_scalar (adios_group, "ELLIPTICITY", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "GRAVITY", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "ROTATION", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "TOPOGRAPHY", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "OCEANS", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "MOVIE_SURFACE", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "MOVIE_VOLUME", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "MOVIE_COARSE", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "RECEIVERS_CAN_BE_BURIED", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "PRINT_SOURCE_TIME_FUNCTION", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "SAVE_MESH_FILES", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "ATTENUATION", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "ATTENUATION_NEW", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "ABSORBING_CONDITIONS", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "SAVE_FORWARD", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "OUTPUT_SEISMOS_ASCII_TEXT", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "OUTPUT_SEISMOS_SAC_ALPHANUM", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "OUTPUT_SEISMOS_SAC_BINARY", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "ROTATE_SEISMOGRAMS_RT", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "WRITE_SEISMOGRAMS_BY_MASTER", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "SAVE_ALL_SEISMOS_IN_ONE_FILE", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_byte_scalar (adios_group, "USE_BINARY_FOR_LARGE_FILE", "/specfem3D_globe_parameter_file", group_size_inc)
+  !-- string variables
+  call define_adios_integer_scalar (adios_group, "model_length", "/specfem3D_globe_parameter_file", group_size_inc)
+  call define_adios_string (adios_group, "MODEL", "/specfem3D_globe_parameter_file", model_length, group_size_inc)
+end subroutine define_par_file_variables
+
+
+!> \brief Define ADIOS variable to store values from the CMTSOLUTION file
+!! \param adios_group The ADIOS entity grouping variables for data transferts
+!! \param group_size_inc The group size to increment wrt. the variable size
+!! \param NSOURCES The number of sources. Needed to define array sizes.
+!! \param datasource_length The number of character of the datasource string.
+!!                          Usefull for reading back the datasources.
+subroutine define_cmtsolution_variables (adios_group, group_size_inc, NSOURCES,&
+    event_name_length, datasource_length)
+  implicit none
+  integer(kind=8), intent(in)    :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+  integer, intent(in) :: NSOURCES, datasource_length, event_name_length
+
+  !-- Number of SOURCES inside the CMTSOLUTION file
+  call define_adios_integer_scalar (adios_group, "NSOURCES", "/CMTSOLUTION", group_size_inc)
+  !-- double precision arrays
+  call define_adios_double_local_array1D (adios_group, "second", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "time_shift", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "half_duration", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "latitude", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "longitude", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "depth", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mrr", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mtt", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mpp", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mrt", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mrp", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "mtp", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  !-- integer arrays
+  call define_adios_integer_local_array1D (adios_group, "year", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_integer_local_array1D (adios_group, "month", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_integer_local_array1D (adios_group, "day", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_integer_local_array1D (adios_group, "hour", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  call define_adios_integer_local_array1D (adios_group, "minute", "/CMTSOLUTION", NSOURCES, "NSOURCES", group_size_inc)
+  !-- string
+  call define_adios_integer_scalar (adios_group, "event_name_length", "/CMTSOLUTION", group_size_inc)
+  call define_adios_string (adios_group, "event_name", "/CMTSOLUTION", event_name_length, group_size_inc)
+  call define_adios_integer_scalar (adios_group, "datasource_length", "/CMTSOLUTION", group_size_inc)
+  call define_adios_string (adios_group, "datasource", "/CMTSOLUTION", datasource_length, group_size_inc)
+end subroutine define_cmtsolution_variables
+
+!> \brief Define ADIOS variable to store values from the STATIONS file
+!! \param adios_group The ADIOS entity grouping variables for data transferts
+!! \param group_size_inc The group size to increment wrt. the variable size
+!! \param NSTATIONS The number of stations. Needed to define array sizes.
+!! \param station_name_length The number of character of the station_name
+!!                            string.  Usefull for reading back the stations.
+!! \param network_name_length The number of character of the station_name
+!!                            string.  Usefull for reading back the networks.
+subroutine define_stations_variables (adios_group, group_size_inc, NSTATIONS,&
+    station_name_length, network_name_length)
+  implicit none
+  integer(kind=8), intent(in)    :: adios_group
+  integer(kind=8), intent(inout) :: group_size_inc
+  integer, intent(in) :: NSTATIONS, station_name_length, network_name_length
+
+  !-- Number of STATIONS inside the STATIONS file 
+  call define_adios_integer_scalar (adios_group, "NSTATIONS", "/STATIONS", group_size_inc)
+  !-- double precision arrays 
+  call define_adios_double_local_array1D (adios_group, "station_latitude", "/STATIONS", NSTATIONS, "NSTATIONS", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "station_longitude", "/STATIONS", NSTATIONS, "NSTATIONS", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "station_elevation", "/STATIONS", NSTATIONS, "NSTATIONS", group_size_inc)
+  call define_adios_double_local_array1D (adios_group, "station_burial", "/STATIONS", NSTATIONS, "NSTATIONS", group_size_inc)
+  !-- string
+  call define_adios_integer_scalar (adios_group, "station_name_length", "/STATIONS", group_size_inc)
+  call define_adios_integer_scalar (adios_group, "network_name_length", "/STATIONS", group_size_inc)
+  call define_adios_string (adios_group, "station_name", "/STATIONS", station_name_length, group_size_inc)
+  call define_adios_string (adios_group, "network_name", "/STATIONS", network_name_length, group_size_inc)
+end subroutine define_stations_variables
+
+!> \brief Read the 'CMTSOLUTION file' and do not modify nor transform variables
+!! \param yr Array to store the year of the events
+!! \param mo Array to store the month of the events
+!! \param da Array to store the day of the events
+!! \param ho Array to store the hour of the events
+!! \param mi Array to store the minute of the events
+!! \param sec Array to store the second of the events
+!! \param t_shift Array to store the time shift at the beginning of the events
+!! \param hdur Array to store the duration of the events
+!! \param lat Array to store the latitude of the events
+!! \param long Array to store the longitude of the events
+!! \param depth Arrays to store the depth of the events
+!! \param mrr Arrays to store the mrr component of the events
+!! \param mtt Arrays to store the mtt component of the events
+!! \param mpp Arrays to store the mpp component of the events
+!! \param mrt Arrays to store the mrt component of the events
+!! \param mrp Arrays to store the mrp component of the events
+!! \param mtp Arrays to store the mtp component of the events
+!! \param event_name_length Variable for keeping the size of the event_name
+!!                          string
+!! \param event_name Strings to store the event name
+!! \param  datasource_length Variable for keeping the size of the datasource 
+!!                          string
+!! \param datasource String in which the different datasource names are
+!!                   concatenated
+!> \note This subroutine and get_cmt.f90 are redundant. Might be factorized in
+!!       the future. For now we do not want the value modification from get_cmt
+subroutine read_raw_cmtsolution (yr, mo, da, ho, mi, sec, t_shift, hdur, lat,  &
+    long, depth, mrr, mtt, mpp, mrt, mrp, mtp, event_name_length, event_name,  &
+    datasource_length, datasource)
+  implicit none
+  ! Parameters
+  integer,           dimension(NSOURCES), intent(out) :: yr, mo, da, ho, mi
+  double precision,  dimension(NSOURCES), intent(out) :: sec, t_shift, hdur, lat, long, depth
+  double precision,  dimension(NSOURCES), intent(out) :: mrr, mtt, mpp, mrt, mrp, mtp 
+  integer, intent(inout) :: event_name_length, datasource_length
+  character(len=16), intent(out) :: event_name
+  character(len=:), allocatable, intent(out)  :: datasource  ! F03 feature
+  ! Local variables
+  character(len=5)   :: datasource_tmp
+  character(len=256) :: CMTSOLUTION, string
+  ! extract all unmodified values from CMTSOLUTION
+  ! get_cmt() routine modify the read values
+  ! TODO factorize what follows and get_cmt.f90 and probably one or two other
+  !      routines
+  call get_value_string(CMTSOLUTION, 'solver.CMTSOLUTION', 'DATA/CMTSOLUTION')
+  open(unit=1,file=CMTSOLUTION,status='old',action='read')
+  datasource_length = 4*NSOURCES ! a datasource is 4 character, by convention 
+  allocate(character(len=(datasource_length)) :: datasource, stat=ier)
+  if (ier /=0) &
+      call exit_MPI (myrank, &
+          "error allocating datasource string for adios header")
+  datasource = ""
+  ! ADIOS only  (1) byte for a string. This may cause data overwriting.
+  ! => increase the generate by the string size -1
+  adios_groupsize = adios_groupsize + 4*NSOURCES - 1
+  do isource=1,NSOURCES
+
+    read(1,"(a256)") string
+    ! skips empty lines
+    do while( len_trim(string) == 0 )
+    read(1,"(a256)") string
+    enddo
+    ! read header with event information
+    read(string,"(a4,i5,i3,i3,i3,i3,f6.2)") datasource_tmp,yr(isource), &
+        mo(isource),da(isource),ho(isource),mi(isource),sec(isource)
+    datasource = datasource // datasource_tmp
+    ! read event name 
+    read(1,"(a)") string
+    read(string(12:len_trim(string)),*) event_name
+    ! read time shift
+    read(1,"(a)") string
+    read(string(12:len_trim(string)),*) t_shift(isource)
+    ! read half duration
+    read(1,"(a)") string
+    read(string(15:len_trim(string)),*) hdur(isource)
+    ! read latitude
+    read(1,"(a)") string
+    read(string(10:len_trim(string)),*) lat(isource)
+    ! read longitude
+    read(1,"(a)") string
+    read(string(11:len_trim(string)),*) long(isource)
+    ! read depth
+    read(1,"(a)") string
+    read(string(7:len_trim(string)),*) depth(isource)
+    ! read Mrr
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mrr(isource)
+    ! read Mtt
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mtt(isource)
+    ! read Mpp
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mpp(isource)
+    ! read Mrt
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mrt(isource)
+    ! read Mrp
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mrp(isource)
+    ! read Mtp
+    read(1,"(a)") string
+    read(string(5:len_trim(string)),*) mtp(isource)
+  enddo
+  close(1)
+  event_name_length = len_trim(event_name)
+end subroutine read_raw_cmtsolution
+
+!> \brief Reads information form the 'STATIONS' file without modifying anything
+!! \param NSTATIONS How many stations are used
+!! \param stlat Array to store the latitude of the stations
+!! \param stlon Array to store the longitude of the stations
+!! \param stele Array to store the elevation of the stations
+!! \param stbur Array to store the burial of the statisons
+!! \param station_name_length Variable to keep the length of the station_name
+!!                            string
+!! \param station_name  String in which the different station names are
+!!                      concatenated
+!! \param network_name_length Variable to keep the length of the network_name
+!!                            string
+!! \param network_name String in which the different network names are
+!!                     concatenated
+subroutine read_raw_stations (NSTATIONS, stlat, stlon, stele, stbur,           &
+    station_name_length, station_name, network_name_length, network_name)
+  implicit none
+  ! Parameters
+  integer :: NSTATIONS
+  integer, intent(inout) :: station_name_length, network_name_length ! for later reading
+  character(len=:), allocatable, intent(out) :: station_name, network_name 
+  double precision, allocatable, dimension(:), intent(out) :: stlat, stlon, stele, stbur
+  ! Local variables
+  character(len=MAX_LENGTH_STATION_NAME) :: station_name_tmp
+  character(len=MAX_LENGTH_NETWORK_NAME) :: network_name_tmp
+  character(len=256) :: STATIONS, string
+
+  ! Extract values from STATIONS File
+  call get_value_string(STATIONS, 'solver.STATIONS', 'DATA/STATIONS')
+  open(unit=1,file=STATIONS,iostat=ier,status='old',action='read')
+  NSTATIONS = 0
+  do while(ier == 0)
+  read(1,"(a)",iostat=ier) string
+  if(ier == 0) NSTATIONS = NSTATIONS + 1
+  enddo
+  allocate (character (len=(MAX_LENGTH_STATION_NAME*NSTATIONS)) :: station_name)
+  allocate (character (len=(MAX_LENGTH_NETWORK_NAME*NSTATIONS)) :: network_name)
+  allocate (stlat (NSTATIONS)) 
+  allocate (stlon (NSTATIONS)) 
+  allocate (stele (NSTATIONS)) 
+  allocate (stbur (NSTATIONS)) 
+  station_name = ""
+  network_name = ""
+  rewind(1)
+  do irec = 1,NSTATIONS
+  read(1,*,iostat=ier) station_name_tmp, network_name_tmp, &
+  stlat(irec),      stlon(irec),      &
+  stele(irec),      stbur(irec)
+  if( ier /= 0 ) then
+    write(IMAIN,*) 'error reading in station ',irec
+    call exit_MPI(myrank,'error reading in station in STATIONS file')
+  endif
+  station_name = station_name // trim(station_name_tmp) // " " 
+  network_name = network_name // trim(network_name_tmp) // " " 
+  enddo
+  close(1)
+  station_name = trim(station_name)
+  network_name = trim(network_name)
+  station_name_length = len(station_name)
+  network_name_length = len(network_name)
+end subroutine read_raw_stations
+
+!> \brief Wrapper to write the 'config.h' variables into the adios header
+!! \param adios_handle The handle to the file where the variable should be
+!!                     written
+subroutine write_adios_solver_info_variables (adios_handle)
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in)    :: adios_handle
+  ! Variables
+  integer :: pkg_str_len, conf_flags_len, adios_err
+  character(len=:), allocatable :: pkg_str
+  character(len=:), allocatable :: conf_flags
+ 
+  pkg_str    = trim(PACKAGE_STRING)
+  conf_flags = trim(CONFIGURE_FLAGS)
+
+  pkg_str_len    = len_trim(PACKAGE_STRING)
+  conf_flags_len = len_trim(CONFIGURE_FLAGS)
+  call adios_write (adios_handle, "package_string_length", pkg_str_len, adios_err)
+  call adios_write (adios_handle, "package_name", pkg_str, adios_err)
+  call adios_write (adios_handle, "conf_flags_len", conf_flags_len, adios_err)
+  call adios_write (adios_handle, "conf_flags", conf_flags, adios_err)
+end subroutine write_adios_solver_info_variables 
+
+!> \brief Wrapper to write the 'Par_file' variables into the adios header
+!! \param adios_handle The handle to the file where the variable should be
+!!                     written
+subroutine write_adios_par_file_variables (adios_handle,                       &
+    ANGULAR_WIDTH_XI_IN_DEGREES, ANGULAR_WIDTH_ETA_IN_DEGREES,                 &
+    CENTER_LONGITUDE_IN_DEGREES, CENTER_LATITUDE_IN_DEGREES,                   &
+    GAMMA_ROTATION_AZIMUTH, HDUR_MOVIE, MOVIE_TOP_KM, MOVIE_BOTTOM_KM,         &
+    MOVIE_EAST_DEG, MOVIE_WEST_DEG, MOVIE_NORTH_DEG, MOVIE_SOUTH_DEG,          &
+    RECORD_LENGTH_IN_MINUTES, NTSTEP_BETWEEN_OUTPUT_SEISMOS,                   &
+    NTSTEP_BETWEEN_READ_ADJSRC, NTSTEP_BETWEEN_FRAMES,                         &
+    NTSTEP_BETWEEN_OUTPUT_INFO, NUMBER_OF_RUNS, NUMBER_OF_THIS_RUN, NCHUNKS,   &
+    SIMULATION_TYPE, MOVIE_VOLUME_TYPE, MOVIE_START, MOVIE_STOP, NEX_XI,       &
+    NEX_ETA, NPROC_XI, NPROC_ETA, NOISE_TOMOGRAPHY, ELLIPTICITY, GRAVITY,      &
+    ROTATION, TOPOGRAPHY, OCEANS, MOVIE_SURFACE, MOVIE_VOLUME, MOVIE_COARSE,   &
+    RECEIVERS_CAN_BE_BURIED, PRINT_SOURCE_TIME_FUNCTION, SAVE_MESH_FILES,      &
+    ATTENUATION, ATTENUATION_NEW, ABSORBING_CONDITIONS, SAVE_FORWARD,          &
+    OUTPUT_SEISMOS_ASCII_TEXT, OUTPUT_SEISMOS_SAC_ALPHANUM,                    &
+    OUTPUT_SEISMOS_SAC_BINARY, ROTATE_SEISMOGRAMS_RT,                          &
+    WRITE_SEISMOGRAMS_BY_MASTER, SAVE_ALL_SEISMOS_IN_ONE_FILE,                 &
+    USE_BINARY_FOR_LARGE_FILE, model_length, MODEL)
+ implicit none
+ ! Parameters
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in)  :: NTSTEP_BETWEEN_OUTPUT_SEISMOS,                       &
+      NTSTEP_BETWEEN_READ_ADJSRC, NTSTEP_BETWEEN_FRAMES,                       &
+      NTSTEP_BETWEEN_OUTPUT_INFO,NUMBER_OF_RUNS, NUMBER_OF_THIS_RUN,NCHUNKS,   &
+      SIMULATION_TYPE, MOVIE_VOLUME_TYPE, MOVIE_START,MOVIE_STOP, NEX_XI,      &
+      NEX_ETA,NPROC_XI,NPROC_ETA, NOISE_TOMOGRAPHY
+  double precision, intent(in) :: ANGULAR_WIDTH_XI_IN_DEGREES,                 &
+      ANGULAR_WIDTH_ETA_IN_DEGREES, CENTER_LONGITUDE_IN_DEGREES,               &
+      CENTER_LATITUDE_IN_DEGREES, GAMMA_ROTATION_AZIMUTH, HDUR_MOVIE,          &
+      MOVIE_TOP_KM,MOVIE_BOTTOM_KM, MOVIE_EAST_DEG,MOVIE_WEST_DEG,             &
+      MOVIE_NORTH_DEG,MOVIE_SOUTH_DEG, RECORD_LENGTH_IN_MINUTES
+  logical, intent(in) :: ELLIPTICITY,GRAVITY,ROTATION,TOPOGRAPHY,OCEANS,       &
+      MOVIE_SURFACE, MOVIE_VOLUME,MOVIE_COARSE, RECEIVERS_CAN_BE_BURIED,       &
+      PRINT_SOURCE_TIME_FUNCTION, SAVE_MESH_FILES,ATTENUATION,ATTENUATION_NEW, &
+      ABSORBING_CONDITIONS,SAVE_FORWARD, OUTPUT_SEISMOS_ASCII_TEXT,            &
+      OUTPUT_SEISMOS_SAC_ALPHANUM,OUTPUT_SEISMOS_SAC_BINARY,                   &
+      ROTATE_SEISMOGRAMS_RT,WRITE_SEISMOGRAMS_BY_MASTER,                       &
+      SAVE_ALL_SEISMOS_IN_ONE_FILE,USE_BINARY_FOR_LARGE_FILE
+  integer, intent(in) :: model_length
+  character(len=*), intent(in) :: MODEL
+  ! Local variables
+  integer  :: adios_err
+
+  call adios_write (adios_handle, "ANGULAR_WIDTH_XI_IN_DEGREES", ANGULAR_WIDTH_XI_IN_DEGREES, adios_err)
+  call adios_write (adios_handle, "ANGULAR_WIDTH_ETA_IN_DEGREES", ANGULAR_WIDTH_ETA_IN_DEGREES, adios_err)
+  call adios_write (adios_handle, "CENTER_LONGITUDE_IN_DEGREES", CENTER_LONGITUDE_IN_DEGREES, adios_err)
+  call adios_write (adios_handle, "CENTER_LATITUDE_IN_DEGREES", CENTER_LATITUDE_IN_DEGREES, adios_err)
+  call adios_write (adios_handle, "GAMMA_ROTATION_AZIMUTH", GAMMA_ROTATION_AZIMUTH, adios_err)
+  call adios_write (adios_handle, "HDUR_MOVIE", HDUR_MOVIE, adios_err)
+  call adios_write (adios_handle, "MOVIE_TOP_KM", MOVIE_TOP_KM, adios_err)
+  call adios_write (adios_handle, "MOVIE_BOTTOM_KM", MOVIE_BOTTOM_KM, adios_err)
+  call adios_write (adios_handle, "MOVIE_EAST_DEG", MOVIE_EAST_DEG, adios_err)
+  call adios_write (adios_handle, "MOVIE_WEST_DEG", MOVIE_WEST_DEG, adios_err)
+  call adios_write (adios_handle, "MOVIE_NORTH_DEG", MOVIE_NORTH_DEG, adios_err)
+  call adios_write (adios_handle, "MOVIE_SOUTH_DEG", MOVIE_SOUTH_DEG, adios_err)
+  call adios_write (adios_handle, "RECORD_LENGTH_IN_MINUTES", RECORD_LENGTH_IN_MINUTES, adios_err)
+  call adios_write (adios_handle, "NTSTEP_BETWEEN_OUTPUT_SEISMOS", NTSTEP_BETWEEN_OUTPUT_SEISMOS, adios_err)
+  call adios_write (adios_handle, "NTSTEP_BETWEEN_READ_ADJSRC", NTSTEP_BETWEEN_READ_ADJSRC, adios_err)
+  call adios_write (adios_handle, "NTSTEP_BETWEEN_FRAMES", NTSTEP_BETWEEN_FRAMES, adios_err)
+  call adios_write (adios_handle, "NTSTEP_BETWEEN_OUTPUT_INFO", NTSTEP_BETWEEN_OUTPUT_INFO, adios_err)
+  call adios_write (adios_handle, "NUMBER_OF_RUNS", NUMBER_OF_RUNS, adios_err)
+  call adios_write (adios_handle, "NUMBER_OF_THIS_RUN", NUMBER_OF_THIS_RUN, adios_err)
+  call adios_write (adios_handle, "NCHUNKS", NCHUNKS, adios_err)
+  call adios_write (adios_handle, "SIMULATION_TYPE", SIMULATION_TYPE, adios_err)
+  call adios_write (adios_handle, "MOVIE_VOLUME_TYPE", MOVIE_VOLUME_TYPE, adios_err)
+  call adios_write (adios_handle, "MOVIE_START", MOVIE_START, adios_err)
+  call adios_write (adios_handle, "MOVIE_STOP", MOVIE_STOP, adios_err)
+  call adios_write (adios_handle, "NEX_XI", NEX_XI, adios_err)
+  call adios_write (adios_handle, "NEX_ETA", NEX_ETA, adios_err)
+  call adios_write (adios_handle, "NPROC_XI", NPROC_XI, adios_err)
+  call adios_write (adios_handle, "NPROC_ETA", NPROC_ETA, adios_err)
+  call adios_write (adios_handle, "NOISE_TOMOGRAPHY", NOISE_TOMOGRAPHY, adios_err)
+  call adios_write (adios_handle, "ELLIPTICITY", ELLIPTICITY, adios_err)
+  call adios_write (adios_handle, "GRAVITY", GRAVITY, adios_err)
+  call adios_write (adios_handle, "ROTATION", ROTATION, adios_err)
+  call adios_write (adios_handle, "TOPOGRAPHY", TOPOGRAPHY, adios_err)
+  call adios_write (adios_handle, "OCEANS", OCEANS, adios_err)
+  call adios_write (adios_handle, "MOVIE_SURFACE", MOVIE_SURFACE, adios_err)
+  call adios_write (adios_handle, "MOVIE_VOLUME", MOVIE_VOLUME, adios_err)
+  call adios_write (adios_handle, "MOVIE_COARSE", MOVIE_COARSE, adios_err)
+  call adios_write (adios_handle, "RECEIVERS_CAN_BE_BURIED", RECEIVERS_CAN_BE_BURIED, adios_err)
+  call adios_write (adios_handle, "PRINT_SOURCE_TIME_FUNCTION", PRINT_SOURCE_TIME_FUNCTION, adios_err)
+  call adios_write (adios_handle, "SAVE_MESH_FILES", SAVE_MESH_FILES, adios_err)
+  call adios_write (adios_handle, "ATTENUATION", ATTENUATION, adios_err)
+  call adios_write (adios_handle, "ATTENUATION_NEW", ATTENUATION_NEW, adios_err)
+  call adios_write (adios_handle, "ABSORBING_CONDITIONS", ABSORBING_CONDITIONS, adios_err)
+  call adios_write (adios_handle, "SAVE_FORWARD", SAVE_FORWARD, adios_err)
+  call adios_write (adios_handle, "OUTPUT_SEISMOS_ASCII_TEXT", OUTPUT_SEISMOS_ASCII_TEXT, adios_err)
+  call adios_write (adios_handle, "OUTPUT_SEISMOS_SAC_ALPHANUM", OUTPUT_SEISMOS_SAC_ALPHANUM, adios_err)
+  call adios_write (adios_handle, "OUTPUT_SEISMOS_SAC_BINARY", OUTPUT_SEISMOS_SAC_BINARY, adios_err)
+  call adios_write (adios_handle, "ROTATE_SEISMOGRAMS_RT", ROTATE_SEISMOGRAMS_RT, adios_err)
+  call adios_write (adios_handle, "WRITE_SEISMOGRAMS_BY_MASTER", WRITE_SEISMOGRAMS_BY_MASTER, adios_err)
+  call adios_write (adios_handle, "SAVE_ALL_SEISMOS_IN_ONE_FILE", SAVE_ALL_SEISMOS_IN_ONE_FILE, adios_err)
+  call adios_write (adios_handle, "USE_BINARY_FOR_LARGE_FILE", USE_BINARY_FOR_LARGE_FILE, adios_err)
+  call adios_write (adios_handle, "model_length", model_length, adios_err)
+  call adios_write (adios_handle, "MODEL", MODEL, adios_err)
+end subroutine write_adios_par_file_variables 
+
+!> \brief Wrapper to write the 'CMTSOLUTION' variables into the adios header
+!! \param adios_handle The handle to the file where the variable should be
+!!                     written
+subroutine write_adios_cmtsolution_variables (adios_handle,                    &
+    NSOURCES, yr, mo, da, ho, mi, sec, t_shift, hdur, lat, long, depth,        &
+    mrr, mtt, mpp, mrt, mrp, mtp, event_name_length, event_name,               &
+    datasource_length, datasource)
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in) :: NSOURCES
+  integer,          dimension(NSOURCES), intent(in) :: yr, mo, da, ho, mi
+  double precision, dimension(NSOURCES), intent(in) :: sec, t_shift, hdur,     &
+                                                       lat, long, depth
+  double precision, dimension(NSOURCES), intent(in) :: mrr, mtt, mpp,          &
+                                                       mrt, mrp, mtp 
+  integer, intent(in) :: event_name_length, datasource_length
+  character(len=16), intent(in) :: event_name
+  character(len=:), allocatable, intent(in)  :: datasource  ! F03 feature
+  ! Local variables
+  integer :: adios_err
+
+  call adios_write (adios_handle, "NSOURCES", NSOURCES, adios_err)
+  call adios_write (adios_handle, "year", yr, adios_err)
+  call adios_write (adios_handle, "month", mo, adios_err)
+  call adios_write (adios_handle, "day", da, adios_err)
+  call adios_write (adios_handle, "hour", ho, adios_err)
+  call adios_write (adios_handle, "minute", mi, adios_err)
+  call adios_write (adios_handle, "second", sec, adios_err)
+  call adios_write (adios_handle, "time_shift", t_shift, adios_err)
+  call adios_write (adios_handle, "half_duration", hdur, adios_err)
+  call adios_write (adios_handle, "latitude", lat, adios_err)
+  call adios_write (adios_handle, "longitude", long, adios_err)
+  call adios_write (adios_handle, "depth", depth, adios_err)
+  call adios_write (adios_handle, "mrr", mrr, adios_err)
+  call adios_write (adios_handle, "mtt", mtt, adios_err)
+  call adios_write (adios_handle, "mpp", mpp, adios_err)
+  call adios_write (adios_handle, "mrt", mrt, adios_err)
+  call adios_write (adios_handle, "mrp", mrp, adios_err)
+  call adios_write (adios_handle, "mtp", mtp, adios_err)
+  call adios_write (adios_handle, "event_name_length", event_name_length, adios_err)
+  call adios_write (adios_handle, "event_name", event_name, adios_err)
+  call adios_write (adios_handle, "datasource_length", datasource_length, adios_err)
+  call adios_write (adios_handle, "datasource", datasource, adios_err)
+end subroutine write_adios_cmtsolution_variables
+
+!> \brief Wrapper to write the 'STATIONS' variables into the adios header
+!! \param adios_handle The handle to the file where the variable should be
+!!                     written
+subroutine write_adios_stations_variables (adios_handle,                       &
+    NSTATIONS, stlat, stlon, stele, stbur, station_name_length, station_name,  &
+    network_name_length, network_name)
+  implicit none
+  ! Parameters
+  integer(kind=8), intent(in) :: adios_handle
+  integer, intent(in):: NSTATIONS
+  integer, intent(in):: station_name_length, network_name_length ! for later reading
+  character(len=:), allocatable, intent(in) :: station_name, network_name 
+  double precision, allocatable, dimension(:), intent(in) :: stlat, stlon,     &
+                                                             stele, stbur
+  ! Local variables
+  integer :: adios_err
+
+  call adios_write (adios_handle, "NSTATIONS", NSTATIONS, adios_err)
+  call adios_write (adios_handle, "station_latitude", stlat, adios_err)
+  call adios_write (adios_handle, "station_longitude", stlon, adios_err)
+  call adios_write (adios_handle, "station_elevation", stele, adios_err)
+  call adios_write (adios_handle, "station_burial", stbur, adios_err)
+  call adios_write (adios_handle, "station_name_length", station_name_length, adios_err)
+  call adios_write (adios_handle, "network_name_length", network_name_length, adios_err)
+  call adios_write (adios_handle, "station_name", station_name, adios_err)
+  call adios_write (adios_handle, "network_name", network_name, adios_err)
+end subroutine write_adios_stations_variables
+
+
+end subroutine write_specfem_header_adios

Copied: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/this_branch_was_created_from_revision_r21488_of_the_SUNFLOWER_branch.txt (from rev 22452, seismo/3D/SPECFEM3D_GLOBE/branches/SUNFLOWER_ADIOS/this_branch_was_created_from_revision_r21488_of_the_SUNFLOWER_branch.txt)
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/this_branch_was_created_from_revision_r21488_of_the_SUNFLOWER_branch.txt	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/this_branch_was_created_from_revision_r21488_of_the_SUNFLOWER_branch.txt	2013-06-30 12:40:04 UTC (rev 22453)
@@ -0,0 +1,7 @@
+
+------------------------------------------------------------------------
+r21488 | lefebvre | 2013-03-11 19:02:42 +0100 (Mon, 11 Mar 2013) | 1 line
+
+Branched from SPECFEM3D_GLOBE_SUNFLOWER to add the ADIOS file format in the GPU version
+------------------------------------------------------------------------
+



More information about the CIG-COMMITS mailing list