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

danielpeter at geodynamics.org danielpeter at geodynamics.org
Thu Dec 27 11:08:43 PST 2012


Author: danielpeter
Date: 2012-12-27 11:08:42 -0800 (Thu, 27 Dec 2012)
New Revision: 21199

Added:
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.guess
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.sub
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/install-sh
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk.cpp
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk_stubs.c
Modified:
   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/src/cuda/assemble_MPI_scalar_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_vector_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/check_fields_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_crust_mantle_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_inner_core_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_outer_core_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/mesh_constants_cuda.h
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_constants_cuda.h
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_mesh_constants_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/specfem3D_gpu_cuda_method_stubs.c
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/transfer_fields_cuda.cu
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/assemble_MPI_central_cube_mesh.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_central_cube_buffers.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/meshfem3D/setup_MPI_interfaces.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/test_MPI_interfaces.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/exit_mpi.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/memory_eval.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_compute_parameters.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/save_header_file.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_coupling.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_element.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_acoustic.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_crust_mantle_Dev.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_elastic.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_inner_core_Dev.F90
   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/iterate_time.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.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_par.F90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_movie_output.f90
Log:
updates cuda routines to be compatible with version 5 addressing; updates configuration files to work with --with-cuda=cuda5 option; adds visual_vtk routines; shortens some variable names

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_Greece_small/DATA/Par_file	2012-12-27 19:08:42 UTC (rev 21199)
@@ -33,7 +33,7 @@
 # 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                           = 1D_transversely_isotropic_prem
+MODEL                           = 1D_transversely_isotropic_prem 
 
 # parameters describing the Earth model
 OCEANS                          = .true.
@@ -42,7 +42,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
-ATTENUATION_NEW                 = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Added: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.guess
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.guess	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.guess	2012-12-27 19:08:42 UTC (rev 21199)
@@ -0,0 +1,1502 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   Free Software Foundation, Inc.
+
+timestamp='2009-12-30'
+
+# This file 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.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches at gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep -q __ELF__
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-unknown-riscos
+	exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+	echo i386-pc-auroraux${UNAME_RELEASE}
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit ;;
+    *:AIX:*:[456])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep -q __LP64__
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
+	echo unknown-hitachi-hiuxwe2
+	exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:FreeBSD:*:*)
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:windows32*:*)
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    authenticamd | genuineintel | EM64T)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    8664:Windows_NT:*)
+	echo x86_64-pc-mks
+	exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i586-pc-interix
+	exit ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep -q ld.so.1
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit ;;
+    i*86:Linux:*:*)
+	LIBC=gnu
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=${UNAME_MACHINE}el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=${UNAME_MACHINE}
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-unknown-linux-gnu
+	exit ;;
+    padre:Linux:*:*)
+	echo sparc-unknown-linux-gnu
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit ;;
+    i*86:*:5:[678]*)
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	test -r /etc/.relid \
+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel at ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes at openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf at swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Darwin:*:*)
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    i386)
+		eval $set_cc_for_build
+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		      grep IS_64BIT_ARCH >/dev/null
+		  then
+		      UNAME_PROCESSOR="x86_64"
+		  fi
+		fi ;;
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.guess
___________________________________________________________________
Name: svn:executable
   + *

Added: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.sub
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.sub	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.sub	2012-12-27 19:08:42 UTC (rev 21199)
@@ -0,0 +1,1714 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   Free Software Foundation, Inc.
+
+timestamp='2010-01-22'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches at gnu.org>.  Submit a context
+# diff and a properly formatted GNU ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis | -knuth | -cray | -microblaze)
+		os=
+		basic_machine=$1
+		;;
+        -bluegene*)
+	        os=-cnk
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| lm32 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep | metag \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64octeon | mips64octeonel \
+	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| moxie \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
+	| ns16k | ns32k \
+	| or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| rx \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| ubicom32 \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k | z80)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| lm32-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64octeon-* | mips64octeonel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* | rx-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tile-* | tilegx-* \
+	| tron-* \
+	| ubicom32-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-* | z80-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aros)
+		basic_machine=i386-pc
+		os=-aros
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	bluegene*)
+		basic_machine=powerpc-ibm
+		os=-cnk
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+        cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+        microblaze)
+		basic_machine=microblaze-xilinx
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	openrisc | openrisc-*)
+		basic_machine=or32-unknown
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+		;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+		;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+		;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+		;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+        # This must be matched before tile*.
+        tilegx*)
+		basic_machine=tilegx-unknown
+		os=-linux-gnu
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+		basic_machine=f301-fujitsu
+		;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	z80-*-coff)
+		basic_machine=z80-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		basic_machine=sparc-sun
+		;;
+	cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+        -auroraux)
+	        os=-auroraux
+		;;
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+	      | -sym* | -kopensolaris* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* | -aros* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* | -cegcc* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-dicos*)
+		os=-dicos
+		;;
+        -nacl*)
+	        ;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
+	# This must come before the *-dec entry.
+	pdp10-*)
+		os=-tops20
+		;;
+	pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+        mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-haiku)
+		os=-haiku
+		;;
+	*-ibm)
+		os=-aix
+		;;
+    	*-knuth)
+		os=-mmixware
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+	*-gould)
+		os=-sysv
+		;;
+	*-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+	*-sgi)
+		os=-irix
+		;;
+	*-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-cnk*|-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/config.sub
___________________________________________________________________
Name: svn:executable
   + *

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure	2012-12-27 19:08:42 UTC (rev 21199)
@@ -1,13 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for Specfem3D Globe 5.1.2.
+# Generated by GNU Autoconf 2.69 for Specfem3D Globe 6.0.0.
 #
 # Report bugs to <jtromp AT princeton.edu>.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -136,6 +134,31 @@
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && 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
@@ -169,7 +192,8 @@
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+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'\" &&
@@ -214,21 +238,25 @@
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # 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
-	export CONFIG_SHELL
-	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+"$@"}
+  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= ;;
+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 :
@@ -331,6 +359,14 @@
 
 
 } # as_fn_mkdir_p
+
+# 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
@@ -452,6 +488,10 @@
   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; }
 
+  # 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).
@@ -486,16 +526,16 @@
     # ... 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 -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -507,28 +547,8 @@
   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_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'"
@@ -560,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='Specfem3D Globe'
 PACKAGE_TARNAME='Specfem3DGlobe'
-PACKAGE_VERSION='5.1.2'
-PACKAGE_STRING='Specfem3D Globe 5.1.2'
+PACKAGE_VERSION='6.0.0'
+PACKAGE_STRING='Specfem3D Globe 6.0.0'
 PACKAGE_BUGREPORT='jtromp AT princeton.edu'
 PACKAGE_URL=''
 
@@ -604,6 +624,7 @@
 
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
+NVCC
 LOCAL_PATH_IS_ALSO_GLOBAL
 RANLIB
 ARFLAGS
@@ -624,6 +645,14 @@
 CFLAGS
 CC
 FCLIBS
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
 FCENV
 OBJEXT
 EXEEXT
@@ -631,6 +660,10 @@
 LDFLAGS
 FCFLAGS
 FC
+COND_VTK_FALSE
+COND_VTK_TRUE
+COND_CUDA5_FALSE
+COND_CUDA5_TRUE
 COND_CUDA_FALSE
 COND_CUDA_TRUE
 CUSTOM_MPI_TYPE
@@ -678,6 +711,7 @@
 enable_option_checking
 enable_double_precision
 with_cuda
+with_vtk
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1156,8 +1190,6 @@
 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
@@ -1243,7 +1275,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Specfem3D Globe 5.1.2 to adapt to many kinds of systems.
+\`configure' configures Specfem3D Globe 6.0.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1299,12 +1331,16 @@
 _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
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Specfem3D Globe 5.1.2:";;
+     short | recursive ) echo "Configuration of Specfem3D Globe 6.0.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1319,6 +1355,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-vtk              build VTK enabled version [default=no]
 
 Some influential environment variables:
   FC          Fortran compiler command
@@ -1414,10 +1451,10 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Specfem3D Globe configure 5.1.2
-generated by GNU Autoconf 2.68
+Specfem3D Globe configure 6.0.0
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1531,7 +1568,7 @@
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1754,8 +1791,8 @@
 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 5.1.2, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by Specfem3D Globe $as_me 6.0.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2135,7 +2172,8 @@
   want_cuda=no
 fi
 
- if test "$want_cuda" = yes; then
+#AM_CONDITIONAL([COND_CUDA], [test "$want_cuda" = yes])
+ if test "$want_cuda" != no; then
   COND_CUDA_TRUE=
   COND_CUDA_FALSE='#'
 else
@@ -2143,8 +2181,32 @@
   COND_CUDA_FALSE=
 fi
 
+ if test "$want_cuda" = cuda5; then
+  COND_CUDA5_TRUE=
+  COND_CUDA5_FALSE='#'
+else
+  COND_CUDA5_TRUE='#'
+  COND_CUDA5_FALSE=
+fi
 
 
+
+# Check whether --with-vtk was given.
+if test "${with_vtk+set}" = set; then :
+  withval=$with_vtk; want_vtk="$withval"
+else
+  want_vtk=no
+fi
+
+ if test "$want_vtk" != no; then
+  COND_VTK_TRUE=
+  COND_VTK_FALSE='#'
+else
+  COND_VTK_TRUE='#'
+  COND_VTK_FALSE=
+fi
+
+
 # Checks for programs.
 
 # a courtesy to the installed base of users
@@ -2160,7 +2222,7 @@
 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 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 pgfortran pgf95 lf95 ftn nagfor 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
@@ -2178,7 +2240,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -2204,7 +2266,7 @@
 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 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 pgfortran pgf95 lf95 ftn nagfor 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
@@ -2222,7 +2284,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -2587,6 +2649,11 @@
   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'
@@ -2607,7 +2674,107 @@
     as_fn_error $? "$flags_guess failed" "$LINENO" 5
 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'
@@ -2662,9 +2829,16 @@
 #        that detects unbalanced quotes in FLIBS should be implemented
 #        and (ugh) tested at some point.
 case $ac_fc_v_output in
-  # If we are using xlf then replace all the commas with spaces.
+  # With xlf replace commas with spaces,
+  # and remove "-link" and closing parenthesis.
   *xlfentry*)
-    ac_fc_v_output=`echo $ac_fc_v_output | sed 's/,/ /g'` ;;
+    ac_fc_v_output=`echo $ac_fc_v_output |
+      sed '
+        s/,/ /g
+        s/ -link / /g
+        s/) *$//
+      '
+    ` ;;
 
   # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
   # $LIBS confuse us, and the libraries appear later in the output anyway).
@@ -2680,6 +2854,16 @@
 	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'` ;;
@@ -2753,9 +2937,16 @@
 #        that detects unbalanced quotes in FLIBS should be implemented
 #        and (ugh) tested at some point.
 case $ac_fc_v_output in
-  # If we are using xlf then replace all the commas with spaces.
+  # With xlf replace commas with spaces,
+  # and remove "-link" and closing parenthesis.
   *xlfentry*)
-    ac_fc_v_output=`echo $ac_fc_v_output | sed 's/,/ /g'` ;;
+    ac_fc_v_output=`echo $ac_fc_v_output |
+      sed '
+        s/,/ /g
+        s/ -link / /g
+        s/) *$//
+      '
+    ` ;;
 
   # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
   # $LIBS confuse us, and the libraries appear later in the output anyway).
@@ -2771,6 +2962,16 @@
 	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'` ;;
@@ -2829,7 +3030,11 @@
 	  |-LANG:=* | -LIST:* | -LNO:* | -link)
 	  ;;
 	-lkernel32)
-	  test x"$CYGWIN" != xyes && ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg"
+	  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.
@@ -2939,7 +3144,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -2979,7 +3184,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -3032,7 +3237,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -3073,7 +3278,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
@@ -3131,7 +3336,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -3175,7 +3380,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -3403,8 +3608,7 @@
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* 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);
@@ -3853,7 +4057,11 @@
 ac_fcflags_srcext_save=$ac_fcflags_srcext
 ac_fcflags_srcext=
 ac_cv_fc_srcext_f90=unknown
-for ac_flag in none -qsuffix=f=f90 -Tf; do
+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
   test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
   cat > conftest.$ac_ext <<_ACEOF
       program main
@@ -3902,7 +4110,7 @@
   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" +source=free -nfix
+	       -freeform "-f free" -8 +source=free -nfix --nfix -Free
 do
   test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
   cat > conftest.$ac_ext <<_ACEOF
@@ -3960,7 +4168,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -4000,7 +4208,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -4053,7 +4261,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -4094,7 +4302,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
@@ -4152,7 +4360,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -4196,7 +4404,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     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 as_fn_executable_p "$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
     break 2
@@ -4424,8 +4632,7 @@
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* 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);
@@ -4678,7 +4885,7 @@
     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"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$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
@@ -4744,7 +4951,7 @@
     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"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$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
@@ -5094,13 +5301,63 @@
 
 
 
+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_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_NVCC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $NVCC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_NVCC="$NVCC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+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
+    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
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+NVCC=$ac_cv_path_NVCC
+if test -n "$NVCC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NVCC" >&5
+$as_echo "$NVCC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$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: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot find 'nvcc' program.
+See \`config.log' for more details" "$LINENO" 5; }
+    NVCC=`echo "Error: nvcc is not installed." ; false`
+  fi
+
+fi
+
 # Checks for typedefs, structures, and compiler characteristics.
 
 
 # Checks for library functions.
 
-
 ac_config_files="$ac_config_files Makefile src/auxiliaries/Makefile src/meshfem3D/Makefile src/specfem3D/Makefile src/create_header_file/Makefile setup/constants.h setup/precision.h"
 
 cat >confcache <<\_ACEOF
@@ -5216,6 +5473,14 @@
   as_fn_error $? "conditional \"COND_CUDA\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 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
+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
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
@@ -5514,16 +5779,16 @@
     # ... 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 -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -5583,29 +5848,17 @@
   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'"
 
@@ -5625,8 +5878,8 @@
 # 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 5.1.2, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by Specfem3D Globe $as_me 6.0.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -5687,11 +5940,11 @@
 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 5.1.2
-configured by $0, generated by GNU Autoconf 2.68,
+Specfem3D Globe config.status 6.0.0
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -5779,7 +6032,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'

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/configure.ac	2012-12-27 19:08:42 UTC (rev 21199)
@@ -2,15 +2,13 @@
 dnl
 dnl Process this file with autoconf to produce the 'configure' script:
 dnl
-dnl ACLOCAL="aclocal -I m4" autoreconf
+dnl autoreconf -I m4
 dnl
 dnl You must have recent versions of Autoconf and Automake installed.
 
-# $Id: configure.ac,v 1.1 2005/08/24 22:45:51 leif Exp $
 
-
 AC_PREREQ(2.61)
-AC_INIT([Specfem3D Globe], [5.1.2], [jtromp AT princeton.edu], [Specfem3DGlobe])
+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_MACRO_DIR([m4])
@@ -38,8 +36,16 @@
         [build cuda GPU enabled version @<:@default=no@:>@])],
     [want_cuda="$withval"],
     [want_cuda=no])
-AM_CONDITIONAL([COND_CUDA], [test "$want_cuda" = yes])
+#AM_CONDITIONAL([COND_CUDA], [test "$want_cuda" = yes])
+AM_CONDITIONAL([COND_CUDA], [test "$want_cuda" != no])
+AM_CONDITIONAL([COND_CUDA5], [test "$want_cuda" = cuda5])
 
+AC_ARG_WITH([vtk],
+    [AC_HELP_STRING([--with-vtk],
+        [build VTK enabled version @<:@default=no@:>@])],
+    [want_vtk="$withval"],
+    [want_vtk=no])
+AM_CONDITIONAL([COND_VTK], [test "$want_vtk" != no])
 
 # Checks for programs.
 
@@ -108,13 +114,15 @@
 
 CIT_FC_MPI_HEADER([$MPIFC], [$FLAGS_NO_CHECK])
 
+if test "$want_cuda" = yes; then
+    CIT_CUDA_COMPILER
+fi
 
 # Checks for typedefs, structures, and compiler characteristics.
 
 
 # Checks for library functions.
 
-
 AC_CONFIG_FILES([
   Makefile 
   src/auxiliaries/Makefile 

Added: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/install-sh
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/install-sh	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/install-sh	2012-12-27 19:08:42 UTC (rev 21199)
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:


Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/install-sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_scalar_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_scalar_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_scalar_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -76,7 +76,7 @@
   if( mp->num_interfaces_outer_core == 0 ) return;
 
   int blocksize = BLOCKSIZE_TRANSFER;
-  int size_padded = ((int)ceil(((double)(mp->max_nibool_interfaces_outer_core))/((double)blocksize)))*blocksize;
+  int size_padded = ((int)ceil(((double)(mp->max_nibool_interfaces_oc))/((double)blocksize)))*blocksize;
   int num_blocks_x = size_padded/blocksize;
   int num_blocks_y = 1;
   while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -91,7 +91,7 @@
     prepare_boundary_potential_on_device<<<grid,threads>>>(mp->d_accel_outer_core,
                                                            mp->d_send_accel_buffer_outer_core,
                                                            mp->num_interfaces_outer_core,
-                                                           mp->max_nibool_interfaces_outer_core,
+                                                           mp->max_nibool_interfaces_oc,
                                                            mp->d_nibool_interfaces_outer_core,
                                                            mp->d_ibool_interfaces_outer_core);
   }
@@ -99,13 +99,13 @@
     prepare_boundary_potential_on_device<<<grid,threads>>>(mp->d_b_accel_outer_core,
                                                            mp->d_send_accel_buffer_outer_core,
                                                            mp->num_interfaces_outer_core,
-                                                           mp->max_nibool_interfaces_outer_core,
+                                                           mp->max_nibool_interfaces_oc,
                                                            mp->d_nibool_interfaces_outer_core,
                                                            mp->d_ibool_interfaces_outer_core);
   }
 
   print_CUDA_error_if_any(cudaMemcpy(send_potential_dot_dot_buffer,mp->d_send_accel_buffer_outer_core,
-                                     (mp->max_nibool_interfaces_outer_core)*(mp->num_interfaces_outer_core)*sizeof(realw),
+                                     (mp->max_nibool_interfaces_oc)*(mp->num_interfaces_outer_core)*sizeof(realw),
                                      cudaMemcpyDeviceToHost),98000);
 
 #ifdef ENABLE_VERY_SLOW_ERROR_CHECKING
@@ -153,12 +153,12 @@
 
   // copies scalar buffer onto GPU
   cudaMemcpy(mp->d_send_accel_buffer_outer_core, buffer_recv_scalar,
-             (mp->max_nibool_interfaces_outer_core)*(mp->num_interfaces_outer_core)*sizeof(realw),
+             (mp->max_nibool_interfaces_oc)*(mp->num_interfaces_outer_core)*sizeof(realw),
              cudaMemcpyHostToDevice);
 
   // assembles on GPU
   int blocksize = BLOCKSIZE_TRANSFER;
-  int size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_outer_core)/((double)blocksize)))*blocksize;
+  int size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_oc)/((double)blocksize)))*blocksize;
   int num_blocks_x = size_padded/blocksize;
   int num_blocks_y = 1;
   while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -174,7 +174,7 @@
     assemble_boundary_potential_on_device<<<grid,threads>>>(mp->d_accel_outer_core,
                                                             mp->d_send_accel_buffer_outer_core,
                                                             mp->num_interfaces_outer_core,
-                                                            mp->max_nibool_interfaces_outer_core,
+                                                            mp->max_nibool_interfaces_oc,
                                                             mp->d_nibool_interfaces_outer_core,
                                                             mp->d_ibool_interfaces_outer_core);
   }
@@ -183,7 +183,7 @@
     assemble_boundary_potential_on_device<<<grid,threads>>>(mp->d_b_accel_outer_core,
                                                             mp->d_send_accel_buffer_outer_core,
                                                             mp->num_interfaces_outer_core,
-                                                            mp->max_nibool_interfaces_outer_core,
+                                                            mp->max_nibool_interfaces_oc,
                                                             mp->d_nibool_interfaces_outer_core,
                                                             mp->d_ibool_interfaces_outer_core);
   }

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_vector_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_vector_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/assemble_MPI_vector_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -81,7 +81,7 @@
     if( mp->num_interfaces_crust_mantle > 0 ){
 
       blocksize = BLOCKSIZE_TRANSFER;
-      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_crust_mantle)/((double)blocksize)))*blocksize;
+      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_cm)/((double)blocksize)))*blocksize;
       num_blocks_x = size_padded/blocksize;
       num_blocks_y = 1;
       while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -95,7 +95,7 @@
         prepare_boundary_accel_on_device<<<grid,threads>>>(mp->d_accel_crust_mantle,
                                                            mp->d_send_accel_buffer_crust_mantle,
                                                            mp->num_interfaces_crust_mantle,
-                                                           mp->max_nibool_interfaces_crust_mantle,
+                                                           mp->max_nibool_interfaces_cm,
                                                            mp->d_nibool_interfaces_crust_mantle,
                                                            mp->d_ibool_interfaces_crust_mantle);
       }
@@ -103,14 +103,14 @@
         prepare_boundary_accel_on_device<<<grid,threads>>>(mp->d_b_accel_crust_mantle,
                                                            mp->d_send_accel_buffer_crust_mantle,
                                                            mp->num_interfaces_crust_mantle,
-                                                           mp->max_nibool_interfaces_crust_mantle,
+                                                           mp->max_nibool_interfaces_cm,
                                                            mp->d_nibool_interfaces_crust_mantle,
                                                            mp->d_ibool_interfaces_crust_mantle);
       }
 
       // copies buffer to CPU
       cudaMemcpy(send_accel_buffer,mp->d_send_accel_buffer_crust_mantle,
-                 3*mp->max_nibool_interfaces_crust_mantle*mp->num_interfaces_crust_mantle*sizeof(realw),
+                 3*mp->max_nibool_interfaces_cm*mp->num_interfaces_crust_mantle*sizeof(realw),
                  cudaMemcpyDeviceToHost);
 
     }
@@ -121,7 +121,7 @@
     if( mp->num_interfaces_inner_core > 0 ){
 
       blocksize = BLOCKSIZE_TRANSFER;
-      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_inner_core)/((double)blocksize)))*blocksize;
+      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_ic)/((double)blocksize)))*blocksize;
       num_blocks_x = size_padded/blocksize;
       num_blocks_y = 1;
       while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -135,7 +135,7 @@
         prepare_boundary_accel_on_device<<<grid,threads>>>(mp->d_accel_inner_core,
                                                            mp->d_send_accel_buffer_inner_core,
                                                            mp->num_interfaces_inner_core,
-                                                           mp->max_nibool_interfaces_inner_core,
+                                                           mp->max_nibool_interfaces_ic,
                                                            mp->d_nibool_interfaces_inner_core,
                                                            mp->d_ibool_interfaces_inner_core);
       }
@@ -143,14 +143,14 @@
         prepare_boundary_accel_on_device<<<grid,threads>>>(mp->d_b_accel_inner_core,
                                                            mp->d_send_accel_buffer_inner_core,
                                                            mp->num_interfaces_inner_core,
-                                                           mp->max_nibool_interfaces_inner_core,
+                                                           mp->max_nibool_interfaces_ic,
                                                            mp->d_nibool_interfaces_inner_core,
                                                            mp->d_ibool_interfaces_inner_core);
       }
 
       // copies buffer to CPU
       cudaMemcpy(send_accel_buffer,mp->d_send_accel_buffer_inner_core,
-                 3*mp->max_nibool_interfaces_inner_core*mp->num_interfaces_inner_core*sizeof(realw),
+                 3*mp->max_nibool_interfaces_ic*mp->num_interfaces_inner_core*sizeof(realw),
                  cudaMemcpyDeviceToHost);
 
     }
@@ -202,12 +202,12 @@
     if( mp->num_interfaces_crust_mantle > 0 ){
       // copies vector buffer values to GPU
       print_CUDA_error_if_any(cudaMemcpy(mp->d_send_accel_buffer_crust_mantle, buffer_recv_vector,
-                                         NDIM*(mp->max_nibool_interfaces_crust_mantle)*(mp->num_interfaces_crust_mantle)*sizeof(realw),
+                                         NDIM*(mp->max_nibool_interfaces_cm)*(mp->num_interfaces_crust_mantle)*sizeof(realw),
                                          cudaMemcpyHostToDevice),41000);
 
       // assembles values
       blocksize = BLOCKSIZE_TRANSFER;
-      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_crust_mantle)/((double)blocksize)))*blocksize;
+      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_cm)/((double)blocksize)))*blocksize;
       num_blocks_x = size_padded/blocksize;
       num_blocks_y = 1;
       while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -223,7 +223,7 @@
         assemble_boundary_accel_on_device<<<grid,threads>>>(mp->d_accel_crust_mantle,
                                                             mp->d_send_accel_buffer_crust_mantle,
                                                             mp->num_interfaces_crust_mantle,
-                                                            mp->max_nibool_interfaces_crust_mantle,
+                                                            mp->max_nibool_interfaces_cm,
                                                             mp->d_nibool_interfaces_crust_mantle,
                                                             mp->d_ibool_interfaces_crust_mantle);
       }
@@ -232,7 +232,7 @@
         assemble_boundary_accel_on_device<<<grid,threads>>>(mp->d_b_accel_crust_mantle,
                                                             mp->d_send_accel_buffer_crust_mantle,
                                                             mp->num_interfaces_crust_mantle,
-                                                            mp->max_nibool_interfaces_crust_mantle,
+                                                            mp->max_nibool_interfaces_cm,
                                                             mp->d_nibool_interfaces_crust_mantle,
                                                             mp->d_ibool_interfaces_crust_mantle);
       }
@@ -248,12 +248,12 @@
     if( mp->num_interfaces_inner_core > 0 ){
       // copies buffer values to GPU
       print_CUDA_error_if_any(cudaMemcpy(mp->d_send_accel_buffer_inner_core, buffer_recv_vector,
-                                         NDIM*(mp->max_nibool_interfaces_inner_core)*(mp->num_interfaces_inner_core)*sizeof(realw),
+                                         NDIM*(mp->max_nibool_interfaces_ic)*(mp->num_interfaces_inner_core)*sizeof(realw),
                                          cudaMemcpyHostToDevice),41001);
 
       // assembles values
       blocksize = BLOCKSIZE_TRANSFER;
-      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_inner_core)/((double)blocksize)))*blocksize;
+      size_padded = ((int)ceil(((double)mp->max_nibool_interfaces_ic)/((double)blocksize)))*blocksize;
       num_blocks_x = size_padded/blocksize;
       num_blocks_y = 1;
       while(num_blocks_x > MAXIMUM_GRID_DIM) {
@@ -269,7 +269,7 @@
         assemble_boundary_accel_on_device<<<grid,threads>>>(mp->d_accel_inner_core,
                                                             mp->d_send_accel_buffer_inner_core,
                                                             mp->num_interfaces_inner_core,
-                                                            mp->max_nibool_interfaces_inner_core,
+                                                            mp->max_nibool_interfaces_ic,
                                                             mp->d_nibool_interfaces_inner_core,
                                                             mp->d_ibool_interfaces_inner_core);
       }
@@ -278,7 +278,7 @@
         assemble_boundary_accel_on_device<<<grid,threads>>>(mp->d_b_accel_inner_core,
                                                             mp->d_send_accel_buffer_inner_core,
                                                             mp->num_interfaces_inner_core,
-                                                            mp->max_nibool_interfaces_inner_core,
+                                                            mp->max_nibool_interfaces_ic,
                                                             mp->d_nibool_interfaces_inner_core,
                                                             mp->d_ibool_interfaces_inner_core);
       }

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/check_fields_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/check_fields_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/check_fields_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -776,7 +776,7 @@
 /* ----------------------------------------------------------------------------------------------- */
 
 /* ----------------------------------------------------------------------------------------------- */
-//daniel: helper function
+// helper function
 /*
  __global__ void check_phase_ispec_kernel(int num_phase_ispec,
  int* phase_ispec,
@@ -845,7 +845,7 @@
  */
 
 /* ----------------------------------------------------------------------------------------------- */
-//daniel: helper function
+// helper function
 /*
  __global__ void check_ispec_is_kernel(int NSPEC_AB,
  int* ispec_is,
@@ -908,7 +908,7 @@
  }
  */
 /* ----------------------------------------------------------------------------------------------- */
-//daniel: helper function
+// helper function
 /*
  __global__ void check_array_ispec_kernel(int num_array_ispec,
  int* array_ispec,

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_crust_mantle_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_crust_mantle_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_crust_mantle_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -1624,7 +1624,7 @@
 
   TRACE("compute_forces_crust_mantle_cuda");
 
-//daniel: debug time
+//debug time
 //  printf("Running compute_forces\n");
 //  double start_time = get_time();
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_inner_core_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_inner_core_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_inner_core_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -1252,7 +1252,7 @@
 
   TRACE("compute_forces_inner_core_cuda");
 
-//daniel: debug
+  // debug timing
   //printf("Running compute_forces_inner_core_cuda\n");
   //double start_time = get_time();
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_outer_core_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_outer_core_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_outer_core_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -584,7 +584,7 @@
 
   TRACE("compute_forces_outer_core_cuda");
 
-//daniel: debug
+  // debug timing
   //printf("Running compute_forces_outer_core_cuda\n");
   //double start_time = get_time();
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/mesh_constants_cuda.h
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/mesh_constants_cuda.h	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/mesh_constants_cuda.h	2012-12-27 19:08:42 UTC (rev 21199)
@@ -154,7 +154,7 @@
 // Texture memory usage:
 // requires CUDA version >= 4.0, see check below
 // Use textures for d_displ and d_accel -- 10% performance boost
-#define USE_TEXTURES_FIELDS
+//#define USE_TEXTURES_FIELDS
 
 // Using texture memory for the hprime-style constants is slower on
 // Fermi generation hardware, but *may* be faster on Kepler
@@ -168,6 +168,7 @@
 #undef USE_TEXTURES_CONSTANTS
 #endif
 
+// compiling infos
 #ifdef USE_TEXTURES_FIELDS
 #pragma message ("\nCompiling with: USE_TEXTURES_FIELDS enabled\n")
 #endif
@@ -276,11 +277,11 @@
   // backward/reconstructed elastic wavefield
   realw* d_b_displ_crust_mantle; realw* d_b_veloc_crust_mantle; realw* d_b_accel_crust_mantle;
 
-#ifdef USE_TEXTURES_FIELDS
-  // Texture references for fast non-coalesced scattered access
-  const textureReference* d_displ_cm_tex_ref_ptr;
-  const textureReference* d_accel_cm_tex_ref_ptr;
-#endif
+//#ifdef USE_TEXTURES_FIELDS
+//  // Texture references for fast non-coalesced scattered access
+//  const textureReference* d_displ_cm_tex_ref_ptr;
+//  const textureReference* d_accel_cm_tex_ref_ptr;
+//#endif
 
   // attenuation
   realw* d_R_xx_crust_mantle;
@@ -361,11 +362,11 @@
   // backward/reconstructed elastic wavefield
   realw* d_b_displ_outer_core; realw* d_b_veloc_outer_core; realw* d_b_accel_outer_core;
 
-#ifdef USE_TEXTURES_FIELDS
-  // Texture references for fast non-coalesced scattered access
-  const textureReference* d_displ_oc_tex_ref_ptr;
-  const textureReference* d_accel_oc_tex_ref_ptr;
-#endif
+//#ifdef USE_TEXTURES_FIELDS
+//  // Texture references for fast non-coalesced scattered access
+//  const textureReference* d_displ_oc_tex_ref_ptr;
+//  const textureReference* d_accel_oc_tex_ref_ptr;
+//#endif
 
   // kernels
   realw* d_rho_kl_outer_core;
@@ -432,11 +433,11 @@
   // backward/reconstructed elastic wavefield
   realw* d_b_displ_inner_core; realw* d_b_veloc_inner_core; realw* d_b_accel_inner_core;
 
-#ifdef USE_TEXTURES_FIELDS
-  // Texture references for fast non-coalesced scattered access
-  const textureReference* d_displ_ic_tex_ref_ptr;
-  const textureReference* d_accel_ic_tex_ref_ptr;
-#endif
+//#ifdef USE_TEXTURES_FIELDS
+//  // Texture references for fast non-coalesced scattered access
+//  const textureReference* d_displ_ic_tex_ref_ptr;
+//  const textureReference* d_accel_ic_tex_ref_ptr;
+//#endif
 
   // attenuation
   realw* d_R_xx_inner_core;
@@ -519,10 +520,10 @@
   //realw* d_hprime_yy; // only needed if NGLLX != NGLLY != NGLLZ
   //realw* d_hprime_zz; // only needed if NGLLX != NGLLY != NGLLZ
 
-#ifdef USE_TEXTURES_CONSTANTS
-  const textureReference* d_hprime_xx_tex_ptr;
-  realw* d_hprime_xx_tex;
-#endif
+//#ifdef USE_TEXTURES_CONSTANTS
+//  const textureReference* d_hprime_xx_tex_ptr;
+//  realw* d_hprime_xx_tex;
+//#endif
 
   realw* d_hprimewgll_xx;
   //realw* d_hprimewgll_yy; // only needed if NGLLX != NGLLY != NGLLZ
@@ -616,19 +617,19 @@
   int myrank;
 
   int num_interfaces_crust_mantle;
-  int max_nibool_interfaces_crust_mantle;
+  int max_nibool_interfaces_cm;
   int* d_nibool_interfaces_crust_mantle;
   int* d_ibool_interfaces_crust_mantle;
   realw* d_send_accel_buffer_crust_mantle;
 
   int num_interfaces_inner_core;
-  int max_nibool_interfaces_inner_core;
+  int max_nibool_interfaces_ic;
   int* d_nibool_interfaces_inner_core;
   int* d_ibool_interfaces_inner_core;
   realw* d_send_accel_buffer_inner_core;
 
   int num_interfaces_outer_core;
-  int max_nibool_interfaces_outer_core;
+  int max_nibool_interfaces_oc;
   int* d_nibool_interfaces_outer_core;
   int* d_ibool_interfaces_outer_core;
   realw* d_send_accel_buffer_outer_core;

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_constants_cuda.h
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_constants_cuda.h	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_constants_cuda.h	2012-12-27 19:08:42 UTC (rev 21199)
@@ -31,6 +31,19 @@
 
 typedef float realw;  // type of "working" variables
 
+// CUDA version >= 5.0 needed for new symbol addressing and texture binding
+#if CUDA_VERSION < 5000
+  #ifndef USE_OLDER_CUDA4_GPU
+    #define USE_OLDER_CUDA4_GPU
+  #endif
+#else
+  #undef USE_OLDER_CUDA4_GPU
+#endif
+
+#ifdef USE_OLDER_CUDA4_GPU
+#pragma message ("\nCompiling with: USE_OLDER_CUDA4_GPU enabled\n")
+#endif
+
 /* ----------------------------------------------------------------------------------------------- */
 
 // CONSTANT arrays setup
@@ -96,7 +109,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_hprime_xx),"d_hprime_xx");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_hprime_xx),d_hprime_xx);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_hprime_xx: %s\n", cudaGetErrorString(err));
     exit(1);
@@ -152,7 +169,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_hprimewgll_xx),"d_hprimewgll_xx");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_hprimewgll_xx),d_hprimewgll_xx);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_hprimewgll_xx: %s\n", cudaGetErrorString(err));
     exit(1);
@@ -206,7 +227,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_xy),"d_wgllwgll_xy");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_xy),d_wgllwgll_xy);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_wgllwgll_xy: %s\n", cudaGetErrorString(err));
     exit(1);
@@ -223,7 +248,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_xz),"d_wgllwgll_xz");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_xz),d_wgllwgll_xz);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_wgllwgll_xz: %s\n", cudaGetErrorString(err));
     exit(1);
@@ -240,7 +269,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_yz),"d_wgllwgll_yz");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_wgllwgll_yz),d_wgllwgll_yz);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_wgllwgll_yz: %s\n", cudaGetErrorString(err));
     exit(1);
@@ -257,7 +290,11 @@
     exit(1);
   }
 
+#ifdef USE_OLDER_CUDA4_GPU
   err = cudaGetSymbolAddress((void**)&(mp->d_wgll_cube),"d_wgll_cube");
+#else
+  err = cudaGetSymbolAddress((void**)&(mp->d_wgll_cube),d_wgll_cube);
+#endif
   if(err != cudaSuccess) {
     fprintf(stderr, "Error with d_wgll_cube: %s\n", cudaGetErrorString(err));
     exit(1);

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_mesh_constants_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_mesh_constants_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/prepare_mesh_constants_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -41,6 +41,26 @@
 #include "mesh_constants_cuda.h"
 #include "prepare_constants_cuda.h"
 
+#ifdef USE_OLDER_CUDA4_GPU
+#else
+  #ifdef USE_TEXTURES_FIELDS
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_displ_cm_tex;
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_accel_cm_tex;
+
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_displ_oc_tex;
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_accel_oc_tex;
+
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_displ_ic_tex;
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_accel_ic_tex;
+  #endif
+
+  #ifdef USE_TEXTURES_CONSTANTS
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_hprime_xx_cm_tex;
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_hprime_xx_oc_tex;
+extern texture<realw, cudaTextureType1D, cudaReadModeElementType> d_hprime_xx_ic_tex;
+  #endif
+#endif
+
 /* ----------------------------------------------------------------------------------------------- */
 
 // helper functions
@@ -160,20 +180,37 @@
   // in the code with #USE_TEXTURES_FIELDS not-defined.
   #ifdef USE_TEXTURES_CONSTANTS
   {
-    print_CUDA_error_if_any(cudaGetTextureReference(&(mp->d_hprime_xx_tex_ptr), "d_hprime_xx_cm_tex"), 1101);
-    cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_hprime_xx_tex_ptr, mp->d_hprime_xx,
-                                            &channelDesc1, sizeof(realw)*(NGLL2)), 1102);
+    #ifdef USE_OLDER_CUDA4_GPU
+      const textureReference* d_hprime_xx_cm_tex_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_hprime_xx_cm_tex_ptr, "d_hprime_xx_cm_tex"), 1101);
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_hprime_xx_cm_tex_ptr, mp->d_hprime_xx,
+                                              &channelDesc1, sizeof(realw)*(NGLL2)), 1102);
 
-    print_CUDA_error_if_any(cudaGetTextureReference(&(mp->d_hprime_xx_tex_ptr), "d_hprime_xx_oc_tex"), 1103);
-    cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_hprime_xx_tex_ptr, mp->d_hprime_xx,
-                                            &channelDesc2, sizeof(realw)*(NGLL2)), 1104);
+      const textureReference* d_hprime_xx_oc_tex_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_hprime_xx_oc_tex_ptr, "d_hprime_xx_oc_tex"), 1103);
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_hprime_xx_oc_tex_ptr, mp->d_hprime_xx,
+                                              &channelDesc2, sizeof(realw)*(NGLL2)), 1104);
 
-    print_CUDA_error_if_any(cudaGetTextureReference(&(mp->d_hprime_xx_tex_ptr), "d_hprime_xx_ic_tex"), 1105);
-    cudaChannelFormatDesc channelDesc3 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_hprime_xx_tex_ptr, mp->d_hprime_xx,
-                                            &channelDesc3, sizeof(realw)*(NGLL2)), 1106);
+      const textureReference* d_hprime_xx_ic_tex_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_hprime_xx_ic_tex_ptr, "d_hprime_xx_ic_tex"), 1105);
+      cudaChannelFormatDesc channelDesc3 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_hprime_xx_ic_tex_ptr, mp->d_hprime_xx,
+                                              &channelDesc3, sizeof(realw)*(NGLL2)), 1106);
+    #else
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_hprime_xx_cm_tex, mp->d_hprime_xx,
+                                              &channelDesc1, sizeof(realw)*(NGLL2)), 1102);
+
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_hprime_xx_oc_tex, mp->d_hprime_xx,
+                                              &channelDesc2, sizeof(realw)*(NGLL2)), 1104);
+
+      cudaChannelFormatDesc channelDesc3 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_hprime_xx_ic_tex, mp->d_hprime_xx,
+                                              &channelDesc3, sizeof(realw)*(NGLL2)), 1106);
+    #endif
   }
   #endif
 
@@ -424,6 +461,11 @@
                                                  realw* R_xy_crust_mantle,
                                                  realw* R_xz_crust_mantle,
                                                  realw* R_yz_crust_mantle,
+                                                 realw* b_R_xx_crust_mantle,
+                                                 realw* b_R_yy_crust_mantle,
+                                                 realw* b_R_xy_crust_mantle,
+                                                 realw* b_R_xz_crust_mantle,
+                                                 realw* b_R_yz_crust_mantle,
                                                  realw* factor_common_crust_mantle,
                                                  realw* one_minus_sum_beta_crust_mantle,
                                                  realw* R_xx_inner_core,
@@ -431,6 +473,11 @@
                                                  realw* R_xy_inner_core,
                                                  realw* R_xz_inner_core,
                                                  realw* R_yz_inner_core,
+                                                 realw* b_R_xx_inner_core,
+                                                 realw* b_R_yy_inner_core,
+                                                 realw* b_R_xy_inner_core,
+                                                 realw* b_R_xz_inner_core,
+                                                 realw* b_R_yz_inner_core,
                                                  realw* factor_common_inner_core,
                                                  realw* one_minus_sum_beta_inner_core,
                                                  realw* alphaval,realw* betaval,realw* gammaval,
@@ -467,6 +514,17 @@
     copy_todevice_realw((void**)&mp->d_R_yz_crust_mantle,R_yz_crust_mantle,R_size1);
   }
 
+  if(mp->simulation_type == 3 ){
+    if( ! mp->use_attenuation_mimic ){
+      // memory variables
+      copy_todevice_realw((void**)&mp->d_b_R_xx_crust_mantle,b_R_xx_crust_mantle,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_yy_crust_mantle,b_R_yy_crust_mantle,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_xy_crust_mantle,b_R_xy_crust_mantle,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_xz_crust_mantle,b_R_xz_crust_mantle,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_yz_crust_mantle,b_R_yz_crust_mantle,R_size1);
+    }
+  }
+
   // inner_core
   R_size1 = N_SLS*NGLL3*mp->NSPEC_INNER_CORE;
   if( mp->use_3d_attenuation_arrays ){
@@ -490,6 +548,17 @@
     copy_todevice_realw((void**)&mp->d_R_yz_inner_core,R_yz_inner_core,R_size1);
   }
 
+  if(mp->simulation_type == 3 ){
+    if( ! mp->use_attenuation_mimic ){
+      // memory variables
+      copy_todevice_realw((void**)&mp->d_b_R_xx_inner_core,b_R_xx_inner_core,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_yy_inner_core,b_R_yy_inner_core,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_xy_inner_core,b_R_xy_inner_core,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_xz_inner_core,b_R_xz_inner_core,R_size1);
+      copy_todevice_realw((void**)&mp->d_b_R_yz_inner_core,b_R_yz_inner_core,R_size1);
+    }
+  }
+
   // alpha,beta,gamma factors
   copy_todevice_realw((void**)&mp->d_alphaval,alphaval,N_SLS);
   copy_todevice_realw((void**)&mp->d_betaval,betaval,N_SLS);
@@ -802,15 +871,15 @@
 void FC_FUNC_(prepare_mpi_buffers_device,
               PREPARE_MPI_BUFFERS_DEVICE)(long* Mesh_pointer_f,
                                           int* num_interfaces_crust_mantle,
-                                          int* max_nibool_interfaces_crust_mantle,
+                                          int* max_nibool_interfaces_cm,
                                           int* nibool_interfaces_crust_mantle,
                                           int* ibool_interfaces_crust_mantle,
                                           int* num_interfaces_inner_core,
-                                          int* max_nibool_interfaces_inner_core,
+                                          int* max_nibool_interfaces_ic,
                                           int* nibool_interfaces_inner_core,
                                           int* ibool_interfaces_inner_core,
                                           int* num_interfaces_outer_core,
-                                          int* max_nibool_interfaces_outer_core,
+                                          int* max_nibool_interfaces_oc,
                                           int* nibool_interfaces_outer_core,
                                           int* ibool_interfaces_outer_core){
 
@@ -822,48 +891,48 @@
 
   // crust/mantle mesh
   mp->num_interfaces_crust_mantle = *num_interfaces_crust_mantle;
-  mp->max_nibool_interfaces_crust_mantle = *max_nibool_interfaces_crust_mantle;
+  mp->max_nibool_interfaces_cm = *max_nibool_interfaces_cm;
   if( mp->num_interfaces_crust_mantle > 0 ){
     // number of ibool entries array
     copy_todevice_int((void**)&mp->d_nibool_interfaces_crust_mantle,nibool_interfaces_crust_mantle,
                       mp->num_interfaces_crust_mantle);
     // ibool entries (iglob indices) values on interface
     copy_todevice_int((void**)&mp->d_ibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,
-                      (mp->num_interfaces_crust_mantle)*(mp->max_nibool_interfaces_crust_mantle));
+                      (mp->num_interfaces_crust_mantle)*(mp->max_nibool_interfaces_cm));
     // allocates mpi buffer for exchange with cpu
     print_CUDA_error_if_any(cudaMalloc((void**)&(mp->d_send_accel_buffer_crust_mantle),
-                                       NDIM*(mp->max_nibool_interfaces_crust_mantle)*(mp->num_interfaces_crust_mantle)*sizeof(realw)),4004);
+                                       NDIM*(mp->max_nibool_interfaces_cm)*(mp->num_interfaces_crust_mantle)*sizeof(realw)),4004);
   }
 
   // inner core mesh
   mp->num_interfaces_inner_core = *num_interfaces_inner_core;
-  mp->max_nibool_interfaces_inner_core = *max_nibool_interfaces_inner_core;
+  mp->max_nibool_interfaces_ic = *max_nibool_interfaces_ic;
   if( mp->num_interfaces_inner_core > 0 ){
     // number of ibool entries array
     copy_todevice_int((void**)&mp->d_nibool_interfaces_inner_core,nibool_interfaces_inner_core,
                       mp->num_interfaces_inner_core);
     // ibool entries (iglob indices) values on interface
     copy_todevice_int((void**)&mp->d_ibool_interfaces_inner_core,ibool_interfaces_inner_core,
-                      (mp->num_interfaces_inner_core)*(mp->max_nibool_interfaces_inner_core));
+                      (mp->num_interfaces_inner_core)*(mp->max_nibool_interfaces_ic));
     // allocates mpi buffer for exchange with cpu
     print_CUDA_error_if_any(cudaMalloc((void**)&(mp->d_send_accel_buffer_inner_core),
-                                       NDIM*(mp->max_nibool_interfaces_inner_core)*(mp->num_interfaces_inner_core)*sizeof(realw)),4004);
+                                       NDIM*(mp->max_nibool_interfaces_ic)*(mp->num_interfaces_inner_core)*sizeof(realw)),4004);
   }
 
   // outer core mesh
   // note: uses only scalar wavefield arrays
   mp->num_interfaces_outer_core = *num_interfaces_outer_core;
-  mp->max_nibool_interfaces_outer_core = *max_nibool_interfaces_outer_core;
+  mp->max_nibool_interfaces_oc = *max_nibool_interfaces_oc;
   if( mp->num_interfaces_outer_core > 0 ){
     // number of ibool entries array
     copy_todevice_int((void**)&mp->d_nibool_interfaces_outer_core,nibool_interfaces_outer_core,
                       mp->num_interfaces_outer_core);
     // ibool entries (iglob indices) values on interface
     copy_todevice_int((void**)&mp->d_ibool_interfaces_outer_core,ibool_interfaces_outer_core,
-                      (mp->num_interfaces_outer_core)*(mp->max_nibool_interfaces_outer_core));
+                      (mp->num_interfaces_outer_core)*(mp->max_nibool_interfaces_oc));
     // allocates mpi buffer for exchange with cpu
     print_CUDA_error_if_any(cudaMalloc((void**)&(mp->d_send_accel_buffer_outer_core),
-                                       (mp->max_nibool_interfaces_outer_core)*(mp->num_interfaces_outer_core)*sizeof(realw)),4004);
+                                       (mp->max_nibool_interfaces_oc)*(mp->num_interfaces_outer_core)*sizeof(realw)),4004);
   }
 }
 
@@ -1031,9 +1100,11 @@
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_xix_crust_mantle, size_padded*sizeof(realw)),1001);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_xiy_crust_mantle, size_padded*sizeof(realw)),1002);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_xiz_crust_mantle, size_padded*sizeof(realw)),1003);
+
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_etax_crust_mantle, size_padded*sizeof(realw)),1004);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_etay_crust_mantle, size_padded*sizeof(realw)),1005);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_etaz_crust_mantle, size_padded*sizeof(realw)),1006);
+
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_gammax_crust_mantle, size_padded*sizeof(realw)),1007);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_gammay_crust_mantle, size_padded*sizeof(realw)),1008);
   print_CUDA_error_if_any(cudaMalloc((void**) &mp->d_gammaz_crust_mantle, size_padded*sizeof(realw)),1009);
@@ -1242,15 +1313,27 @@
 
   #ifdef USE_TEXTURES_FIELDS
   {
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_cm_tex_ref_ptr, "d_displ_cm_tex"), 4021);
-    cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_cm_tex_ref_ptr, mp->d_displ_crust_mantle,
-                                            &channelDesc1, sizeof(realw)*size), 4021);
+    #ifdef USE_OLDER_CUDA4_GPU
+      const textureReference* d_displ_cm_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_cm_tex_ref_ptr, "d_displ_cm_tex"), 4021);
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_cm_tex_ref_ptr, mp->d_displ_crust_mantle,
+                                              &channelDesc1, sizeof(realw)*size), 4021);
 
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_accel_cm_tex_ref_ptr, "d_accel_cm_tex"), 4023);
-    cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_accel_cm_tex_ref_ptr, mp->d_accel_crust_mantle,
-                                            &channelDesc2, sizeof(realw)*size), 4023);
+      const textureReference* d_accel_cm_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_accel_cm_tex_ref_ptr, "d_accel_cm_tex"), 4023);
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_accel_cm_tex_ref_ptr, mp->d_accel_crust_mantle,
+                                              &channelDesc2, sizeof(realw)*size), 4023);
+    #else
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_displ_cm_tex, mp->d_displ_crust_mantle,
+                                              &channelDesc1, sizeof(realw)*size), 4021);
+
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_accel_cm_tex, mp->d_accel_crust_mantle,
+                                              &channelDesc2, sizeof(realw)*size), 4023);
+    #endif
   }
   #endif
 
@@ -1441,15 +1524,27 @@
 
   #ifdef USE_TEXTURES_FIELDS
   {
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_oc_tex_ref_ptr, "d_displ_oc_tex"), 5021);
-    cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_oc_tex_ref_ptr, mp->d_displ_outer_core,
-                                            &channelDesc1, sizeof(realw)*size), 5021);
+    #ifdef USE_OLDER_CUDA4_GPU
+      const textureReference* d_displ_oc_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_oc_tex_ref_ptr, "d_displ_oc_tex"), 5021);
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_oc_tex_ref_ptr, mp->d_displ_outer_core,
+                                              &channelDesc1, sizeof(realw)*size), 5021);
 
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_accel_oc_tex_ref_ptr, "d_accel_oc_tex"), 5023);
-    cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_accel_oc_tex_ref_ptr, mp->d_accel_outer_core,
-                                            &channelDesc2, sizeof(realw)*size), 5023);
+      const textureReference* d_accel_oc_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_accel_oc_tex_ref_ptr, "d_accel_oc_tex"), 5023);
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_accel_oc_tex_ref_ptr, mp->d_accel_outer_core,
+                                              &channelDesc2, sizeof(realw)*size), 5023);
+    #else
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_displ_oc_tex, mp->d_displ_outer_core,
+                                              &channelDesc1, sizeof(realw)*size), 5021);
+
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_accel_oc_tex, mp->d_accel_outer_core,
+                                              &channelDesc2, sizeof(realw)*size), 5023);
+    #endif
   }
   #endif
 
@@ -1645,15 +1740,29 @@
 
   #ifdef USE_TEXTURES_FIELDS
   {
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_ic_tex_ref_ptr, "d_displ_ic_tex"), 6021);
-    cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_ic_tex_ref_ptr, mp->d_displ_inner_core,
-                                            &channelDesc1, sizeof(realw)*size), 6021);
+    #ifdef USE_OLDER_CUDA4_GPU
+      const textureReference* d_displ_ic_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_displ_ic_tex_ref_ptr, "d_displ_ic_tex"), 6021);
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, mp->d_displ_ic_tex_ref_ptr, mp->d_displ_inner_core,
+                                              &channelDesc1, sizeof(realw)*size), 6021);
 
-    print_CUDA_error_if_any(cudaGetTextureReference(&mp->d_accel_ic_tex_ref_ptr, "d_accel_ic_tex"), 6023);
-    cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
-    print_CUDA_error_if_any(cudaBindTexture(0, mp->d_accel_ic_tex_ref_ptr, mp->d_accel_inner_core,
-                                            &channelDesc2, sizeof(realw)*size), 6023);
+      const textureReference* d_accel_ic_tex_ref_ptr;
+      print_CUDA_error_if_any(cudaGetTextureReference(&d_accel_ic_tex_ref_ptr, "d_accel_ic_tex"), 6023);
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<realw>();
+      print_CUDA_error_if_any(cudaBindTexture(0, d_accel_ic_tex_ref_ptr, mp->d_accel_inner_core,
+                                              &channelDesc2, sizeof(realw)*size), 6023);
+    #else
+      cudaChannelFormatDesc channelDesc1 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_displ_ic_tex, mp->d_displ_inner_core,
+                                              &channelDesc1, sizeof(realw)*size), 6021);
+
+      cudaChannelFormatDesc channelDesc2 = cudaCreateChannelDesc<float>();
+      print_CUDA_error_if_any(cudaBindTexture(0, &d_accel_ic_tex, mp->d_accel_inner_core,
+                                              &channelDesc2, sizeof(realw)*size), 6023);
+    #endif
+
+
   }
   #endif
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/specfem3D_gpu_cuda_method_stubs.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/specfem3D_gpu_cuda_method_stubs.c	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/specfem3D_gpu_cuda_method_stubs.c	2012-12-27 19:08:42 UTC (rev 21199)
@@ -408,6 +408,11 @@
                                                  realw* R_xy_crust_mantle,
                                                  realw* R_xz_crust_mantle,
                                                  realw* R_yz_crust_mantle,
+                                                 realw* b_R_xx_crust_mantle,
+                                                 realw* b_R_yy_crust_mantle,
+                                                 realw* b_R_xy_crust_mantle,
+                                                 realw* b_R_xz_crust_mantle,
+                                                 realw* b_R_yz_crust_mantle,
                                                  realw* factor_common_crust_mantle,
                                                  realw* one_minus_sum_beta_crust_mantle,
                                                  realw* R_xx_inner_core,
@@ -415,6 +420,11 @@
                                                  realw* R_xy_inner_core,
                                                  realw* R_xz_inner_core,
                                                  realw* R_yz_inner_core,
+                                                 realw* b_R_xx_inner_core,
+                                                 realw* b_R_yy_inner_core,
+                                                 realw* b_R_xy_inner_core,
+                                                 realw* b_R_xz_inner_core,
+                                                 realw* b_R_yz_inner_core,
                                                  realw* factor_common_inner_core,
                                                  realw* one_minus_sum_beta_inner_core,
                                                  realw* alphaval,realw* betaval,realw* gammaval,
@@ -479,15 +489,15 @@
 void FC_FUNC_(prepare_mpi_buffers_device,
               PREPARE_MPI_BUFFERS_DEVICE)(long* Mesh_pointer_f,
                                           int* num_interfaces_crust_mantle,
-                                          int* max_nibool_interfaces_crust_mantle,
+                                          int* max_nibool_interfaces_cm,
                                           int* nibool_interfaces_crust_mantle,
                                           int* ibool_interfaces_crust_mantle,
                                           int* num_interfaces_inner_core,
-                                          int* max_nibool_interfaces_inner_core,
+                                          int* max_nibool_interfaces_ic,
                                           int* nibool_interfaces_inner_core,
                                           int* ibool_interfaces_inner_core,
                                           int* num_interfaces_outer_core,
-                                          int* max_nibool_interfaces_outer_core,
+                                          int* max_nibool_interfaces_oc,
                                           int* nibool_interfaces_outer_core,
                                           int* ibool_interfaces_outer_core){} 
 
@@ -641,9 +651,6 @@
               TRANSFER_B_FIELDS_OC_FROM_DEVICE)(int* size, realw* b_displ, realw* b_veloc, realw* b_accel,
                                                 long* Mesh_pointer_f) {} 
 
-void FC_FUNC_(transfer_accel_cm_to_device,
-              TRANSFER_ACCEL_CM_TO_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {} 
-
 void FC_FUNC_(transfer_displ_cm_from_device,
               TRANSFER_DISPL_CM_FROM_DEVICE)(int* size, realw* displ, long* Mesh_pointer_f) {} 
 
@@ -663,8 +670,17 @@
               TRANSFER_B_DISPL_OC_FROM_DEVICE)(int* size, realw* displ, long* Mesh_pointer_f) {} 
 
 void FC_FUNC_(transfer_veloc_cm_from_device,
-              TRANSFER_DISPL_CM_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {} 
+              TRANSFER_VELOC_CM_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {} 
 
+void FC_FUNC_(transfer_veloc_ic_from_device,
+              TRANSFER_VELOC_IC_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {} 
+
+void FC_FUNC_(transfer_veloc_oc_from_device,
+              TRANSFER_VELOC_OC_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {} 
+
+void FC_FUNC_(transfer_accel_cm_to_device,
+              TRANSFER_ACCEL_CM_TO_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {} 
+
 void FC_FUNC_(transfer_accel_cm_from_device,
               TRANSFER_ACCEL_CM_FROM_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {} 
 
@@ -711,6 +727,22 @@
                                               realw* epsilondev_xz,
                                               realw* epsilondev_yz) {} 
 
+void FC_FUNC_(transfer_b_rmemory_cm_to_device,
+              TRANSFER_B_RMEMORY_CM_TO_DEVICE)(long* Mesh_pointer,
+                                              realw* b_R_xx,
+                                              realw* b_R_yy,
+                                              realw* b_R_xy,
+                                              realw* b_R_xz,
+                                              realw* b_R_yz) {} 
+
+void FC_FUNC_(transfer_b_rmemory_ic_to_device,
+              TRANSFER_B_RMEMORY_IC_TO_DEVICE)(long* Mesh_pointer,
+                                              realw* b_R_xx,
+                                              realw* b_R_yy,
+                                              realw* b_R_xy,
+                                              realw* b_R_xz,
+                                              realw* b_R_yz) {} 
+
 void FC_FUNC_(transfer_rotation_from_device,
               TRANSFER_ROTATION_FROM_DEVICE)(long* Mesh_pointer,
                                              realw* A_array_rotation,

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/transfer_fields_cuda.cu
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/transfer_fields_cuda.cu	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/transfer_fields_cuda.cu	2012-12-27 19:08:42 UTC (rev 21199)
@@ -256,19 +256,14 @@
 
 /* ----------------------------------------------------------------------------------------------- */
 
-extern "C"
-void FC_FUNC_(transfer_accel_cm_to_device,
-              TRANSFER_ACCEL_CM_TO_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {
+// single wavefield transfers
 
-TRACE("transfer_accel_cm_to_device");
+/* ----------------------------------------------------------------------------------------------- */
 
-  Mesh* mp = (Mesh*)(*Mesh_pointer_f); //get mesh pointer out of fortran integer container
+/* ----------------------------------------------------------------------------------------------- */
 
-  print_CUDA_error_if_any(cudaMemcpy(mp->d_accel_crust_mantle,accel,sizeof(realw)*(*size),cudaMemcpyHostToDevice),40016);
+// displacements
 
-}
-
-
 /* ----------------------------------------------------------------------------------------------- */
 
 extern "C"
@@ -347,11 +342,16 @@
   print_CUDA_error_if_any(cudaMemcpy(displ,mp->d_b_displ_outer_core,sizeof(realw)*(*size),cudaMemcpyDeviceToHost),40006);
 }
 
+
 /* ----------------------------------------------------------------------------------------------- */
 
+// velocities
+
+/* ----------------------------------------------------------------------------------------------- */
+
 extern "C"
 void FC_FUNC_(transfer_veloc_cm_from_device,
-              TRANSFER_DISPL_CM_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {
+              TRANSFER_VELOC_CM_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {
 
   TRACE("transfer_veloc_cm_from_device");
 
@@ -363,6 +363,51 @@
 /* ----------------------------------------------------------------------------------------------- */
 
 extern "C"
+void FC_FUNC_(transfer_veloc_ic_from_device,
+              TRANSFER_VELOC_IC_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {
+
+  TRACE("transfer_veloc_ic_from_device");
+
+  Mesh* mp = (Mesh*)(*Mesh_pointer_f); //get mesh pointer out of fortran integer container
+
+  print_CUDA_error_if_any(cudaMemcpy(veloc,mp->d_veloc_inner_core,sizeof(realw)*(*size),cudaMemcpyDeviceToHost),40007);
+}
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(transfer_veloc_oc_from_device,
+              TRANSFER_VELOC_OC_FROM_DEVICE)(int* size, realw* veloc, long* Mesh_pointer_f) {
+
+  TRACE("transfer_veloc_oc_from_device");
+
+  Mesh* mp = (Mesh*)(*Mesh_pointer_f); //get mesh pointer out of fortran integer container
+
+  print_CUDA_error_if_any(cudaMemcpy(veloc,mp->d_veloc_outer_core,sizeof(realw)*(*size),cudaMemcpyDeviceToHost),40007);
+}
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
+// accelerations
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(transfer_accel_cm_to_device,
+              TRANSFER_ACCEL_CM_TO_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {
+
+TRACE("transfer_accel_cm_to_device");
+
+  Mesh* mp = (Mesh*)(*Mesh_pointer_f); //get mesh pointer out of fortran integer container
+
+  print_CUDA_error_if_any(cudaMemcpy(mp->d_accel_crust_mantle,accel,sizeof(realw)*(*size),cudaMemcpyHostToDevice),40016);
+
+}
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
 void FC_FUNC_(transfer_accel_cm_from_device,
               TRANSFER_ACCEL_CM_FROM_DEVICE)(int* size, realw* accel,long* Mesh_pointer_f) {
 
@@ -543,9 +588,72 @@
 #endif
 }
 
+/* ----------------------------------------------------------------------------------------------- */
 
+// R memory variables
+
 /* ----------------------------------------------------------------------------------------------- */
 
+// crust/mantle
+
+extern "C"
+void FC_FUNC_(transfer_b_rmemory_cm_to_device,
+              TRANSFER_B_RMEMORY_CM_TO_DEVICE)(long* Mesh_pointer,
+                                              realw* b_R_xx,
+                                              realw* b_R_yy,
+                                              realw* b_R_xy,
+                                              realw* b_R_xz,
+                                              realw* b_R_yz) {
+  TRACE("transfer_b_Rmemory_cm_to_device");
+  //get mesh pointer out of fortran integer container
+  Mesh* mp = (Mesh*)(*Mesh_pointer);
+
+  int size = N_SLS*NGLL3*mp->NSPEC_CRUST_MANTLE;
+
+  cudaMemcpy(mp->d_b_R_xx_crust_mantle,b_R_xx,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_yy_crust_mantle,b_R_yy,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_xy_crust_mantle,b_R_xy,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_xz_crust_mantle,b_R_xz,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_yz_crust_mantle,b_R_yz,size*sizeof(realw),cudaMemcpyHostToDevice);
+
+#ifdef ENABLE_VERY_SLOW_ERROR_CHECKING
+  exit_on_cuda_error("after transfer_b_Rmemory_cm_to_device");
+#endif
+}
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
+// inner core
+
+extern "C"
+void FC_FUNC_(transfer_b_rmemory_ic_to_device,
+              TRANSFER_B_RMEMORY_IC_TO_DEVICE)(long* Mesh_pointer,
+                                              realw* b_R_xx,
+                                              realw* b_R_yy,
+                                              realw* b_R_xy,
+                                              realw* b_R_xz,
+                                              realw* b_R_yz) {
+  TRACE("transfer_b_Rmemory_ic_to_device");
+  //get mesh pointer out of fortran integer container
+  Mesh* mp = (Mesh*)(*Mesh_pointer);
+
+  int size = N_SLS*NGLL3*mp->NSPEC_INNER_CORE;
+
+  cudaMemcpy(mp->d_b_R_xx_inner_core,b_R_xx,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_yy_inner_core,b_R_yy,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_xy_inner_core,b_R_xy,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_xz_inner_core,b_R_xz,size*sizeof(realw),cudaMemcpyHostToDevice);
+  cudaMemcpy(mp->d_b_R_yz_inner_core,b_R_yz,size*sizeof(realw),cudaMemcpyHostToDevice);
+
+#ifdef ENABLE_VERY_SLOW_ERROR_CHECKING
+  exit_on_cuda_error("after transfer_b_Rmemory_ic_to_device");
+#endif
+}
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
 // rotation arrays
 
 /* ----------------------------------------------------------------------------------------------- */

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/assemble_MPI_central_cube_mesh.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/assemble_MPI_central_cube_mesh.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/assemble_MPI_central_cube_mesh.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -103,14 +103,13 @@
 
   ! send info to central cube from all the slices except those in CHUNK_AB & CHUNK_AB_ANTIPODE
   if(ichunk /= CHUNK_AB .and. ichunk /= CHUNK_AB_ANTIPODE) then
-
-  ! for bottom elements in contact with central cube from the slices side
+    ! for bottom elements in contact with central cube from the slices side
     ipoin = 0
     do ispec2D = 1,NSPEC2D_BOTTOM_INNER_CORE
 
       ispec = ibelm_bottom_inner_core(ispec2D)
 
-  ! only for DOFs exactly on surface of central cube (bottom of these elements)
+      ! only for DOFs exactly on surface of central cube (bottom of these elements)
       k = 1
       do j = 1,NGLLY
         do i = 1,NGLLX
@@ -120,12 +119,12 @@
       enddo
     enddo
 
-  ! send buffer to central cube
+    ! send buffer to central cube
     receiver = receiver_cube_from_slices
     call MPI_SEND(buffer_slices,ndim_assemble*npoin2D_cube_from_slices, &
                  MPI_DOUBLE_PRECISION,receiver,itag,MPI_COMM_WORLD,ier)
 
-    ! daniel: in case NPROC_XI == 1, the other chunks exchange all bottom points with
+    ! in case NPROC_XI == 1, the other chunks exchange all bottom points with
     ! CHUNK_AB **and** CHUNK_AB_ANTIPODE
     if(NPROC_XI==1) then
       call MPI_SEND(buffer_slices,ndim_assemble*npoin2D_cube_from_slices, &
@@ -134,7 +133,6 @@
                    itag,MPI_COMM_WORLD,ier)
     endif
 
-
   endif  ! end sending info to central cube
 
 
@@ -268,14 +266,13 @@
 
   ! receive info from central cube on all the slices except those in CHUNK_AB & CHUNK_AB_ANTIPODE
   if(ichunk /= CHUNK_AB .and. ichunk /= CHUNK_AB_ANTIPODE) then
-
-  ! receive buffers from slices
+    ! receive buffers from slices
     sender = receiver_cube_from_slices
     call MPI_RECV(buffer_slices, &
                 ndim_assemble*npoin2D_cube_from_slices,MPI_DOUBLE_PRECISION,sender, &
                 itag,MPI_COMM_WORLD,msg_status,ier)
 
-    ! daniel: in case NPROC_XI == 1, the other chunks exchange all bottom points with
+    ! in case NPROC_XI == 1, the other chunks exchange all bottom points with
     ! CHUNK_AB **and** CHUNK_AB_ANTIPODE
     if(NPROC_XI==1) then
       call MPI_RECV(buffer_slices2, &
@@ -286,20 +283,19 @@
       buffer_slices = buffer_slices + buffer_slices2
     endif
 
-
-  ! for bottom elements in contact with central cube from the slices side
+    ! for bottom elements in contact with central cube from the slices side
     ipoin = 0
     do ispec2D = 1,NSPEC2D_BOTTOM_INNER_CORE
 
       ispec = ibelm_bottom_inner_core(ispec2D)
 
-  ! only for DOFs exactly on surface of central cube (bottom of these elements)
+      ! only for DOFs exactly on surface of central cube (bottom of these elements)
       k = 1
       do j = 1,NGLLY
         do i = 1,NGLLX
           ipoin = ipoin + 1
 
-  ! distinguish between single and double precision for reals
+          ! distinguish between single and double precision for reals
           if(CUSTOM_REAL == SIZE_REAL) then
             vector_assemble(1:ndim_assemble,ibool_inner_core(i,j,k,ispec)) = sngl(buffer_slices(ipoin,1:ndim_assemble))
           else

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_central_cube_buffers.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_central_cube_buffers.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_central_cube_buffers.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -147,11 +147,10 @@
 
 ! only for slices in central cube
   if(ichunk == CHUNK_AB) then
-
-! initialize index of sender
+    ! initialize index of sender
     imsg = 0
 
-! define sender for xi = xi_min edge
+    ! define sender for xi = xi_min edge
     if(iproc_xi == 0) then
       do iproc_xi_loop = nproc_xi_half_floor,NPROC_XI-1
         imsg = imsg + 1
@@ -159,7 +158,7 @@
       enddo
     endif
 
-! define sender for xi = xi_max edge
+    ! define sender for xi = xi_max edge
     if(iproc_xi == NPROC_XI-1) then
       do iproc_xi_loop = 0, floor((NPROC_XI-1)/2.d0)
         imsg = imsg + 1
@@ -167,7 +166,7 @@
       enddo
     endif
 
-! define sender for eta = eta_min edge
+    ! define sender for eta = eta_min edge
     if(iproc_eta == 0) then
       do iproc_xi_loop = nproc_xi_half_floor,NPROC_XI-1
         imsg = imsg + 1
@@ -175,7 +174,7 @@
       enddo
     endif
 
-! define sender for eta = eta_max edge
+    ! define sender for eta = eta_max edge
     if(iproc_eta == NPROC_ETA-1) then
       do iproc_xi_loop = nproc_xi_half_floor,NPROC_XI-1
         imsg = imsg + 1
@@ -183,23 +182,22 @@
       enddo
     endif
 
-! define sender for bottom edge
-! bottom of cube, direct correspondence but with inverted xi axis
+    ! define sender for bottom edge
+    ! bottom of cube, direct correspondence but with inverted xi axis
     imsg = imsg + 1
     sender_from_slices_to_cube(imsg) = addressing(CHUNK_AB_ANTIPODE,NPROC_XI-1-iproc_xi,iproc_eta)
 
-! check that total number of faces found is correct
+    ! check that total number of faces found is correct
     if(imsg /= nb_msgs_theor_in_cube) then
       print*,'error ',myrank,'nb_msgs_theor_in_cube:',nb_msgs_theor_in_cube,imsg
       call exit_MPI(myrank,'wrong number of faces found for central cube')
     endif
 
   else if(ichunk == CHUNK_AB_ANTIPODE) then
-
-! initialize index of sender
+    ! initialize index of sender
     imsg = 0
 
-! define sender for xi = xi_min edge
+    ! define sender for xi = xi_min edge
     if(iproc_xi == 0) then
       do iproc_xi_loop = nproc_xi_half_ceil,NPROC_XI-1
         imsg = imsg + 1
@@ -207,7 +205,7 @@
       enddo
     endif
 
-! define sender for xi = xi_max edge
+    ! define sender for xi = xi_max edge
     if(iproc_xi == NPROC_XI-1) then
       do iproc_xi_loop = 0, floor((NPROC_XI/2.d0)-1.d0)
         imsg = imsg + 1
@@ -215,7 +213,7 @@
       enddo
     endif
 
-! define sender for eta = eta_min edge
+    ! define sender for eta = eta_min edge
     if(iproc_eta == 0) then
       do iproc_xi_loop = 0, floor((NPROC_XI/2.d0)-1.d0)
         imsg = imsg + 1
@@ -223,7 +221,7 @@
       enddo
     endif
 
-! define sender for eta = eta_max edge
+    ! define sender for eta = eta_max edge
     if(iproc_eta == NPROC_ETA-1) then
       do iproc_xi_loop = 0, floor((NPROC_XI/2.d0)-1.d0)
         imsg = imsg + 1
@@ -231,7 +229,7 @@
       enddo
     endif
 
-    ! daniel: in case NPROC_XI == 1, the other chunks exchange all bottom points with
+    ! in case NPROC_XI == 1, the other chunks exchange all bottom points with
     ! CHUNK_AB **and** CHUNK_AB_ANTIPODE
     if(NPROC_XI==1) then
       ! define sender for xi = xi_min edge
@@ -259,12 +257,12 @@
       endif
     endif
 
-! define sender for bottom edge
-! bottom of cube, direct correspondence but with inverted xi axis
+    ! define sender for bottom edge
+    ! bottom of cube, direct correspondence but with inverted xi axis
     imsg = imsg + 1
     sender_from_slices_to_cube(imsg) = addressing(CHUNK_AB,NPROC_XI-1-iproc_xi,iproc_eta)
 
-! check that total number of faces found is correct
+    ! check that total number of faces found is correct
     if(imsg /= nb_msgs_theor_in_cube) then
       print*,'error ',myrank,'nb_msgs_theor_in_cube:',nb_msgs_theor_in_cube,imsg
       call exit_MPI(myrank,'wrong number of faces found for central cube')
@@ -272,7 +270,7 @@
 
   else
 
-! dummy value in slices
+    ! dummy value in slices
     sender_from_slices_to_cube(1) = -1
 
   endif
@@ -296,7 +294,6 @@
 
   ! send info to central cube from all the slices except those in CHUNK_AB & CHUNK_AB_ANTIPODE
   if(ichunk /= CHUNK_AB .and. ichunk /= CHUNK_AB_ANTIPODE ) then
-
     ! for bottom elements in contact with central cube from the slices side
     ipoin = 0
     do ispec2D = 1,NSPEC2D_BOTTOM_INNER_CORE
@@ -321,7 +318,7 @@
     call MPI_SEND(buffer_slices,NDIM*npoin2D_cube_from_slices, &
               MPI_DOUBLE_PRECISION,receiver,itag,MPI_COMM_WORLD,ier)
 
-    ! daniel: in case NPROC_XI == 1, the other chunks exchange all bottom points with
+    ! in case NPROC_XI == 1, the other chunks exchange all bottom points with
     ! CHUNK_AB **and** CHUNK_AB_ANTIPODE
     if(NPROC_XI==1) then
       call MPI_SEND(buffer_slices,NDIM*npoin2D_cube_from_slices, &

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/meshfem3D_par.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -486,7 +486,7 @@
   ! MPI crust/mantle mesh
   !--------------------------------------
   integer :: num_interfaces_crust_mantle
-  integer :: max_nibool_interfaces_crust_mantle
+  integer :: max_nibool_interfaces_cm
   integer, dimension(:), allocatable :: my_neighbours_crust_mantle,nibool_interfaces_crust_mantle
   integer, dimension(:,:), allocatable :: ibool_interfaces_crust_mantle
 
@@ -545,7 +545,7 @@
   ! MPI inner core mesh
   !--------------------------------------
   integer :: num_interfaces_inner_core
-  integer :: max_nibool_interfaces_inner_core
+  integer :: max_nibool_interfaces_ic
   integer, dimension(:), allocatable :: my_neighbours_inner_core,nibool_interfaces_inner_core
   integer, dimension(:,:), allocatable :: ibool_interfaces_inner_core
 
@@ -614,7 +614,7 @@
   ! MPI outer core mesh
   !--------------------------------------
   integer :: num_interfaces_outer_core
-  integer :: max_nibool_interfaces_outer_core
+  integer :: max_nibool_interfaces_oc
   integer, dimension(:), allocatable :: my_neighbours_outer_core,nibool_interfaces_outer_core
   integer, dimension(:,:), allocatable :: ibool_interfaces_outer_core
 

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/save_arrays_solver.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -490,7 +490,7 @@
   case( IREGION_CRUST_MANTLE )
     ! crust mantle
     call save_MPI_arrays(myrank,IREGION_CRUST_MANTLE,LOCAL_PATH, &
-                             num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                             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, &
@@ -502,7 +502,7 @@
   case( IREGION_OUTER_CORE )
     ! outer core
     call save_MPI_arrays(myrank,IREGION_OUTER_CORE,LOCAL_PATH, &
-                             num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                             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, &
@@ -513,7 +513,7 @@
   case( IREGION_INNER_CORE )
     ! inner core
     call save_MPI_arrays(myrank,IREGION_INNER_CORE,LOCAL_PATH, &
-                             num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                             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, &

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_MPI_interfaces.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_MPI_interfaces.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_MPI_interfaces.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -187,7 +187,7 @@
   ! determines neighbor rank for shared faces
   call get_MPI_interfaces(myrank,NGLOB_CRUST_MANTLE,NSPEC_CRUST_MANTLE, &
                             test_flag,my_neighbours,nibool_neighbours,ibool_neighbours, &
-                            num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                            num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                             max_nibool,MAX_NEIGHBOURS, &
                             ibool,is_on_a_slice_edge, &
                             IREGION_CRUST_MANTLE,.false.,dummy_i,INCLUDE_CENTRAL_CUBE, &
@@ -206,7 +206,7 @@
 
   ! copies interfaces arrays
   if( num_interfaces_crust_mantle > 0 ) then
-    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
+    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
            stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_crust_mantle')
     ibool_interfaces_crust_mantle = 0
@@ -216,10 +216,10 @@
     ! number of global ibool entries on each interface
     nibool_interfaces_crust_mantle(:) = nibool_neighbours(1:num_interfaces_crust_mantle)
     ! global iglob point ids on each interface
-    ibool_interfaces_crust_mantle(:,:) = ibool_neighbours(1:max_nibool_interfaces_crust_mantle,1:num_interfaces_crust_mantle)
+    ibool_interfaces_crust_mantle(:,:) = ibool_neighbours(1:max_nibool_interfaces_cm,1:num_interfaces_crust_mantle)
   else
     ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_crust_mantle = 0
+    max_nibool_interfaces_cm = 0
     allocate(ibool_interfaces_crust_mantle(0,0),stat=ier)
   endif
 
@@ -238,7 +238,7 @@
 
   ! checks addressing
   call test_MPI_neighbours(IREGION_CRUST_MANTLE, &
-                              num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                              num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                               my_neighbours_crust_mantle,nibool_interfaces_crust_mantle, &
                               ibool_interfaces_crust_mantle)
 
@@ -318,7 +318,7 @@
   ! determines neighbor rank for shared faces
   call get_MPI_interfaces(myrank,NGLOB_OUTER_CORE,NSPEC_OUTER_CORE, &
                             test_flag,my_neighbours,nibool_neighbours,ibool_neighbours, &
-                            num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                            num_interfaces_outer_core,max_nibool_interfaces_oc, &
                             max_nibool,MAX_NEIGHBOURS, &
                             ibool,is_on_a_slice_edge, &
                             IREGION_OUTER_CORE,.false.,dummy_i,INCLUDE_CENTRAL_CUBE, &
@@ -337,7 +337,7 @@
 
   ! copies interfaces arrays
   if( num_interfaces_outer_core > 0 ) then
-    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
+    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
            stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_outer_core')
     ibool_interfaces_outer_core = 0
@@ -347,10 +347,10 @@
     ! number of global ibool entries on each interface
     nibool_interfaces_outer_core(:) = nibool_neighbours(1:num_interfaces_outer_core)
     ! global iglob point ids on each interface
-    ibool_interfaces_outer_core(:,:) = ibool_neighbours(1:max_nibool_interfaces_outer_core,1:num_interfaces_outer_core)
+    ibool_interfaces_outer_core(:,:) = ibool_neighbours(1:max_nibool_interfaces_oc,1:num_interfaces_outer_core)
   else
     ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_outer_core = 0
+    max_nibool_interfaces_oc = 0
     allocate(ibool_interfaces_outer_core(0,0),stat=ier)
   endif
 
@@ -369,7 +369,7 @@
 
   ! checks addressing
   call test_MPI_neighbours(IREGION_OUTER_CORE, &
-                              num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                              num_interfaces_outer_core,max_nibool_interfaces_oc, &
                               my_neighbours_outer_core,nibool_interfaces_outer_core, &
                               ibool_interfaces_outer_core)
 
@@ -498,7 +498,7 @@
   !    ! determines neighbor rank for shared faces
   !    call get_MPI_interfaces(myrank,NGLOB_INNER_CORE,NSPEC_INNER_CORE, &
   !                          test_flag,my_neighbours,nibool_neighbours,ibool_neighbours, &
-  !                          num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+  !                          num_interfaces_inner_core,max_nibool_interfaces_ic, &
   !                          max_nibool,MAX_NEIGHBOURS, &
   !                          ibool,is_on_a_slice_edge, &
   !                          IREGION_INNER_CORE,.false.,idoubling,INCLUDE_CENTRAL_CUBE, &
@@ -511,7 +511,7 @@
   ! determines neighbor rank for shared faces
   call get_MPI_interfaces(myrank,NGLOB_INNER_CORE,NSPEC_INNER_CORE, &
                         test_flag,my_neighbours,nibool_neighbours,ibool_neighbours, &
-                        num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                        num_interfaces_inner_core,max_nibool_interfaces_ic, &
                         max_nibool,MAX_NEIGHBOURS, &
                         ibool,is_on_a_slice_edge, &
                         IREGION_INNER_CORE,.false.,idoubling,INCLUDE_CENTRAL_CUBE, &
@@ -529,7 +529,7 @@
 
   ! copies interfaces arrays
   if( num_interfaces_inner_core > 0 ) then
-    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
+    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_ic,num_interfaces_inner_core), &
            stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_inner_core')
     ibool_interfaces_inner_core = 0
@@ -539,10 +539,10 @@
     ! number of global ibool entries on each interface
     nibool_interfaces_inner_core(:) = nibool_neighbours(1:num_interfaces_inner_core)
     ! global iglob point ids on each interface
-    ibool_interfaces_inner_core(:,:) = ibool_neighbours(1:max_nibool_interfaces_inner_core,1:num_interfaces_inner_core)
+    ibool_interfaces_inner_core(:,:) = ibool_neighbours(1:max_nibool_interfaces_ic,1:num_interfaces_inner_core)
   else
     ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_inner_core = 0
+    max_nibool_interfaces_ic = 0
     allocate(ibool_interfaces_inner_core(0,0),stat=ier)
   endif
 
@@ -561,7 +561,7 @@
 
   ! checks addressing
   call test_MPI_neighbours(IREGION_INNER_CORE, &
-                              num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                              num_interfaces_inner_core,max_nibool_interfaces_ic, &
                               my_neighbours_inner_core,nibool_interfaces_inner_core, &
                               ibool_interfaces_inner_core)
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -1002,7 +1002,7 @@
 !-------------------------------------------------------------------------------------------------
 !
 
-! daniel: deprecated ...
+! deprecated ...
 !
 !  subroutine setup_color_perm(myrank,iregion_code,nspec,nglob, &
 !                              ibool,is_on_a_slice_edge,prname, &

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/test_MPI_interfaces.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/test_MPI_interfaces.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/test_MPI_interfaces.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -52,7 +52,7 @@
   logical :: is_okay
   logical,dimension(:),allocatable :: mask
 
-  ! daniel: debug output
+  ! debug output
   !do iproc=0,NPROCTOT-1
   !  if( myrank == iproc ) then
   !    print*, 'mpi rank',myrank,'interfaces : ',num_interfaces,'region',iregion_code
@@ -304,7 +304,7 @@
   ! adds contributions from different partitions to flag arrays
   call assemble_MPI_vector(NPROCTOT,NGLOB_CRUST_MANTLE, &
                       test_flag_vector, &
-                      num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                      num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                       nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                       my_neighbours_crust_mantle)
 
@@ -415,7 +415,7 @@
   ! adds contributions from different partitions to flag arrays
   call assemble_MPI_scalar(NPROCTOT,NGLOB_OUTER_CORE, &
                                 test_flag, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core,&
                                 my_neighbours_outer_core)
 
@@ -525,7 +525,7 @@
   ! adds contributions from different partitions to flag arrays
   call assemble_MPI_vector(NPROCTOT,NGLOB_INNER_CORE, &
                       test_flag_vector, &
-                      num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                      num_interfaces_inner_core,max_nibool_interfaces_ic, &
                       nibool_interfaces_inner_core,ibool_interfaces_inner_core,&
                       my_neighbours_inner_core)
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/exit_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/exit_mpi.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/exit_mpi.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -438,7 +438,7 @@
 
   implicit none
 
-! standard include of the MPI library
+  ! standard include of the MPI library
   include 'mpif.h'
 
   !integer sendbuf,sendcount,dest,sendtag
@@ -459,7 +459,7 @@
 
   implicit none
 
-! standard include of the MPI library
+  ! standard include of the MPI library
   include 'mpif.h'
 
   !integer sendbuf,sendcount,dest,sendtag
@@ -479,7 +479,7 @@
 
   implicit none
 
-! standard include of the MPI library
+  ! standard include of the MPI library
   include 'mpif.h'
 
   integer size
@@ -497,7 +497,7 @@
 
   implicit none
 
-! standard include of the MPI library
+  ! standard include of the MPI library
   include 'mpif.h'
 
   integer rank
@@ -507,3 +507,80 @@
 
   end subroutine world_rank
 
+!
+!-------------------------------------------------------------------------------------------------
+!
+
+  subroutine gather_all_i(sendbuf, sendcnt, recvbuf, recvcount, NPROC)
+
+  implicit none
+
+  ! standard include of the MPI library
+  include 'mpif.h'
+
+  integer sendcnt, recvcount, NPROC
+  integer, dimension(sendcnt) :: sendbuf
+  integer, dimension(recvcount,0:NPROC-1) :: recvbuf
+
+  integer ier
+
+  call MPI_GATHER(sendbuf,sendcnt,MPI_INTEGER, &
+                  recvbuf,recvcount,MPI_INTEGER, &
+                  0,MPI_COMM_WORLD,ier)
+
+  end subroutine gather_all_i
+
+!
+!-------------------------------------------------------------------------------------------------
+!
+
+  subroutine gatherv_all_i(sendbuf, sendcnt, recvbuf, recvcount, recvoffset,recvcounttot, NPROC)
+
+  implicit none
+
+  ! standard include of the MPI library
+  include 'mpif.h'
+
+  include "constants.h"
+  include "precision.h"
+
+  integer :: sendcnt,recvcounttot,NPROC
+  integer, dimension(NPROC) :: recvcount,recvoffset
+  integer, dimension(sendcnt) :: sendbuf
+  integer, dimension(recvcounttot) :: recvbuf
+
+  integer :: ier
+
+  call MPI_GATHERV(sendbuf,sendcnt,MPI_INTEGER, &
+                  recvbuf,recvcount,recvoffset,MPI_INTEGER, &
+                  0,MPI_COMM_WORLD,ier)
+
+  end subroutine gatherv_all_i
+
+!
+!-------------------------------------------------------------------------------------------------
+!
+
+  subroutine gatherv_all_cr(sendbuf, sendcnt, recvbuf, recvcount, recvoffset,recvcounttot, NPROC)
+
+  implicit none
+
+  ! standard include of the MPI library
+  include 'mpif.h'
+
+  include "constants.h"
+  include "precision.h"
+
+  integer :: sendcnt,recvcounttot,NPROC
+  integer, dimension(NPROC) :: recvcount,recvoffset
+  real(kind=CUSTOM_REAL), dimension(sendcnt) :: sendbuf
+  real(kind=CUSTOM_REAL), dimension(recvcounttot) :: recvbuf
+
+  integer :: ier
+
+  call MPI_GATHERV(sendbuf,sendcnt,CUSTOM_MPI_TYPE, &
+                  recvbuf,recvcount,recvoffset,CUSTOM_MPI_TYPE, &
+                  0,MPI_COMM_WORLD,ier)
+
+  end subroutine gatherv_all_cr
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/memory_eval.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/memory_eval.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/memory_eval.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -271,14 +271,25 @@
   static_memory_size = static_memory_size + &
     3.d0*dble(NDIM)*nglob(IREGION_CRUST_MANTLE)*dble(CUSTOM_REAL)
 
-  ! one_minus_sum_beta_crust_mantle, factor_scale_crust_mantle
-  static_memory_size = static_memory_size +  &
-    2.d0*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
+  ! attenuation arrays
+  if( USE_3D_ATTENUATION_ARRAYS ) then
+    ! one_minus_sum_beta_crust_mantle, factor_scale_crust_mantle
+    static_memory_size = static_memory_size +  &
+      2.d0*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
 
-  ! factor_common_crust_mantle
-  static_memory_size = static_memory_size +  &
-    dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
+    ! factor_common_crust_mantle
+    static_memory_size = static_memory_size +  &
+      dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
+  else
+    ! one_minus_sum_beta_crust_mantle, factor_scale_crust_mantle
+    static_memory_size = static_memory_size +  &
+      2.d0*dble(1)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
 
+    ! factor_common_crust_mantle
+    static_memory_size = static_memory_size +  &
+      dble(N_SLS)*dble(1)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
+  endif
+
   ! R_memory_crust_mantle (R_xx, R_yy, ..)
   static_memory_size = static_memory_size +  &
     5.d0*dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_CRUST_MANTLE_ATTENUAT*dble(CUSTOM_REAL)
@@ -334,14 +345,25 @@
   static_memory_size = static_memory_size + &
     3.d0*dble(NDIM)*nglob(IREGION_INNER_CORE)*dble(CUSTOM_REAL)
 
-  ! one_minus_sum_beta_inner_core, factor_scale_inner_core
-  static_memory_size = static_memory_size +  &
-    2.d0*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
+  ! attenuation arrays
+  if( USE_3D_ATTENUATION_ARRAYS ) then
+    ! one_minus_sum_beta_inner_core, factor_scale_inner_core
+    static_memory_size = static_memory_size +  &
+      2.d0*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
 
-  ! factor_common_inner_core
-  static_memory_size = static_memory_size +  &
-    dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
+    ! factor_common_inner_core
+    static_memory_size = static_memory_size +  &
+      dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
+  else
+    ! one_minus_sum_beta_inner_core, factor_scale_inner_core
+    static_memory_size = static_memory_size +  &
+      2.d0*dble(1)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
 
+    ! factor_common_inner_core
+    static_memory_size = static_memory_size +  &
+      dble(N_SLS)*dble(1)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)
+  endif
+
   ! R_memory_inner_core
   static_memory_size = static_memory_size +  &
     5.d0*dble(N_SLS)*dble(NGLLX)*dble(NGLLY)*dble(NGLLZ)*NSPEC_INNER_CORE_ATTENUATION*dble(CUSTOM_REAL)

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_compute_parameters.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_compute_parameters.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_compute_parameters.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -422,12 +422,12 @@
     stop 'need six chunks to include central cube'
 
   ! check that sphere can be cut into slices without getting negative Jacobian
-  if(NCHUNKS == 6 ) then
-    if(NEX_XI < 48) &
-      stop 'NEX_XI must be greater than 48 to cut the sphere into slices with positive Jacobian'
-    if(NEX_ETA < 48) &
-      stop 'NEX_ETA must be greater than 48 to cut the sphere into slices with positive Jacobian'
-  endif
+!  if(NCHUNKS == 6 ) then
+!    if(NEX_XI < 48) &
+!      stop 'NEX_XI must be greater than 48 to cut the sphere into slices with positive Jacobian'
+!    if(NEX_ETA < 48) &
+!      stop 'NEX_ETA must be greater than 48 to cut the sphere into slices with positive Jacobian'
+!  endif
 
   ! check that topology is correct if more than two chunks
   if(NCHUNKS > 2 .and. NEX_XI /= NEX_ETA) &
@@ -436,11 +436,7 @@
   if(NCHUNKS > 2 .and. NPROC_XI /= NPROC_ETA) &
     stop 'must have NPROC_XI = NPROC_ETA for more than two chunks'
 
-  ! support for only one slice per chunk has been discontinued when there is more than one chunk
-  ! because it induces topological problems, and we are not interested in using small meshes
-!daniel: debug topological problems?
-  !if(NCHUNKS > 1 .and. (NPROC_XI == 1 .or. NPROC_ETA == 1)) stop 'support for only one slice per chunk has been discontinued'
-
+  ! small meshes useful for testing, also for GPU version
   if(NCHUNKS > 1 .and. (NPROC_XI == 1 .or. NPROC_ETA == 1) ) then
     if( NUMFACES_SHARED < 4 ) &
       stop 'NPROC_XI,NPROC_ETA==1: please set in constants.h NUMFACES_SHARED and NUMCORNERS_SHARED equal to 4 and recompile'

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/save_header_file.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/save_header_file.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/save_header_file.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -487,6 +487,8 @@
     ! attenuation mimic:
     ! mimicking effect of attenuation on apparent velocities, not amplitudes. that is,
     ! phase shifts should be correctly accounted for, but amplitudes will differ in adjoint simulations
+
+!daniel: att - debug - check if mimic is still needed
     if( ATTENUATION ) then
       write(IOUT,*) 'logical, parameter :: USE_ATTENUATION_MIMIC = .true.'
     else

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/Makefile.in	2012-12-27 19:08:42 UTC (rev 21199)
@@ -41,16 +41,37 @@
 MPI_INC = @MPI_INC@
 
 @COND_CUDA_TRUE at NVCC = nvcc
- at COND_CUDA_FALSE@NVCC = g++
+ at COND_CUDA_FALSE@NVCC = @CC@
 
 # GPU architecture
+
+# CUDA architecture / code version
 # Fermi: -gencode=arch=compute_10,code=sm_10 not supported
 # Tesla (default): -gencode=arch=compute_20,code=sm_20
-# Kepler: -gencode=arch=compute_30,code=sm_30
- at COND_CUDA_TRUE@NVCC_FLAGS = $(CUDA_INC) $(MPI_INC) -DWITH_MPI -DCUDA -gencode=arch=compute_20,code=sm_20
- at COND_CUDA_FALSE@NVCC_FLAGS = $(MPI_INC) -DWITH_MPI
+# Geforce GT 650m: -gencode=arch=compute_30,code=sm_30
+# Kepler (cuda5) : -gencode=arch=compute_35,code=sm_35
+GENCODE_20 = -gencode=arch=compute_20,code=\"sm_20,compute_20\"
+GENCODE_30 = -gencode=arch=compute_30,code=\"sm_30,compute_30\"
+GENCODE_35 = -gencode=arch=compute_35,code=\"sm_35,compute_35\"
 
+# CUDA version 5.x
+ at COND_CUDA_TRUE@@COND_CUDA5_TRUE at GENCODE = $(GENCODE_35)
+# CUDA version 4.x
+ at COND_CUDA_TRUE@@COND_CUDA5_FALSE at GENCODE = $(GENCODE_20)
 
+# CUDA flags and linking
+ at COND_CUDA_TRUE@NVCC_FLAGS_BASE = $(CUDA_INC) $(MPI_INC)
+ at COND_CUDA_TRUE@@COND_CUDA5_TRUE at NVCC_FLAGS = $(NVCC_FLAGS_BASE) -dc -DCUDA $(GENCODE)
+ at COND_CUDA_TRUE@@COND_CUDA5_FALSE at NVCC_FLAGS = $(NVCC_FLAGS_BASE) -DCUDA -DUSE_OLDER_CUDA4_GPU $(GENCODE)
+
+ at COND_CUDA_TRUE@@COND_CUDA5_TRUE at NVCCLINK_BASE = $(NVCC) $(CUDA_INC) $(MPI_INC) -DCUDA
+ at COND_CUDA_TRUE@@COND_CUDA5_TRUE at NVCCLINK = $(NVCCLINK_BASE) -dlink $(GENCODE)
+ at COND_CUDA_TRUE@@COND_CUDA5_FALSE at NVCCLINK = $(NVCCLINK_BASE) -DUSE_OLDER_CUDA4_GPU $(GENCODE)
+
+ at COND_CUDA_FALSE@NVCC_FLAGS = $(MPI_INC)
+ at COND_CUDA_FALSE@NVCCLINK = $(NVCC) $(NVCC_FLAGS)
+
+
 FC = @FC@
 FCFLAGS = #@FCFLAGS@
 MPIFC = @MPIFC@
@@ -64,6 +85,8 @@
 MPIFCCOMPILE_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(FLAGS_CHECK)
 MPIFCCOMPILE_NO_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(FLAGS_NO_CHECK)
 
+FCLINK = $(MPIFCCOMPILE_NO_CHECK)
+
 CC = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = -I../../setup @CPPFLAGS@
@@ -212,11 +235,33 @@
 CUDA_STUBS = \
 	$O/specfem3D_gpu_cuda_method_stubs.cudacc.o
 
+CUDA_DEVICE_OBJ = \
+        $O/cuda_device_obj.o \
+        $(EMPTY_MACRO)
 
-
 LIBSPECFEM_SOLVER = $O/libspecfem_solver.a
 
+# solver also depends on values from mesher
+ at COND_CUDA_TRUE@XSPECFEM_OBJECTS_PRE = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_OBJECTS)
+ at COND_CUDA_FALSE@XSPECFEM_OBJECTS_PRE = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_STUBS)
 
+
+# vtk visualization
+VTK_OBJECTS = \
+	$O/visual_vtk.visualcc.o
+
+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@CPPFLAGS = -I../../setup @CPPFLAGS@ -DWITH_VTK
+ at COND_VTK_TRUE@FCCOMPILE_CHECK =@FCENV@ ${FC} ${FCFLAGS} $(FLAGS_CHECK) -DWITH_VTK
+ at COND_VTK_TRUE@FCCOMPILE_NO_CHECK =@FCENV@ ${FC} ${FCFLAGS} $(FLAGS_NO_CHECK) -DWITH_VTK
+ at COND_VTK_TRUE@MPIFCCOMPILE_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(FLAGS_CHECK) -DWITH_VTK
+ at COND_VTK_TRUE@MPIFCCOMPILE_NO_CHECK =@FCENV@ ${MPIFC} ${FCFLAGS} $(FLAGS_NO_CHECK) -DWITH_VTK
+
 #######################################
 
 ####
@@ -244,14 +289,11 @@
 #### rules for executables
 ####
 
-# solver also depends on values from mesher
- at COND_CUDA_TRUE@XSPECFEM_OBJECTS = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_OBJECTS)
- at COND_CUDA_FALSE@XSPECFEM_OBJECTS = $(SOLVER_ARRAY_OBJECTS) $O/exit_mpi.sharedmpi.o $(LIBSPECFEM_SOLVER) $(CUDA_STUBS)
-
-
 xspecfem3D: $(XSPECFEM_OBJECTS)
-## use MPI here
-	${MPIFCCOMPILE_NO_CHECK} -o ${E}/xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS) $(CUDA_LINK)
+ at 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)
 
 reqheader:
 	(cd ../create_header_file; make)
@@ -279,7 +321,6 @@
 #### rule for each .o file below
 ####
 
-
 ##
 ## shared
 ##
@@ -345,6 +386,20 @@
 #######################################
 
 ###
+### VTK compilation
+###
+
+$O/%.visualcc.o: %.cpp ${SETUP}/config.h
+	${CC} -c $(CPPFLAGS) $(MPI_INC) -o $@ $<
+
+$O/%.visualc.o: %.c ${SETUP}/config.h
+	${CC} -c $(CPPFLAGS) $(MPI_INC) -o $@ $<
+
+
+
+#######################################
+
+###
 ### rule for the header file
 ###
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_coupling.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_coupling.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_coupling.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -450,8 +450,6 @@
   include "constants.h"
   include "OUTPUT_FILES/values_from_mesher.h"
 
-  integer :: NGLOB_XY
-
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_CRUST_MANTLE) :: &
     accel_crust_mantle
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_CRUST_MANTLE_ADJOINT) :: &
@@ -465,6 +463,7 @@
   !
   ! 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
+  integer :: NGLOB_XY
   real(kind=CUSTOM_REAL), dimension(NGLOB_XY) :: rmassx_crust_mantle
   real(kind=CUSTOM_REAL), dimension(NGLOB_XY) :: rmassy_crust_mantle
   real(kind=CUSTOM_REAL), dimension(NGLOB_CRUST_MANTLE) :: rmassz_crust_mantle

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_element.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_element.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_element.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -49,7 +49,7 @@
                     tempx1_att,tempx2_att,tempx3_att, &
                     tempy1_att,tempy2_att,tempy3_att, &
                     tempz1_att,tempz2_att,tempz3_att, &
-                    epsilondev_loc,rho_s_H)
+                    epsilondev_loc,rho_s_H,is_backward_field)
 
 ! this routine is optimized for NGLLX = NGLLY = NGLLZ = 5 using the Deville et al. (2002) inlined matrix-matrix products
 
@@ -107,6 +107,8 @@
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLLX,NGLLY,NGLLZ) :: rho_s_H
   real(kind=CUSTOM_REAL), dimension(5,NGLLX,NGLLY,NGLLZ) :: epsilondev_loc
 
+  logical :: is_backward_field
+
 ! local parameters
   real(kind=CUSTOM_REAL) one_minus_sum_beta_use
   real(kind=CUSTOM_REAL) xixl,xiyl,xizl,etaxl,etayl,etazl,gammaxl,gammayl,gammazl,jacobianl
@@ -155,9 +157,9 @@
         gammazl = gammaz(i,j,k,ispec)
 
         ! compute the jacobian
-        jacobianl = 1._CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
-                      - xiyl*(etaxl*gammazl-etazl*gammaxl) &
-                      + xizl*(etaxl*gammayl-etayl*gammaxl))
+        jacobianl = 1.0_CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
+                                     - xiyl*(etaxl*gammazl-etazl*gammaxl) &
+                                     + xizl*(etaxl*gammayl-etayl*gammaxl))
 
         duxdxl = xixl*tempx1(i,j,k) + etaxl*tempx2(i,j,k) + gammaxl*tempx3(i,j,k)
         duxdyl = xiyl*tempx1(i,j,k) + etayl*tempx2(i,j,k) + gammayl*tempx3(i,j,k)
@@ -208,9 +210,9 @@
            epsilon_trace_over_3(i,j,k,ispec_strain) = templ
            epsilondev_loc(1,i,j,k) = duxdxl_att - templ
            epsilondev_loc(2,i,j,k) = duydyl_att - templ
-           epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl_att
-           epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl_att
-           epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl_att
+           epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl_att
+           epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl_att
+           epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl_att
         else
            ! compute deviatoric strain
            if (COMPUTE_AND_STORE_STRAIN) then
@@ -226,21 +228,12 @@
               endif
               epsilondev_loc(1,i,j,k) = duxdxl - templ
               epsilondev_loc(2,i,j,k) = duydyl - templ
-              epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl
-              epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl
-              epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl
+              epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl
+              epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl
+              epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl
            endif
         endif
 
-       ! precompute terms for attenuation if needed
-        if( ATTENUATION_VAL ) then
-          if( USE_3D_ATTENUATION_ARRAYS ) then
-            one_minus_sum_beta_use = one_minus_sum_beta(i,j,k,ispec)
-          else
-            one_minus_sum_beta_use = one_minus_sum_beta(1,1,1,ispec)
-          endif
-        endif
-
         !
         ! compute  isotropic  elements
         !
@@ -250,10 +243,18 @@
         mul = muvstore(i,j,k,ispec)
 
         ! use unrelaxed parameters if attenuation
-        if(ATTENUATION_VAL) mul = mul * one_minus_sum_beta_use
+        if(ATTENUATION_VAL) then
+          ! precompute terms for attenuation if needed
+          if( USE_3D_ATTENUATION_ARRAYS ) then
+            one_minus_sum_beta_use = one_minus_sum_beta(i,j,k,ispec)
+          else
+            one_minus_sum_beta_use = one_minus_sum_beta(1,1,1,ispec)
+          endif
+          mul = mul * one_minus_sum_beta_use
+        endif
 
         lambdalplus2mul = kappal + FOUR_THIRDS * mul
-        lambdal = lambdalplus2mul - 2.0*mul
+        lambdal = lambdalplus2mul - 2.0_CUSTOM_REAL*mul
 
         ! compute stress sigma
         sigma_xx = lambdalplus2mul*duxdxl + lambdal*duydyl_plus_duzdzl
@@ -267,13 +268,25 @@
         ! subtract memory variables if attenuation
         if(ATTENUATION_VAL .and. ( USE_ATTENUATION_MIMIC .eqv. .false. )  ) then
 
+!daniel: att - debug update
+!          call compute_element_att_mem_up_cm(ispec,i,j,k, &
+!                                          R_xx(1,i,j,k,ispec), &
+!                                          R_yy(1,i,j,k,ispec), &
+!                                          R_xy(1,i,j,k,ispec), &
+!                                          R_xz(1,i,j,k,ispec), &
+!                                          R_yz(1,i,j,k,ispec), &
+!                                          epsilondev_loc(:,i,j,k),muvstore(i,j,k,ispec),is_backward_field)
+! dummy to avoid compiler warning
+          if( is_backward_field ) then
+          endif
+
           ! note: fortran passes pointers to array location, thus R_memory(1,1,...) should be fine
           call compute_element_att_stress(R_xx(1,i,j,k,ispec), &
-                                         R_yy(1,i,j,k,ispec), &
-                                         R_xy(1,i,j,k,ispec), &
-                                         R_xz(1,i,j,k,ispec), &
-                                         R_yz(1,i,j,k,ispec), &
-                                         sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
+                                          R_yy(1,i,j,k,ispec), &
+                                          R_xy(1,i,j,k,ispec), &
+                                          R_xz(1,i,j,k,ispec), &
+                                          R_yz(1,i,j,k,ispec), &
+                                          sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
 
         endif ! ATTENUATION_VAL
 
@@ -431,13 +444,12 @@
                     tempx1_att,tempx2_att,tempx3_att, &
                     tempy1_att,tempy2_att,tempy3_att, &
                     tempz1_att,tempz2_att,tempz3_att, &
-                    epsilondev_loc,rho_s_H)
+                    epsilondev_loc,rho_s_H,is_backward_field)
 
 ! this routine is optimized for NGLLX = NGLLY = NGLLZ = 5 using the Deville et al. (2002) inlined matrix-matrix products
 
   implicit none
 
-
   include "constants.h"
 
   ! include values created by the mesher
@@ -494,6 +506,7 @@
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLLX,NGLLY,NGLLZ) :: rho_s_H
   real(kind=CUSTOM_REAL), dimension(5,NGLLX,NGLLY,NGLLZ) :: epsilondev_loc
 
+  logical :: is_backward_field
 
 ! local parameters
   real(kind=CUSTOM_REAL) one_minus_sum_beta_use
@@ -556,7 +569,7 @@
         gammazl = gammaz(i,j,k,ispec)
 
         ! compute the jacobian
-        jacobianl = 1._CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
+        jacobianl = 1.0_CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
                       - xiyl*(etaxl*gammazl-etazl*gammaxl) &
                       + xizl*(etaxl*gammayl-etayl*gammaxl))
 
@@ -609,9 +622,9 @@
            epsilon_trace_over_3(i,j,k,ispec_strain) = templ
            epsilondev_loc(1,i,j,k) = duxdxl_att - templ
            epsilondev_loc(2,i,j,k) = duydyl_att - templ
-           epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl_att
-           epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl_att
-           epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl_att
+           epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl_att
+           epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl_att
+           epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl_att
         else
            ! compute deviatoric strain
            if (COMPUTE_AND_STORE_STRAIN) then
@@ -627,22 +640,12 @@
               endif
               epsilondev_loc(1,i,j,k) = duxdxl - templ
               epsilondev_loc(2,i,j,k) = duydyl - templ
-              epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl
-              epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl
-              epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl
+              epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl
+              epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl
+              epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl
            endif
         endif
 
-        ! precompute terms for attenuation if needed
-        if( ATTENUATION_VAL ) then
-          if( USE_3D_ATTENUATION_ARRAYS ) then
-            one_minus_sum_beta_use = one_minus_sum_beta(i,j,k,ispec)
-          else
-            one_minus_sum_beta_use = one_minus_sum_beta(1,1,1,ispec)
-          endif
-        endif
-
-
         !
         ! compute either isotropic or anisotropic elements
         !
@@ -667,6 +670,12 @@
         ! use unrelaxed parameters if attenuation
         ! eta does not need to be shifted since it is a ratio
         if(ATTENUATION_VAL) then
+          ! precompute terms for attenuation if needed
+          if( USE_3D_ATTENUATION_ARRAYS ) then
+            one_minus_sum_beta_use = one_minus_sum_beta(i,j,k,ispec)
+          else
+            one_minus_sum_beta_use = one_minus_sum_beta(1,1,1,ispec)
+          endif
           muvl = muvl * one_minus_sum_beta_use
           muhl = muhl * one_minus_sum_beta_use
         endif
@@ -703,31 +712,31 @@
         cosphifour = cosphisq * cosphisq
         sinphifour = sinphisq * sinphisq
 
-        costwotheta = cos(2.0*theta)
-        sintwotheta = sin(2.0*theta)
-        costwophi = cos(2.0*phi)
-        sintwophi = sin(2.0*phi)
+        costwotheta = cos(2.0_CUSTOM_REAL*theta)
+        sintwotheta = sin(2.0_CUSTOM_REAL*theta)
+        costwophi = cos(2.0_CUSTOM_REAL*phi)
+        sintwophi = sin(2.0_CUSTOM_REAL*phi)
 
-        cosfourtheta = cos(4.0*theta)
-        cosfourphi = cos(4.0*phi)
+        cosfourtheta = cos(4.0_CUSTOM_REAL*theta)
+        cosfourphi = cos(4.0_CUSTOM_REAL*phi)
 
         costwothetasq = costwotheta * costwotheta
 
         costwophisq = costwophi * costwophi
         sintwophisq = sintwophi * sintwophi
 
-        etaminone = eta_aniso - 1.0
-        twoetaminone = 2.0 * eta_aniso - 1.0
+        etaminone = eta_aniso - 1.0_CUSTOM_REAL
+        twoetaminone = 2.0_CUSTOM_REAL * eta_aniso - 1.0_CUSTOM_REAL
 
         ! precompute some products to reduce the CPU time
-        two_eta_aniso = 2.0*eta_aniso
-        four_eta_aniso = 4.0*eta_aniso
-        six_eta_aniso = 6.0*eta_aniso
+        two_eta_aniso = 2.0_CUSTOM_REAL*eta_aniso
+        four_eta_aniso = 4.0_CUSTOM_REAL*eta_aniso
+        six_eta_aniso = 6.0_CUSTOM_REAL*eta_aniso
 
-        two_rhovsvsq = 2.0*rhovsvsq
-        two_rhovshsq = 2.0*rhovshsq
-        four_rhovsvsq = 4.0*rhovsvsq
-        four_rhovshsq = 4.0*rhovshsq
+        two_rhovsvsq = 2.0_CUSTOM_REAL*rhovsvsq
+        two_rhovshsq = 2.0_CUSTOM_REAL*rhovshsq
+        four_rhovsvsq = 4.0_CUSTOM_REAL*rhovsvsq
+        four_rhovshsq = 4.0_CUSTOM_REAL*rhovshsq
 
 
         ! way 2: pre-compute temporary values
@@ -741,87 +750,87 @@
 
         ! way 2: reordering operations to facilitate compilation, avoiding divisions, using locality for temporary values
         c11 = rhovphsq*sinphifour &
-              + 2.0*cosphisq*sinphisq* &
+              + 2.0_CUSTOM_REAL*cosphisq*sinphisq* &
               ( rhovphsq*costhetasq + sinthetasq*(eta_aniso*rhovphsq + two_rhovsvsq - two_eta_aniso*rhovsvsq) ) &
               + cosphifour*(rhovphsq*costhetafour &
-                + 2.0*costhetasq*sinthetasq*(eta_aniso*rhovphsq + two_rhovsvsq - two_eta_aniso*rhovsvsq) &
+                + 2.0_CUSTOM_REAL*costhetasq*sinthetasq*(eta_aniso*rhovphsq + two_rhovsvsq - two_eta_aniso*rhovsvsq) &
                 + rhovpvsq*sinthetafour)
 
-        c12 = 0.25*costhetasq*(rhovphsq - two_rhovshsq)*(3.0 + cosfourphi) &
+        c12 = 0.25_CUSTOM_REAL*costhetasq*(rhovphsq - two_rhovshsq)*(3.0_CUSTOM_REAL + cosfourphi) &
               - four_rhovshsq*cosphisq*costhetasq*sinphisq &
-              + 0.03125*rhovphsq*sintwophisq*(11.0 + cosfourtheta + 4.0*costwotheta) &
+              + 0.03125_CUSTOM_REAL*rhovphsq*sintwophisq*(11.0_CUSTOM_REAL + cosfourtheta + 4.0*costwotheta) &
               + eta_aniso*sinthetasq*(rhovphsq - two_rhovsvsq) &
-                         *(cosphifour + sinphifour + 2.0*cosphisq*costhetasq*sinphisq) &
+                         *(cosphifour + sinphifour + 2.0_CUSTOM_REAL*cosphisq*costhetasq*sinphisq) &
               + rhovpvsq*cosphisq*sinphisq*sinthetafour &
               - rhovsvsq*sintwophisq*sinthetafour
 
-        c13 = 0.125*cosphisq*(rhovphsq + six_eta_aniso*rhovphsq + rhovpvsq - four_rhovsvsq &
-                    - 12.0*eta_aniso*rhovsvsq + cosfourtheta*templ1) &
+        c13 = 0.125_CUSTOM_REAL*cosphisq*(rhovphsq + six_eta_aniso*rhovphsq + rhovpvsq - four_rhovsvsq &
+                    - 12.0_CUSTOM_REAL*eta_aniso*rhovsvsq + cosfourtheta*templ1) &
               + sinphisq*(eta_aniso*costhetasq*(rhovphsq - two_rhovsvsq) + sinthetasq*(rhovphsq - two_rhovshsq))
 
         ! uses temporary templ1 from c13
         c15 = cosphi*costheta*sintheta* &
-              ( 0.5*cosphisq* (rhovpvsq - rhovphsq + costwotheta*templ1) &
+              ( 0.5_CUSTOM_REAL*cosphisq* (rhovpvsq - rhovphsq + costwotheta*templ1) &
                 + etaminone*sinphisq*(rhovphsq - two_rhovsvsq))
 
         c14 = costheta*sinphi*sintheta* &
-              ( 0.5*cosphisq*(templ2_cos + four_rhovshsq - four_rhovsvsq) &
-                + sinphisq*(etaminone*rhovphsq + 2.0*(rhovshsq - eta_aniso*rhovsvsq)) )
+              ( 0.5_CUSTOM_REAL*cosphisq*(templ2_cos + four_rhovshsq - four_rhovsvsq) &
+                + sinphisq*(etaminone*rhovphsq + 2.0_CUSTOM_REAL*(rhovshsq - eta_aniso*rhovsvsq)) )
 
         ! uses temporary templ2_cos from c14
-        c16 = 0.5*cosphi*sinphi*sinthetasq* &
+        c16 = 0.5_CUSTOM_REAL*cosphi*sinphi*sinthetasq* &
               ( cosphisq*templ2_cos &
-                + 2.0*etaminone*sinphisq*(rhovphsq - two_rhovsvsq) )
+                + 2.0_CUSTOM_REAL*etaminone*sinphisq*(rhovphsq - two_rhovsvsq) )
 
-        c22 = rhovphsq*cosphifour + 2.0*cosphisq*sinphisq* &
+        c22 = rhovphsq*cosphifour + 2.0_CUSTOM_REAL*cosphisq*sinphisq* &
               (rhovphsq*costhetasq + sinthetasq*(eta_aniso*rhovphsq + two_rhovsvsq - two_eta_aniso*rhovsvsq)) &
               + sinphifour* &
-              (rhovphsq*costhetafour + 2.0*costhetasq*sinthetasq*(eta_aniso*rhovphsq  &
+              (rhovphsq*costhetafour + 2.0_CUSTOM_REAL*costhetasq*sinthetasq*(eta_aniso*rhovphsq  &
                     + two_rhovsvsq - two_eta_aniso*rhovsvsq) + rhovpvsq*sinthetafour)
 
         ! uses temporary templ1 from c13
-        c23 = 0.125*sinphisq*(rhovphsq + six_eta_aniso*rhovphsq &
-                + rhovpvsq - four_rhovsvsq - 12.0*eta_aniso*rhovsvsq + cosfourtheta*templ1) &
+        c23 = 0.125_CUSTOM_REAL*sinphisq*(rhovphsq + six_eta_aniso*rhovphsq &
+                + rhovpvsq - four_rhovsvsq - 12.0_CUSTOM_REAL*eta_aniso*rhovsvsq + cosfourtheta*templ1) &
               + cosphisq*(eta_aniso*costhetasq*(rhovphsq - two_rhovsvsq) + sinthetasq*(rhovphsq - two_rhovshsq))
 
         ! uses temporary templ1 from c13
         c24 = costheta*sinphi*sintheta* &
               ( etaminone*cosphisq*(rhovphsq - two_rhovsvsq) &
-                + 0.5*sinphisq*(rhovpvsq - rhovphsq + costwotheta*templ1) )
+                + 0.5_CUSTOM_REAL*sinphisq*(rhovpvsq - rhovphsq + costwotheta*templ1) )
 
         ! uses temporary templ2_cos from c14
         c25 = cosphi*costheta*sintheta* &
-              ( cosphisq*(etaminone*rhovphsq + 2.0*(rhovshsq - eta_aniso*rhovsvsq)) &
-                + 0.5*sinphisq*(templ2_cos + four_rhovshsq - four_rhovsvsq) )
+              ( cosphisq*(etaminone*rhovphsq + 2.0_CUSTOM_REAL*(rhovshsq - eta_aniso*rhovsvsq)) &
+                + 0.5_CUSTOM_REAL*sinphisq*(templ2_cos + four_rhovshsq - four_rhovsvsq) )
 
         ! uses temporary templ2_cos from c14
-        c26 = 0.5*cosphi*sinphi*sinthetasq* &
-              ( 2.0*etaminone*cosphisq*(rhovphsq - two_rhovsvsq) &
+        c26 = 0.5_CUSTOM_REAL*cosphi*sinphi*sinthetasq* &
+              ( 2.0_CUSTOM_REAL*etaminone*cosphisq*(rhovphsq - two_rhovsvsq) &
                 + sinphisq*templ2_cos )
 
         c33 = rhovpvsq*costhetafour &
-              + 2.0*costhetasq*sinthetasq*(two_rhovsvsq + eta_aniso*(rhovphsq - two_rhovsvsq)) &
+              + 2.0_CUSTOM_REAL*costhetasq*sinthetasq*(two_rhovsvsq + eta_aniso*(rhovphsq - two_rhovsvsq)) &
               + rhovphsq*sinthetafour
 
         ! uses temporary templ1_cos from c13
-        c34 = - 0.25*sinphi*sintwotheta*templ1_cos
+        c34 = - 0.25_CUSTOM_REAL*sinphi*sintwotheta*templ1_cos
 
         ! uses temporary templ1_cos from c34
-        c35 = - 0.25*cosphi*sintwotheta*templ1_cos
+        c35 = - 0.25_CUSTOM_REAL*cosphi*sintwotheta*templ1_cos
 
         ! uses temporary templ1_cos from c34
-        c36 = - 0.25*sintwophi*sinthetasq*(templ1_cos - four_rhovshsq + four_rhovsvsq)
+        c36 = - 0.25_CUSTOM_REAL*sintwophi*sinthetasq*(templ1_cos - four_rhovshsq + four_rhovsvsq)
 
         c44 = cosphisq*(rhovsvsq*costhetasq + rhovshsq*sinthetasq) &
               + sinphisq*(rhovsvsq*costwothetasq + costhetasq*sinthetasq*templ3)
 
         ! uses temporary templ3 from c44
         c46 = - cosphi*costheta*sintheta* &
-                ( cosphisq*(rhovshsq - rhovsvsq) - 0.5*sinphisq*templ3_cos  )
+                ( cosphisq*(rhovshsq - rhovsvsq) - 0.5_CUSTOM_REAL*sinphisq*templ3_cos  )
 
         ! uses templ3 from c46
-        c45 = 0.25*sintwophi*sinthetasq* &
-              (templ3_two + costwotheta*(rhovphsq + rhovpvsq - two_eta_aniso*rhovphsq + 4.0*etaminone*rhovsvsq))
+        c45 = 0.25_CUSTOM_REAL*sintwophi*sinthetasq* &
+              (templ3_two + costwotheta*(rhovphsq + rhovpvsq - two_eta_aniso*rhovphsq + 4.0_CUSTOM_REAL*etaminone*rhovsvsq))
 
         c55 = sinphisq*(rhovsvsq*costhetasq + rhovshsq*sinthetasq) &
               + cosphisq*(rhovsvsq*costwothetasq &
@@ -829,15 +838,17 @@
 
         ! uses temporary templ3_cos from c46
         c56 = costheta*sinphi*sintheta* &
-              ( 0.5*cosphisq*templ3_cos + sinphisq*(rhovsvsq - rhovshsq) )
+              ( 0.5_CUSTOM_REAL*cosphisq*templ3_cos + sinphisq*(rhovsvsq - rhovshsq) )
 
         c66 = rhovshsq*costwophisq*costhetasq &
-              - 2.0*cosphisq*costhetasq*sinphisq*(rhovphsq - two_rhovshsq) &
-              + 0.03125*rhovphsq*sintwophisq*(11.0 + 4.0*costwotheta + cosfourtheta) &
-              - 0.125*rhovsvsq*sinthetasq*( -6.0 - 2.0*costwotheta - 2.0*cosfourphi &
-                        + cos(4.0*phi - 2.0*theta) + cos(2.0*(2.0*phi + theta)) ) &
+              - 2.0_CUSTOM_REAL*cosphisq*costhetasq*sinphisq*(rhovphsq - two_rhovshsq) &
+              + 0.03125_CUSTOM_REAL*rhovphsq*sintwophisq*(11.0_CUSTOM_REAL + 4.0_CUSTOM_REAL*costwotheta + cosfourtheta) &
+              - 0.125_CUSTOM_REAL*rhovsvsq*sinthetasq* &
+              ( -6.0_CUSTOM_REAL - 2.0_CUSTOM_REAL*costwotheta - 2.0_CUSTOM_REAL*cosfourphi &
+                        + cos(4.0_CUSTOM_REAL*phi - 2.0_CUSTOM_REAL*theta) &
+                        + cos(2.0_CUSTOM_REAL*(2.0_CUSTOM_REAL*phi + theta)) ) &
               + rhovpvsq*cosphisq*sinphisq*sinthetafour &
-              - 0.5*eta_aniso*sintwophisq*sinthetafour*(rhovphsq - two_rhovsvsq)
+              - 0.5_CUSTOM_REAL*eta_aniso*sintwophisq*sinthetafour*(rhovphsq - two_rhovsvsq)
 
 
         ! general expression of stress tensor for full Cijkl with 21 coefficients
@@ -862,13 +873,25 @@
         ! subtract memory variables if attenuation
         if(ATTENUATION_VAL .and. ( USE_ATTENUATION_MIMIC .eqv. .false. )  ) then
 
+!daniel: att - debug update
+!          call compute_element_att_mem_up_cm(ispec,i,j,k, &
+!                                          R_xx(:,i,j,k,ispec), &
+!                                          R_yy(:,i,j,k,ispec), &
+!                                          R_xy(:,i,j,k,ispec), &
+!                                          R_xz(:,i,j,k,ispec), &
+!                                          R_yz(:,i,j,k,ispec), &
+!                                          epsilondev_loc(:,i,j,k),muvstore(i,j,k,ispec),is_backward_field)
+! dummy to avoid compiler warning
+          if( is_backward_field ) then
+          endif
+
           ! note: fortran passes pointers to array location, thus R_memory(1,1,...) should be fine
           call compute_element_att_stress(R_xx(1,i,j,k,ispec), &
-                                         R_yy(1,i,j,k,ispec), &
-                                         R_xy(1,i,j,k,ispec), &
-                                         R_xz(1,i,j,k,ispec), &
-                                         R_yz(1,i,j,k,ispec), &
-                                         sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
+                                          R_yy(1,i,j,k,ispec), &
+                                          R_xy(1,i,j,k,ispec), &
+                                          R_xz(1,i,j,k,ispec), &
+                                          R_yz(1,i,j,k,ispec), &
+                                          sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
 
         endif ! ATTENUATION_VAL
 
@@ -1025,7 +1048,7 @@
                     tempx1_att,tempx2_att,tempx3_att, &
                     tempy1_att,tempy2_att,tempy3_att, &
                     tempz1_att,tempz2_att,tempz3_att, &
-                    epsilondev_loc,rho_s_H)
+                    epsilondev_loc,rho_s_H,is_backward_field)
 
 
 ! this routine is optimized for NGLLX = NGLLY = NGLLZ = 5 using the Deville et al. (2002) inlined matrix-matrix products
@@ -1087,8 +1110,10 @@
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLLX,NGLLY,NGLLZ) :: rho_s_H
   real(kind=CUSTOM_REAL), dimension(5,NGLLX,NGLLY,NGLLZ) :: epsilondev_loc
 
+  logical :: is_backward_field
+
 ! local parameters
-  real(kind=CUSTOM_REAL) one_minus_sum_beta_use
+  !real(kind=CUSTOM_REAL) one_minus_sum_beta_use
   real(kind=CUSTOM_REAL) minus_sum_beta,mul
   ! the 21 coefficients for an anisotropic medium in reduced notation
   real(kind=CUSTOM_REAL) c11,c22,c33,c44,c55,c66,c12,c13,c23,c14,c24,c34,c15,c25,c35,c45,c16,c26,c36,c46,c56
@@ -1137,7 +1162,7 @@
         gammazl = gammaz(i,j,k,ispec)
 
         ! compute the jacobian
-        jacobianl = 1._CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
+        jacobianl = 1.0_CUSTOM_REAL / (xixl*(etayl*gammazl-etazl*gammayl) &
                       - xiyl*(etaxl*gammazl-etazl*gammaxl) &
                       + xizl*(etaxl*gammayl-etayl*gammaxl))
 
@@ -1190,9 +1215,9 @@
            epsilon_trace_over_3(i,j,k,ispec_strain) = templ
            epsilondev_loc(1,i,j,k) = duxdxl_att - templ
            epsilondev_loc(2,i,j,k) = duydyl_att - templ
-           epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl_att
-           epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl_att
-           epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl_att
+           epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl_att
+           epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl_att
+           epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl_att
         else
            ! compute deviatoric strain
            if (COMPUTE_AND_STORE_STRAIN) then
@@ -1208,23 +1233,12 @@
               endif
               epsilondev_loc(1,i,j,k) = duxdxl - templ
               epsilondev_loc(2,i,j,k) = duydyl - templ
-              epsilondev_loc(3,i,j,k) = 0.5 * duxdyl_plus_duydxl
-              epsilondev_loc(4,i,j,k) = 0.5 * duzdxl_plus_duxdzl
-              epsilondev_loc(5,i,j,k) = 0.5 * duzdyl_plus_duydzl
+              epsilondev_loc(3,i,j,k) = 0.5_CUSTOM_REAL * duxdyl_plus_duydxl
+              epsilondev_loc(4,i,j,k) = 0.5_CUSTOM_REAL * duzdxl_plus_duxdzl
+              epsilondev_loc(5,i,j,k) = 0.5_CUSTOM_REAL * duzdyl_plus_duydzl
            endif
         endif
 
-        ! precompute terms for attenuation if needed
-        if( ATTENUATION_VAL ) then
-          if( USE_3D_ATTENUATION_ARRAYS ) then
-            one_minus_sum_beta_use = one_minus_sum_beta(i,j,k,ispec)
-            minus_sum_beta =  one_minus_sum_beta_use - 1.0_CUSTOM_REAL
-          else
-            one_minus_sum_beta_use = one_minus_sum_beta(1,1,1,ispec)
-            minus_sum_beta =  one_minus_sum_beta_use - 1.0_CUSTOM_REAL
-          endif
-        endif
-
         !
         ! compute anisotropic elements
         !
@@ -1252,6 +1266,12 @@
         c66 = c66store(i,j,k,ispec)
 
         if(ATTENUATION_VAL) then
+          ! precompute terms for attenuation if needed
+          if( USE_3D_ATTENUATION_ARRAYS ) then
+            minus_sum_beta =  one_minus_sum_beta(i,j,k,ispec) - 1.0_CUSTOM_REAL
+          else
+            minus_sum_beta =  one_minus_sum_beta(1,1,1,ispec) - 1.0_CUSTOM_REAL
+          endif
           !mul = c44
           mul = c44 * minus_sum_beta
           c11 = c11 + FOUR_THIRDS * mul ! * minus_sum_beta * mul
@@ -1286,13 +1306,26 @@
         ! subtract memory variables if attenuation
         if(ATTENUATION_VAL .and. ( USE_ATTENUATION_MIMIC .eqv. .false. )  ) then
 
+!daniel: att - debug update
+!          call compute_element_att_mem_up_cm(ispec,i,j,k, &
+!                                          R_xx(:,i,j,k,ispec), &
+!                                          R_yy(:,i,j,k,ispec), &
+!                                          R_xy(:,i,j,k,ispec), &
+!                                          R_xz(:,i,j,k,ispec), &
+!                                          R_yz(:,i,j,k,ispec), &
+!                                          epsilondev_loc(:,i,j,k),c44store(i,j,k,ispec),is_backward_field)
+! dummy to avoid compiler warning
+          if( is_backward_field ) then
+          endif
+
+
           ! note: fortran passes pointers to array location, thus R_memory(1,1,...) should be fine
           call compute_element_att_stress(R_xx(1,i,j,k,ispec), &
-                                         R_yy(1,i,j,k,ispec), &
-                                         R_xy(1,i,j,k,ispec), &
-                                         R_xz(1,i,j,k,ispec), &
-                                         R_yz(1,i,j,k,ispec), &
-                                         sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
+                                          R_yy(1,i,j,k,ispec), &
+                                          R_xy(1,i,j,k,ispec), &
+                                          R_xz(1,i,j,k,ispec), &
+                                          R_yz(1,i,j,k,ispec), &
+                                          sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
 
         endif ! ATTENUATION_VAL
 
@@ -1499,8 +1532,8 @@
         sigma_xx = sigma_xx - R_xx_val1 - R_xx_val2 - R_xx_val3
         sigma_yy = sigma_yy - R_yy_val1 - R_yy_val2 - R_yy_val3
         sigma_zz = sigma_zz + R_xx_val1 + R_yy_val1 &
-             + R_xx_val2 + R_yy_val2 &
-             + R_xx_val3 + R_yy_val3
+                            + R_xx_val2 + R_yy_val2 &
+                            + R_xx_val3 + R_yy_val3
 
         sigma_xy = sigma_xy - R_xy_loc(i_SLS)
         sigma_xz = sigma_xz - R_xz_loc(i_SLS)
@@ -1517,6 +1550,7 @@
   endif
 #else
 ! way 1:
+
   do i_SLS = 1,N_SLS
      R_xx_val1 = R_xx_loc(i_SLS) ! R_memory(1,i_SLS,i,j,k,ispec)
      R_yy_val1 = R_yy_loc(i_SLS) ! R_memory(2,i_SLS,i,j,k,ispec)
@@ -1527,6 +1561,7 @@
      sigma_xz = sigma_xz - R_xz_loc(i_SLS) ! R_memory(4,i_SLS,i,j,k,ispec)
      sigma_yz = sigma_yz - R_yz_loc(i_SLS) ! R_memory(5,i_SLS,i,j,k,ispec)
   enddo
+
 #endif
 
   end subroutine compute_element_att_stress
@@ -1536,13 +1571,13 @@
 !--------------------------------------------------------------------------------------------
 !
 
-  subroutine compute_element_att_memory_cr(ispec,R_xx,R_yy,R_xy,R_xz,R_yz, &
+  subroutine compute_element_att_memory_cm(ispec,R_xx,R_yy,R_xy,R_xz,R_yz, &
                                         vx,vy,vz,vnspec,factor_common, &
                                         alphaval,betaval,gammaval, &
                                         c44store,muvstore, &
                                         epsilondev_xx,epsilondev_yy,epsilondev_xy, &
                                         epsilondev_xz,epsilondev_yz, &
-                                        epsilondev_loc)
+                                        epsilondev_loc,is_backward_field)
 ! crust mantle
 ! update memory variables based upon the Runge-Kutta scheme
 
@@ -1560,6 +1595,9 @@
 ! therefore Q_\alpha is not zero; for instance for V_p / V_s = sqrt(3)
 ! we get Q_\alpha = (9 / 4) * Q_\mu = 2.25 * Q_\mu
 
+!daniel: att - debug predictor
+!  use specfem_par,only: tau_sigma_dble,deltat,b_deltat
+
   implicit none
 
   include "constants.h"
@@ -1591,10 +1629,14 @@
 
   real(kind=CUSTOM_REAL), dimension(5,NGLLX,NGLLY,NGLLZ) :: epsilondev_loc
 
+  logical :: is_backward_field
+
 ! local parameters
   real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: factor_common_c44_muv
   integer :: i_SLS
 
+!  double precision :: kappa
+
 #ifdef _HANDOPT_ATT
   real(kind=CUSTOM_REAL) :: alphal,betal,gammal
   integer :: i,j,k
@@ -1606,6 +1648,7 @@
   ! IMPROVE we use mu_v here even if there is some anisotropy
   ! IMPROVE we should probably use an average value instead
 
+
 #ifdef _HANDOPT_ATT
 ! way 2:
   do i_SLS = 1,N_SLS
@@ -1658,6 +1701,8 @@
   enddo ! i_SLS
 #else
 ! way 1:
+
+!daniel: att - debug original
   do i_SLS = 1,N_SLS
     ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
     if( USE_3D_ATTENUATION_ARRAYS ) then
@@ -1674,12 +1719,6 @@
       endif
     endif
 
-    !    do i_memory = 1,5
-    !      R_memory(i_memory,i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_memory(i_memory,i_SLS,:,:,:,ispec) &
-    !                + factor_common_c44_muv(:,:,:) &
-    !                * (betaval(i_SLS) * epsilondev(i_memory,:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(i_memory,:,:,:))
-    !    enddo
-
     R_xx(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
           (betaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(1,:,:,:))
 
@@ -1696,10 +1735,240 @@
           (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
 
   enddo ! i_SLS
+
+!daniel: att - debug
+!  if( .not. is_backward_field ) then
+!
+!  do i_SLS = 1,N_SLS
+!    ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
+!    if( USE_3D_ATTENUATION_ARRAYS ) then
+!      if(ANISOTROPIC_3D_MANTLE_VAL) then
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * c44store(:,:,:,ispec)
+!      else
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * muvstore(:,:,:,ispec)
+!      endif
+!    else
+!      if(ANISOTROPIC_3D_MANTLE_VAL) then
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * c44store(:,:,:,ispec)
+!      else
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * muvstore(:,:,:,ispec)
+!      endif
+!    endif
+!
+!!daniel: att - debug original
+!    R_xx(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(1,:,:,:))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yy(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_yy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(2,:,:,:))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xy(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(3,:,:,:))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xz(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(4,:,:,:))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yz(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
+!
+!!daniel: att - debug runge-kutta
+!    if( .false. ) then
+!    ! classical RK4:  R'(t) = - 1/tau * R(t)
+!    kappa = - dble(deltat)/tau_sigma_dble(i_SLS)
+!
+!    R_xx(i_SLS,:,:,:,ispec) = R_xx(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = R_yy(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = R_xy(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = R_xz(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = R_yz(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    endif
+!    if( .false. ) then
+! Butcher RK5:
+! 0     |
+! 1/4   | 1/4
+! 1/4   | 1/8   1/8
+! 1/2   | 0     -1/2    1
+! 3/4   | 3/16  0       0     9/16
+! 1     | -3/7  2/7     12/7  -12/7   8/7
+! -----------------------------------------------------------------------------
+!          7/90  0     32/90   12/90  32/90   7/90
+!
+!    k1 = dt * ( -1.0/tau * R_n )
+!    k2 = dt * ( -1.0/tau * (R_n + 1./4.*k1) )
+!    k3 = dt * ( -1.0/tau * (R_n + 1./8.*k1  + 1./8.*k2) )
+!    k4 = dt * ( -1.0/tau * (R_n + 0.*k1     - 1./2.*k2   + 1.* k3) )
+!    k5 = dt * ( -1.0/tau * (R_n + 3./16.*k1 + 0.*k2      + 0.*k3     + 9./16.*k4) )
+!    k6 = dt * ( -1.0/tau * (R_n - 3./7.*k1  + 2./7.*k2   + 12./7.*k3 - 12./7.*k4 + 8./7.*k5) )
+!
+!    R_nplus1 = R_n + 7./90.*k1 + 0.*k2 + 32./90.*k3 + 12./90.*k4 + 32./90.*k5 + 7./90.*k6
+!
+!    or:
+!    k = - dt/tau
+!    R_nplus1 = R_n*(1.0 + k*(1.0 + 0.5*k*(1.0 + 1./6.*k*(1.0 + 1./24.*k*(1.0 + 1./120.*k*(1.0 + 1./640.*k))))))
+!
+!    kappa = - dble(deltat)/tau_sigma_dble(i_SLS)
+!
+!    R_xx(i_SLS,:,:,:,ispec) = R_xx(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = R_yy(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = R_xy(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = R_xz(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = R_yz(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    endif
+!
+!  enddo ! i_SLS
+!
+!  else
+!
+!  ! backward/reconstruction, re-constructs previous memory variables, note strain arrays are now switched
+!
+!  do i_SLS = 1,N_SLS
+!    ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
+!    if( USE_3D_ATTENUATION_ARRAYS ) then
+!      if(ANISOTROPIC_3D_MANTLE_VAL) then
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * c44store(:,:,:,ispec)
+!      else
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * muvstore(:,:,:,ispec)
+!      endif
+!    else
+!      if(ANISOTROPIC_3D_MANTLE_VAL) then
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * c44store(:,:,:,ispec)
+!      else
+!        factor_common_c44_muv(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * muvstore(:,:,:,ispec)
+!      endif
+!    endif
+!
+!!daniel: att - debug original
+!    R_xx(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(1,:,:,:))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yy(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_yy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(2,:,:,:))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xy(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(3,:,:,:))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xz(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_xz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(4,:,:,:))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yz(i_SLS,:,:,:,ispec) + factor_common_c44_muv(:,:,:) * &
+!          (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
+!
+!!daniel: att - debug runge-kutta
+!    if( .false. ) then
+! classical RK 4:       R'(t) =  - 1/tau * R(t)
+!
+! Butcher RK5:
+! 0     |
+! 1/2   | 1/2
+! 1/2   | 0    1/2
+! 1     | 0          1
+! -----------------------------------------------------------------------------
+!         1/6  1/3   1/3   1/6
+!
+!    kappa = - dble(b_deltat)/tau_sigma_dble(i_SLS)
+!
+!    R_xx(i_SLS,:,:,:,ispec) = R_xx(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = R_yy(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = R_xy(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = R_xz(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = R_yz(i_SLS,:,:,:,ispec) * &
+!      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+!
+!    endif
+!
+!!daniel: att - debug
+!    if( .false. ) then
+! Butcher RK5:
+! 0     |
+! 1/4   | 1/4
+! 1/4   | 1/8   1/8
+! 1/2   | 0     -1/2    1
+! 3/4   | 3/16  0       0     9/16
+! 1     | -3/7  2/7     12/7  -12/7   8/7
+! -----------------------------------------------------------------------------
+!          7/90  0     32/90   12/90  32/90   7/90
+!
+!    k1 = dt * ( -1.0/tau * R_n )
+!    k2 = dt * ( -1.0/tau * (R_n + 1./4.*k1) )
+!    k3 = dt * ( -1.0/tau * (R_n + 1./8.*k1  + 1./8.*k2) )
+!    k4 = dt * ( -1.0/tau * (R_n + 0.*k1     - 1./2.*k2   + 1.* k3) )
+!    k5 = dt * ( -1.0/tau * (R_n + 3./16.*k1 + 0.*k2      + 0.*k3     + 9./16.*k4) )
+!    k6 = dt * ( -1.0/tau * (R_n - 3./7.*k1  + 2./7.*k2   + 12./7.*k3 - 12./7.*k4 + 8./7.*k5) )
+!
+!    R_nplus1 = R_n + 7./90.*k1 + 0.*k2 + 32./90.*k3 + 12./90.*k4 + 32./90.*k5 + 7./90.*k6
+!
+!    or:
+!    k = - dt/tau
+!    R_nplus1 = R_n*(1.0 + k*(1.0 + 0.5*k*(1.0 + 1./6.*k*(1.0 + 1./24.*k*(1.0 + 1./120.*k*(1.0 + 1./640.*k))))))
+!    kappa = - dble(b_deltat)/tau_sigma_dble(i_SLS)
+!
+!    R_xx(i_SLS,:,:,:,ispec) = R_xx(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = R_yy(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = R_xy(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = R_xz(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = R_yz(i_SLS,:,:,:,ispec) * &
+!      (1.d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.d0/6.d0*kappa*(1.d0 + &
+!                    1.d0/24.d0*kappa*(1.d0 + 1.d0/120.d0*kappa*(1.d0 + 1.d0/640.d0*kappa))))))
+!
+!    endif
+!
+!  enddo ! i_SLS
+!
+!  endif ! is_backward_field
+! dummy to avoid compiler warning
+  if( is_backward_field ) then
+  endif
+
+
 #endif
 
 
-  end subroutine compute_element_att_memory_cr
+  end subroutine compute_element_att_memory_cm
 
 !
 !--------------------------------------------------------------------------------------------
@@ -1711,7 +1980,7 @@
                                         muvstore, &
                                         epsilondev_xx,epsilondev_yy,epsilondev_xy, &
                                         epsilondev_xz,epsilondev_yz, &
-                                        epsilondev_loc)
+                                        epsilondev_loc,is_backward_field)
 ! inner core
 ! update memory variables based upon the Runge-Kutta scheme
 
@@ -1757,6 +2026,8 @@
 
   real(kind=CUSTOM_REAL), dimension(5,NGLLX,NGLLY,NGLLZ) :: epsilondev_loc
 
+  logical :: is_backward_field
+
 ! local parameters
   real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: factor_common_use
 
@@ -1814,6 +2085,7 @@
   enddo ! i_SLS
 #else
 ! way 1:
+
   do i_SLS = 1,N_SLS
 
     ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
@@ -1845,8 +2117,212 @@
          (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
 
   enddo
+
+!daniel: att - debug
+!  if( .not. is_backward_field ) then
+!  do i_SLS = 1,N_SLS
+!    ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
+!    if( USE_3D_ATTENUATION_ARRAYS ) then
+!      factor_common_use(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * muvstore(:,:,:,ispec)
+!    else
+!      factor_common_use(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * muvstore(:,:,:,ispec)
+!    endif
+!
+!    do i_memory = 1,5
+!       R_memory(i_memory,i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_memory(i_memory,i_SLS,:,:,:,ispec) &
+!            + muvstore(:,:,:,ispec) * factor_common_use(:,:,:) * &
+!            (betaval(i_SLS) * epsilondev(i_memory,:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(i_memory,:,:,:))
+!    enddo
+!
+!    R_xx(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(1,:,:,:))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yy(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_yy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(2,:,:,:))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xy(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(3,:,:,:))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xz(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(4,:,:,:))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yz(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
+!
+!  enddo
+!
+!  else
+!
+!  ! backward/reconstruction, strain arrays are not switched
+!  do i_SLS = 1,N_SLS
+!    ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
+!    if( USE_3D_ATTENUATION_ARRAYS ) then
+!      factor_common_use(:,:,:) = factor_common(i_SLS,:,:,:,ispec) * muvstore(:,:,:,ispec)
+!    else
+!      factor_common_use(:,:,:) = factor_common(i_SLS,1,1,1,ispec) * muvstore(:,:,:,ispec)
+!    endif
+!
+!daniel: att - debug original
+!    R_xx(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(1,:,:,:))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yy(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_yy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(2,:,:,:))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xy(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xy(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(3,:,:,:))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_xz(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_xz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(4,:,:,:))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = alphaval(i_SLS) * R_yz(i_SLS,:,:,:,ispec) + factor_common_use(:,:,:) * &
+!         (betaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + gammaval(i_SLS) * epsilondev_loc(5,:,:,:))
+!
+!daniel: att - debug switched
+!    if( .false.) then
+!    R_xx(i_SLS,:,:,:,ispec) = 1.0_CUSTOM_REAL/alphaval(i_SLS) * R_xx(i_SLS,:,:,:,ispec) - factor_common_use(:,:,:) * &
+!         (gammaval(i_SLS) * epsilondev_xx(:,:,:,ispec) + betaval(i_SLS) * epsilondev_loc(1,:,:,:))
+!
+!    R_yy(i_SLS,:,:,:,ispec) = 1.0_CUSTOM_REAL/alphaval(i_SLS) * R_yy(i_SLS,:,:,:,ispec) - factor_common_use(:,:,:) * &
+!         (gammaval(i_SLS) * epsilondev_yy(:,:,:,ispec) + betaval(i_SLS) * epsilondev_loc(2,:,:,:))
+!
+!    R_xy(i_SLS,:,:,:,ispec) = 1.0_CUSTOM_REAL/alphaval(i_SLS) * R_xy(i_SLS,:,:,:,ispec) - factor_common_use(:,:,:) * &
+!         (gammaval(i_SLS) * epsilondev_xy(:,:,:,ispec) + betaval(i_SLS) * epsilondev_loc(3,:,:,:))
+!
+!    R_xz(i_SLS,:,:,:,ispec) = 1.0_CUSTOM_REAL/alphaval(i_SLS) * R_xz(i_SLS,:,:,:,ispec) - factor_common_use(:,:,:) * &
+!         (gammaval(i_SLS) * epsilondev_xz(:,:,:,ispec) + betaval(i_SLS) * epsilondev_loc(4,:,:,:))
+!
+!    R_yz(i_SLS,:,:,:,ispec) = 1.0_CUSTOM_REAL/alphaval(i_SLS) * R_yz(i_SLS,:,:,:,ispec) - factor_common_use(:,:,:) * &
+!         (gammaval(i_SLS) * epsilondev_yz(:,:,:,ispec) + betaval(i_SLS) * epsilondev_loc(5,:,:,:))
+!    endif
+!
+!  enddo
+!
+!  endif ! is_backward_field
+! dummy to avoid compiler warning
+  if( is_backward_field ) then
+  endif
+
 #endif
 
+
+!daniel: att - debug no att
+!  R_xx = 0.0
+!  R_yy = 0.0
+!  R_xy = 0.0
+!  R_xz = 0.0
+!  R_yz = 0.0
+
   end subroutine compute_element_att_memory_ic
 
 
+!
+!--------------------------------------------------------------------------------------------
+!
+
+  subroutine compute_element_att_mem_up_cm(ispec,i,j,k, &
+                                              R_xx_loc,R_yy_loc,R_xy_loc,R_xz_loc,R_yz_loc, &
+                                              epsilondev_loc,c44_muv,is_backward_field)
+! crust mantle
+! update memory variables based upon the Runge-Kutta scheme
+
+
+!daniel: att - debug update
+  use specfem_par,only: tau_sigma_dble,deltat,b_deltat
+
+  use specfem_par_crustmantle,only: factor_common=>factor_common_crust_mantle
+
+
+  implicit none
+
+  include "constants.h"
+
+  ! include values created by the mesher
+  ! done for performance only using static allocation to allow for loop unrolling
+  include "OUTPUT_FILES/values_from_mesher.h"
+
+  ! element id
+  integer :: ispec,i,j,k
+
+  ! attenuation
+  ! memory variables for attenuation
+  ! memory variables R_ij are stored at the local rather than global level
+  ! to allow for optimization of cache access by compiler
+!  real(kind=CUSTOM_REAL), dimension(5,N_SLS) :: R_memory_loc
+  real(kind=CUSTOM_REAL), dimension(N_SLS) :: R_xx_loc
+  real(kind=CUSTOM_REAL), dimension(N_SLS) :: R_yy_loc
+  real(kind=CUSTOM_REAL), dimension(N_SLS) :: R_xy_loc
+  real(kind=CUSTOM_REAL), dimension(N_SLS) :: R_xz_loc
+  real(kind=CUSTOM_REAL), dimension(N_SLS) :: R_yz_loc
+
+  real(kind=CUSTOM_REAL), dimension(5) :: epsilondev_loc
+  real(kind=CUSTOM_REAL) :: c44_muv
+
+  logical :: is_backward_field
+  double precision :: dt,kappa
+
+! local parameters
+  real(kind=CUSTOM_REAL) :: factor_common_c44_muv
+  integer :: i_SLS
+
+  ! R'(t) = - 1/tau * R(t) + 1/tau * dc:grad(s)
+  !
+  ! here we add integral contribution for: 1/tau * dc:grad(s)
+  !
+  ! R_n+1 = R_n+1  + dt * ( 1/tau * dc:grad(s_n+1)
+  !
+  ! note: s at this point is known at: s(t+dt)
+
+  if( .not. is_backward_field ) then
+    dt = dble(deltat)
+  else
+    ! backward/reconstruction: reverse time
+    dt = dble(b_deltat)
+  endif
+
+  do i_SLS = 1,N_SLS
+
+    ! runge-kutta scheme to update memory variables R(t)
+    if( .false. ) then
+! classical RK 4:       R'(t) =  - 1/tau * R(t)
+!
+! Butcher RK4:
+! 0     |
+! 1/2   | 1/2
+! 1/2   | 0    1/2
+! 1     | 0          1
+! -----------------------------------------------------------------------------
+!         1/6  1/3   1/3   1/6
+    kappa = - dt/tau_sigma_dble(i_SLS)
+
+    R_xx_loc(i_SLS) = R_xx_loc(i_SLS) * &
+      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+    R_yy_loc(i_SLS) = R_yy_loc(i_SLS) * &
+      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+    R_xy_loc(i_SLS) = R_xy_loc(i_SLS) * &
+      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+    R_xz_loc(i_SLS) = R_xz_loc(i_SLS) * &
+      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+    R_yz_loc(i_SLS) = R_yz_loc(i_SLS) * &
+      (1.0d0 + kappa*(1.d0 + 0.5d0*kappa*(1.d0 + 1.0d0/6.0d0*kappa*(1.d0 + 1.0d0/24.0d0*kappa))))
+    endif
+
+
+    ! reformatted R_memory to handle large factor_common and reduced [alpha,beta,gamma]val
+    if( USE_3D_ATTENUATION_ARRAYS ) then
+      factor_common_c44_muv = factor_common(i_SLS,i,j,k,ispec) * c44_muv
+    else
+      factor_common_c44_muv = factor_common(i_SLS,1,1,1,ispec) * c44_muv
+    endif
+
+    ! adds contributions from current strain
+    R_xx_loc(i_SLS) = R_xx_loc(i_SLS) + 0.5d0 * dt * dble(factor_common_c44_muv) * dble(epsilondev_loc(1))
+    R_yy_loc(i_SLS) = R_yy_loc(i_SLS) + 0.5d0 * dt * dble(factor_common_c44_muv) * dble(epsilondev_loc(2))
+    R_xy_loc(i_SLS) = R_xy_loc(i_SLS) + 0.5d0 * dt * dble(factor_common_c44_muv) * dble(epsilondev_loc(3))
+    R_xz_loc(i_SLS) = R_xz_loc(i_SLS) + 0.5d0 * dt * dble(factor_common_c44_muv) * dble(epsilondev_loc(4))
+    R_yz_loc(i_SLS) = R_yz_loc(i_SLS) + 0.5d0 * dt * dble(factor_common_c44_muv) * dble(epsilondev_loc(5))
+
+
+  enddo ! i_SLS
+
+  end subroutine compute_element_att_mem_up_cm

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_acoustic.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_acoustic.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_acoustic.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -183,19 +183,19 @@
         call assemble_MPI_scalar_s(NPROCTOT_VAL,NGLOB_OUTER_CORE, &
                                 accel_outer_core, &
                                 buffer_send_scalar_outer_core,buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core,&
                                 my_neighbours_outer_core, &
-                                request_send_scalar_outer_core,request_recv_scalar_outer_core)
+                                request_send_scalar_oc,request_recv_scalar_oc)
       else
         ! on GPU
         ! outer core
         call assemble_MPI_scalar_send_cuda(NPROCTOT_VAL, &
                                 buffer_send_scalar_outer_core,buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,&
                                 my_neighbours_outer_core, &
-                                request_send_scalar_outer_core,request_recv_scalar_outer_core, &
+                                request_send_scalar_oc,request_recv_scalar_oc, &
                                 1) ! <-- 1 == fwd accel
       endif
 
@@ -206,19 +206,19 @@
           call assemble_MPI_scalar_s(NPROCTOT_VAL,NGLOB_OUTER_CORE, &
                                 b_accel_outer_core, &
                                 b_buffer_send_scalar_outer_core,b_buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core,&
                                 my_neighbours_outer_core, &
-                                b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core)
+                                b_request_send_scalar_oc,b_request_recv_scalar_oc)
         else
           ! on GPU
           ! outer core
           call assemble_MPI_scalar_send_cuda(NPROCTOT_VAL, &
                                 b_buffer_send_scalar_outer_core,b_buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,&
                                 my_neighbours_outer_core, &
-                                b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core, &
+                                b_request_send_scalar_oc,b_request_recv_scalar_oc, &
                                 3) ! <-- 3 == adjoint b_accel
         endif ! GPU
       endif ! SIMULATION_TYPE == 3
@@ -231,15 +231,15 @@
         call assemble_MPI_scalar_w(NPROCTOT_VAL,NGLOB_OUTER_CORE, &
                                 accel_outer_core, &
                                 buffer_recv_scalar_outer_core,num_interfaces_outer_core,&
-                                max_nibool_interfaces_outer_core, &
+                                max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core, &
-                                request_send_scalar_outer_core,request_recv_scalar_outer_core)
+                                request_send_scalar_oc,request_recv_scalar_oc)
       else
         ! on GPU
         call assemble_MPI_scalar_write_cuda(NPROCTOT_VAL, &
                                 buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
-                                request_send_scalar_outer_core,request_recv_scalar_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
+                                request_send_scalar_oc,request_recv_scalar_oc, &
                                 1) ! <-- 1 == fwd accel
       endif
 
@@ -250,15 +250,15 @@
           call assemble_MPI_scalar_w(NPROCTOT_VAL,NGLOB_OUTER_CORE, &
                                 b_accel_outer_core, &
                                 b_buffer_recv_scalar_outer_core,num_interfaces_outer_core,&
-                                max_nibool_interfaces_outer_core, &
+                                max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core, &
-                                b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core)
+                                b_request_send_scalar_oc,b_request_recv_scalar_oc)
         else
           ! on GPU
           call assemble_MPI_scalar_write_cuda(NPROCTOT_VAL, &
                                 b_buffer_recv_scalar_outer_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
-                                b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
+                                b_request_send_scalar_oc,b_request_recv_scalar_oc, &
                                 3) ! <-- 3 == adjoint b_accel
         endif
       endif ! SIMULATION_TYPE == 3

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_crust_mantle_Dev.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_crust_mantle_Dev.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_crust_mantle_Dev.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -45,7 +45,7 @@
                                               epsilondev_xz,epsilondev_yz, &
                                               epsilon_trace_over_3, &
                                               alphaval,betaval,gammaval, &
-                                              factor_common,vx,vy,vz,vnspec)
+                                              factor_common,vx,vy,vz,vnspec,is_backward_field)
 
 ! this routine is optimized for NGLLX = NGLLY = NGLLZ = 5 using the Deville et al. (2002) inlined matrix-matrix products
 
@@ -77,6 +77,9 @@
     nspec_outer => nspec_outer_crust_mantle, &
     nspec_inner => nspec_inner_crust_mantle
 
+!daniel: att - debug
+!  use specfem_par,only: it,NSTEP
+
   implicit none
 
   integer :: NSPEC,NGLOB,NSPEC_ATT
@@ -108,6 +111,8 @@
   ! inner/outer element run flag
   logical :: phase_is_inner
 
+  logical :: is_backward_field
+
   ! local parameters
 
   ! Deville
@@ -130,19 +135,6 @@
   equivalence(newtempy1,E2_m1_m2_5points)
   equivalence(newtempz1,E3_m1_m2_5points)
 
-  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: &
-    tempx1_att,tempx2_att,tempx3_att,tempy1_att,tempy2_att,tempy3_att,tempz1_att,tempz2_att,tempz3_att
-  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: dummyx_loc_att,dummyy_loc_att,dummyz_loc_att
-  real(kind=CUSTOM_REAL), dimension(NGLLX,m2) :: B1_m1_m2_5points_att,B2_m1_m2_5points_att,B3_m1_m2_5points_att
-  real(kind=CUSTOM_REAL), dimension(m1,m2) :: C1_m1_m2_5points_att,C2_m1_m2_5points_att,C3_m1_m2_5points_att
-
-  equivalence(dummyx_loc_att,B1_m1_m2_5points_att)
-  equivalence(dummyy_loc_att,B2_m1_m2_5points_att)
-  equivalence(dummyz_loc_att,B3_m1_m2_5points_att)
-  equivalence(tempx1_att,C1_m1_m2_5points_att)
-  equivalence(tempy1_att,C2_m1_m2_5points_att)
-  equivalence(tempz1_att,C3_m1_m2_5points_att)
-
   real(kind=CUSTOM_REAL), dimension(m2,NGLLX) :: &
     A1_mxm_m2_m1_5points,A2_mxm_m2_m1_5points,A3_mxm_m2_m1_5points
   real(kind=CUSTOM_REAL), dimension(m2,m1) :: &
@@ -160,6 +152,20 @@
   equivalence(newtempy3,E2_mxm_m2_m1_5points)
   equivalence(newtempz3,E3_mxm_m2_m1_5points)
 
+  ! attenuation arrays
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: &
+    tempx1_att,tempx2_att,tempx3_att,tempy1_att,tempy2_att,tempy3_att,tempz1_att,tempz2_att,tempz3_att
+  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ) :: dummyx_loc_att,dummyy_loc_att,dummyz_loc_att
+  real(kind=CUSTOM_REAL), dimension(NGLLX,m2) :: B1_m1_m2_5points_att,B2_m1_m2_5points_att,B3_m1_m2_5points_att
+  real(kind=CUSTOM_REAL), dimension(m1,m2) :: C1_m1_m2_5points_att,C2_m1_m2_5points_att,C3_m1_m2_5points_att
+
+  equivalence(dummyx_loc_att,B1_m1_m2_5points_att)
+  equivalence(dummyy_loc_att,B2_m1_m2_5points_att)
+  equivalence(dummyz_loc_att,B3_m1_m2_5points_att)
+  equivalence(tempx1_att,C1_m1_m2_5points_att)
+  equivalence(tempy1_att,C2_m1_m2_5points_att)
+  equivalence(tempz1_att,C3_m1_m2_5points_att)
+
   real(kind=CUSTOM_REAL), dimension(m2,NGLLX) :: &
     A1_mxm_m2_m1_5points_att,A2_mxm_m2_m1_5points_att,A3_mxm_m2_m1_5points_att
   real(kind=CUSTOM_REAL), dimension(m2,m1) :: &
@@ -242,10 +248,10 @@
 #else
 ! way 1:
         do i=1,NGLLX
-            iglob1 = ibool(i,j,k,ispec)
-            dummyx_loc(i,j,k) = displ_crust_mantle(1,iglob1)
-            dummyy_loc(i,j,k) = displ_crust_mantle(2,iglob1)
-            dummyz_loc(i,j,k) = displ_crust_mantle(3,iglob1)
+          iglob1 = ibool(i,j,k,ispec)
+          dummyx_loc(i,j,k) = displ_crust_mantle(1,iglob1)
+          dummyy_loc(i,j,k) = displ_crust_mantle(2,iglob1)
+          dummyz_loc(i,j,k) = displ_crust_mantle(3,iglob1)
         enddo
 
 #endif
@@ -253,6 +259,7 @@
     enddo
 
     if(ATTENUATION_VAL .and. COMPUTE_AND_STORE_STRAIN) then
+
        if(ATTENUATION_NEW_VAL) then
           ! takes new routines
           ! use first order Taylor expansion of displacement for local storage of stresses
@@ -266,33 +273,33 @@
                 ! since we know that NGLLX = 5, this should help pipelining
                 iglobv5(:) = ibool(:,j,k,ispec)
 
-                dummyx_loc_att(1,j,k) = deltat*veloc_crust_mantle(1,iglobv5(1))
-                dummyy_loc_att(1,j,k) = deltat*veloc_crust_mantle(2,iglobv5(1))
-                dummyz_loc_att(1,j,k) = deltat*veloc_crust_mantle(3,iglobv5(1))
+                dummyx_loc_att(1,j,k) = dummyx_loc(1,j,k) + deltat*veloc_crust_mantle(1,iglobv5(1))
+                dummyy_loc_att(1,j,k) = dummyy_loc(1,j,k) + deltat*veloc_crust_mantle(2,iglobv5(1))
+                dummyz_loc_att(1,j,k) = dummyz_loc(1,j,k) + deltat*veloc_crust_mantle(3,iglobv5(1))
 
-                dummyx_loc_att(2,j,k) = deltat*veloc_crust_mantle(1,iglobv5(2))
-                dummyy_loc_att(2,j,k) = deltat*veloc_crust_mantle(2,iglobv5(2))
-                dummyz_loc_att(2,j,k) = deltat*veloc_crust_mantle(3,iglobv5(2))
+                dummyx_loc_att(2,j,k) = dummyx_loc(2,j,k) + deltat*veloc_crust_mantle(1,iglobv5(2))
+                dummyy_loc_att(2,j,k) = dummyy_loc(2,j,k) + deltat*veloc_crust_mantle(2,iglobv5(2))
+                dummyz_loc_att(2,j,k) = dummyz_loc(2,j,k) + deltat*veloc_crust_mantle(3,iglobv5(2))
 
-                dummyx_loc_att(3,j,k) = deltat*veloc_crust_mantle(1,iglobv5(3))
-                dummyy_loc_att(3,j,k) = deltat*veloc_crust_mantle(2,iglobv5(3))
-                dummyz_loc_att(3,j,k) = deltat*veloc_crust_mantle(3,iglobv5(3))
+                dummyx_loc_att(3,j,k) = dummyx_loc(3,j,k) + deltat*veloc_crust_mantle(1,iglobv5(3))
+                dummyy_loc_att(3,j,k) = dummyy_loc(3,j,k) + deltat*veloc_crust_mantle(2,iglobv5(3))
+                dummyz_loc_att(3,j,k) = dummyz_loc(3,j,k) + deltat*veloc_crust_mantle(3,iglobv5(3))
 
-                dummyx_loc_att(4,j,k) = deltat*veloc_crust_mantle(1,iglobv5(4))
-                dummyy_loc_att(4,j,k) = deltat*veloc_crust_mantle(2,iglobv5(4))
-                dummyz_loc_att(4,j,k) = deltat*veloc_crust_mantle(3,iglobv5(4))
+                dummyx_loc_att(4,j,k) = dummyx_loc(4,j,k) + deltat*veloc_crust_mantle(1,iglobv5(4))
+                dummyy_loc_att(4,j,k) = dummyy_loc(4,j,k) + deltat*veloc_crust_mantle(2,iglobv5(4))
+                dummyz_loc_att(4,j,k) = dummyz_loc(4,j,k) + deltat*veloc_crust_mantle(3,iglobv5(4))
 
-                dummyx_loc_att(5,j,k) = deltat*veloc_crust_mantle(1,iglobv5(5))
-                dummyy_loc_att(5,j,k) = deltat*veloc_crust_mantle(2,iglobv5(5))
-                dummyz_loc_att(5,j,k) = deltat*veloc_crust_mantle(3,iglobv5(5))
+                dummyx_loc_att(5,j,k) = dummyx_loc(5,j,k) + deltat*veloc_crust_mantle(1,iglobv5(5))
+                dummyy_loc_att(5,j,k) = dummyy_loc(5,j,k) + deltat*veloc_crust_mantle(2,iglobv5(5))
+                dummyz_loc_att(5,j,k) = dummyz_loc(5,j,k) + deltat*veloc_crust_mantle(3,iglobv5(5))
 
 #else
                 ! way 1:
                 do i=1,NGLLX
-                   iglob1 = ibool(i,j,k,ispec)
-                   dummyx_loc_att(i,j,k) = deltat*veloc_crust_mantle(1,iglob1)
-                   dummyy_loc_att(i,j,k) = deltat*veloc_crust_mantle(2,iglob1)
-                   dummyz_loc_att(i,j,k) = deltat*veloc_crust_mantle(3,iglob1)
+                  iglob1 = ibool(i,j,k,ispec)
+                  dummyx_loc_att(i,j,k) = dummyx_loc(i,j,k) + deltat*veloc_crust_mantle(1,iglob1)
+                  dummyy_loc_att(i,j,k) = dummyy_loc(i,j,k) + deltat*veloc_crust_mantle(2,iglob1)
+                  dummyz_loc_att(i,j,k) = dummyz_loc(i,j,k) + deltat*veloc_crust_mantle(3,iglob1)
                 enddo
 
 #endif
@@ -303,204 +310,180 @@
           do k=1,NGLLZ
              do j=1,NGLLY
 #ifdef _HANDOPT
-                dummyx_loc_att(1,j,k) = 0._CUSTOM_REAL
-                dummyy_loc_att(1,j,k) = 0._CUSTOM_REAL
-                dummyz_loc_att(1,j,k) = 0._CUSTOM_REAL
+                dummyx_loc_att(1,j,k) = dummyx_loc(1,j,k)
+                dummyx_loc_att(2,j,k) = dummyx_loc(2,j,k)
+                dummyx_loc_att(3,j,k) = dummyx_loc(3,j,k)
+                dummyx_loc_att(4,j,k) = dummyx_loc(4,j,k)
+                dummyx_loc_att(5,j,k) = dummyx_loc(5,j,k)
 
-                dummyx_loc_att(2,j,k) = 0._CUSTOM_REAL
-                dummyy_loc_att(2,j,k) = 0._CUSTOM_REAL
-                dummyz_loc_att(2,j,k) = 0._CUSTOM_REAL
+                dummyy_loc_att(1,j,k) = dummyy_loc(1,j,k)
+                dummyy_loc_att(2,j,k) = dummyy_loc(2,j,k)
+                dummyy_loc_att(3,j,k) = dummyy_loc(3,j,k)
+                dummyy_loc_att(4,j,k) = dummyy_loc(4,j,k)
+                dummyy_loc_att(5,j,k) = dummyy_loc(5,j,k)
 
-                dummyx_loc_att(3,j,k) = 0._CUSTOM_REAL
-                dummyy_loc_att(3,j,k) = 0._CUSTOM_REAL
-                dummyz_loc_att(3,j,k) = 0._CUSTOM_REAL
+                dummyz_loc_att(1,j,k) = dummyz_loc(1,j,k)
+                dummyz_loc_att(2,j,k) = dummyz_loc(2,j,k)
+                dummyz_loc_att(3,j,k) = dummyz_loc(3,j,k)
+                dummyz_loc_att(4,j,k) = dummyz_loc(4,j,k)
+                dummyz_loc_att(5,j,k) = dummyz_loc(5,j,k)
+#else
+                !do i=1,NGLLX
+                !  dummyx_loc_att(i,j,k) = dummyx_loc(i,j,k)
+                !  dummyy_loc_att(i,j,k) = dummyy_loc(i,j,k)
+                !  dummyz_loc_att(i,j,k) = dummyz_loc(i,j,k)
+                !enddo
 
-                dummyx_loc_att(4,j,k) = 0._CUSTOM_REAL
-                dummyy_loc_att(4,j,k) = 0._CUSTOM_REAL
-                dummyz_loc_att(4,j,k) = 0._CUSTOM_REAL
+                dummyx_loc_att(:,j,k) = dummyx_loc(:,j,k)
+                dummyy_loc_att(:,j,k) = dummyy_loc(:,j,k)
+                dummyz_loc_att(:,j,k) = dummyz_loc(:,j,k)
 
-                dummyx_loc_att(5,j,k) = 0._CUSTOM_REAL
-                dummyy_loc_att(5,j,k) = 0._CUSTOM_REAL
-                dummyz_loc_att(5,j,k) = 0._CUSTOM_REAL
-#else
-                do i=1,NGLLX
-                   dummyx_loc_att(i,j,k) = 0._CUSTOM_REAL
-                   dummyy_loc_att(i,j,k) = 0._CUSTOM_REAL
-                   dummyz_loc_att(i,j,k) = 0._CUSTOM_REAL
-                enddo
 #endif
              enddo
           enddo
        endif
-    endif
+    endif ! ATTENUATION_VAL
 
     do j=1,m2
        do i=1,m1
           C1_m1_m2_5points(i,j) = hprime_xx(i,1)*B1_m1_m2_5points(1,j) + &
-               hprime_xx(i,2)*B1_m1_m2_5points(2,j) + &
-               hprime_xx(i,3)*B1_m1_m2_5points(3,j) + &
-               hprime_xx(i,4)*B1_m1_m2_5points(4,j) + &
-               hprime_xx(i,5)*B1_m1_m2_5points(5,j)
+                                  hprime_xx(i,2)*B1_m1_m2_5points(2,j) + &
+                                  hprime_xx(i,3)*B1_m1_m2_5points(3,j) + &
+                                  hprime_xx(i,4)*B1_m1_m2_5points(4,j) + &
+                                  hprime_xx(i,5)*B1_m1_m2_5points(5,j)
 
           C2_m1_m2_5points(i,j) = hprime_xx(i,1)*B2_m1_m2_5points(1,j) + &
-               hprime_xx(i,2)*B2_m1_m2_5points(2,j) + &
-               hprime_xx(i,3)*B2_m1_m2_5points(3,j) + &
-               hprime_xx(i,4)*B2_m1_m2_5points(4,j) + &
-               hprime_xx(i,5)*B2_m1_m2_5points(5,j)
+                                  hprime_xx(i,2)*B2_m1_m2_5points(2,j) + &
+                                  hprime_xx(i,3)*B2_m1_m2_5points(3,j) + &
+                                  hprime_xx(i,4)*B2_m1_m2_5points(4,j) + &
+                                  hprime_xx(i,5)*B2_m1_m2_5points(5,j)
 
           C3_m1_m2_5points(i,j) = hprime_xx(i,1)*B3_m1_m2_5points(1,j) + &
-               hprime_xx(i,2)*B3_m1_m2_5points(2,j) + &
-               hprime_xx(i,3)*B3_m1_m2_5points(3,j) + &
-               hprime_xx(i,4)*B3_m1_m2_5points(4,j) + &
-               hprime_xx(i,5)*B3_m1_m2_5points(5,j)
+                                  hprime_xx(i,2)*B3_m1_m2_5points(2,j) + &
+                                  hprime_xx(i,3)*B3_m1_m2_5points(3,j) + &
+                                  hprime_xx(i,4)*B3_m1_m2_5points(4,j) + &
+                                  hprime_xx(i,5)*B3_m1_m2_5points(5,j)
        enddo
     enddo
 
-    if(ATTENUATION_VAL .and. COMPUTE_AND_STORE_STRAIN) then
-       ! temporary variables used for fixing attenuation in a consistent way
-       do j=1,m2
-          do i=1,m1
-             C1_m1_m2_5points_att(i,j) = C1_m1_m2_5points(i,j) + &
-                  hprime_xx(i,1)*B1_m1_m2_5points_att(1,j) + &
-                  hprime_xx(i,2)*B1_m1_m2_5points_att(2,j) + &
-                  hprime_xx(i,3)*B1_m1_m2_5points_att(3,j) + &
-                  hprime_xx(i,4)*B1_m1_m2_5points_att(4,j) + &
-                  hprime_xx(i,5)*B1_m1_m2_5points_att(5,j)
-
-             C2_m1_m2_5points_att(i,j) = C2_m1_m2_5points(i,j) + &
-                  hprime_xx(i,1)*B2_m1_m2_5points_att(1,j) + &
-                  hprime_xx(i,2)*B2_m1_m2_5points_att(2,j) + &
-                  hprime_xx(i,3)*B2_m1_m2_5points_att(3,j) + &
-                  hprime_xx(i,4)*B2_m1_m2_5points_att(4,j) + &
-                  hprime_xx(i,5)*B2_m1_m2_5points_att(5,j)
-
-             C3_m1_m2_5points_att(i,j) = C3_m1_m2_5points(i,j) + &
-                  hprime_xx(i,1)*B3_m1_m2_5points_att(1,j) + &
-                  hprime_xx(i,2)*B3_m1_m2_5points_att(2,j) + &
-                  hprime_xx(i,3)*B3_m1_m2_5points_att(3,j) + &
-                  hprime_xx(i,4)*B3_m1_m2_5points_att(4,j) + &
-                  hprime_xx(i,5)*B3_m1_m2_5points_att(5,j)
-          enddo
-       enddo
-    else
-       tempx1_att(:,:,:) = 0._CUSTOM_REAL
-       tempy1_att(:,:,:) = 0._CUSTOM_REAL
-       tempz1_att(:,:,:) = 0._CUSTOM_REAL
-    endif
-
     do j=1,m1
        do i=1,m1
           ! for efficiency it is better to leave this loop on k inside, it leads to slightly faster code
           do k = 1,NGLLX
              tempx2(i,j,k) = dummyx_loc(i,1,k)*hprime_xxT(1,j) + &
-                  dummyx_loc(i,2,k)*hprime_xxT(2,j) + &
-                  dummyx_loc(i,3,k)*hprime_xxT(3,j) + &
-                  dummyx_loc(i,4,k)*hprime_xxT(4,j) + &
-                  dummyx_loc(i,5,k)*hprime_xxT(5,j)
+                             dummyx_loc(i,2,k)*hprime_xxT(2,j) + &
+                             dummyx_loc(i,3,k)*hprime_xxT(3,j) + &
+                             dummyx_loc(i,4,k)*hprime_xxT(4,j) + &
+                             dummyx_loc(i,5,k)*hprime_xxT(5,j)
 
              tempy2(i,j,k) = dummyy_loc(i,1,k)*hprime_xxT(1,j) + &
-                  dummyy_loc(i,2,k)*hprime_xxT(2,j) + &
-                  dummyy_loc(i,3,k)*hprime_xxT(3,j) + &
-                  dummyy_loc(i,4,k)*hprime_xxT(4,j) + &
-                  dummyy_loc(i,5,k)*hprime_xxT(5,j)
+                             dummyy_loc(i,2,k)*hprime_xxT(2,j) + &
+                             dummyy_loc(i,3,k)*hprime_xxT(3,j) + &
+                             dummyy_loc(i,4,k)*hprime_xxT(4,j) + &
+                             dummyy_loc(i,5,k)*hprime_xxT(5,j)
 
              tempz2(i,j,k) = dummyz_loc(i,1,k)*hprime_xxT(1,j) + &
-                  dummyz_loc(i,2,k)*hprime_xxT(2,j) + &
-                  dummyz_loc(i,3,k)*hprime_xxT(3,j) + &
-                  dummyz_loc(i,4,k)*hprime_xxT(4,j) + &
-                  dummyz_loc(i,5,k)*hprime_xxT(5,j)
+                             dummyz_loc(i,2,k)*hprime_xxT(2,j) + &
+                             dummyz_loc(i,3,k)*hprime_xxT(3,j) + &
+                             dummyz_loc(i,4,k)*hprime_xxT(4,j) + &
+                             dummyz_loc(i,5,k)*hprime_xxT(5,j)
           enddo
        enddo
     enddo
 
-    if(ATTENUATION_VAL .and. COMPUTE_AND_STORE_STRAIN) then
-       ! temporary variables used for fixing attenuation in a consistent way
-       do j=1,m1
-          do i=1,m1
-             ! for efficiency it is better to leave this loop on k inside, it leads to slightly faster code
-             do k = 1,NGLLX
-                tempx2_att(i,j,k) = tempx2(i,j,k) + &
-                     dummyx_loc_att(i,1,k)*hprime_xxT(1,j) + &
-                     dummyx_loc_att(i,2,k)*hprime_xxT(2,j) + &
-                     dummyx_loc_att(i,3,k)*hprime_xxT(3,j) + &
-                     dummyx_loc_att(i,4,k)*hprime_xxT(4,j) + &
-                     dummyx_loc_att(i,5,k)*hprime_xxT(5,j)
-
-                tempy2_att(i,j,k) = tempy2(i,j,k) + &
-                     dummyy_loc_att(i,1,k)*hprime_xxT(1,j) + &
-                     dummyy_loc_att(i,2,k)*hprime_xxT(2,j) + &
-                     dummyy_loc_att(i,3,k)*hprime_xxT(3,j) + &
-                     dummyy_loc_att(i,4,k)*hprime_xxT(4,j) + &
-                     dummyy_loc_att(i,5,k)*hprime_xxT(5,j)
-
-                tempz2_att(i,j,k) = tempz2(i,j,k) + &
-                     dummyz_loc_att(i,1,k)*hprime_xxT(1,j) + &
-                     dummyz_loc_att(i,2,k)*hprime_xxT(2,j) + &
-                     dummyz_loc_att(i,3,k)*hprime_xxT(3,j) + &
-                     dummyz_loc_att(i,4,k)*hprime_xxT(4,j) + &
-                     dummyz_loc_att(i,5,k)*hprime_xxT(5,j)
-             enddo
-          enddo
-       enddo
-    else
-       tempx2_att(:,:,:) = 0._CUSTOM_REAL
-       tempy2_att(:,:,:) = 0._CUSTOM_REAL
-       tempz2_att(:,:,:) = 0._CUSTOM_REAL
-    endif
-
     do j=1,m1
        do i=1,m2
           C1_mxm_m2_m1_5points(i,j) = A1_mxm_m2_m1_5points(i,1)*hprime_xxT(1,j) + &
-               A1_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
-               A1_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
-               A1_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
-               A1_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
+                                      A1_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
+                                      A1_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
+                                      A1_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
+                                      A1_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
 
           C2_mxm_m2_m1_5points(i,j) = A2_mxm_m2_m1_5points(i,1)*hprime_xxT(1,j) + &
-               A2_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
-               A2_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
-               A2_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
-               A2_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
+                                      A2_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
+                                      A2_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
+                                      A2_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
+                                      A2_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
 
           C3_mxm_m2_m1_5points(i,j) = A3_mxm_m2_m1_5points(i,1)*hprime_xxT(1,j) + &
-               A3_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
-               A3_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
-               A3_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
-               A3_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
+                                      A3_mxm_m2_m1_5points(i,2)*hprime_xxT(2,j) + &
+                                      A3_mxm_m2_m1_5points(i,3)*hprime_xxT(3,j) + &
+                                      A3_mxm_m2_m1_5points(i,4)*hprime_xxT(4,j) + &
+                                      A3_mxm_m2_m1_5points(i,5)*hprime_xxT(5,j)
        enddo
     enddo
 
     if(ATTENUATION_VAL .and. COMPUTE_AND_STORE_STRAIN) then
        ! temporary variables used for fixing attenuation in a consistent way
+       do j=1,m2
+          do i=1,m1
+             C1_m1_m2_5points_att(i,j) = hprime_xx(i,1)*B1_m1_m2_5points_att(1,j) + &
+                                         hprime_xx(i,2)*B1_m1_m2_5points_att(2,j) + &
+                                         hprime_xx(i,3)*B1_m1_m2_5points_att(3,j) + &
+                                         hprime_xx(i,4)*B1_m1_m2_5points_att(4,j) + &
+                                         hprime_xx(i,5)*B1_m1_m2_5points_att(5,j)
+
+             C2_m1_m2_5points_att(i,j) = hprime_xx(i,1)*B2_m1_m2_5points_att(1,j) + &
+                                         hprime_xx(i,2)*B2_m1_m2_5points_att(2,j) + &
+                                         hprime_xx(i,3)*B2_m1_m2_5points_att(3,j) + &
+                                         hprime_xx(i,4)*B2_m1_m2_5points_att(4,j) + &
+                                         hprime_xx(i,5)*B2_m1_m2_5points_att(5,j)
+
+             C3_m1_m2_5points_att(i,j) = hprime_xx(i,1)*B3_m1_m2_5points_att(1,j) + &
+                                         hprime_xx(i,2)*B3_m1_m2_5points_att(2,j) + &
+                                         hprime_xx(i,3)*B3_m1_m2_5points_att(3,j) + &
+                                         hprime_xx(i,4)*B3_m1_m2_5points_att(4,j) + &
+                                         hprime_xx(i,5)*B3_m1_m2_5points_att(5,j)
+          enddo
+       enddo
+       ! temporary variables used for fixing attenuation in a consistent way
        do j=1,m1
+          do i=1,m1
+             ! for efficiency it is better to leave this loop on k inside, it leads to slightly faster code
+             do k = 1,NGLLX
+                tempx2_att(i,j,k) = dummyx_loc_att(i,1,k)*hprime_xxT(1,j) + &
+                                    dummyx_loc_att(i,2,k)*hprime_xxT(2,j) + &
+                                    dummyx_loc_att(i,3,k)*hprime_xxT(3,j) + &
+                                    dummyx_loc_att(i,4,k)*hprime_xxT(4,j) + &
+                                    dummyx_loc_att(i,5,k)*hprime_xxT(5,j)
+
+                tempy2_att(i,j,k) = dummyy_loc_att(i,1,k)*hprime_xxT(1,j) + &
+                                    dummyy_loc_att(i,2,k)*hprime_xxT(2,j) + &
+                                    dummyy_loc_att(i,3,k)*hprime_xxT(3,j) + &
+                                    dummyy_loc_att(i,4,k)*hprime_xxT(4,j) + &
+                                    dummyy_loc_att(i,5,k)*hprime_xxT(5,j)
+
+                tempz2_att(i,j,k) = dummyz_loc_att(i,1,k)*hprime_xxT(1,j) + &
+                                    dummyz_loc_att(i,2,k)*hprime_xxT(2,j) + &
+                                    dummyz_loc_att(i,3,k)*hprime_xxT(3,j) + &
+                                    dummyz_loc_att(i,4,k)*hprime_xxT(4,j) + &
+                                    dummyz_loc_att(i,5,k)*hprime_xxT(5,j)
+             enddo
+          enddo
+       enddo
+       ! temporary variables used for fixing attenuation in a consistent way
+       do j=1,m1
           do i=1,m2
-             C1_mxm_m2_m1_5points_att(i,j) = C1_mxm_m2_m1_5points(i,j) + &
-                  A1_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
-                  A1_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
-                  A1_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
-                  A1_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
-                  A1_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
+             C1_mxm_m2_m1_5points_att(i,j) = A1_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
+                                             A1_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
+                                             A1_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
+                                             A1_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
+                                             A1_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
 
-             C2_mxm_m2_m1_5points_att(i,j) = C2_mxm_m2_m1_5points(i,j) + &
-                  A2_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
-                  A2_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
-                  A2_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
-                  A2_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
-                  A2_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
+             C2_mxm_m2_m1_5points_att(i,j) = A2_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
+                                             A2_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
+                                             A2_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
+                                             A2_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
+                                             A2_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
 
-             C3_mxm_m2_m1_5points_att(i,j) = C3_mxm_m2_m1_5points(i,j) + &
-                  A3_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
-                  A3_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
-                  A3_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
-                  A3_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
-                  A3_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
+             C3_mxm_m2_m1_5points_att(i,j) = A3_mxm_m2_m1_5points_att(i,1)*hprime_xxT(1,j) + &
+                                             A3_mxm_m2_m1_5points_att(i,2)*hprime_xxT(2,j) + &
+                                             A3_mxm_m2_m1_5points_att(i,3)*hprime_xxT(3,j) + &
+                                             A3_mxm_m2_m1_5points_att(i,4)*hprime_xxT(4,j) + &
+                                             A3_mxm_m2_m1_5points_att(i,5)*hprime_xxT(5,j)
           enddo
        enddo
-    else
-       tempx3_att(:,:,:) = 0._CUSTOM_REAL
-       tempy3_att(:,:,:) = 0._CUSTOM_REAL
-       tempz3_att(:,:,:) = 0._CUSTOM_REAL
-    endif
+    endif ! ATTENUATION_VAL
 
     !
     ! compute either isotropic, transverse isotropic or anisotropic elements
@@ -525,7 +508,7 @@
             tempx1_att,tempx2_att,tempx3_att, &
             tempy1_att,tempy2_att,tempy3_att, &
             tempz1_att,tempz2_att,tempz3_att, &
-            epsilondev_loc,rho_s_H)
+            epsilondev_loc,rho_s_H,is_backward_field)
     else
 
        if( .not. ispec_is_tiso(ispec) ) then
@@ -546,7 +529,7 @@
                tempx1_att,tempx2_att,tempx3_att, &
                tempy1_att,tempy2_att,tempy3_att, &
                tempz1_att,tempz2_att,tempz3_att, &
-               epsilondev_loc,rho_s_H)
+               epsilondev_loc,rho_s_H,is_backward_field)
        else
           ! transverse isotropic element
 
@@ -565,7 +548,7 @@
                tempx1_att,tempx2_att,tempx3_att, &
                tempy1_att,tempy2_att,tempy3_att, &
                tempz1_att,tempz2_att,tempz3_att, &
-               epsilondev_loc,rho_s_H)
+               epsilondev_loc,rho_s_H,is_backward_field)
        endif ! .not. ispec_is_tiso
     endif
 
@@ -575,22 +558,22 @@
     do j=1,m2
       do i=1,m1
         E1_m1_m2_5points(i,j) = hprimewgll_xxT(i,1)*C1_m1_m2_5points(1,j) + &
-                              hprimewgll_xxT(i,2)*C1_m1_m2_5points(2,j) + &
-                              hprimewgll_xxT(i,3)*C1_m1_m2_5points(3,j) + &
-                              hprimewgll_xxT(i,4)*C1_m1_m2_5points(4,j) + &
-                              hprimewgll_xxT(i,5)*C1_m1_m2_5points(5,j)
+                                hprimewgll_xxT(i,2)*C1_m1_m2_5points(2,j) + &
+                                hprimewgll_xxT(i,3)*C1_m1_m2_5points(3,j) + &
+                                hprimewgll_xxT(i,4)*C1_m1_m2_5points(4,j) + &
+                                hprimewgll_xxT(i,5)*C1_m1_m2_5points(5,j)
 
         E2_m1_m2_5points(i,j) = hprimewgll_xxT(i,1)*C2_m1_m2_5points(1,j) + &
-                              hprimewgll_xxT(i,2)*C2_m1_m2_5points(2,j) + &
-                              hprimewgll_xxT(i,3)*C2_m1_m2_5points(3,j) + &
-                              hprimewgll_xxT(i,4)*C2_m1_m2_5points(4,j) + &
-                              hprimewgll_xxT(i,5)*C2_m1_m2_5points(5,j)
+                                hprimewgll_xxT(i,2)*C2_m1_m2_5points(2,j) + &
+                                hprimewgll_xxT(i,3)*C2_m1_m2_5points(3,j) + &
+                                hprimewgll_xxT(i,4)*C2_m1_m2_5points(4,j) + &
+                                hprimewgll_xxT(i,5)*C2_m1_m2_5points(5,j)
 
         E3_m1_m2_5points(i,j) = hprimewgll_xxT(i,1)*C3_m1_m2_5points(1,j) + &
-                              hprimewgll_xxT(i,2)*C3_m1_m2_5points(2,j) + &
-                              hprimewgll_xxT(i,3)*C3_m1_m2_5points(3,j) + &
-                              hprimewgll_xxT(i,4)*C3_m1_m2_5points(4,j) + &
-                              hprimewgll_xxT(i,5)*C3_m1_m2_5points(5,j)
+                                hprimewgll_xxT(i,2)*C3_m1_m2_5points(2,j) + &
+                                hprimewgll_xxT(i,3)*C3_m1_m2_5points(3,j) + &
+                                hprimewgll_xxT(i,4)*C3_m1_m2_5points(4,j) + &
+                                hprimewgll_xxT(i,5)*C3_m1_m2_5points(5,j)
       enddo
     enddo
     do i=1,m1
@@ -598,44 +581,44 @@
         ! for efficiency it is better to leave this loop on k inside, it leads to slightly faster code
         do k = 1,NGLLX
           newtempx2(i,j,k) = tempx2(i,1,k)*hprimewgll_xx(1,j) + &
-                           tempx2(i,2,k)*hprimewgll_xx(2,j) + &
-                           tempx2(i,3,k)*hprimewgll_xx(3,j) + &
-                           tempx2(i,4,k)*hprimewgll_xx(4,j) + &
-                           tempx2(i,5,k)*hprimewgll_xx(5,j)
+                             tempx2(i,2,k)*hprimewgll_xx(2,j) + &
+                             tempx2(i,3,k)*hprimewgll_xx(3,j) + &
+                             tempx2(i,4,k)*hprimewgll_xx(4,j) + &
+                             tempx2(i,5,k)*hprimewgll_xx(5,j)
 
           newtempy2(i,j,k) = tempy2(i,1,k)*hprimewgll_xx(1,j) + &
-                           tempy2(i,2,k)*hprimewgll_xx(2,j) + &
-                           tempy2(i,3,k)*hprimewgll_xx(3,j) + &
-                           tempy2(i,4,k)*hprimewgll_xx(4,j) + &
-                           tempy2(i,5,k)*hprimewgll_xx(5,j)
+                             tempy2(i,2,k)*hprimewgll_xx(2,j) + &
+                             tempy2(i,3,k)*hprimewgll_xx(3,j) + &
+                             tempy2(i,4,k)*hprimewgll_xx(4,j) + &
+                             tempy2(i,5,k)*hprimewgll_xx(5,j)
 
           newtempz2(i,j,k) = tempz2(i,1,k)*hprimewgll_xx(1,j) + &
-                           tempz2(i,2,k)*hprimewgll_xx(2,j) + &
-                           tempz2(i,3,k)*hprimewgll_xx(3,j) + &
-                           tempz2(i,4,k)*hprimewgll_xx(4,j) + &
-                           tempz2(i,5,k)*hprimewgll_xx(5,j)
+                             tempz2(i,2,k)*hprimewgll_xx(2,j) + &
+                             tempz2(i,3,k)*hprimewgll_xx(3,j) + &
+                             tempz2(i,4,k)*hprimewgll_xx(4,j) + &
+                             tempz2(i,5,k)*hprimewgll_xx(5,j)
         enddo
       enddo
     enddo
     do j=1,m1
       do i=1,m2
         E1_mxm_m2_m1_5points(i,j) = C1_mxm_m2_m1_5points(i,1)*hprimewgll_xx(1,j) + &
-                                  C1_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
-                                  C1_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
-                                  C1_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
-                                  C1_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
+                                    C1_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
+                                    C1_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
+                                    C1_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
+                                    C1_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
 
         E2_mxm_m2_m1_5points(i,j) = C2_mxm_m2_m1_5points(i,1)*hprimewgll_xx(1,j) + &
-                                  C2_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
-                                  C2_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
-                                  C2_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
-                                  C2_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
+                                    C2_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
+                                    C2_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
+                                    C2_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
+                                    C2_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
 
         E3_mxm_m2_m1_5points(i,j) = C3_mxm_m2_m1_5points(i,1)*hprimewgll_xx(1,j) + &
-                                  C3_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
-                                  C3_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
-                                  C3_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
-                                  C3_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
+                                    C3_mxm_m2_m1_5points(i,2)*hprimewgll_xx(2,j) + &
+                                    C3_mxm_m2_m1_5points(i,3)*hprimewgll_xx(3,j) + &
+                                    C3_mxm_m2_m1_5points(i,4)*hprimewgll_xx(4,j) + &
+                                    C3_mxm_m2_m1_5points(i,5)*hprimewgll_xx(5,j)
       enddo
     enddo
 
@@ -699,15 +682,20 @@
 
     if(ATTENUATION_VAL .and. ( USE_ATTENUATION_MIMIC .eqv. .false. ) ) then
 
+!daniel: att - debug update R_memory variable only if not last time step which will be saved..
+!      if( .not. it == NSTEP ) then
+
       ! updates R_memory
-      call compute_element_att_memory_cr(ispec,R_xx,R_yy,R_xy,R_xz,R_yz, &
-                                      vx,vy,vz,vnspec,factor_common, &
-                                      alphaval,betaval,gammaval, &
-                                      c44store,muvstore, &
-                                      epsilondev_xx,epsilondev_yy,epsilondev_xy, &
-                                      epsilondev_xz,epsilondev_yz, &
-                                      epsilondev_loc)
+      call compute_element_att_memory_cm(ispec,R_xx,R_yy,R_xy,R_xz,R_yz, &
+                                         vx,vy,vz,vnspec,factor_common, &
+                                         alphaval,betaval,gammaval, &
+                                         c44store,muvstore, &
+                                         epsilondev_xx,epsilondev_yy,epsilondev_xy, &
+                                         epsilondev_xz,epsilondev_yz, &
+                                         epsilondev_loc,is_backward_field)
 
+!      endif
+
     endif
 
     ! save deviatoric strain for Runge-Kutta scheme

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_elastic.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_elastic.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_elastic.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -42,9 +42,45 @@
   ! non blocking MPI
   ! iphase: iphase = 1 is for computing outer elements in the crust_mantle and inner_core regions,
   !              iphase = 2 is for computing inner elements (former icall parameter)
-  integer :: iphase,NGLOB_XY
+  integer :: iphase
   logical :: phase_is_inner
 
+
+!daniel: att - debug
+!  integer :: iglob
+!  logical,parameter :: DEBUG = .false.
+!  if( DEBUG ) then
+!    iglob = ibool_crust_mantle(1,1,1,100)
+!    if( SIMULATION_TYPE == 1) then
+!      if( it == NSTEP .and. myrank == 0 ) then
+!        print*,'last step',it,'Rxx:',R_xx_crust_mantle(1,1,1,1,100),epsilondev_xx_crust_mantle(1,1,1,100), &
+!          displ_crust_mantle(1,iglob),displ_crust_mantle(2,iglob),displ_crust_mantle(3,iglob)
+!      endif
+!      if( it == NSTEP-1 .and. myrank == 0 ) then
+!        print*,'second last step',it,'Rxx:',R_xx_crust_mantle(1,1,1,1,100),epsilondev_xx_crust_mantle(1,1,1,100), &
+!          displ_crust_mantle(1,iglob),displ_crust_mantle(2,iglob),displ_crust_mantle(3,iglob)
+!      endif
+!      if( it == NSTEP-2 .and. myrank == 0 ) then
+!        print*,'third last step',it,'Rxx:',R_xx_crust_mantle(1,1,1,1,100),epsilondev_xx_crust_mantle(1,1,1,100), &
+!          displ_crust_mantle(1,iglob),displ_crust_mantle(2,iglob),displ_crust_mantle(3,iglob)
+!      endif
+!    elseif( SIMULATION_TYPE == 3 ) then
+!      if( it == 1 .and. myrank == 0 ) then
+!        print*,'first step',it,'Rxx:',b_R_xx_crust_mantle(1,1,1,1,100),b_epsilondev_xx_crust_mantle(1,1,1,100), &
+!          b_displ_crust_mantle(1,iglob),b_displ_crust_mantle(2,iglob),b_displ_crust_mantle(3,iglob)
+!      endif
+!      if( it == 2 .and. myrank == 0 ) then
+!        print*,'second step',it,'Rxx:',b_R_xx_crust_mantle(1,1,1,1,100),b_epsilondev_xx_crust_mantle(1,1,1,100), &
+!          b_displ_crust_mantle(1,iglob),b_displ_crust_mantle(2,iglob),b_displ_crust_mantle(3,iglob)
+!      endif
+!      if( it == 3 .and. myrank == 0 ) then
+!        print*,'third step',it,'Rxx:',b_R_xx_crust_mantle(1,1,1,1,100),b_epsilondev_xx_crust_mantle(1,1,1,100), &
+!          b_displ_crust_mantle(1,iglob),b_displ_crust_mantle(2,iglob),b_displ_crust_mantle(3,iglob)
+!      endif
+!    endif
+!  endif
+
+
   ! ****************************************************
   !   big loop over all spectral elements in the solid
   ! ****************************************************
@@ -88,7 +124,7 @@
                eps_trace_over_3_crust_mantle, &
                alphaval,betaval,gammaval,factor_common_crust_mantle, &
                size(factor_common_crust_mantle,2), size(factor_common_crust_mantle,3), &
-               size(factor_common_crust_mantle,4), size(factor_common_crust_mantle,5) )
+               size(factor_common_crust_mantle,4), size(factor_common_crust_mantle,5), .false. )
           ! inner core region
           call compute_forces_inner_core_Dev( NSPEC_INNER_CORE_STR_OR_ATT,NGLOB_INNER_CORE, &
                NSPEC_INNER_CORE_ATTENUATION, &
@@ -102,7 +138,7 @@
                alphaval,betaval,gammaval, &
                factor_common_inner_core, &
                size(factor_common_inner_core,2), size(factor_common_inner_core,3), &
-               size(factor_common_inner_core,4), size(factor_common_inner_core,5) )
+               size(factor_common_inner_core,4), size(factor_common_inner_core,5), .false. )
 
        else
           ! no Deville optimization
@@ -155,7 +191,7 @@
                   b_eps_trace_over_3_crust_mantle, &
                   b_alphaval,b_betaval,b_gammaval,factor_common_crust_mantle, &
                   size(factor_common_crust_mantle,2), size(factor_common_crust_mantle,3), &
-                  size(factor_common_crust_mantle,4), size(factor_common_crust_mantle,5) )
+                  size(factor_common_crust_mantle,4), size(factor_common_crust_mantle,5), .true. )
              ! inner core region
              call compute_forces_inner_core_Dev( NSPEC_INNER_CORE_ADJOINT,NGLOB_INNER_CORE_ADJOINT, &
                   NSPEC_INNER_CORE_STR_AND_ATT, &
@@ -170,7 +206,7 @@
                   b_alphaval,b_betaval,b_gammaval, &
                   factor_common_inner_core, &
                   size(factor_common_inner_core,2), size(factor_common_inner_core,3), &
-                  size(factor_common_inner_core,4), size(factor_common_inner_core,5) )
+                  size(factor_common_inner_core,4), size(factor_common_inner_core,5), .true. )
 
           else
              ! no Deville optimization
@@ -332,36 +368,36 @@
         call assemble_MPI_vector_s(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                       accel_crust_mantle, &
                       buffer_send_vector_crust_mantle,buffer_recv_vector_crust_mantle, &
-                      num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                      num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                       nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                       my_neighbours_crust_mantle, &
-                      request_send_vector_crust_mantle,request_recv_vector_crust_mantle)
+                      request_send_vector_cm,request_recv_vector_cm)
         ! inner core
         call assemble_MPI_vector_s(NPROCTOT_VAL,NGLOB_INNER_CORE, &
                       accel_inner_core, &
                       buffer_send_vector_inner_core,buffer_recv_vector_inner_core, &
-                      num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                      num_interfaces_inner_core,max_nibool_interfaces_ic, &
                       nibool_interfaces_inner_core,ibool_interfaces_inner_core,&
                       my_neighbours_inner_core, &
-                      request_send_vector_inner_core,request_recv_vector_inner_core)
+                      request_send_vector_ic,request_recv_vector_ic)
       else
         ! on GPU
         ! crust mantle
         call assemble_MPI_vector_send_cuda(NPROCTOT_VAL, &
                       buffer_send_vector_crust_mantle,buffer_recv_vector_crust_mantle, &
-                      num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                      num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                       nibool_interfaces_crust_mantle,&
                       my_neighbours_crust_mantle, &
-                      request_send_vector_crust_mantle,request_recv_vector_crust_mantle, &
+                      request_send_vector_cm,request_recv_vector_cm, &
                       IREGION_CRUST_MANTLE, &
                       1) ! <-- 1 == fwd accel
         ! inner core
         call assemble_MPI_vector_send_cuda(NPROCTOT_VAL, &
                       buffer_send_vector_inner_core,buffer_recv_vector_inner_core, &
-                      num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                      num_interfaces_inner_core,max_nibool_interfaces_ic, &
                       nibool_interfaces_inner_core,&
                       my_neighbours_inner_core, &
-                      request_send_vector_inner_core,request_recv_vector_inner_core, &
+                      request_send_vector_ic,request_recv_vector_ic, &
                       IREGION_INNER_CORE, &
                       1)
       endif ! GPU_MODE
@@ -374,37 +410,37 @@
           ! crust mantle
           call assemble_MPI_vector_s(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                         b_accel_crust_mantle, &
-                        b_buffer_send_vector_crust_mantle,b_buffer_recv_vector_crust_mantle, &
-                        num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                        b_buffer_send_vector_cm,b_buffer_recv_vector_cm, &
+                        num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                         nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                         my_neighbours_crust_mantle, &
-                        b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle)
+                        b_request_send_vector_cm,b_request_recv_vector_cm)
           ! inner core
           call assemble_MPI_vector_s(NPROCTOT_VAL,NGLOB_INNER_CORE, &
                         b_accel_inner_core, &
                         b_buffer_send_vector_inner_core,b_buffer_recv_vector_inner_core, &
-                        num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                        num_interfaces_inner_core,max_nibool_interfaces_ic, &
                         nibool_interfaces_inner_core,ibool_interfaces_inner_core,&
                         my_neighbours_inner_core, &
-                        b_request_send_vector_inner_core,b_request_recv_vector_inner_core)
+                        b_request_send_vector_ic,b_request_recv_vector_ic)
         else
           ! on GPU
           ! crust mantle
           call assemble_MPI_vector_send_cuda(NPROCTOT_VAL, &
-                      b_buffer_send_vector_crust_mantle,b_buffer_recv_vector_crust_mantle, &
-                      num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                      b_buffer_send_vector_cm,b_buffer_recv_vector_cm, &
+                      num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                       nibool_interfaces_crust_mantle,&
                       my_neighbours_crust_mantle, &
-                      b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle, &
+                      b_request_send_vector_cm,b_request_recv_vector_cm, &
                       IREGION_CRUST_MANTLE, &
                       3) ! <-- 3 == adjoint b_accel
           ! inner core
           call assemble_MPI_vector_send_cuda(NPROCTOT_VAL, &
                       b_buffer_send_vector_inner_core,b_buffer_recv_vector_inner_core, &
-                      num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                      num_interfaces_inner_core,max_nibool_interfaces_ic, &
                       nibool_interfaces_inner_core,&
                       my_neighbours_inner_core, &
-                      b_request_send_vector_inner_core,b_request_recv_vector_inner_core, &
+                      b_request_send_vector_ic,b_request_recv_vector_ic, &
                       IREGION_INNER_CORE, &
                       3)
         endif ! GPU
@@ -418,30 +454,30 @@
         call assemble_MPI_vector_w(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                               accel_crust_mantle, &
                               buffer_recv_vector_crust_mantle,num_interfaces_crust_mantle,&
-                              max_nibool_interfaces_crust_mantle, &
+                              max_nibool_interfaces_cm, &
                               nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
-                              request_send_vector_crust_mantle,request_recv_vector_crust_mantle)
+                              request_send_vector_cm,request_recv_vector_cm)
         ! inner core
         call assemble_MPI_vector_w(NPROCTOT_VAL,NGLOB_INNER_CORE, &
                               accel_inner_core, &
                               buffer_recv_vector_inner_core,num_interfaces_inner_core,&
-                              max_nibool_interfaces_inner_core, &
+                              max_nibool_interfaces_ic, &
                               nibool_interfaces_inner_core,ibool_interfaces_inner_core, &
-                              request_send_vector_inner_core,request_recv_vector_inner_core)
+                              request_send_vector_ic,request_recv_vector_ic)
       else
         ! on GPU
         ! crust mantle
         call assemble_MPI_vector_write_cuda(NPROCTOT_VAL, &
                             buffer_recv_vector_crust_mantle, &
-                            num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
-                            request_send_vector_crust_mantle,request_recv_vector_crust_mantle, &
+                            num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
+                            request_send_vector_cm,request_recv_vector_cm, &
                             IREGION_CRUST_MANTLE, &
                             1) ! <-- 1 == fwd accel
         ! inner core
         call assemble_MPI_vector_write_cuda(NPROCTOT_VAL, &
                             buffer_recv_vector_inner_core, &
-                            num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
-                            request_send_vector_inner_core,request_recv_vector_inner_core, &
+                            num_interfaces_inner_core,max_nibool_interfaces_ic, &
+                            request_send_vector_ic,request_recv_vector_ic, &
                             IREGION_INNER_CORE, &
                             1)
       endif
@@ -455,32 +491,32 @@
           ! crust mantle
           call assemble_MPI_vector_w(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                               b_accel_crust_mantle, &
-                              b_buffer_recv_vector_crust_mantle,num_interfaces_crust_mantle,&
-                              max_nibool_interfaces_crust_mantle, &
+                              b_buffer_recv_vector_cm,num_interfaces_crust_mantle,&
+                              max_nibool_interfaces_cm, &
                               nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
-                              b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle)
+                              b_request_send_vector_cm,b_request_recv_vector_cm)
           ! inner core
           call assemble_MPI_vector_w(NPROCTOT_VAL,NGLOB_INNER_CORE, &
                               b_accel_inner_core, &
                               b_buffer_recv_vector_inner_core,num_interfaces_inner_core,&
-                              max_nibool_interfaces_inner_core, &
+                              max_nibool_interfaces_ic, &
                               nibool_interfaces_inner_core,ibool_interfaces_inner_core, &
-                              b_request_send_vector_inner_core,b_request_recv_vector_inner_core)
+                              b_request_send_vector_ic,b_request_recv_vector_ic)
 
         else
           ! on GPU
           ! crust mantle
           call assemble_MPI_vector_write_cuda(NPROCTOT_VAL, &
-                            b_buffer_recv_vector_crust_mantle, &
-                            num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
-                            b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle, &
+                            b_buffer_recv_vector_cm, &
+                            num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
+                            b_request_send_vector_cm,b_request_recv_vector_cm, &
                             IREGION_CRUST_MANTLE, &
                             3) ! <-- 3 == adjoint b_accel
           ! inner core
           call assemble_MPI_vector_write_cuda(NPROCTOT_VAL,&
                             b_buffer_recv_vector_inner_core, &
-                            num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
-                            b_request_send_vector_inner_core,b_request_recv_vector_inner_core, &
+                            num_interfaces_inner_core,max_nibool_interfaces_ic, &
+                            b_request_send_vector_ic,b_request_recv_vector_ic, &
                             IREGION_INNER_CORE, &
                             3)
         endif
@@ -489,22 +525,16 @@
 
   enddo ! iphase
 
-  if( NCHUNKS_VAL /= 6 .and. ABSORBING_CONDITIONS ) then
-     NGLOB_XY = NGLOB_CRUST_MANTLE
-  else
-     NGLOB_XY = 1
-  endif
-
   ! updates (only) acceleration w/ rotation in the crust/mantle region (touches oceans)
   if(.NOT. GPU_MODE) then
      ! on CPU
-     call compute_forces_el_update_accel(NGLOB_CRUST_MANTLE,NGLOB_XY,veloc_crust_mantle,accel_crust_mantle, &
+     call compute_forces_el_update_accel(NGLOB_CRUST_MANTLE,NGLOB_XY_CM,veloc_crust_mantle,accel_crust_mantle, &
                                         two_omega_earth, &
                                         rmassx_crust_mantle,rmassy_crust_mantle,rmassz_crust_mantle, &
                                         NCHUNKS_VAL,ABSORBING_CONDITIONS)
      ! adjoint / kernel runs
      if (SIMULATION_TYPE == 3) &
-          call compute_forces_el_update_accel(NGLOB_CRUST_MANTLE_ADJOINT,NGLOB_XY,b_veloc_crust_mantle,b_accel_crust_mantle, &
+          call compute_forces_el_update_accel(NGLOB_CRUST_MANTLE_ADJOINT,NGLOB_XY_CM,b_veloc_crust_mantle,b_accel_crust_mantle, &
                                              b_two_omega_earth, &
                                              rmassx_crust_mantle,rmassy_crust_mantle,rmassz_crust_mantle, &
                                              NCHUNKS_VAL,ABSORBING_CONDITIONS)
@@ -523,7 +553,7 @@
              rmassx_crust_mantle, rmassy_crust_mantle, rmassz_crust_mantle, &
              rmass_ocean_load,normal_top_crust_mantle, &
              ibool_crust_mantle,ibelm_top_crust_mantle, &
-             updated_dof_ocean_load,NGLOB_XY, &
+             updated_dof_ocean_load,NGLOB_XY_CM, &
              SIMULATION_TYPE,NSPEC2D_TOP(IREGION_CRUST_MANTLE), &
              ABSORBING_CONDITIONS)
 
@@ -552,6 +582,20 @@
                         deltatover2,SIMULATION_TYPE,b_deltatover2)
   endif
 
+
+!daniel: att - debug
+!  if( DEBUG ) then
+!    if( SIMULATION_TYPE == 1) then
+!      if( it > NSTEP - 1000 .and. myrank == 0 ) then
+!        print*,'it',it,'Rxx:',R_xx_crust_mantle(1,1,1,1,100),epsilondev_xx_crust_mantle(1,1,1,100)
+!      endif
+!    elseif( SIMULATION_TYPE == 3 ) then
+!      if( it <= 1000 .and. myrank == 0 ) then
+!        print*,'it',it,'Rxx:',b_R_xx_crust_mantle(1,1,1,1,100),b_epsilondev_xx_crust_mantle(1,1,1,100)
+!      endif
+!    endif
+!  endif
+
   end subroutine compute_forces_elastic
 
 

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_inner_core_Dev.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_inner_core_Dev.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/compute_forces_inner_core_Dev.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -45,7 +45,7 @@
                                             epsilondev_xz,epsilondev_yz, &
                                             epsilon_trace_over_3,&
                                             alphaval,betaval,gammaval,factor_common, &
-                                            vx,vy,vz,vnspec)
+                                            vx,vy,vz,vnspec,is_backward_field)
 
 ! this routine is optimized for NGLLX = NGLLY = NGLLZ = 5 using the Deville et al. (2002) inlined matrix-matrix products
 
@@ -100,6 +100,8 @@
   ! inner/outer element run flag
   logical :: phase_is_inner
 
+  logical :: is_backward_field
+
   ! local parameters
 
   ! Deville
@@ -695,11 +697,11 @@
 
               ! note: fortran passes pointers to array location, thus R_memory(1,1,...) should be fine
               call compute_element_att_stress(R_xx(1,i,j,k,ispec), &
-                                             R_yy(1,i,j,k,ispec), &
-                                             R_xy(1,i,j,k,ispec), &
-                                             R_xz(1,i,j,k,ispec), &
-                                             R_yz(1,i,j,k,ispec), &
-                                             sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
+                                              R_yy(1,i,j,k,ispec), &
+                                              R_xy(1,i,j,k,ispec), &
+                                              R_xz(1,i,j,k,ispec), &
+                                              R_yz(1,i,j,k,ispec), &
+                                              sigma_xx,sigma_yy,sigma_zz,sigma_xy,sigma_xz,sigma_yz)
 
             endif
 
@@ -970,7 +972,7 @@
                                       muvstore, &
                                       epsilondev_xx,epsilondev_yy,epsilondev_xy, &
                                       epsilondev_xz,epsilondev_yz, &
-                                      epsilondev_loc)
+                                      epsilondev_loc,is_backward_field)
 
       endif
 

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/finalize_simulation.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -151,19 +151,19 @@
 
   ! mpi buffers
   deallocate(buffer_send_vector_crust_mantle,buffer_recv_vector_crust_mantle, &
-            request_send_vector_crust_mantle,request_recv_vector_crust_mantle)
+            request_send_vector_cm,request_recv_vector_cm)
   deallocate(buffer_send_scalar_outer_core,buffer_recv_scalar_outer_core, &
-            request_send_scalar_outer_core,request_recv_scalar_outer_core)
+            request_send_scalar_oc,request_recv_scalar_oc)
   deallocate(buffer_send_vector_inner_core,buffer_recv_vector_inner_core, &
-            request_send_vector_inner_core,request_recv_vector_inner_core)
+            request_send_vector_ic,request_recv_vector_ic)
 
   if( SIMULATION_TYPE == 3 ) then
-    deallocate(b_buffer_send_vector_crust_mantle,b_buffer_recv_vector_crust_mantle, &
-              b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle)
+    deallocate(b_buffer_send_vector_cm,b_buffer_recv_vector_cm, &
+              b_request_send_vector_cm,b_request_recv_vector_cm)
     deallocate(b_buffer_send_scalar_outer_core,b_buffer_recv_scalar_outer_core, &
-              b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core)
+              b_request_send_scalar_oc,b_request_recv_scalar_oc)
     deallocate(b_buffer_send_vector_inner_core,b_buffer_recv_vector_inner_core, &
-              b_request_send_vector_inner_core,b_request_recv_vector_inner_core)
+              b_request_send_vector_ic,b_request_recv_vector_ic)
   endif
 
   deallocate(my_neighbours_crust_mantle,nibool_interfaces_crust_mantle)
@@ -244,6 +244,19 @@
               mask_noise,noise_surface_movie)
   endif
 
+  ! vtk visualization
+  if( VTK_MODE ) then
+    ! closes/cleans up vtk window
+    if(myrank == 0 ) call finish_vtkwindow()
+
+    ! frees memory
+    deallocate(vtkdata,vtkmask)
+    if( NPROCTOT_VAL > 1 ) then
+      deallocate(vtkdata_points_all,vtkdata_offset_all)
+      if( myrank == 0 ) deallocate(vtkdata_all)
+    endif
+  endif
+
   ! close the main output file
   if(myrank == 0) then
     write(IMAIN,*)

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/get_attenuation.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -96,6 +96,7 @@
       enddo
     enddo
   else
+    ! uses 1-D arrays for attenuation
     do ispec = 1, vnspec
       tau_e(:) = factor_common(:,1,1,1,ispec)
       Q_mu     = scale_factor(1,1,1,ispec)

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/initialize_simulation.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -29,6 +29,7 @@
   subroutine initialize_simulation()
 
   use specfem_par
+  use specfem_par_movie
 
   implicit none
 
@@ -309,6 +310,11 @@
   ! initializes GPU cards
   if( GPU_MODE ) call initialize_GPU()
 
+  ! initializes VTK window
+  if( VTK_MODE ) then
+    if(myrank == 0 ) call initialize_vtkwindow(GPU_MODE)
+  endif
+
   end subroutine initialize_simulation
 
 !
@@ -425,11 +431,16 @@
     if ( ATTENUATION_VAL) then
       ! checks mimic flag:
       ! attenuation for adjoint simulations must have USE_ATTENUATION_MIMIC set by xcreate_header_file
+
+!daniel: att - debug todo check attenuation mimick
       if( USE_ATTENUATION_MIMIC .eqv. .false. ) &
         call exit_MPI(myrank,'error in compiled attenuation parameters, please recompile solver 17b')
 
       ! user output
-      if( myrank == 0 ) write(IMAIN,*) 'incorporates ATTENUATION for time-reversed simulation'
+      if( myrank == 0 ) then
+        write(IMAIN,*) 'incorporates ATTENUATION for time-reversed simulation'
+        write(IMAIN,*)
+      endif
     endif
 
     ! checks adjoint array dimensions

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/iterate_time.F90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/iterate_time.F90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/iterate_time.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -115,10 +115,15 @@
 
     ! first step of noise tomography, i.e., save a surface movie at every time step
     ! modified from the subroutine 'write_movie_surface'
-    if ( NOISE_TOMOGRAPHY == 1 ) then
+    if( NOISE_TOMOGRAPHY == 1 ) then
       call noise_save_surface_movie()
     endif
 
+    ! updates vtk window
+    if( VTK_MODE ) then
+      call it_update_vtkwindow()
+    endif
+
   enddo   ! end of main time loop
 
   !
@@ -478,7 +483,7 @@
                         SIMULATION_TYPE,OUTPUT_FILES,time_start,DT,t0,NSTEP, &
                         myrank)
 
-  ! daniel: debugging
+  ! debug output
   !if( maxval(displ_crust_mantle(1,:)**2 + &
   !                displ_crust_mantle(2,:)**2 + displ_crust_mantle(3,:)**2) > 1.e4 ) then
   !  print*,'slice',myrank
@@ -578,3 +583,73 @@
   call prepare_cleanup_device(Mesh_pointer,NCHUNKS_VAL)
 
   end subroutine it_transfer_from_GPU
+
+!=====================================================================
+
+
+  subroutine it_update_vtkwindow()
+
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_movie
+
+  implicit none
+
+  real :: currenttime
+  integer :: iglob,inum
+  real(kind=CUSTOM_REAL),dimension(1):: dummy
+
+  ! vtk rendering at frame interval
+  if( mod(it,NTSTEP_BETWEEN_FRAMES) == 0 ) then
+
+    ! user output
+    !if( myrank == 0 ) print*,"  vtk rendering..."
+
+    ! updates time
+    currenttime = sngl((it-1)*DT-t0)
+
+    ! transfers fields from GPU to host
+    if( GPU_MODE ) then
+      !if( myrank == 0 ) print*,"  vtk: transfering velocity from gpu"
+      call transfer_veloc_cm_from_device(NDIM*NGLOB_CRUST_MANTLE,veloc_crust_mantle,Mesh_pointer)
+    endif
+
+    ! updates wavefield
+    !if( myrank == 0 ) print*,"  vtk: it = ",it," out of ",it_end," - norm of velocity field"
+    inum = 0
+    vtkdata(:) = 0.0
+    do iglob = 1,NGLOB_CRUST_MANTLE
+      if( vtkmask(iglob) .eqv. .true. ) then
+        inum = inum + 1
+        ! stores norm of velocity vector
+        vtkdata(inum) = sqrt(veloc_crust_mantle(1,iglob)**2 &
+                           + veloc_crust_mantle(2,iglob)**2 &
+                           + veloc_crust_mantle(3,iglob)**2)
+      endif
+    enddo
+
+    ! updates for multiple mpi process
+    if( NPROCTOT_VAL > 1 ) then
+      if( myrank == 0 ) then
+        ! gather data
+        call gatherv_all_cr(vtkdata,size(vtkdata),&
+                            vtkdata_all,vtkdata_points_all,vtkdata_offset_all, &
+                            vtkdata_numpoints_all,NPROCTOT_VAL)
+        ! updates vtk window
+        call visualize_vtkdata(it,currenttime,vtkdata_all)
+      else
+        ! all other process just send data
+        call gatherv_all_cr(vtkdata,size(vtkdata),&
+                            dummy,vtkdata_points_all,vtkdata_offset_all, &
+                            1,NPROCTOT_VAL)
+      endif
+    else
+      ! serial run
+      ! updates vtk window
+      call visualize_vtkdata(it,currenttime,vtkdata)
+    endif
+
+  endif
+
+  end subroutine it_update_vtkwindow
+

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -44,6 +44,8 @@
     xi_source,eta_source,gamma_source,nu_source, &
     islice_selected_source,ispec_selected_source
 
+  use specfem_par_movie,only: vtkdata_source_x,vtkdata_source_y,vtkdata_source_z
+
   implicit none
 
   ! standard include of the MPI library
@@ -166,10 +168,10 @@
   call hex_nodes(iaddx,iaddy,iaddr)
 
   ! compute typical size of elements at the surface
-  typical_size = TWO_PI * R_UNIT_SPHERE / (4.*NEX_XI_VAL)
+  typical_size = TWO_PI * R_UNIT_SPHERE / (4.0 * NEX_XI_VAL)
 
   ! use 10 times the distance as a criterion for source detection
-  typical_size = 10. * typical_size
+  typical_size = 10.0 * typical_size
 
   ! initializes source mask
   if( SAVE_SOURCE_MASK .and. SIMULATION_TYPE == 3 ) then
@@ -328,8 +330,9 @@
       y_target_source = r_target_source*dsin(theta)*dsin(phi)
       z_target_source = r_target_source*dcos(theta)
 
+      ! debug
       ! would only output desired target locations
-      !if(myrank == 0) write(IOVTK,*) sngl(x_target_source),sngl(y_target_source),sngl(z_target_source)
+      !if(myrank == 0) print*,sngl(x_target_source),sngl(y_target_source),sngl(z_target_source)
 
       ! set distance to huge initial value
       distmin = HUGEVAL
@@ -393,6 +396,7 @@
                 iy_initial_guess_source = j
                 iz_initial_guess_source = k
                 located_target = .true.
+                !debug
                 !print*,myrank,'dist:',distmin*R_EARTH/1000.d0,i,j,k,ispec
               endif
 
@@ -704,6 +708,13 @@
           write(IMAIN,*) '*****************************************************'
         endif
 
+        ! stores location for vtk visualization
+        if(isource == 1 ) then
+          vtkdata_source_x = sngl(x_found_source(isource_in_this_subset))
+          vtkdata_source_y = sngl(y_found_source(isource_in_this_subset))
+          vtkdata_source_z = sngl(z_found_source(isource_in_this_subset))
+        endif
+
       enddo ! end of loop on all the sources within current source subset
 
     endif ! end of section executed by main process only

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/prepare_timerun.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -50,12 +50,12 @@
 
   ! allocate files to save movies
   ! for noise tomography, store_val_x/y/z/ux/uy/uz needed for 'surface movie'
-  if(MOVIE_SURFACE .or. NOISE_TOMOGRAPHY /= 0 ) then
+  if( MOVIE_SURFACE .or. NOISE_TOMOGRAPHY /= 0 ) then
     call prepare_timerun_movie_surface()
   endif
 
   ! output point and element information for 3D movies
-  if(MOVIE_VOLUME) call prepare_timerun_movie_volume()
+  if( MOVIE_VOLUME ) call prepare_timerun_movie_volume()
 
   ! sets up time increments and rotation constants
   call prepare_timerun_constants()
@@ -76,14 +76,17 @@
   call read_forward_arrays_startrun()
 
   ! prepares stacey boundary arrays for re-construction of wavefields
-  if(ABSORBING_CONDITIONS) call prepare_timerun_stacey()
+  if( ABSORBING_CONDITIONS ) call prepare_timerun_stacey()
 
   ! prepares noise simulations
   call prepare_timerun_noise()
 
   ! prepares GPU arrays
-  if(GPU_MODE) call prepare_timerun_GPU()
+  if( GPU_MODE ) call prepare_timerun_GPU()
 
+  ! prepares vtk window visualization
+  if( VTK_MODE ) call prepare_vtk_window()
+
   ! synchronize all the processes
   call sync_all()
 
@@ -104,11 +107,15 @@
 
     ! daniel: total time estimation
     !  average time per element per time step:
-    !     isotropic models              ~ dt = 3.1857107305545455e-05
-    !     transverse isotropic models   ~ dt = 3.7492335549202518e-05
+    !     global simulations:
+    !       isotropic models              ~ dt = 3.1857107305545455e-05
+    !       transverse isotropic models   ~ dt = 3.7492335549202518e-05
+    !                                            4.2252082718299598e-05 w/ attenuation (intel xeon @ 2.67GHz)
+    !                                            1.0069202789238270e-04 w/ simulation_type==3 (intel xeon @ 2.67GHz)
+    !     regional simulations:
+    !       transverse isotropic models   ~ dt = 4.3039939919998860e-05 w/ attenuation (intel xeon @ 2.67GHz)
+    !                                            7.6099242919530619e-05 (intel xeon @ 2.27GHz)
     !
-    !     regional transverse isotropic models ~ dt = 7.6099242919530619e-05 (intel xeon @ 2.27GHz)
-    !
     !  total time per time step:
     !     T_total = dt * total_number_of_elements
     !
@@ -263,7 +270,7 @@
   if (OCEANS_VAL) then
     call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                         rmass_ocean_load, &
-                        num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                        num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                         nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                         my_neighbours_crust_mantle)
   endif
@@ -272,34 +279,34 @@
   if(NCHUNKS_VAL /= 6 .and. ABSORBING_CONDITIONS) then
      call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                            rmassx_crust_mantle, &
-                           num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                           num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                            nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                            my_neighbours_crust_mantle)
 
      call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                            rmassy_crust_mantle, &
-                           num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                           num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                            nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                            my_neighbours_crust_mantle)
   endif
 
   call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_CRUST_MANTLE, &
                         rmassz_crust_mantle, &
-                        num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                        num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                         nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle,&
                         my_neighbours_crust_mantle)
 
   ! outer core
   call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_OUTER_CORE, &
                         rmass_outer_core, &
-                        num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                        num_interfaces_outer_core,max_nibool_interfaces_oc, &
                         nibool_interfaces_outer_core,ibool_interfaces_outer_core,&
                         my_neighbours_outer_core)
 
   ! inner core
   call assemble_MPI_scalar(NPROCTOT_VAL,NGLOB_INNER_CORE, &
                         rmass_inner_core, &
-                        num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                        num_interfaces_inner_core,max_nibool_interfaces_ic, &
                         nibool_interfaces_inner_core,ibool_interfaces_inner_core,&
                         my_neighbours_inner_core)
 
@@ -702,7 +709,6 @@
   double precision, dimension(:,:,:,:,:), allocatable :: factor_common_inner_core_dble
 
   double precision, dimension(N_SLS) :: alphaval_dble, betaval_dble, gammaval_dble
-  double precision, dimension(N_SLS) :: tau_sigma_dble
   double precision :: scale_factor,scale_factor_minus_one
 
   real(kind=CUSTOM_REAL) :: mul
@@ -736,7 +742,7 @@
   omsb_crust_mantle_dble = 0.d0
   factor_common_crust_mantle_dble = 0.d0
   factor_scale_crust_mantle_dble = 0.d0
-  tau_sigma_dble = 0.d0
+  tau_sigma_dble(:) = 0.d0
 
   ! reads in attenuation values
   call create_name_database(prnamel, myrank, IREGION_CRUST_MANTLE, LOCAL_PATH)
@@ -1551,10 +1557,14 @@
     call prepare_fields_attenuat_device(Mesh_pointer, &
                                         R_xx_crust_mantle,R_yy_crust_mantle,R_xy_crust_mantle, &
                                         R_xz_crust_mantle,R_yz_crust_mantle, &
+                                        b_R_xx_crust_mantle,b_R_yy_crust_mantle,b_R_xy_crust_mantle, &
+                                        b_R_xz_crust_mantle,b_R_yz_crust_mantle, &
                                         factor_common_crust_mantle, &
                                         one_minus_sum_beta_crust_mantle, &
                                         R_xx_inner_core,R_yy_inner_core,R_xy_inner_core, &
                                         R_xz_inner_core,R_yz_inner_core, &
+                                        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, &
                                         factor_common_inner_core, &
                                         one_minus_sum_beta_inner_core, &
                                         alphaval,betaval,gammaval, &
@@ -1618,11 +1628,11 @@
   if(myrank == 0 ) write(IMAIN,*) "  loading mpi interfaces"
 
   call prepare_mpi_buffers_device(Mesh_pointer, &
-                                num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
+                                num_interfaces_crust_mantle,max_nibool_interfaces_cm, &
                                 nibool_interfaces_crust_mantle,ibool_interfaces_crust_mantle, &
-                                num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
+                                num_interfaces_inner_core,max_nibool_interfaces_ic, &
                                 nibool_interfaces_inner_core,ibool_interfaces_inner_core, &
-                                num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
+                                num_interfaces_outer_core,max_nibool_interfaces_oc, &
                                 nibool_interfaces_outer_core,ibool_interfaces_outer_core)
 
   ! prepares fields on GPU for noise simulations
@@ -1828,3 +1838,622 @@
   endif
 
   end subroutine prepare_timerun_GPU
+
+!
+!-------------------------------------------------------------------------------------------------
+!
+
+! VTK visualization
+
+  subroutine prepare_vtk_window()
+
+  use specfem_par
+  use specfem_par_crustmantle
+  use specfem_par_movie
+
+  implicit none
+
+  ! local parameters
+  integer :: i,j,k,iglob,ispec,inum,ier
+  integer :: id1,id2,id3,id4,id5,id6,id7,id8
+  integer :: ispec2D,NIT_res
+
+  ! free surface points
+  integer :: free_np,free_nspec
+  real, dimension(:),allocatable :: free_x,free_y,free_z
+  integer, dimension(:,:),allocatable :: free_conn
+  integer, dimension(:),allocatable :: free_perm
+  ! gather arrays for multi-mpi simulations
+  real, dimension(:),allocatable :: free_x_all,free_y_all,free_z_all
+  integer, dimension(:,:),allocatable :: free_conn_all
+  integer, dimension(:),allocatable :: free_conn_offset_all,free_conn_nspec_all
+  integer, dimension(:),allocatable :: free_points_all,free_offset_all
+  integer :: free_np_all,free_nspec_all
+
+  ! volume points
+  integer :: vol_np,vol_nspec
+  real, dimension(:),allocatable :: vol_x,vol_y,vol_z
+  integer, dimension(:,:),allocatable :: vol_conn
+  integer, dimension(:),allocatable :: vol_perm
+  ! gather arrays for multi-mpi simulations
+  real, dimension(:),allocatable :: vol_x_all,vol_y_all,vol_z_all
+  integer, dimension(:,:),allocatable :: vol_conn_all
+  integer, dimension(:),allocatable :: vol_conn_offset_all,vol_conn_nspec_all
+  integer :: vol_nspec_all,ispec_start,ispec_end
+  real(kind=CUSTOM_REAL),dimension(1):: dummy
+  integer,dimension(1):: dummy_i
+  integer :: NPROC
+
+  real(kind=CUSTOM_REAL) :: x,y,z
+
+  !-----------------------------------------------------------------------
+  ! user parameter
+  logical, parameter :: VTK_USE_HIRES         = .false.
+  logical, parameter :: VTK_SHOW_FREESURFACE  = .true.
+  logical, parameter :: VTK_SHOW_VOLUME       = .true.
+  !-----------------------------------------------------------------------
+
+  ! user output
+  if( myrank == 0 ) then
+    print*
+    print*,"vtk:"
+  endif
+  call sync_all()
+
+  ! to avoid compiler warnings
+  NPROC = NPROCTOT_VAL
+
+  ! adds source
+  if( myrank == 0 ) then
+    ! user output
+    print*,"  vtk source sphere:"
+    call prepare_vtksource(vtkdata_source_x,vtkdata_source_y,vtkdata_source_z)
+  endif
+  call sync_all()
+
+  ! mask
+  allocate(vtkmask(NGLOB_CRUST_MANTLE),stat=ier)
+  if( ier /= 0 ) stop 'error allocating arrays'
+
+  if( VTK_USE_HIRES ) then
+    NIT_res = 1
+  else
+    NIT_res = NGLLX - 1
+  endif
+
+  ! free surface
+  if( VTK_SHOW_FREESURFACE ) then
+    ! user output
+    if( myrank == 0 ) then
+      print*,"  vtk free surface:"
+      print*,"    free surface elements    : ",NSPEC_TOP
+    endif
+
+    ! counts global free surface points
+    vtkmask(:) = .false.
+
+    ! determines number of global points on surface
+    do ispec2D = 1, NSPEC_TOP ! NSPEC2D_TOP(IREGION_CRUST_MANTLE)
+      ispec = ibelm_top_crust_mantle(ispec2D)
+      ! in case of global, NCHUNKS_VAL == 6 simulations, be aware that for
+      ! the cubed sphere, the mapping changes for different chunks,
+      ! i.e. e.g. x(1,1) and x(5,5) flip left and right sides of the elements in geographical coordinates.
+      ! for future consideration, like in create_movie_GMT_global.f90 ...
+      k = NGLLZ
+      ! loop on all the points inside the element
+      do j = 1,NGLLY,NIT_res
+        do i = 1,NGLLX,NIT_res
+          iglob = ibool_crust_mantle(i,j,k,ispec)
+          vtkmask(iglob) = .true.
+        enddo
+      enddo
+    enddo
+
+    ! loads free surface into data
+    free_np = count(vtkmask(:))
+
+    ! user output
+    if( myrank == 0 ) print*,"    loading surface points: ",free_np
+
+    allocate(free_x(free_np),free_y(free_np),free_z(free_np),stat=ier)
+    if( ier /= 0 ) stop 'error allocating arrays'
+
+    ! permutation array
+    allocate(free_perm(NGLOB_CRUST_MANTLE),stat=ier)
+    if( ier /= 0 ) stop 'error allocating arrays'
+
+    free_perm(:) = 0
+    inum = 0
+    do iglob = 1,NGLOB_CRUST_MANTLE
+      if( vtkmask(iglob) .eqv. .true. ) then
+        inum = inum + 1
+        ! note: xstore/ystore/zstore have changed coordinates to r/theta/phi,
+        !       converts back to x/y/z
+        call rthetaphi_2_xyz(x,y,z,xstore_crust_mantle(iglob), &
+                             ystore_crust_mantle(iglob),zstore_crust_mantle(iglob))
+
+        free_x(inum) = x
+        free_y(inum) = y
+        free_z(inum) = z
+        ! stores permutation
+        free_perm(iglob) = inum
+      endif
+    enddo
+    if( inum /= free_np) stop 'error free_np count in loading free surface points'
+
+    ! hi/low resolution
+    if( VTK_USE_HIRES ) then
+      ! point connectivity
+      free_nspec = NSPEC_TOP*(NGLLX-1)*(NGLLY-1)
+
+      allocate(free_conn(4,free_nspec),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      inum = 0
+      free_conn(:,:) = -1
+      do ispec2D = 1,NSPEC_TOP
+        ispec = ibelm_top_crust_mantle(ispec2D)
+        k = NGLLZ
+        do j = 1, NGLLY-1
+          do i = 1, NGLLX-1
+            ! indices of corner points
+            id1 = free_perm(ibool_crust_mantle(i,j,k,ispec))
+            id2 = free_perm(ibool_crust_mantle(i+1,j,k,ispec))
+            id3 = free_perm(ibool_crust_mantle(i+1,j+1,k,ispec))
+            id4 = free_perm(ibool_crust_mantle(i,j+1,k,ispec))
+            ! note: indices for vtk start at 0
+            inum = inum+1
+            free_conn(1,inum) = id1 - 1
+            free_conn(2,inum) = id2 - 1
+            free_conn(3,inum) = id3 - 1
+            free_conn(4,inum) = id4 - 1
+          enddo
+        enddo
+      enddo
+    else
+      ! point connectivity
+      free_nspec = NSPEC_TOP
+
+      allocate(free_conn(4,free_nspec),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      inum = 0
+      free_conn(:,:) = -1
+      do ispec2D = 1,NSPEC_TOP
+        ispec = ibelm_top_crust_mantle(ispec2D)
+        ! indices of corner points
+        id1 = free_perm(ibool_crust_mantle(1,1,NGLLZ,ispec))
+        id2 = free_perm(ibool_crust_mantle(NGLLX,1,NGLLZ,ispec))
+        id3 = free_perm(ibool_crust_mantle(NGLLX,NGLLY,NGLLZ,ispec))
+        id4 = free_perm(ibool_crust_mantle(1,NGLLY,NGLLZ,ispec))
+        ! note: indices for vtk start at 0
+        inum = inum + 1
+        free_conn(1,inum) = id1 - 1
+        free_conn(2,inum) = id2 - 1
+        free_conn(3,inum) = id3 - 1
+        free_conn(4,inum) = id4 - 1
+      enddo
+    endif
+    if( minval(free_conn(:,:)) < 0) stop 'error vtk free surface point connectivity'
+
+    ! gathers data from all mpi processes
+    if( NPROC > 1 ) then
+      ! multiple mpi processes
+
+      ! user output
+      !if( myrank == 0 ) print*,"    gathering all mpi infos... "
+
+      ! number of volume points for all partitions together
+      call sum_all_i(free_np,free_np_all)
+      if( myrank == 0 ) print*,"    all freesurface points: ",free_np_all
+
+      ! gathers point infos
+      allocate(free_points_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      free_points_all(:) = 0
+      call gather_all_i(free_np,1,free_points_all,1,NPROC)
+
+      ! array offsets
+      allocate(free_offset_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      free_offset_all(1) = 0
+      do i = 2, NPROC
+        free_offset_all(i) = sum(free_points_all(1:i-1))
+      enddo
+
+      ! number of volume elements
+      call sum_all_i(free_nspec,free_nspec_all)
+      if( myrank == 0 ) print*,"    all freesurface elements: ",free_nspec_all
+
+      ! freesurface elements
+      allocate(free_conn_nspec_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      free_conn_nspec_all(:) = 0
+      call gather_all_i(4*free_nspec,1,free_conn_nspec_all,1,NPROC)
+
+      ! array offsets
+      allocate(free_conn_offset_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      free_conn_offset_all(1) = 0
+      do i = 2, NPROC
+        free_conn_offset_all(i) = sum(free_conn_nspec_all(1:i-1))
+      enddo
+
+      ! global data arrays (only needed on master process)
+      if( myrank == 0 ) then
+        ! gather locations
+        allocate(free_x_all(free_np_all), &
+                 free_y_all(free_np_all), &
+                 free_z_all(free_np_all),stat=ier )
+        if(ier /= 0 ) stop 'error allocating free_x_all,... arrays'
+
+        free_x_all(:) = 0.0
+        free_y_all(:) = 0.0
+        free_z_all(:) = 0.0
+
+        ! connectivity
+        allocate(free_conn_all(4,free_nspec_all),stat=ier)
+        if(ier /= 0 ) stop 'error allocating free_conn_all array'
+        free_conn_all(:,:) = 0
+      endif
+
+      if( myrank == 0 ) then
+        ! locations
+        !if( myrank == 0 ) print*,"    locations..."
+        call gatherv_all_cr(free_x,free_np, &
+                            free_x_all,free_points_all,free_offset_all, &
+                            free_np_all,NPROC)
+        call gatherv_all_cr(free_y,free_np, &
+                            free_y_all,free_points_all,free_offset_all, &
+                            free_np_all,NPROC)
+        call gatherv_all_cr(free_z,free_np, &
+                            free_z_all,free_points_all,free_offset_all, &
+                            free_np_all,NPROC)
+
+        ! connectivity
+        !if( myrank == 0 ) print*,"    connectivity..."
+        call gatherv_all_i(free_conn,4*free_nspec, &
+                           free_conn_all,free_conn_nspec_all,free_conn_offset_all, &
+                           free_nspec_all,NPROC)
+
+        ! shifts connectivity ids for all additional slices
+        do i = 2, NPROC
+          ! divides by 4 to get nspec numbers
+          ispec_start = free_conn_offset_all(i)/4 + 1
+          ispec_end = free_conn_offset_all(i)/4 + free_conn_nspec_all(i)/4
+          do ispec = ispec_start,ispec_end
+            free_conn_all(:,ispec) = free_conn_all(:,ispec) + free_offset_all(i)
+          enddo
+        enddo
+
+        !if( myrank == 0 ) print*,"    preparing vtk field..."
+
+        ! adds free surface to vtk window
+        call prepare_vtkfreesurface(free_np_all,free_x_all,free_y_all,free_z_all, &
+                                    free_nspec_all,free_conn_all)
+
+      else
+        ! all other process just send data
+        ! locations
+        call gatherv_all_cr(free_x,free_np, &
+                            dummy,free_points_all,free_offset_all, &
+                            1,NPROC)
+        call gatherv_all_cr(free_y,free_np, &
+                            dummy,free_points_all,free_offset_all, &
+                            1,NPROC)
+        call gatherv_all_cr(free_z,free_np, &
+                            dummy,free_points_all,free_offset_all, &
+                            1,NPROC)
+        ! connectivity
+        call gatherv_all_i(free_conn,4*free_nspec, &
+                            dummy_i,free_conn_nspec_all,free_conn_offset_all, &
+                            1,NPROC)
+
+      endif
+    else
+      ! serial run
+      ! creates vtk freesurface actor
+      call prepare_vtkfreesurface(free_np,free_x,free_y,free_z, &
+                                  free_nspec,free_conn)
+
+    endif
+
+    ! frees memory
+    deallocate(free_x,free_y,free_z)
+    deallocate(free_conn,free_perm)
+    if( NPROC > 1 ) then
+      deallocate(free_conn_nspec_all,free_conn_offset_all)
+      deallocate(free_points_all,free_offset_all)
+      if(myrank == 0 ) deallocate(free_x_all,free_y_all,free_z_all,free_conn_all)
+    endif
+  endif ! VTK_SHOW_FREESURFACE
+  call sync_all()
+
+  ! volume data
+  if( VTK_SHOW_VOLUME ) then
+    ! user output
+    if( myrank == 0 ) then
+      print*,"  vtk volume:"
+      print*,"    spectral elements    : ",NSPEC_CRUST_MANTLE
+    endif
+
+    ! sets new point mask
+    vtkmask(:) = .false.
+    do ispec = 1,NSPEC_CRUST_MANTLE
+      ! hi/low resolution
+      ! loops only over points
+      do k = 1,NGLLZ,NIT_res
+        do j = 1,NGLLY,NIT_res
+          do i = 1,NGLLX,NIT_res
+            iglob = ibool_crust_mantle(i,j,k,ispec)
+            ! sets mask
+            vtkmask(iglob) = .true.
+          enddo
+        enddo
+      enddo
+    enddo
+    vol_np = count(vtkmask(:))
+
+    ! loads volume data arrays
+    if( myrank == 0 ) print*,"    loading volume points: ",vol_np
+
+    allocate(vol_x(vol_np),vol_y(vol_np),vol_z(vol_np),stat=ier)
+    if( ier /= 0 ) stop 'error allocating arrays'
+
+    ! permutation array
+    allocate(vol_perm(NGLOB_CRUST_MANTLE),stat=ier)
+    if( ier /= 0 ) stop 'error allocating arrays'
+
+    vol_perm(:) = 0
+    inum = 0
+    do iglob = 1,NGLOB_CRUST_MANTLE
+      if( vtkmask(iglob) .eqv. .true. ) then
+        inum = inum + 1
+        ! note: xstore/ystore/zstore have changed coordinates to r/theta/phi,
+        !       converts back to x/y/z
+        call rthetaphi_2_xyz(x,y,z,xstore_crust_mantle(iglob), &
+                             ystore_crust_mantle(iglob),zstore_crust_mantle(iglob))
+        vol_x(inum) = x
+        vol_y(inum) = y
+        vol_z(inum) = z
+        ! stores permutation
+        vol_perm(iglob) = inum
+      endif
+    enddo
+    if( inum /= vol_np) stop 'error vol_np count in loading volume points'
+
+    ! hi/low resolution
+    if( VTK_USE_HIRES ) then
+      ! point connectivity
+      vol_nspec = NSPEC_CRUST_MANTLE*(NGLLX-1)*(NGLLY-1)*(NGLLZ-1)
+
+      allocate(vol_conn(8,vol_nspec),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      inum = 0
+      vol_conn(:,:) = -1
+      do ispec = 1,NSPEC_CRUST_MANTLE
+        do k = 1, NGLLZ-1
+          do j = 1, NGLLY-1
+            do i = 1, NGLLX-1
+              ! indices of corner points
+              id1 = vol_perm(ibool_crust_mantle(i,j,k,ispec))
+              id2 = vol_perm(ibool_crust_mantle(i+1,j,k,ispec))
+              id3 = vol_perm(ibool_crust_mantle(i+1,j+1,k,ispec))
+              id4 = vol_perm(ibool_crust_mantle(i,j+1,k,ispec))
+
+              id5 = vol_perm(ibool_crust_mantle(i,j,k+1,ispec))
+              id6 = vol_perm(ibool_crust_mantle(i+1,j,k+1,ispec))
+              id7 = vol_perm(ibool_crust_mantle(i+1,j+1,k+1,ispec))
+              id8 = vol_perm(ibool_crust_mantle(i,j+1,k+1,ispec))
+
+              ! note: indices for vtk start at 0
+              inum = inum+1
+              vol_conn(1,inum) = id1 - 1
+              vol_conn(2,inum) = id2 - 1
+              vol_conn(3,inum) = id3 - 1
+              vol_conn(4,inum) = id4 - 1
+              vol_conn(5,inum) = id5 - 1
+              vol_conn(6,inum) = id6 - 1
+              vol_conn(7,inum) = id7 - 1
+              vol_conn(8,inum) = id8 - 1
+            enddo
+          enddo
+        enddo
+      enddo
+    else
+      ! point connectivity
+      vol_nspec = NSPEC_CRUST_MANTLE
+
+      allocate(vol_conn(8,vol_nspec),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      vol_conn(:,:) = -1
+      do ispec = 1,NSPEC_CRUST_MANTLE
+        ! indices of corner points
+        id1 = vol_perm(ibool_crust_mantle(1,1,1,ispec))
+        id2 = vol_perm(ibool_crust_mantle(NGLLX,1,1,ispec))
+        id3 = vol_perm(ibool_crust_mantle(NGLLX,NGLLY,1,ispec))
+        id4 = vol_perm(ibool_crust_mantle(1,NGLLY,1,ispec))
+
+        id5 = vol_perm(ibool_crust_mantle(1,1,NGLLZ,ispec))
+        id6 = vol_perm(ibool_crust_mantle(NGLLX,1,NGLLZ,ispec))
+        id7 = vol_perm(ibool_crust_mantle(NGLLX,NGLLY,NGLLZ,ispec))
+        id8 = vol_perm(ibool_crust_mantle(1,NGLLY,NGLLZ,ispec))
+
+        ! note: indices for vtk start at 0
+        vol_conn(1,ispec) = id1 - 1
+        vol_conn(2,ispec) = id2 - 1
+        vol_conn(3,ispec) = id3 - 1
+        vol_conn(4,ispec) = id4 - 1
+        vol_conn(5,ispec) = id5 - 1
+        vol_conn(6,ispec) = id6 - 1
+        vol_conn(7,ispec) = id7 - 1
+        vol_conn(8,ispec) = id8 - 1
+      enddo
+    endif
+    if( minval(vol_conn(:,:)) < 0) stop 'error vtk volume point connectivity'
+
+    ! allocates local data array
+    allocate(vtkdata(vol_np),stat=ier)
+    if( ier /= 0 ) stop 'error allocating arrays'
+
+    vtkdata(:) = 0.0
+
+    ! gathers data from all mpi processes
+    if( NPROC > 1 ) then
+      ! multiple mpi processes
+
+      ! user output
+      !if( myrank == 0 ) print*,"    gathering all mpi infos... "
+
+      ! number of volume points for all partitions together
+      call sum_all_i(vol_np,vtkdata_numpoints_all)
+      if( myrank == 0 ) print*,"    all volume points: ",vtkdata_numpoints_all
+
+      ! gathers point infos
+      allocate(vtkdata_points_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      vtkdata_points_all(:) = 0
+      call gather_all_i(vol_np,1,vtkdata_points_all,1,NPROC)
+
+      ! array offsets
+      allocate(vtkdata_offset_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      vtkdata_offset_all(1) = 0
+      do i = 2, NPROC
+        vtkdata_offset_all(i) = sum(vtkdata_points_all(1:i-1))
+      enddo
+
+      ! number of volume elements
+      call sum_all_i(vol_nspec,vol_nspec_all)
+      if( myrank == 0 ) print*,"    all volume elements: ",vol_nspec_all
+
+      ! volume elements
+      allocate(vol_conn_nspec_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      vol_conn_nspec_all(:) = 0
+      call gather_all_i(8*vol_nspec,1,vol_conn_nspec_all,1,NPROC)
+
+      ! array offsets
+      allocate(vol_conn_offset_all(NPROC),stat=ier)
+      if( ier /= 0 ) stop 'error allocating arrays'
+
+      vol_conn_offset_all(1) = 0
+      do i = 2, NPROC
+        vol_conn_offset_all(i) = sum(vol_conn_nspec_all(1:i-1))
+      enddo
+
+      ! global data arrays (only needed on master process)
+      if( myrank == 0 ) then
+        ! point data
+        allocate(vtkdata_all(vtkdata_numpoints_all),stat=ier)
+        if(ier /= 0 ) stop 'error allocating vtkdata_all array'
+
+        vtkdata_all(:) = 0.0
+
+        ! gather locations
+        allocate(vol_x_all(vtkdata_numpoints_all), &
+                 vol_y_all(vtkdata_numpoints_all), &
+                 vol_z_all(vtkdata_numpoints_all),stat=ier )
+        if(ier /= 0 ) stop 'error allocating vol_x_all,... arrays'
+
+        vol_x_all(:) = 0.0
+        vol_y_all(:) = 0.0
+        vol_z_all(:) = 0.0
+
+        ! connectivity
+        allocate(vol_conn_all(8,vol_nspec_all),stat=ier)
+        if(ier /= 0 ) stop 'error allocating vol_conn_all array'
+
+        vol_conn_all(:,:) = 0
+
+      endif
+
+      if( myrank == 0 ) then
+        ! locations
+        !if( myrank == 0 ) print*,"    locations..."
+        call gatherv_all_cr(vol_x,vol_np, &
+                            vol_x_all,vtkdata_points_all,vtkdata_offset_all, &
+                            vtkdata_numpoints_all,NPROC)
+        call gatherv_all_cr(vol_y,vol_np, &
+                            vol_y_all,vtkdata_points_all,vtkdata_offset_all, &
+                            vtkdata_numpoints_all,NPROC)
+        call gatherv_all_cr(vol_z,vol_np, &
+                            vol_z_all,vtkdata_points_all,vtkdata_offset_all, &
+                            vtkdata_numpoints_all,NPROC)
+
+        ! connectivity
+        !if( myrank == 0 ) print*,"    connectivity..."
+        call gatherv_all_i(vol_conn,8*vol_nspec, &
+                           vol_conn_all,vol_conn_nspec_all,vol_conn_offset_all, &
+                           vol_nspec_all,NPROC)
+
+        ! shifts connectivity ids for all additional slices
+        do i = 2, NPROC
+          ! divides by 8 to get nspec numbers
+          ispec_start = vol_conn_offset_all(i)/8 + 1
+          ispec_end = vol_conn_offset_all(i)/8 + vol_conn_nspec_all(i)/8
+          do ispec = ispec_start,ispec_end
+            vol_conn_all(:,ispec) = vol_conn_all(:,ispec) + vtkdata_offset_all(i)
+          enddo
+        enddo
+
+        !if( myrank == 0 ) print*,"    preparing vtk field..."
+
+        ! adds total volume wavefield to vtk window
+        call prepare_vtkfield(vtkdata_numpoints_all,vol_x_all,vol_y_all,vol_z_all, &
+                              vol_nspec_all,vol_conn_all)
+
+      else
+        ! all other process just send data
+        ! locations
+        call gatherv_all_cr(vol_x,vol_np, &
+                            dummy,vtkdata_points_all,vtkdata_offset_all, &
+                            1,NPROC)
+        call gatherv_all_cr(vol_y,vol_np, &
+                            dummy,vtkdata_points_all,vtkdata_offset_all, &
+                            1,NPROC)
+        call gatherv_all_cr(vol_z,vol_np, &
+                            dummy,vtkdata_points_all,vtkdata_offset_all, &
+                            1,NPROC)
+        ! connectivity
+        call gatherv_all_i(vol_conn,8*vol_nspec, &
+                            dummy_i,vol_conn_nspec_all,vol_conn_offset_all, &
+                            1,NPROC)
+      endif
+
+    else
+      ! serial run
+      !if( myrank == 0 ) print*,"    preparing vtk field..."
+
+      ! adds volume wavefield to vtk window
+      call prepare_vtkfield(vol_np,vol_x,vol_y,vol_z,vol_nspec,vol_conn)
+    endif
+
+    ! frees memory
+    deallocate(vol_x,vol_y,vol_z)
+    deallocate(vol_conn,vol_perm)
+    if( NPROC > 1 ) then
+      deallocate(vol_conn_nspec_all,vol_conn_offset_all)
+      if(myrank == 0 ) deallocate(vol_x_all,vol_y_all,vol_z_all,vol_conn_all)
+    endif
+  endif ! VTK_SHOW_VOLUME
+  call sync_all()
+
+  ! user output
+  !if( myrank == 0 ) then
+  !  print*
+  !  print*,"  vtk visualization preparation done"
+  !  print*
+  !endif
+
+  end subroutine prepare_vtk_window
+

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_forward_arrays.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -43,7 +43,9 @@
   if(NUMBER_OF_THIS_RUN < 1 .or. NUMBER_OF_THIS_RUN > NUMBER_OF_RUNS) stop 'incorrect run number'
   if (SIMULATION_TYPE /= 1 .and. NUMBER_OF_RUNS /= 1) stop 'Only 1 run for SIMULATION_TYPE = 2/3'
 
-  if(NUMBER_OF_RUNS == 3) then
+  ! set start/end steps for time iteration loop
+  select case( NUMBER_OF_RUNS )
+  case( 3 )
     if(NUMBER_OF_THIS_RUN == 1) then
       it_begin = 1
       it_end = NSTEP/3
@@ -54,8 +56,7 @@
       it_begin = 2*(NSTEP/3) + 1
       it_end = NSTEP
     endif
-
-  else if(NUMBER_OF_RUNS == 2) then
+  case( 2 )
     if(NUMBER_OF_THIS_RUN == 1) then
       it_begin = 1
       it_end = NSTEP/2
@@ -63,11 +64,10 @@
       it_begin = NSTEP/2 + 1
       it_end = NSTEP
     endif
-
-  else
+  case default
     it_begin = 1
     it_end = NSTEP
-  endif
+  end select
 
   ! read files back from local disk or MT tape system if restart file
   if(NUMBER_OF_THIS_RUN > 1) then
@@ -114,14 +114,17 @@
     close(55)
   endif
 
+  ! initializes backward/reconstructed arrays
   if (SIMULATION_TYPE == 3) then
-    ! initializes
+    ! initializes wavefields
     b_displ_crust_mantle = 0._CUSTOM_REAL
     b_veloc_crust_mantle = 0._CUSTOM_REAL
     b_accel_crust_mantle = 0._CUSTOM_REAL
+
     b_displ_inner_core = 0._CUSTOM_REAL
     b_veloc_inner_core = 0._CUSTOM_REAL
     b_accel_inner_core = 0._CUSTOM_REAL
+
     b_displ_outer_core = 0._CUSTOM_REAL
     b_veloc_outer_core = 0._CUSTOM_REAL
     b_accel_outer_core = 0._CUSTOM_REAL
@@ -142,6 +145,7 @@
       b_A_array_rotation = 0._CUSTOM_REAL
       b_B_array_rotation = 0._CUSTOM_REAL
     endif
+
     if (ATTENUATION_VAL) then
       b_R_xx_crust_mantle = 0._CUSTOM_REAL
       b_R_yy_crust_mantle = 0._CUSTOM_REAL
@@ -154,7 +158,6 @@
       b_R_xy_inner_core = 0._CUSTOM_REAL
       b_R_xz_inner_core = 0._CUSTOM_REAL
       b_R_yz_inner_core = 0._CUSTOM_REAL
-
     endif
   endif
 
@@ -190,9 +193,11 @@
   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_outer_core
   read(55) b_veloc_outer_core
   read(55) b_accel_outer_core
@@ -257,14 +262,21 @@
      read(55) b_R_xz_inner_core
      read(55) b_R_yz_inner_core
 
-     ! note: for kernel simulations (SIMULATION_TYPE == 3), attenuation is
+     ! 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,
-     ! therefore no need to transfer arrays onto GPU
-     !if(GPU_MODE) then
-     !endif
+     ! arrays b_R_xx, ... are not used when USE_ATTENUATION_MIMIC is set
+     if(GPU_MODE) 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, &
+                                    b_R_yz_crust_mantle)
+      call transfer_b_rmemory_ic_to_device(Mesh_pointer, &
+                                    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
   close(55)

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/read_mesh_databases.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -93,7 +93,7 @@
   implicit none
 
   ! local parameters
-  integer :: nspec_iso,nspec_tiso,nspec_ani,NGLOB_XY
+  integer :: nspec_iso,nspec_tiso,nspec_ani
   logical :: READ_KAPPA_MU,READ_TISO
   ! dummy array that does not need to be actually read
   integer, dimension(:),allocatable :: dummy_idoubling
@@ -131,9 +131,9 @@
   ! 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
   if(NCHUNKS_VAL /= 6 .and. ABSORBING_CONDITIONS) then
-     NGLOB_XY = NGLOB_CRUST_MANTLE
+     NGLOB_XY_CM = NGLOB_CRUST_MANTLE
   else
-     NGLOB_XY = 1
+     NGLOB_XY_CM = 1
   endif
 
   ! allocates dummy array
@@ -141,15 +141,15 @@
   if( ier /= 0 ) call exit_mpi(myrank,'error allocating dummy idoubling in crust_mantle')
 
   ! allocates mass matrices
-  allocate(rmassx_crust_mantle(NGLOB_XY), &
-          rmassy_crust_mantle(NGLOB_XY),stat=ier)
+  allocate(rmassx_crust_mantle(NGLOB_XY_CM), &
+          rmassy_crust_mantle(NGLOB_XY_CM),stat=ier)
   if(ier /= 0) stop 'error allocating dummy rmassx, rmassy in crust_mantle'
   allocate(rmassz_crust_mantle(NGLOB_CRUST_MANTLE),stat=ier)
   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, &
+            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, &
@@ -192,7 +192,7 @@
   implicit none
 
   ! local parameters
-  integer :: nspec_iso,nspec_tiso,nspec_ani,NGLOB_XY
+  integer :: nspec_iso,nspec_tiso,nspec_ani,NGLOB_XY_dummy
   logical :: READ_KAPPA_MU,READ_TISO
   integer :: ier
 
@@ -212,9 +212,9 @@
   nspec_ani = 1
 
   ! dummy allocation
-  NGLOB_XY = 1
+  NGLOB_XY_dummy = 1
 
-  allocate(dummy_rmass(NGLOB_XY), &
+  allocate(dummy_rmass(NGLOB_XY_dummy), &
           dummy_ispec_is_tiso(NSPEC_OUTER_CORE), &
           dummy_idoubling_outer_core(NSPEC_OUTER_CORE), &
           stat=ier)
@@ -232,7 +232,7 @@
   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, &
+            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, &
@@ -275,7 +275,7 @@
   implicit none
 
   ! local parameters
-  integer :: nspec_iso,nspec_tiso,nspec_ani,NGLOB_XY
+  integer :: nspec_iso,nspec_tiso,nspec_ani,NGLOB_XY_dummy
   logical :: READ_KAPPA_MU,READ_TISO
   integer :: ier
 
@@ -297,9 +297,9 @@
   endif
 
   ! dummy allocation
-  NGLOB_XY = 1
+  NGLOB_XY_dummy = 1
 
-  allocate(dummy_rmass(NGLOB_XY), &
+  allocate(dummy_rmass(NGLOB_XY_dummy), &
           dummy_ispec_is_tiso(NSPEC_INNER_CORE), &
           stat=ier)
   if(ier /= 0) stop 'error allocating dummy rmass and dummy ispec in inner core'
@@ -316,7 +316,7 @@
   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, &
+            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, &
@@ -638,37 +638,37 @@
   ! crust mantle
   call read_mesh_databases_MPI_CM()
 
-  allocate(buffer_send_vector_crust_mantle(NDIM,max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
-          buffer_recv_vector_crust_mantle(NDIM,max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
-          request_send_vector_crust_mantle(num_interfaces_crust_mantle), &
-          request_recv_vector_crust_mantle(num_interfaces_crust_mantle), &
+  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), &
+          request_send_vector_cm(num_interfaces_crust_mantle), &
+          request_recv_vector_cm(num_interfaces_crust_mantle), &
           stat=ier)
   if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_crust_mantle etc.')
 
   if( SIMULATION_TYPE == 3 ) then
-    allocate(b_buffer_send_vector_crust_mantle(NDIM,max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
-            b_buffer_recv_vector_crust_mantle(NDIM,max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
-            b_request_send_vector_crust_mantle(num_interfaces_crust_mantle), &
-            b_request_recv_vector_crust_mantle(num_interfaces_crust_mantle), &
+    allocate(b_buffer_send_vector_cm(NDIM,max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
+            b_buffer_recv_vector_cm(NDIM,max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
+            b_request_send_vector_cm(num_interfaces_crust_mantle), &
+            b_request_recv_vector_cm(num_interfaces_crust_mantle), &
             stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating array b_buffer_send_vector_crust_mantle etc.')
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating array b_buffer_send_vector_cm etc.')
   endif
 
   ! outer core
   call read_mesh_databases_MPI_OC()
 
-  allocate(buffer_send_scalar_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
-          buffer_recv_scalar_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
-          request_send_scalar_outer_core(num_interfaces_outer_core), &
-          request_recv_scalar_outer_core(num_interfaces_outer_core), &
+  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), &
+          request_send_scalar_oc(num_interfaces_outer_core), &
+          request_recv_scalar_oc(num_interfaces_outer_core), &
           stat=ier)
   if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_outer_core etc.')
 
   if( SIMULATION_TYPE == 3 ) then
-    allocate(b_buffer_send_scalar_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
-            b_buffer_recv_scalar_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
-            b_request_send_scalar_outer_core(num_interfaces_outer_core), &
-            b_request_recv_scalar_outer_core(num_interfaces_outer_core), &
+    allocate(b_buffer_send_scalar_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
+            b_buffer_recv_scalar_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
+            b_request_send_scalar_oc(num_interfaces_outer_core), &
+            b_request_recv_scalar_oc(num_interfaces_outer_core), &
             stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array b_buffer_send_vector_outer_core etc.')
   endif
@@ -676,18 +676,18 @@
   ! inner core
   call read_mesh_databases_MPI_IC()
 
-  allocate(buffer_send_vector_inner_core(NDIM,max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
-          buffer_recv_vector_inner_core(NDIM,max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
-          request_send_vector_inner_core(num_interfaces_inner_core), &
-          request_recv_vector_inner_core(num_interfaces_inner_core), &
+  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), &
+          request_send_vector_ic(num_interfaces_inner_core), &
+          request_recv_vector_ic(num_interfaces_inner_core), &
           stat=ier)
   if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_inner_core etc.')
 
   if( SIMULATION_TYPE == 3 ) then
-    allocate(b_buffer_send_vector_inner_core(NDIM,max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
-            b_buffer_recv_vector_inner_core(NDIM,max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
-            b_request_send_vector_inner_core(num_interfaces_inner_core), &
-            b_request_recv_vector_inner_core(num_interfaces_inner_core), &
+    allocate(b_buffer_send_vector_inner_core(NDIM,max_nibool_interfaces_ic,num_interfaces_inner_core), &
+            b_buffer_recv_vector_inner_core(NDIM,max_nibool_interfaces_ic,num_interfaces_inner_core), &
+            b_request_send_vector_ic(num_interfaces_inner_core), &
+            b_request_recv_vector_ic(num_interfaces_inner_core), &
             stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array b_buffer_send_vector_inner_core etc.')
   endif
@@ -749,8 +749,8 @@
     call exit_mpi(myrank,'error allocating array my_neighbours_crust_mantle etc.')
 
   if( num_interfaces_crust_mantle > 0 ) then
-    read(IIN) max_nibool_interfaces_crust_mantle
-    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_crust_mantle,num_interfaces_crust_mantle), &
+    read(IIN) max_nibool_interfaces_cm
+    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_cm,num_interfaces_crust_mantle), &
             stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_crust_mantle')
 
@@ -759,7 +759,7 @@
     read(IIN) ibool_interfaces_crust_mantle
   else
     ! dummy array
-    max_nibool_interfaces_crust_mantle = 0
+    max_nibool_interfaces_cm = 0
     allocate(ibool_interfaces_crust_mantle(0,0),stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array dummy ibool_interfaces_crust_mantle')
   endif
@@ -834,8 +834,8 @@
     call exit_mpi(myrank,'error allocating array my_neighbours_outer_core etc.')
 
   if( num_interfaces_outer_core > 0 ) then
-    read(IIN) max_nibool_interfaces_outer_core
-    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_outer_core,num_interfaces_outer_core), &
+    read(IIN) max_nibool_interfaces_oc
+    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_oc,num_interfaces_outer_core), &
             stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_outer_core')
 
@@ -844,7 +844,7 @@
     read(IIN) ibool_interfaces_outer_core
   else
     ! dummy array
-    max_nibool_interfaces_outer_core = 0
+    max_nibool_interfaces_oc = 0
     allocate(ibool_interfaces_outer_core(0,0),stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array dummy ibool_interfaces_outer_core')
   endif
@@ -918,8 +918,8 @@
     call exit_mpi(myrank,'error allocating array my_neighbours_inner_core etc.')
 
   if( num_interfaces_inner_core > 0 ) then
-    read(IIN) max_nibool_interfaces_inner_core
-    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_inner_core,num_interfaces_inner_core), &
+    read(IIN) max_nibool_interfaces_ic
+    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_ic,num_interfaces_inner_core), &
             stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array ibool_interfaces_inner_core')
 
@@ -928,7 +928,7 @@
     read(IIN) ibool_interfaces_inner_core
   else
     ! dummy array
-    max_nibool_interfaces_inner_core = 0
+    max_nibool_interfaces_ic = 0
     allocate(ibool_interfaces_inner_core(0,0),stat=ier)
     if( ier /= 0 ) call exit_mpi(myrank,'error allocating array dummy ibool_interfaces_inner_core')
   endif

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/save_forward_arrays.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -90,9 +90,11 @@
     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
@@ -113,6 +115,7 @@
       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
@@ -125,8 +128,8 @@
        write(55) R_xy_inner_core
        write(55) R_xz_inner_core
        write(55) R_yz_inner_core
+    endif
 
-    endif
     close(55)
   endif
 

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	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/specfem3D_par.F90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -78,6 +78,9 @@
   ! ADJOINT
   real(kind=CUSTOM_REAL), dimension(N_SLS) :: b_alphaval, b_betaval, b_gammaval
 
+  ! attenuation: predictor
+  double precision, dimension(N_SLS) :: tau_sigma_dble
+
   !-----------------------------------------------------------------
   ! topography/bathymetry & oceans
   !-----------------------------------------------------------------
@@ -258,39 +261,39 @@
   ! collected MPI interfaces
   ! MPI crust/mantle mesh
   integer :: num_interfaces_crust_mantle
-  integer :: max_nibool_interfaces_crust_mantle
+  integer :: max_nibool_interfaces_cm
   integer, dimension(:), allocatable :: my_neighbours_crust_mantle,nibool_interfaces_crust_mantle
   integer, dimension(:,:), allocatable :: ibool_interfaces_crust_mantle
 
   real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: buffer_send_vector_crust_mantle,buffer_recv_vector_crust_mantle
-  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_send_vector_crust_mantle,b_buffer_recv_vector_crust_mantle
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_send_vector_cm,b_buffer_recv_vector_cm
 
-  integer, dimension(:), allocatable :: request_send_vector_crust_mantle,request_recv_vector_crust_mantle
-  integer, dimension(:), allocatable :: b_request_send_vector_crust_mantle,b_request_recv_vector_crust_mantle
+  integer, dimension(:), allocatable :: request_send_vector_cm,request_recv_vector_cm
+  integer, dimension(:), allocatable :: b_request_send_vector_cm,b_request_recv_vector_cm
 
   ! MPI inner core mesh
   integer :: num_interfaces_inner_core
-  integer :: max_nibool_interfaces_inner_core
+  integer :: max_nibool_interfaces_ic
   integer, dimension(:), allocatable :: my_neighbours_inner_core,nibool_interfaces_inner_core
   integer, dimension(:,:), allocatable :: ibool_interfaces_inner_core
 
   real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: buffer_send_vector_inner_core,buffer_recv_vector_inner_core
   real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_send_vector_inner_core,b_buffer_recv_vector_inner_core
 
-  integer, dimension(:), allocatable :: request_send_vector_inner_core,request_recv_vector_inner_core
-  integer, dimension(:), allocatable :: b_request_send_vector_inner_core,b_request_recv_vector_inner_core
+  integer, dimension(:), allocatable :: request_send_vector_ic,request_recv_vector_ic
+  integer, dimension(:), allocatable :: b_request_send_vector_ic,b_request_recv_vector_ic
 
   ! MPI outer core mesh
   integer :: num_interfaces_outer_core
-  integer :: max_nibool_interfaces_outer_core
+  integer :: max_nibool_interfaces_oc
   integer, dimension(:), allocatable :: my_neighbours_outer_core,nibool_interfaces_outer_core
   integer, dimension(:,:), allocatable :: ibool_interfaces_outer_core
 
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: buffer_send_scalar_outer_core,buffer_recv_scalar_outer_core
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: b_buffer_send_scalar_outer_core,b_buffer_recv_scalar_outer_core
 
-  integer, dimension(:), allocatable :: request_send_scalar_outer_core,request_recv_scalar_outer_core
-  integer, dimension(:), allocatable :: b_request_send_scalar_outer_core,b_request_recv_scalar_outer_core
+  integer, dimension(:), allocatable :: request_send_scalar_oc,request_recv_scalar_oc
+  integer, dimension(:), allocatable :: b_request_send_scalar_oc,b_request_recv_scalar_oc
 
   !-----------------------------------------------------------------
   ! gpu
@@ -373,6 +376,7 @@
   real(kind=CUSTOM_REAL), dimension(:), allocatable :: rmassx_crust_mantle
   real(kind=CUSTOM_REAL), dimension(:), allocatable :: rmassy_crust_mantle
   real(kind=CUSTOM_REAL), dimension(:), allocatable :: rmassz_crust_mantle
+  integer :: NGLOB_XY_CM
 
   ! displacement, velocity, acceleration
   real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_CRUST_MANTLE) :: &
@@ -723,4 +727,20 @@
   logical, dimension(NGLLX,NGLLY,NGLLZ,NSPEC_CRUST_MANTLE_3DMOVIE) :: mask_3dmovie
   logical, dimension(NGLOB_CRUST_MANTLE_3DMOVIE) :: mask_ibool
 
+  ! vtk run-time visualization
+#ifdef WITH_VTK
+  ! vtk window
+  logical, parameter :: VTK_MODE = .true.
+#else
+  logical, parameter :: VTK_MODE = .false.
+#endif
+  real,dimension(:),allocatable :: vtkdata
+  logical,dimension(:),allocatable :: vtkmask
+  ! multi-mpi processes, gather data arrays on master
+  real,dimension(:),allocatable :: vtkdata_all
+  integer,dimension(:),allocatable :: vtkdata_points_all
+  integer,dimension(:),allocatable :: vtkdata_offset_all
+  integer :: vtkdata_numpoints_all
+  real :: vtkdata_source_x,vtkdata_source_y,vtkdata_source_z
+
 end module specfem_par_movie

Added: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk.cpp
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk.cpp	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk.cpp	2012-12-27 19:08:42 UTC (rev 21199)
@@ -0,0 +1,1198 @@
+/*
+ !=====================================================================
+ !
+ !          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.
+ !
+ !=====================================================================
+ */
+
+#include "config.h"
+
+#ifdef WITH_VTK
+
+#pragma message ("\nCompiling with: WITH_VTK enabled\n")
+
+#include <stdio.h>
+#include <unistd.h>
+using namespace std;
+
+// vtk includes
+#include <vtkCellArray.h>
+#include <vtkProperty.h>
+#include <vtkDataSetMapper.h>
+#include <vtkActor.h>
+#include <vtkPoints.h>
+#include <vtkPolyData.h>
+#include <vtkPolygon.h>
+#include <vtkSmartPointer.h>
+#include <vtkMath.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCleanPolyData.h>
+#include <vtkDelaunay2D.h>
+#include <vtkDelaunay3D.h>
+#include <vtkXMLPolyDataReader.h>
+#include <vtkDoubleArray.h>
+#include <vtkPointData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkXMLDataSetWriter.h>
+#include <vtkPolyDataWriter.h>
+#include <vtkPolyDataReader.h>
+#include <vtkXMLUnstructuredGridWriter.h>
+#include <vtkUnstructuredGridWriter.h>
+#include <vtkCamera.h>
+#include <vtkCommand.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <vtkHexahedron.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkTimerLog.h>
+#include <vtkPlane.h>
+#include <vtkBox.h>
+#include <vtkBoxClipDataSet.h>
+#include <vtkBoundingBox.h>
+#include <vtkClipPolyData.h>
+#include <vtkClipVolume.h>
+#include <vtkDataSetSurfaceFilter.h>
+#include <vtkLookupTable.h>
+#include <vtkLegendBoxActor.h>
+#include <vtkScalarBarActor.h>
+#include <vtkLegendBoxActor.h>
+#include <vtkScalarBarActor.h>
+#include <vtkClipDataSet.h>
+#include <vtkAppendFilter.h>
+#include <vtkJPEGWriter.h>
+#include <vtkWindowToImageFilter.h>
+#include <vtkSphereSource.h>
+#include <vtkGeometryFilter.h>
+#include <vtkTableBasedClipDataSet.h>
+#include <vtkQuad.h>
+#include <vtkContourFilter.h>
+
+/* ----------------------------------------------------------------------------------------------- */
+
+// USER PARAMETERS
+int SHOW_FREESURFACE = 0;
+int SHOW_VOLUMEDATA = 0;
+
+// color range
+double gcolor_min  = 0.0;
+double gcolor_max  = 0.005;
+double gcolor_incr = 0.001;
+
+/* ----------------------------------------------------------------------------------------------- */
+
+
+class Visualization {
+  public:
+    // 2D surface data
+    vtkPoints* points2D;
+    vtkDoubleArray* data_array2D;
+    vtkCellArray* cells2D;
+  
+    vtkUnstructuredGrid* volume2D;
+
+    vtkDataSetMapper* mapMesh2D;
+    vtkActor* actor2D;
+  
+    // 3D volume data
+    vtkPoints* points3D;
+    vtkDoubleArray* data_array3D;
+    vtkCellArray* cells;
+
+    vtkUnstructuredGrid* volume3D;
+
+    vtkDataSetMapper* mapMesh3D;
+    vtkActor* actor3D;
+
+    // clipping
+    vtkPlane* clipPlane1;
+    vtkPlane* clipPlane2;
+
+    vtkTableBasedClipDataSet* clip1;
+    vtkTableBasedClipDataSet* clip2;
+    vtkTableBasedClipDataSet* clip1m;
+  
+    // visualizing
+    vtkAppendFilter *merger;
+    vtkDataSetSurfaceFilter* clippersurface;
+  
+    // colors
+    vtkLookupTable* lut2D;
+    vtkLookupTable* lut;
+    int icolor;
+    vtkScalarBarActor* legendcolor;
+
+    // window text
+    vtkTextActor* text;
+    vtkTextActor* textGPU;
+    vtkTextActor* help;
+
+    // user interaction
+    int helpOn;
+    int jpegImageOn;
+    int colorAdjustOn;
+    int bgBlackOn;
+
+    // rendering
+    vtkRenderer* ren;
+    vtkRenderWindow* renWin;
+    vtkRenderWindowInteractor* iren;
+
+    // camera
+    vtkCamera* camera;
+    double pcam[3]; // camera position
+    double rclip[2]; // clipping range
+    double pfocal[3]; // focal point
+  
+    // source sphere
+    vtkSphereSource* sphere;
+    vtkPolyDataMapper* mapperSphere;
+    vtkActor* actorSphere;  
+    double pos_source[3]; // source location
+
+    // countours
+    vtkContourFilter* contour;
+    vtkPolyDataMapper* contourMapper;
+    vtkActor* contourActor;
+};
+
+class VTKmesh{
+  public:
+    int np;
+    int nspec;  
+};
+
+class VTKState {
+  public:
+    // vtk rendering
+    Visualization vtk;
+    
+    // meshes
+    VTKmesh freesurface;
+    VTKmesh volume;
+
+    // timing
+    vtkTimerLog* timer;  
+};
+
+// global vtk state variable
+static VTKState fs;
+
+/* ----------------------------------------------------------------------------------------------- */
+
+void interactor_usage(){
+  cout << endl;
+  cout << "interactor usage, press: " << endl;
+  cout << "  a            - adjust color scale value (toggle on/off) " << endl;
+  cout << "  b            - change background color (toggle white/black) " << endl;
+  cout << "  c            - change color scale " << endl;
+  cout << "  h            - help (toggle on/off) " << endl;
+  cout << "  mouse click  - move/rotate view " << endl;
+  cout << "  r            - reset view " << endl;
+  cout << "  s            - save snapshot as vtu file " << endl;
+  cout << "  i            - save snapshot as jpg image (toggle on/off) " << endl;
+  cout << "  <space>,q    - continue simulation " << endl;
+  cout << endl;
+}
+
+void save_snapshot_vtu(){
+  // Write vtu file
+  printf("writing unstructured grid data...\n");
+
+  std::string filename = "test_snapshot.vtu";
+  
+  // creates writer
+  vtkXMLUnstructuredGridWriter* writer = vtkXMLUnstructuredGridWriter::New();
+  writer->SetFileName(filename.c_str());
+  writer->SetInput(fs.vtk.volume3D);
+  writer->SetDataModeToAscii();
+  writer->Write();
+  
+  //clean up
+  writer->Delete();
+
+  printf("snapshot written to file: %s\n\n",filename.c_str());
+}
+
+
+void save_snapshot_jpg(int it){
+  // Write vtu file
+  printf("writing jpg image...\n");
+  
+  //std::string filename = "test_snapshot.jpg";
+  
+  char filename[180];
+  if( it > 0 ){
+    sprintf(filename,"test_snapshot.%6.6d.jpg",it);
+  }else{
+    sprintf(filename,"test_snapshot.jpg");
+  }
+  
+  // window filter
+  vtkWindowToImageFilter* w2i = vtkWindowToImageFilter::New();
+  w2i->SetInput(fs.vtk.renWin);
+  w2i->Update();
+  
+  // creates writer
+  vtkJPEGWriter* writer = vtkJPEGWriter::New();
+  //writer->SetFileName(filename.c_str());
+  writer->SetFileName(filename);
+  writer->SetInputConnection(w2i->GetOutputPort());
+  writer->Write();
+  
+  //clean up
+  writer->Delete();
+  w2i->Delete();
+  
+  printf("snapshot written to file: %s\n\n",filename);
+}
+
+
+void set_color_scale(int icolor){
+  if( icolor == 0 ){
+    // sets (default) rainbow color scale
+    //# Set the hue range: from low to high the
+    //# table passes through blue, green, yellow,
+    //# orange, and red
+    gcolor_min = 0.0;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLinear();
+    
+    fs.vtk.lut->SetValueRange( 0.6, 1.0 );
+    fs.vtk.lut->SetHueRange( 0.66667, 0.0 );
+    fs.vtk.lut->SetSaturationRange( 1.0, 1.0 );
+  }else if( icolor == 1 ){
+    // red-blue color scale
+    // Since the default lut is
+    // a rainbow lut, we only have
+    // to worry about the hue range.
+    gcolor_min = 0.0;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLinear();
+
+    fs.vtk.lut->SetValueRange( 0.6, 1.0 );
+    fs.vtk.lut->SetHueRange( 0.0, 0.667 );
+    fs.vtk.lut->SetSaturationRange( 1.0, 1.0 );
+  }else if( icolor == 2 ){
+    // red color scale
+    gcolor_min = 1.e-3*gcolor_max;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLog10();
+    
+    fs.vtk.lut->SetValueRange( 0.4, 1.0 );
+    fs.vtk.lut->SetHueRange( 0.0, 0.4 );
+    fs.vtk.lut->SetSaturationRange( 0.5, 0.0 );
+  }else if( icolor == 3 ){
+    // blue color scale
+    gcolor_min = 1.e-3*gcolor_max;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLog10();
+    
+    fs.vtk.lut->SetValueRange( 0.4, 1.0 );
+    fs.vtk.lut->SetHueRange( 0.6, 0.6 );
+    fs.vtk.lut->SetSaturationRange( 0.5, 0.0 );
+  }else if( icolor == 4 ){
+    // black color scale
+    gcolor_min = 1.e-3*gcolor_max;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLog10();
+    
+    fs.vtk.lut->SetValueRange( 0.4, 1.0 ); // from black to white
+    fs.vtk.lut->SetHueRange( 0.0, 1.0 );
+    fs.vtk.lut->SetSaturationRange( 0.0, 0.0 ); // no color saturation
+  }else{
+    // reset
+    fs.vtk.icolor = 0;
+    // sets (default) rainbow color scale
+    //# Set the hue range: from low to high the
+    //# table passes through blue, green, yellow,
+    //# orange, and red
+    gcolor_min = 0.0;
+    fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+    fs.vtk.lut->SetScaleToLinear();
+    
+    fs.vtk.lut->SetValueRange( 0.6, 1.0 );
+    fs.vtk.lut->SetHueRange( 0.66667, 0.0 );
+    fs.vtk.lut->SetSaturationRange( 1.0, 1.0 );
+  }
+  fs.vtk.lut->Build();
+}
+
+// A class not derived from vtkObjectBase
+class MyInteractor{
+  public:
+    void KeypressCallbackFunction(vtkObject* caller,long unsigned int eventId,void* callData ){
+      //cout << "Pressed: " << fs.vtk.iren->GetKeySym() << endl;
+      // usage
+      if( string(fs.vtk.iren->GetKeySym()) == "h"){
+        interactor_usage();
+        // displays help text
+        if( fs.vtk.helpOn == 0 ){
+          fs.vtk.help = vtkTextActor::New();
+          fs.vtk.help->GetTextProperty()->SetFontSize ( 16 );
+          fs.vtk.help->SetPosition( 10, 80 );
+          fs.vtk.help->GetTextProperty()->SetColor( 0.1, 0.1, 0.1 );
+          // updates displayed text
+          fs.vtk.help->SetInput( "interactor usage, press:\n  a            - adjust color scale value (toggle on/off)\n  b            - change background color (toggle white/black) \n  c            - change color scale \n  h            - help (toggle on/off) \n  mouse click  - move/rotate view \n  r            - reset view \n  s            - save snapshot as vtu file\n  i            - save snapshot as jpg image (toggle on/off)\n  <space>,q    - continue simulation \n" );
+                    fs.vtk.ren->AddActor2D( fs.vtk.help );
+          fs.vtk.renWin->Render();
+          fs.vtk.helpOn = 1;
+        }else{
+          fs.vtk.ren->RemoveActor2D( fs.vtk.help );
+          fs.vtk.renWin->Render();
+          fs.vtk.help->Delete();
+          fs.vtk.helpOn = 0;
+        }                
+      }
+      // changes color scales
+      if( string(fs.vtk.iren->GetKeySym()) == "c"){
+        fs.vtk.icolor++;
+        set_color_scale(fs.vtk.icolor);
+        fs.vtk.renWin->Render();
+      }
+      // adjust color scaling
+      if( string(fs.vtk.iren->GetKeySym()) == "a"){
+        fs.vtk.colorAdjustOn++;
+        fs.vtk.colorAdjustOn = fs.vtk.colorAdjustOn % 2 ;
+        if( fs.vtk.colorAdjustOn ){
+          printf("\ntoggle on: color adjusting\n");
+        }else{
+          printf("\ntoggle off: color adjusting off\n");
+        }
+        set_color_scale(fs.vtk.icolor);
+        fs.vtk.renWin->Render();
+      }      
+      // saves vtu snapshot
+      if( string(fs.vtk.iren->GetKeySym()) == "s"){
+        save_snapshot_vtu();
+      }
+      // saves jpg snapshot
+      if( string(fs.vtk.iren->GetKeySym()) == "i"){
+        // toggles jpeg output flag
+        if( fs.vtk.jpegImageOn == 0 ){
+          printf("\ntoggle on: save snapshot as jpeg-image\n");
+          fs.vtk.jpegImageOn = 1;
+        }else{
+          printf("\ntoggle off: save snapshot as jpeg-image\n");
+          fs.vtk.jpegImageOn = 0;
+        }
+      }
+      // stops interaction, continues running simulation
+      if( string(fs.vtk.iren->GetKeySym()) == "space" || string(fs.vtk.iren->GetKeySym()) == "q" ){
+        // updates text
+        fs.vtk.text->SetInput( "...continue simulation " );
+        fs.vtk.renWin->Render();        
+        
+        // stops interactive renderer
+        fs.vtk.iren->TerminateApp();
+      }
+      // stops interaction, continues running simulation
+      if( string(fs.vtk.iren->GetKeySym()) == "r"){
+        // reposition the camera, so that actor can be fully seen
+        //fs.vtk.ren->ResetCamera(); // only resets zoom effect
+
+        // range
+        fs.vtk.camera->SetClippingRange( fs.vtk.rclip );
+        // focal point
+        fs.vtk.camera->SetFocalPoint( fs.vtk.pfocal );
+        // position
+        fs.vtk.camera->SetPosition( fs.vtk.pcam );
+
+        // view
+        fs.vtk.camera->SetViewAngle( 30.0 );
+        fs.vtk.camera->SetViewUp( 0.0, 0.0, 1.0 );
+        
+        fs.vtk.renWin->Render();        
+      }
+      // changes color scale maximum values
+      if(string(fs.vtk.iren->GetKeySym()) == "Up") {
+        // increases color max by 10%
+        gcolor_max = gcolor_max + gcolor_incr;
+        fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+        fs.vtk.lut->Build();
+        fs.vtk.renWin->Render();
+      }
+      if(string(fs.vtk.iren->GetKeySym()) == "Down") {
+        // decreases color max by 10%
+        gcolor_max = gcolor_max - gcolor_incr;
+        if(gcolor_max < gcolor_min ) gcolor_max = gcolor_min;
+        fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+        fs.vtk.lut->Build();
+        fs.vtk.renWin->Render();
+      }
+      // changes background
+      if( string(fs.vtk.iren->GetKeySym()) == "b"){
+        // toggles background
+        if( fs.vtk.bgBlackOn == 0 ){
+          printf("\ntoggle on: background black/white\n");
+          fs.vtk.bgBlackOn = 1;
+          fs.vtk.ren->SetBackground(0,0,0); // Background color black
+          fs.vtk.renWin->Render();
+        }else{
+          printf("\ntoggle off: background black/white\n");
+          fs.vtk.bgBlackOn = 0;
+          fs.vtk.ren->SetBackground(1,1,1); // Background color white
+          fs.vtk.renWin->Render();
+        }
+      }
+      // toggles freesurface visibility
+      if( string(fs.vtk.iren->GetKeySym()) == "1" ){
+        if( SHOW_FREESURFACE == 1 ){
+          if( fs.vtk.actor2D->GetVisibility() == 1){
+            fs.vtk.contourActor->SetVisibility( 0 );
+            fs.vtk.actor2D->SetVisibility( 0 );
+          }else{
+            fs.vtk.contourActor->SetVisibility( 1 );
+            fs.vtk.actor2D->SetVisibility( 1 );
+          }
+          fs.vtk.renWin->Render();
+        }
+      }      
+    }
+};
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(initialize_vtkwindow,INITIALIZE_VTKWINDOW)(int* GPU_MODE) {
+
+  // user output
+  printf(" vtk window initialization\n");
+
+  // initializes window
+  //
+  // camera position
+  fs.vtk.camera = vtkCamera::New();
+
+  // initial settings
+  fs.vtk.rclip[0] = -1.5;
+  fs.vtk.rclip[1] = 1.5;
+  fs.vtk.pfocal[0] = 0.0;
+  fs.vtk.pfocal[1] = 0.0;
+  fs.vtk.pfocal[2] = 0.0;
+  fs.vtk.pcam[0] = 1.0;
+  fs.vtk.pcam[1] = 1.0;
+  fs.vtk.pcam[2] = 0.3;
+
+  // range
+  fs.vtk.camera->SetClippingRange( fs.vtk.rclip );
+  // camer focal point
+  fs.vtk.camera->SetFocalPoint( fs.vtk.pfocal );
+  // camer position
+  fs.vtk.camera->SetPosition( fs.vtk.pcam );
+
+  // view
+  fs.vtk.camera->SetViewAngle( 30.0 );
+  fs.vtk.camera->SetViewUp( 0.0, 0.0, 1.0 );
+
+  // renderer
+  fs.vtk.ren = vtkRenderer::New();
+  fs.vtk.ren->SetActiveCamera(fs.vtk.camera);
+  
+  // Background color white
+  fs.vtk.bgBlackOn = 0;
+  fs.vtk.ren->SetBackground(1,1,1);
+  
+  // text actors
+  // GPU flag
+  fs.vtk.textGPU = vtkTextActor::New();
+  fs.vtk.textGPU->GetTextProperty()->SetFontSize ( 32 );
+  fs.vtk.textGPU->SetPosition( 10, 560 );
+  if( *GPU_MODE ){
+    fs.vtk.textGPU->SetInput( "GPU" );
+    fs.vtk.textGPU->GetTextProperty()->SetColor( 0.2,0.8,0.2 );
+  }else{
+    fs.vtk.textGPU->SetInput( "CPU" );
+    fs.vtk.textGPU->GetTextProperty()->SetColor( 0.8,0.2,0.2 );
+  }
+  fs.vtk.ren->AddActor2D( fs.vtk.textGPU );
+  
+  // progress text
+  fs.vtk.text = vtkTextActor::New();
+  fs.vtk.text->GetTextProperty()->SetFontSize ( 16 );
+  fs.vtk.text->SetPosition( 10, 530 );
+  fs.vtk.text->SetInput( "...initializing data " );
+  fs.vtk.text->GetTextProperty()->SetColor( 0.5,0.5,0.5 );
+  fs.vtk.ren->AddActor2D( fs.vtk.text );
+
+  // color table
+  int tableSize = 256;
+  fs.vtk.icolor = 0; // from blue to red
+  fs.vtk.colorAdjustOn = 1; // automatic adjust
+  
+  fs.vtk.lut = vtkLookupTable::New();
+  fs.vtk.lut->SetNumberOfColors( tableSize );
+
+  // sets (default) rainbow color scale
+  set_color_scale(fs.vtk.icolor);
+
+  // render window
+  fs.vtk.renWin = vtkRenderWindow::New();
+  fs.vtk.renWin->AddRenderer( fs.vtk.ren );
+
+  fs.vtk.renWin->SetPosition(500,0);
+  fs.vtk.renWin->SetSize(900,600);
+  
+  // window interactor
+  fs.vtk.iren = vtkRenderWindowInteractor::New();
+  fs.vtk.iren->SetRenderWindow(fs.vtk.renWin);
+  fs.vtk.iren->Initialize();
+
+  // callback function
+  MyInteractor mykey;
+  fs.vtk.iren->AddObserver(vtkCommand::KeyPressEvent, &mykey, &MyInteractor::KeypressCallbackFunction);
+
+  // renders window
+  fs.vtk.renWin->Render();
+
+  // timer
+  fs.timer = vtkTimerLog::New();
+  
+  //printf("      initialized vtk window successfully\n");
+}
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(prepare_vtksource,PREPARE_VTKSOURCE)(float* xs_x,float* xs_y, float* xs_z) {
+
+  double xyz[3];
+  
+  // sets source location
+  fs.vtk.pos_source[0] = *xs_x;
+  fs.vtk.pos_source[1] = *xs_y;
+  fs.vtk.pos_source[2] = *xs_z;
+  printf("     sphere location: %f %f %f \n",fs.vtk.pos_source[0],fs.vtk.pos_source[1],fs.vtk.pos_source[2]);
+  
+  // creates sphere around source location
+  fs.vtk.sphere = vtkSphereSource::New();
+  fs.vtk.sphere->SetCenter(fs.vtk.pos_source);
+  fs.vtk.sphere->SetRadius(0.02);
+
+  fs.vtk.mapperSphere = vtkPolyDataMapper::New();
+  fs.vtk.mapperSphere->SetInputConnection(fs.vtk.sphere->GetOutputPort());
+ 
+  fs.vtk.actorSphere = vtkActor::New();
+  fs.vtk.actorSphere->SetMapper(fs.vtk.mapperSphere);
+
+  // adds actor
+  fs.vtk.ren->AddActor(fs.vtk.actorSphere);
+
+  // render window
+  fs.vtk.renWin->Render();
+
+}
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(prepare_vtkfreesurface,PREPARE_VTKFREESURFACE)(int* free_np,
+                                                             float* free_x,
+                                                             float* free_y,
+                                                             float* free_z,
+                                                             int* free_nspec,
+                                                             int* free_conn) {
+  double xyz[3];
+  int id1,id2,id3,id4;
+  
+  // user output
+  //printf("    prepare vtk freesurface...\n");
+
+  // initializes
+  SHOW_FREESURFACE = 1;
+  
+  // number of points
+  fs.freesurface.np = *free_np;
+  printf("     free surface points: %d\n", fs.freesurface.np);
+
+  // checks
+  if( fs.freesurface.np == 0 ){
+    fprintf(stderr,"ERROR: VTK_MODE without 2D freesurface points \n");
+    exit(1);
+  }
+
+  // creates new points and data arrays
+  fs.vtk.points2D = vtkPoints::New();
+  fs.vtk.points2D->SetNumberOfPoints(fs.freesurface.np);
+
+  fs.vtk.data_array2D = vtkDoubleArray::New();
+  fs.vtk.data_array2D->SetNumberOfComponents(1);
+  fs.vtk.data_array2D->SetNumberOfValues(fs.freesurface.np);
+  fs.vtk.data_array2D->SetName("topo");
+
+  for(int i=0;i<fs.freesurface.np;i++) {
+    xyz[0] = free_x[i];
+    xyz[1] = free_y[i];
+    xyz[2] = free_z[i];
+    fs.vtk.points2D->SetPoint(i,xyz);
+    fs.vtk.data_array2D->SetValue(i,6371000.0*(sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2])-1.0) );
+  }
+  // Find min and max
+  double bounds[2];
+  fs.vtk.data_array2D->GetValueRange(bounds);
+  double min = bounds[0];
+  double max = bounds[1];
+  printf("     topo: min = %f max = %f\n", min,max);
+
+  // black color scale
+  int tableSize = 256;  
+  fs.vtk.lut2D = vtkLookupTable::New();
+  fs.vtk.lut2D->SetNumberOfColors(tableSize);
+  fs.vtk.lut2D->SetValueRange( 0.4, 1.0 ); // from black to white
+  fs.vtk.lut2D->SetHueRange( 0.0, 1.0 );
+  fs.vtk.lut2D->SetSaturationRange( 0.0, 0.0 ); // no color saturation
+  fs.vtk.lut2D->SetTableRange( min, max );
+  fs.vtk.lut2D->Build();
+  
+  // creates cell connectivity
+  fs.freesurface.nspec = *free_nspec;
+
+  // cells
+  fs.vtk.cells2D = vtkCellArray::New();
+  vtkQuad* quad = vtkQuad::New();
+  for(int ispec=0;ispec<fs.freesurface.nspec;ispec++){
+    id1 = free_conn[0+ispec*4];
+    id2 = free_conn[1+ispec*4];
+    id3 = free_conn[2+ispec*4];
+    id4 = free_conn[3+ispec*4];
+    quad->GetPointIds()->SetId(0,id1);
+    quad->GetPointIds()->SetId(1,id2);
+    quad->GetPointIds()->SetId(2,id3);
+    quad->GetPointIds()->SetId(3,id4);
+    fs.vtk.cells2D->InsertNextCell(quad);
+  }
+  quad->Delete();
+
+  fs.vtk.volume2D = vtkUnstructuredGrid::New();
+  // points
+  fs.vtk.volume2D->SetPoints(fs.vtk.points2D);
+  fs.vtk.volume2D->GetPointData()->SetScalars(fs.vtk.data_array2D);
+  // cells
+  fs.vtk.volume2D->SetCells(VTK_QUAD, fs.vtk.cells2D);
+
+  // contour iso-surfacing
+  fs.vtk.contour = vtkContourFilter::New();
+  fs.vtk.contour->SetInput(  fs.vtk.volume2D );
+  fs.vtk.contour->SetNumberOfContours(7);
+  fs.vtk.contour->SetValue(0, 0.0);
+  fs.vtk.contour->SetValue(1, min*0.25);
+  fs.vtk.contour->SetValue(2, max*0.25);
+  fs.vtk.contour->SetValue(3, min*0.5);
+  fs.vtk.contour->SetValue(4, max*0.5);
+  fs.vtk.contour->SetValue(5, min*0.75);
+  fs.vtk.contour->SetValue(6, max*0.75);
+
+  fs.vtk.contour->ComputeScalarsOff();
+  fs.vtk.contour->ComputeGradientsOff();
+
+  fs.vtk.contourMapper = vtkPolyDataMapper::New();
+  fs.vtk.contourMapper->SetInputConnection(0, fs.vtk.contour->GetOutputPort() );
+  fs.vtk.contourMapper->ScalarVisibilityOff();
+  
+  fs.vtk.contourActor = vtkActor::New();
+  fs.vtk.contourActor->SetMapper( fs.vtk.contourMapper );
+  fs.vtk.contourActor->GetProperty()->SetOpacity( 1.0 );
+  fs.vtk.contourActor->SetScale( 1.001,1.001,1.001 );
+  fs.vtk.contourActor->GetProperty()->SetColor( 0.5, 0.5, 0.5 );
+  
+  fs.vtk.ren->AddActor(fs.vtk.contourActor);
+  
+  // mapping
+  fs.vtk.mapMesh2D = vtkDataSetMapper::New();
+  fs.vtk.mapMesh2D->SetInput( fs.vtk.volume2D );
+  
+  fs.vtk.mapMesh2D->SetLookupTable(fs.vtk.lut2D);
+  fs.vtk.mapMesh2D->SetColorModeToMapScalars();
+  fs.vtk.mapMesh2D->SetScalarModeToUsePointData();
+  fs.vtk.mapMesh2D->ScalarVisibilityOn();
+  fs.vtk.mapMesh2D->UseLookupTableScalarRangeOn();
+
+  // actor
+  fs.vtk.actor2D = vtkActor::New();
+  fs.vtk.actor2D->SetMapper(fs.vtk.mapMesh2D);
+  fs.vtk.actor2D->GetProperty()->SetOpacity( 0.5 );
+  fs.vtk.actor2D->SetScale( 1.001,1.001,1.001 );
+
+  // 2D actor
+  fs.vtk.ren->AddActor(fs.vtk.actor2D);
+
+  // render window
+  fs.vtk.renWin->Render();
+}
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(prepare_vtkfield,PREPARE_VTKFIELD)(int* vol_np,
+                                                 float* vol_x,
+                                                 float* vol_y,
+                                                 float* vol_z,
+                                                 int* vol_nspec,
+                                                 int* vol_conn) {
+
+  double xyz[3];
+  double data_bounds[2];
+  double model_bounds[6];  
+  int id1,id2,id3,id4,id5,id6,id7,id8;
+  static int debug_file = 0;
+  
+  // user output
+  //printf("    prepare vtk wavefield ...\n");
+
+  // initializes
+  SHOW_VOLUMEDATA = 1;
+  
+  // volumetric wavefield
+  // text
+  fs.vtk.text->SetInput( "...adding wavefield " );
+  
+  // update view
+  fs.vtk.renWin->Render();
+  
+  // volume mesh
+  fs.volume.np = *vol_np;
+  printf("     volume points: %d\n", fs.volume.np);
+
+  // checks
+  if( fs.volume.np == 0 ){
+    fprintf(stderr,"ERROR: VTK_MODE without 3D volume points \n");
+    exit(1);
+  }
+      
+  // volume data
+  // point locations
+  fs.vtk.points3D = vtkPoints::New();
+  fs.vtk.points3D->SetNumberOfPoints(fs.volume.np);
+
+  // point data (wavefield)
+  fs.vtk.data_array3D = vtkDoubleArray::New();
+  fs.vtk.data_array3D->SetNumberOfComponents(1);
+  fs.vtk.data_array3D->SetName("vnorm");
+  fs.vtk.data_array3D->SetNumberOfValues(fs.volume.np);    
+
+  for(int i=0;i<fs.volume.np;i++) {
+    xyz[0] = vol_x[i];
+    xyz[1] = vol_y[i];
+    xyz[2] = vol_z[i];
+    fs.vtk.points3D->SetPoint(i,xyz);
+    fs.vtk.data_array3D->SetValue(i,0.0);
+    //fs.vtk.data_array3D->SetValue(i,i*1.0);
+  }
+  //fs.vtk.data_array3D->Update();
+  // Find min and max
+  fs.vtk.data_array3D->GetValueRange(data_bounds);
+  double min = data_bounds[0];
+  double max = data_bounds[1];
+  printf("     data: min = %f max = %f\n",min,max);
+
+  // Find min and max
+  fs.vtk.points3D->GetBounds(model_bounds);
+  double xmin = model_bounds[0];
+  double xmax = model_bounds[1];
+  double ymin = model_bounds[2];
+  double ymax = model_bounds[3];
+  double zmin = model_bounds[4];
+  double zmax = model_bounds[5];
+  printf("     model: xmin/xmax = %f / %f\n",xmin,xmax);
+  printf("     model: ymin/ymax = %f / %f\n",ymin,ymax);
+  printf("     model: zmin/zmax = %f / %f\n",zmin,zmax);
+  
+  // adjusts camera settings
+  fs.vtk.rclip[0] = xmin - 0.1*(xmax-xmin);
+  fs.vtk.rclip[1] = xmax + 0.1*(xmax-xmin);
+  fs.vtk.pfocal[0] = fs.vtk.pos_source[0]; //(xmax-xmin)/2.0;
+  fs.vtk.pfocal[1] = fs.vtk.pos_source[1]; //(ymax-ymin)/2.0;
+  fs.vtk.pfocal[2] = fs.vtk.pos_source[2]; // (zmax-zmin)/2.0;
+  fs.vtk.pcam[0] = fs.vtk.pos_source[0] + 0.5*(zmax-zmin); // (xmax-xmin)/2.0 - 0.1*(xmax-xmin);
+  fs.vtk.pcam[1] = fs.vtk.pos_source[1] + 0.5*(zmax-zmin); // (ymax-ymin)/2.0 + 0.1*(ymax-ymin);
+  fs.vtk.pcam[2] = fs.vtk.pos_source[2] + 0.5*(zmax-zmin); // (zmax-zmin)/2.0 + 0.5*(zmax-zmin);
+  
+  // range
+  fs.vtk.camera->SetClippingRange( fs.vtk.rclip );
+  // camer focal point
+  fs.vtk.camera->SetFocalPoint( fs.vtk.pfocal );
+  // camer position
+  fs.vtk.camera->SetPosition( fs.vtk.pcam );
+  
+  //
+  // unstructured grid
+  //
+  // creates cell connectivity
+  fs.volume.nspec = *vol_nspec;
+
+  // cells
+  fs.vtk.cells = vtkCellArray::New();
+  vtkHexahedron* hex = vtkHexahedron::New();
+  for(int ispec=0;ispec<fs.volume.nspec;ispec++){
+    id1 = vol_conn[0+ispec*8];
+    id2 = vol_conn[1+ispec*8];
+    id3 = vol_conn[2+ispec*8];
+    id4 = vol_conn[3+ispec*8];
+    id5 = vol_conn[4+ispec*8];
+    id6 = vol_conn[5+ispec*8];
+    id7 = vol_conn[6+ispec*8];
+    id8 = vol_conn[7+ispec*8];
+    hex->GetPointIds()->SetId(0,id1);
+    hex->GetPointIds()->SetId(1,id2);
+    hex->GetPointIds()->SetId(2,id3);
+    hex->GetPointIds()->SetId(3,id4);
+    hex->GetPointIds()->SetId(4,id5);
+    hex->GetPointIds()->SetId(5,id6);
+    hex->GetPointIds()->SetId(6,id7);
+    hex->GetPointIds()->SetId(7,id8);
+    fs.vtk.cells->InsertNextCell(hex);      
+  }
+  hex->Delete();
+  
+  fs.vtk.volume3D = vtkUnstructuredGrid::New();
+  // points
+  fs.vtk.volume3D->SetPoints(fs.vtk.points3D);
+  fs.vtk.volume3D->GetPointData()->SetScalars(fs.vtk.data_array3D);
+  // cells
+  fs.vtk.volume3D->SetCells(VTK_HEXAHEDRON, fs.vtk.cells);
+
+  //
+  // clip box
+  //
+  // bounds
+  double bb_all[6] = { xmin,xmax,ymin,ymax,zmin,zmax };
+
+  // normalized source location
+  double norm  = sqrt( fs.vtk.pos_source[0]*fs.vtk.pos_source[0]
+                   + fs.vtk.pos_source[1]*fs.vtk.pos_source[1]
+                   + fs.vtk.pos_source[2]*fs.vtk.pos_source[2]);
+  // normalized vector to source
+  double v[3];
+  if( norm > 0.0 ){
+    v[0] = fs.vtk.pos_source[0]/norm;
+    v[1] = fs.vtk.pos_source[1]/norm;
+    v[2] = fs.vtk.pos_source[2]/norm;
+  }else{
+    v[0] = 0.0;
+    v[1] = 0.0;
+    v[2] = 1.0;
+  }
+  
+  // source location vector / perpendicular vectors
+  //
+  // vectorproduct(vector1, vector2, product)
+  // calculates the vector product of vector1 and vector2
+  //    product(1) = vector1(2)*vector2(3) - vector1(3)*vector2(2)
+  //    product(2) = - vector1(1)*vector2(3) + vector1(3)*vector2(1)
+  //    product(3) = vector1(1)*vector2(2) - vector1(2)*vector2(1)
+  double p1[3],p2[3];
+  if( norm > 0 ){
+    p1[0] = 0.0;
+    p1[1] = 0.0;
+    p1[2] = 1.0;
+    
+    p2[0] = 0.0;
+    p2[1] = 1.0;
+    p2[2] = 0.0;
+  }else{
+    p1[0] = 0.0;
+    p1[1] = 1.0;
+    p1[2] = 0.0;
+    
+    p2[0] = 1.0;
+    p2[1] = 0.0;
+    p2[2] = 0.0;
+  }
+  double pn1[3],pn2[3];
+  pn1[0] = v[1]*p1[2] - v[2]*p1[1];
+  pn1[1] = -v[0]*p1[2] + v[2]*p1[0];
+  pn1[2] = v[0]*p1[1] - v[1]*p1[0];
+
+  pn2[0] = v[1]*p2[2] - v[2]*p2[1];
+  pn2[1] = -v[0]*p2[2] + v[2]*p2[0];
+  pn2[2] = v[0]*p2[1] - v[1]*p2[0];
+  
+  // flips normal depending on location of source
+  if( fabs(v[0]-xmin) < fabs(v[0]-xmax) ){
+    pn1[0] *= -1.0;
+    pn1[1] *= -1.0;
+    pn1[2] *= -1.0;
+  }
+  if( fabs(v[1]-ymin) < fabs(v[1]-ymax) ){
+    pn2[0] *= -1.0;
+    pn2[1] *= -1.0;
+    pn2[2] *= -1.0;
+  }
+  
+  // plane through source location
+  fs.vtk.clipPlane1 = vtkPlane::New();
+  fs.vtk.clipPlane1->SetNormal( pn1 );
+  fs.vtk.clipPlane1->SetOrigin(0.0, 0.0, 0.0);
+
+  fs.vtk.clipPlane2 = vtkPlane::New();
+  fs.vtk.clipPlane2->SetNormal( pn2 );
+  fs.vtk.clipPlane2->SetOrigin(0.0, 0.0, 0.0);
+
+  // table based clipping
+  fs.vtk.clip1 = vtkTableBasedClipDataSet::New();
+  fs.vtk.clip1->SetInput( fs.vtk.volume3D );
+  fs.vtk.clip1->SetClipFunction( fs.vtk.clipPlane1 );
+  fs.vtk.clip1->Update();
+
+  fs.vtk.clip1m = vtkTableBasedClipDataSet::New();
+  fs.vtk.clip1m->SetInput( fs.vtk.volume3D );
+  fs.vtk.clip1m->SetClipFunction( fs.vtk.clipPlane1 );
+  fs.vtk.clip1m->InsideOutOn();
+  fs.vtk.clip1m->Update();
+
+  fs.vtk.clip2 = vtkTableBasedClipDataSet::New();
+  fs.vtk.clip2->SetInput( fs.vtk.clip1m->GetOutput() );
+  fs.vtk.clip2->SetClipFunction( fs.vtk.clipPlane2 );
+  fs.vtk.clip2->Update();
+
+  // merges mesh parts
+  fs.vtk.merger = vtkAppendFilter::New();
+  fs.vtk.merger->MergePointsOn();
+  fs.vtk.merger->AddInput( fs.vtk.clip1->GetOutput() );
+  fs.vtk.merger->AddInput( fs.vtk.clip2->GetOutput() );
+  fs.vtk.merger->Update();
+  
+  // test file
+  if( debug_file == 1){
+    vtkUnstructuredGrid* data = fs.vtk.merger->GetOutput();
+    cout << "    merger: cells  = " << data->GetNumberOfCells() << endl;
+    cout << "    merger: points = " << data->GetNumberOfPoints() << endl;
+    // Write vtu file
+    printf("\nwriting unstructured grid data...\n");
+    std::string filename = "test_init_snapshot.vtu";
+    // creates writer
+    vtkXMLUnstructuredGridWriter* writer = vtkXMLUnstructuredGridWriter::New();
+    writer->SetFileName(filename.c_str());
+    writer->SetInput(data);
+    writer->SetDataModeToAscii();
+    writer->Write();
+    //clean up
+    writer->Delete();
+    printf("snapshot written to file: %s\n\n",filename.c_str());
+  }
+  
+  // clipper surface
+  fs.vtk.clippersurface = vtkDataSetSurfaceFilter::New();
+  fs.vtk.clippersurface->SetInputConnection(0, fs.vtk.merger->GetOutputPort());
+  fs.vtk.clippersurface->Update();
+  
+  // cell connectivity mapping
+  fs.vtk.mapMesh3D = vtkDataSetMapper::New();
+  fs.vtk.mapMesh3D->SetInputConnection(fs.vtk.clippersurface->GetOutputPort());
+
+  fs.vtk.mapMesh3D->SetLookupTable(fs.vtk.lut);
+  fs.vtk.mapMesh3D->SetColorModeToMapScalars();
+  fs.vtk.mapMesh3D->SetScalarModeToUsePointData();
+  fs.vtk.mapMesh3D->ScalarVisibilityOn();
+  fs.vtk.mapMesh3D->UseLookupTableScalarRangeOn();
+  
+  //actor
+  fs.vtk.actor3D = vtkActor::New();
+  fs.vtk.actor3D->SetMapper(fs.vtk.mapMesh3D);
+  //fs.vtk.actor3D->GetProperty()->SetRepresentationToSurface();
+  //fs.vtk.actor3D->GetProperty()->SetEdgeVisibility(1);
+  
+  // 3D actor
+  fs.vtk.ren->AddActor(fs.vtk.actor3D);
+  
+  // legend for colors
+  fs.vtk.legendcolor = vtkScalarBarActor::New();
+  fs.vtk.legendcolor->SetLookupTable(fs.vtk.lut);
+  fs.vtk.legendcolor->SetTitle( "vnorm" );
+  fs.vtk.legendcolor->SetWidth( 0.1 );
+  //fs.vtk.legendcolor->SetFontSize ( 16 );
+  fs.vtk.ren->AddActor(fs.vtk.legendcolor);
+
+  // reposition the camera, so that actor can be fully seen
+  fs.vtk.ren->ResetCamera();
+
+  // text
+  fs.vtk.text->SetInput( "...update view with mouse/keyboard, then press <space> to continue " );
+
+  // renders window
+  fs.vtk.renWin->Render();
+
+  // window interactor
+  // below call might crash if window is rendered before interactor is initialized
+  // error in X11: GLXBadCurrentWindow
+  interactor_usage();
+  fs.vtk.iren->Start();
+  
+  // starts timer
+  fs.timer->StartTimer();  
+}
+
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(visualize_vtkdata,VISUALIZE_VTKDATA)(int* it_h,float* time_h, float* data) {
+
+  double xyz[3];
+  double bounds[2];
+  double min,max;
+  
+  static int DEBUG = 0;
+  
+  int it = *it_h;
+  float time = *time_h;
+  
+  if( DEBUG ) printf("     visual: it = %d time = %f \n",it,time);
+
+  // time for calculating new wavefield
+  fs.timer->StopTimer();
+  double timeInSeconds = fs.timer->GetElapsedTime();
+  fs.timer->StartTimer();
+  
+  // frames per second (based on computing new wavefield
+  double fps = 1.0/timeInSeconds;
+  // updates time string
+  char inputString[180];
+  sprintf(inputString,"time step: %d \t time: %6.3f \t fps: %f",it,time,fps);
+  fs.vtk.text->SetInput(inputString);
+
+  // updates data
+  if(SHOW_VOLUMEDATA == 1 ){
+    for(int i=0;i<fs.volume.np;i++) {
+      fs.vtk.data_array3D->SetValue(i,data[i]);
+    }
+    // mark as modified to update rendering
+    fs.vtk.data_array3D->Modified();
+
+    // Find min and max
+    fs.vtk.data_array3D->GetValueRange(bounds);
+    min = bounds[0];
+    max = bounds[1];
+    
+    // adjusts color maximum
+    if( fs.vtk.colorAdjustOn ){
+      if( gcolor_max < 0.0 ) gcolor_max = 1.e-10;
+      gcolor_max = max;
+      gcolor_incr = 0.1 * max;
+      if( fs.vtk.icolor >= 2 ) gcolor_min = 1.e-3*gcolor_max;
+      fs.vtk.lut->SetTableRange( gcolor_min, gcolor_max );
+      fs.vtk.lut->Build();
+    }
+  }
+
+  // updates window
+  fs.vtk.renWin->Render();
+
+  // saves snapshot image
+  if( fs.vtk.jpegImageOn ){
+    save_snapshot_jpg( it );
+  }
+
+  // time for rendering
+  fs.timer->StopTimer();
+  double time_renderer = fs.timer->GetElapsedTime();
+  fs.timer->StartTimer();
+
+  if( DEBUG ){
+    printf("     visual: %s \n",inputString);
+    printf("     timer : time for rendering = %f (s) \n", time_renderer);
+    printf("     data  : min = %e max = %e \n\n",min,max);
+  }
+}
+
+/* ----------------------------------------------------------------------------------------------- */
+
+extern "C"
+void FC_FUNC_(finish_vtkwindow,FINISH_VTKWINDOW)() {
+
+  // text
+  fs.vtk.text->SetInput( "...change view with mouse/keyboard, then press <space> to finish " );
+  
+  // render window
+  fs.vtk.renWin->Render();
+
+  // window interactor
+  // below call might crash if window is rendered before interactor is initialized
+  // error in X11: GLXBadCurrentWindow
+  interactor_usage();
+  fs.vtk.iren->Start();
+
+  fs.timer->StopTimer();
+  fs.timer->Delete();
+  
+  // free arrays
+  if(SHOW_FREESURFACE == 1 ){
+    fs.vtk.points2D->Delete();
+    fs.vtk.data_array2D->Delete();
+    fs.vtk.cells2D->Delete();
+
+    fs.vtk.lut2D->Delete();
+
+    // contour
+    fs.vtk.contourActor->Delete();
+    fs.vtk.contourMapper->Delete();
+    fs.vtk.contour->Delete();
+    
+    fs.vtk.actor2D->Delete();
+    fs.vtk.mapMesh2D->Delete();    
+  }
+
+  if(SHOW_VOLUMEDATA == 1 ){
+    fs.vtk.points3D->Delete();
+    fs.vtk.data_array3D->Delete();
+    fs.vtk.cells->Delete();
+
+    fs.vtk.legendcolor->Delete();
+    fs.vtk.lut->Delete();
+
+    fs.vtk.clipPlane1->Delete();
+    fs.vtk.clipPlane2->Delete();
+    
+    fs.vtk.clippersurface->Delete();
+    fs.vtk.merger->Delete();
+    
+    fs.vtk.clip1->Delete();
+    fs.vtk.clip1m->Delete();
+    fs.vtk.clip2->Delete();
+    
+    fs.vtk.actor3D->Delete();
+    fs.vtk.mapMesh3D->Delete();
+  }
+
+  // source sphere
+  fs.vtk.actorSphere->Delete();
+  fs.vtk.mapperSphere->Delete();
+  fs.vtk.sphere->Delete();
+
+  fs.vtk.textGPU->Delete();
+  fs.vtk.text->Delete();
+
+  fs.vtk.iren->Delete();
+  fs.vtk.renWin->Delete();
+  fs.vtk.ren->Delete();
+  fs.vtk.camera->Delete();  
+}
+
+
+#endif // WITH_VTK
+

Added: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk_stubs.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk_stubs.c	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/visual_vtk_stubs.c	2012-12-27 19:08:42 UTC (rev 21199)
@@ -0,0 +1,63 @@
+/* 
+!=====================================================================
+!
+!          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.
+!
+!=====================================================================
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "config.h"
+
+/* ----------------------------------------------------------------------------------------------- */
+
+// empty stubs
+
+/* ----------------------------------------------------------------------------------------------- */
+
+void FC_FUNC_(initialize_vtkwindow,INITIALIZE_VTKWINDOW)(int* GPU_MODE) {
+  //printf("VTK_MODE not enabled at compile time: use -DWITH_VTK\n");
+}
+
+void FC_FUNC_(prepare_vtksource,PREPARE_VTKSOURCE)(float* xs_x,float* xs_y, float* xs_z) {}
+
+void FC_FUNC_(prepare_vtkfreesurface,PREPARE_VTKFREESURFACE)(int* free_np,
+                                                             float* free_x,
+                                                             float* free_y,
+                                                             float* free_z,
+                                                             int* free_nspec,
+                                                             int* free_conn) {}
+
+void FC_FUNC_(prepare_vtkfield,PREPARE_VTKFIELD)(int* vol_np,
+                                                 float* vol_x,
+                                                 float* vol_y,
+                                                 float* vol_z,
+                                                 int* vol_nspec,
+                                                 int* vol_conn) {}
+
+void FC_FUNC_(visualize_vtkdata,VISUALIZE_VTKDATA)(int* it_h,float* time_h, float* data) {}
+
+void FC_FUNC_(finish_vtkwindow,FINISH_VTKWINDOW)() {}

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_movie_output.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_movie_output.f90	2012-12-27 16:02:25 UTC (rev 21198)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_movie_output.f90	2012-12-27 19:08:42 UTC (rev 21199)
@@ -38,8 +38,13 @@
   ! debugging
   character(len=256) :: filename
   integer,dimension(:),allocatable :: dummy_i
+
   logical, parameter :: DEBUG_SNAPSHOT = .false.
 
+  logical, parameter :: RUN_EXTERNAL_SCRIPT = .true.
+  character(len=256) :: script_name = "tar_databases_file.sh"
+  character(len=256) :: system_command
+
   ! save movie on surface
   if( MOVIE_SURFACE ) then
     if( mod(it,NTSTEP_BETWEEN_FRAMES) == 0) then
@@ -157,9 +162,9 @@
 
         scalingval = scale_displ
         call write_movie_volume_vector(myrank,it,npoints_3dmovie, &
-                    LOCAL_TMP_PATH,MOVIE_VOLUME_TYPE, &
-                    MOVIE_COARSE,ibool_crust_mantle,displ_crust_mantle, &
-                    scalingval,mask_3dmovie,nu_3dmovie)
+                                       LOCAL_TMP_PATH,MOVIE_VOLUME_TYPE,MOVIE_COARSE,ibool_crust_mantle, &
+                                       displ_crust_mantle, &
+                                       scalingval,mask_3dmovie,nu_3dmovie)
 
       case( 6 )
         !output velocity
@@ -169,22 +174,19 @@
 
         scalingval = scale_veloc
         call write_movie_volume_vector(myrank,it,npoints_3dmovie, &
-                    LOCAL_TMP_PATH,MOVIE_VOLUME_TYPE, &
-                    MOVIE_COARSE,ibool_crust_mantle,veloc_crust_mantle, &
-                    scalingval,mask_3dmovie,nu_3dmovie)
+                                       LOCAL_TMP_PATH,MOVIE_VOLUME_TYPE,MOVIE_COARSE,ibool_crust_mantle, &
+                                       veloc_crust_mantle, &
+                                       scalingval,mask_3dmovie,nu_3dmovie)
 
       case( 7 )
         ! output norm of displacement
 
         ! gets resulting array values onto CPU
         if( GPU_MODE ) then
-          ! wavefields
-          call transfer_fields_cm_from_device(NDIM*NGLOB_CRUST_MANTLE, &
-                                displ_crust_mantle,veloc_crust_mantle,accel_crust_mantle,Mesh_pointer)
-          call transfer_fields_ic_from_device(NDIM*NGLOB_INNER_CORE, &
-                                displ_inner_core,veloc_inner_core,accel_inner_core,Mesh_pointer)
-          call transfer_fields_oc_from_device(NGLOB_OUTER_CORE, &
-                                displ_outer_core,veloc_outer_core,accel_outer_core,Mesh_pointer)
+          ! displacement wavefields
+          call transfer_displ_cm_from_device(NDIM*NGLOB_CRUST_MANTLE,displ_crust_mantle,Mesh_pointer)
+          call transfer_displ_ic_from_device(NDIM*NGLOB_INNER_CORE,displ_inner_core,Mesh_pointer)
+          call transfer_displ_oc_from_device(NGLOB_OUTER_CORE,displ_outer_core,Mesh_pointer)
         endif
 
         call write_movie_volume_displnorm(myrank,it,LOCAL_TMP_PATH, &
@@ -196,13 +198,10 @@
 
         ! gets resulting array values onto CPU
         if( GPU_MODE ) then
-          ! wavefields
-          call transfer_fields_cm_from_device(NDIM*NGLOB_CRUST_MANTLE, &
-                                displ_crust_mantle,veloc_crust_mantle,accel_crust_mantle,Mesh_pointer)
-          call transfer_fields_ic_from_device(NDIM*NGLOB_INNER_CORE, &
-                                displ_inner_core,veloc_inner_core,accel_inner_core,Mesh_pointer)
-          call transfer_fields_oc_from_device(NGLOB_OUTER_CORE, &
-                                displ_outer_core,veloc_outer_core,accel_outer_core,Mesh_pointer)
+          ! velocity wavefields
+          call transfer_veloc_cm_from_device(NDIM*NGLOB_CRUST_MANTLE,veloc_crust_mantle,Mesh_pointer)
+          call transfer_veloc_ic_from_device(NDIM*NGLOB_INNER_CORE,veloc_inner_core,Mesh_pointer)
+          call transfer_veloc_oc_from_device(NGLOB_OUTER_CORE,veloc_outer_core,Mesh_pointer)
         endif
 
         call write_movie_volume_velnorm(myrank,it,LOCAL_TMP_PATH, &
@@ -214,13 +213,10 @@
 
         ! gets resulting array values onto CPU
         if( GPU_MODE ) then
-          ! wavefields
-          call transfer_fields_cm_from_device(NDIM*NGLOB_CRUST_MANTLE, &
-                                displ_crust_mantle,veloc_crust_mantle,accel_crust_mantle,Mesh_pointer)
-          call transfer_fields_ic_from_device(NDIM*NGLOB_INNER_CORE, &
-                                displ_inner_core,veloc_inner_core,accel_inner_core,Mesh_pointer)
-          call transfer_fields_oc_from_device(NGLOB_OUTER_CORE, &
-                                displ_outer_core,veloc_outer_core,accel_outer_core,Mesh_pointer)
+          ! acceleration wavefields
+          call transfer_accel_cm_from_device(NDIM*NGLOB_CRUST_MANTLE,accel_crust_mantle,Mesh_pointer)
+          call transfer_accel_ic_from_device(NDIM*NGLOB_INNER_CORE,accel_inner_core,Mesh_pointer)
+          call transfer_accel_oc_from_device(NGLOB_OUTER_CORE,accel_outer_core,Mesh_pointer)
         endif
 
         call write_movie_volume_accelnorm(myrank,it,LOCAL_TMP_PATH, &
@@ -232,6 +228,15 @@
 
       end select ! MOVIE_VOLUME_TYPE
 
+      ! executes an external script on the node
+      if( RUN_EXTERNAL_SCRIPT ) then
+        call sync_all()
+        if( myrank == 0 ) then
+          write(system_command,"('./',a,1x,i6.6,' >& out.',i6.6,'.log &')") trim(script_name),it,it
+          !print*,trim(system_command)
+          call system(system_command)
+        endif
+      endif
     endif
   endif ! MOVIE_VOLUME
 



More information about the CIG-COMMITS mailing list