[cig-commits] r20389 - in seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER: DATA EXAMPLES/global_PREM_kernels/amplitude/DATA EXAMPLES/global_PREM_kernels/traveltime/DATA EXAMPLES/global_s362ani/DATA EXAMPLES/global_s362ani_small/DATA EXAMPLES/noise_examples/global_long EXAMPLES/noise_examples/global_short EXAMPLES/noise_examples/regional EXAMPLES/noise_examples/test_global EXAMPLES/noise_examples/test_regional EXAMPLES/regional_MiddleEast/DATA src/cuda src/meshfem3D src/shared src/specfem3D

danielpeter at geodynamics.org danielpeter at geodynamics.org
Tue Jun 19 15:14:48 PDT 2012


Author: danielpeter
Date: 2012-06-19 15:14:47 -0700 (Tue, 19 Jun 2012)
New Revision: 20389

Modified:
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/amplitude/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/traveltime/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani_small/DATA/Par_file
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_3_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_3_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_3_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_3_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_attenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_3_noattenuation
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_MiddleEast/DATA/Par_file
   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/mesh_constants_cuda.h
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/save_and_compare_cpu_vs_gpu.c
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_MPI_interfaces.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_mass_matrices.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.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/write_c_binary.c
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_receivers.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.f90
   seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_seismograms.f90
Log:
updates mesher routines; updates Par_files in examples

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -42,7 +42,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
-ATTENUATION_NEW			= .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/amplitude/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/amplitude/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/amplitude/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/traveltime/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/traveltime/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_PREM_kernels/traveltime/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani_small/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani_small/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/global_s362ani_small/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -41,6 +41,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_1_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_2_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_3_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_3_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_long/Par_file_NOISE_3_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_1_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_2_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_3_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_3_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/global_short/Par_file_NOISE_3_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_1_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_2_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_3_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_3_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/regional/Par_file_NOISE_3_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_1_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_2_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_3_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_3_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_global/Par_file_NOISE_3_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .false.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_1_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_attenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_attenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_attenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_2_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_3_noattenuation
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_3_noattenuation	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/noise_examples/test_regional/Par_file_NOISE_3_noattenuation	2012-06-19 22:14:47 UTC (rev 20389)
@@ -47,6 +47,7 @@
 GRAVITY                         = .false.
 ROTATION                        = .false.
 ATTENUATION                     = .false.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_MiddleEast/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_MiddleEast/DATA/Par_file	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/EXAMPLES/regional_MiddleEast/DATA/Par_file	2012-06-19 22:14:47 UTC (rev 20389)
@@ -42,6 +42,7 @@
 GRAVITY                         = .true.
 ROTATION                        = .true.
 ATTENUATION                     = .true.
+ATTENUATION_NEW                 = .false.
 
 # absorbing boundary conditions for a regional simulation
 ABSORBING_CONDITIONS            = .true.

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-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/compute_forces_crust_mantle_cuda.cu	2012-06-19 22:14:47 UTC (rev 20389)
@@ -686,12 +686,14 @@
     // or with loss of accuracy:  __sincosf(theta, &sintheta, &costheta);
     // or compile with: -use_fast_math
 
-    costheta = cosf(theta);
-    sintheta = sinf(theta);
-
-    cosphi = cosf(phi);
-    sinphi = sinf(phi);
-
+    //costheta = cosf(theta);
+    //sintheta = sinf(theta);
+    sincosf(theta, &sintheta, &costheta);
+    
+    //cosphi = cosf(phi);
+    //sinphi = sinf(phi);
+    sincosf(phi, &sinphi, &cosphi);
+    
     costwotheta = cosf(2.0f * theta);
     sintwotheta = sinf(2.0f * theta);
     costwophi = cosf(2.0f * phi);

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-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/mesh_constants_cuda.h	2012-06-19 22:14:47 UTC (rev 20389)
@@ -478,16 +478,12 @@
   // ------------------------------------------------------------------ //
   // gravity
   // ------------------------------------------------------------------ //
-  realw* d_d_ln_density_dr_table; // needed for no gravity case
+  realw* d_d_ln_density_dr_table; // needed also for no gravity case
   realw* d_minus_rho_g_over_kappa_fluid;
   realw* d_minus_gravity_table;
   realw* d_minus_deriv_gravity_table;
   realw* d_density_table;
 
-  //daniel: TODO old...
-  //realw* d_minus_g;
-  //realw* d_minus_deriv_gravity;
-
   // ------------------------------------------------------------------ //
   // rotation
   // ------------------------------------------------------------------ //

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/save_and_compare_cpu_vs_gpu.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/save_and_compare_cpu_vs_gpu.c	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/cuda/save_and_compare_cpu_vs_gpu.c	2012-06-19 22:14:47 UTC (rev 20389)
@@ -101,7 +101,7 @@
   //char* errorstr;
   if(fp == 0) {
     //errorstr = (char*) strerror(errno);
-    printf("FILE ERROR:%s\n",strerror(errno));
+    printf("FILE ERROR:%s\n",(char*) strerror(errno));
     perror("file error\n");
     exit(1);
   }
@@ -181,7 +181,7 @@
   if(fp_cpu == 0) {
     //errorstr = (char*) strerror(errno);
     //printf("CPU FILE ERROR:%s\n",errorstr);
-    printf("CPU FILE ERROR:%s\n",strerror(errno));
+    printf("CPU FILE ERROR:%s\n",(char*) strerror(errno));
     perror("cpu file error\n");
   }
   FILE* fp_gpu;
@@ -190,7 +190,7 @@
   if(fp_gpu == NULL) {
     //errorstr = (char*) strerror(errno);
     //printf("GPU FILE ERROR:%s\n",errorstr);
-    printf("GPU FILE ERROR:%s\n",strerror(errno));
+    printf("GPU FILE ERROR:%s\n",(char*) strerror(errno));
     perror("gpu file error\n");
   }
 
@@ -265,7 +265,7 @@
   for(i=0;i<*size;i++) {
     if((fabs(vector[i] - compare_vector[i])/vector[i] > 0.0001)) {
       if(error_count < 30) {
-  printf("ERROR[%d]: %g != %g\n",i,compare_vector[i], vector[i]);
+  printf("ERROR[%d]: %f != %f\n",i,compare_vector[i], vector[i]);
       }
       error_count++;
       /* if(compare_vector[i] > 1e-30) error_count++; */
@@ -308,7 +308,7 @@
   int error_count=0;
   for(i=0;i<*size;i++) {
     if((abs(vector[i] - compare_vector[i])/vector[i] > 0.01) && error_count < 30) {
-      printf("ERROR[%d]: %g != %g\n",i,compare_vector[i], vector[i]);
+      printf("ERROR[%d]: %d != %d\n",i, compare_vector[i], vector[i]);
       error_count++;
     }
   }

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/Makefile.in	2012-06-19 22:14:47 UTC (rev 20389)
@@ -168,7 +168,9 @@
 	$O/moho_stretching.o \
 	$O/read_arrays_buffers_mesher.mpi.o \
 	$O/save_arrays_solver.o \
-	$O/setup_color_perm.mpi.o \
+	$O/setup_color_perm.o \
+	$O/setup_inner_outer.o \
+	$O/setup_MPI_interfaces.o \
 	$O/sort_array_coordinates.o \
 	$O/stretching_function.o \
 	$O/test_MPI_interfaces.mpi.o \

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_MPI_interfaces.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_MPI_interfaces.f90	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_MPI_interfaces.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -268,13 +268,13 @@
   call cmi_read_buffers()
 
   ! sets up MPI interfaces
-  call cmi_setup_MPIinterfaces()
+  call setup_MPI_interfaces()
 
   ! sets up inner/outer element arrays
-  call cmi_setup_InnerOuter()
+  call setup_Inner_Outer()
 
   ! sets up mesh coloring
-  call cmi_setup_color_perm()
+  call setup_color_perm()
 
   ! saves interface infos
   call cmi_save_interfaces()
@@ -719,689 +719,7 @@
 !-------------------------------------------------------------------------------------------------
 !
 
-  subroutine cmi_setup_MPIinterfaces()
 
-  use meshfem3D_par
-  use create_MPI_interfaces_par
-  implicit none
-
-  include 'mpif.h'
-
-  ! local parameters
-  integer :: ier,ndim_assemble
-
-  ! temporary buffers for send and receive between faces of the slices and the chunks
-  real(kind=CUSTOM_REAL), dimension(npoin2D_max_all_CM_IC) ::  &
-    buffer_send_faces_scalar,buffer_received_faces_scalar
-
-  ! assigns initial maximum arrays
-  ! for global slices, maximum number of neighbor is around 17 ( 8 horizontal, max of 8 on bottom )
-  integer :: MAX_NEIGHBOURS
-  integer, dimension(:),allocatable :: my_neighbours,nibool_neighbours
-  integer, dimension(:,:),allocatable :: ibool_neighbours
-  integer :: max_nibool
-  real(kind=CUSTOM_REAL),dimension(:),allocatable :: test_flag
-  integer,dimension(:),allocatable :: dummy_i
-  integer :: i,j,k,ispec,iglob
-  ! debug
-  character(len=150) :: filename
-  logical,parameter :: DEBUG_INTERFACES = .false.
-
-  ! estimates a maximum size of needed arrays
-  MAX_NEIGHBOURS = 8 + NCORNERSCHUNKS
-  if( INCLUDE_CENTRAL_CUBE ) MAX_NEIGHBOURS = MAX_NEIGHBOURS + NUMMSGS_FACES
-
-  allocate(my_neighbours(MAX_NEIGHBOURS), &
-          nibool_neighbours(MAX_NEIGHBOURS),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating my_neighbours array')
-
-  ! estimates initial maximum ibool array
-  max_nibool = npoin2D_max_all_CM_IC * NUMFACES_SHARED &
-               + non_zero_nb_msgs_theor_in_cube*npoin2D_cube_from_slices
-
-  allocate(ibool_neighbours(max_nibool,MAX_NEIGHBOURS), stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating ibool_neighbours')
-
-
-! sets up MPI interfaces
-! crust mantle region
-  if( myrank == 0 ) write(IMAIN,*) 'crust mantle mpi:'
-  allocate(test_flag(NGLOB_CRUST_MANTLE), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating test_flag')
-
-  ! sets flag to rank id (+1 to avoid problems with zero rank)
-  test_flag(:) = myrank + 1.0
-
-  ! assembles values
-  call assemble_MPI_scalar_block(myrank,test_flag, &
-            NGLOB_CRUST_MANTLE, &
-            iproc_xi,iproc_eta,ichunk,addressing, &
-            iboolleft_xi_crust_mantle,iboolright_xi_crust_mantle,iboolleft_eta_crust_mantle,iboolright_eta_crust_mantle, &
-            npoin2D_faces_crust_mantle,npoin2D_xi_crust_mantle,npoin2D_eta_crust_mantle, &
-            iboolfaces_crust_mantle,iboolcorner_crust_mantle, &
-            iprocfrom_faces,iprocto_faces,imsg_type, &
-            iproc_master_corners,iproc_worker1_corners,iproc_worker2_corners, &
-            buffer_send_faces_scalar,buffer_received_faces_scalar,npoin2D_max_all_CM_IC, &
-            buffer_send_chunkcorn_scalar,buffer_recv_chunkcorn_scalar, &
-            NUMMSGS_FACES,NUM_MSG_TYPES,NCORNERSCHUNKS, &
-            NPROC_XI,NPROC_ETA,NGLOB1D_RADIAL(IREGION_CRUST_MANTLE), &
-            NGLOB2DMAX_XMIN_XMAX(IREGION_CRUST_MANTLE),NGLOB2DMAX_YMIN_YMAX(IREGION_CRUST_MANTLE),NGLOB2DMAX_XY,NCHUNKS)
-
-  ! removes own myrank id (+1)
-  test_flag(:) = test_flag(:) - ( myrank + 1.0)
-
-  ! debug: saves array
-  !write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_test_flag_crust_mantle_proc',myrank
-  !call write_VTK_glob_points(NGLOB_CRUST_MANTLE, &
-  !                      xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
-  !                      test_flag,filename)
-
-  allocate(dummy_i(NSPEC_CRUST_MANTLE),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating dummy_i')
-
-  ! 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, &
-                            max_nibool,MAX_NEIGHBOURS, &
-                            ibool_crust_mantle,&
-                            is_on_a_slice_edge_crust_mantle, &
-                            IREGION_CRUST_MANTLE,.false.,dummy_i,INCLUDE_CENTRAL_CUBE, &
-                            xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle,NPROCTOT)
-
-  deallocate(test_flag)
-  deallocate(dummy_i)
-
-  ! stores MPI interfaces informations
-  allocate(my_neighbours_crust_mantle(num_interfaces_crust_mantle), &
-          nibool_interfaces_crust_mantle(num_interfaces_crust_mantle), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array my_neighbours_crust_mantle etc.')
-  my_neighbours_crust_mantle = -1
-  nibool_interfaces_crust_mantle = 0
-
-  ! copies interfaces arrays
-  if( num_interfaces_crust_mantle > 0 ) then
-    allocate(ibool_interfaces_crust_mantle(max_nibool_interfaces_crust_mantle,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
-
-    ! ranks of neighbour processes
-    my_neighbours_crust_mantle(:) = my_neighbours(1:num_interfaces_crust_mantle)
-    ! 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)
-  else
-    ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_crust_mantle = 0
-    allocate(ibool_interfaces_crust_mantle(0,0),stat=ier)
-  endif
-
-  ! debug: outputs MPI interface
-  if( DEBUG_INTERFACES ) then
-  do i=1,num_interfaces_crust_mantle
-    write(filename,'(a,i6.6,a,i2.2)') trim(OUTPUT_FILES)//'/MPI_points_crust_mantle_proc',myrank, &
-                    '_',my_neighbours_crust_mantle(i)
-    call write_VTK_data_points(NGLOB_crust_mantle, &
-                      xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
-                      ibool_interfaces_crust_mantle(1:nibool_interfaces_crust_mantle(i),i), &
-                      nibool_interfaces_crust_mantle(i),filename)
-  enddo
-  call sync_all()
-  endif
-
-  ! checks addressing
-  call test_MPI_neighbours(IREGION_CRUST_MANTLE, &
-                              num_interfaces_crust_mantle,max_nibool_interfaces_crust_mantle, &
-                              my_neighbours_crust_mantle,nibool_interfaces_crust_mantle, &
-                              ibool_interfaces_crust_mantle)
-
-  ! allocates MPI buffers
-  ! crust mantle
-  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), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_crust_mantle etc.')
-
-  ! checks with assembly of test fields
-  call test_MPI_cm()
-
-
-! outer core region
-  if( myrank == 0 ) write(IMAIN,*) 'outer core mpi:'
-
-  allocate(test_flag(NGLOB_OUTER_CORE), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating test_flag outer core')
-
-  ! sets flag to rank id (+1 to avoid problems with zero rank)
-  test_flag(:) = myrank + 1.0
-
-  ! assembles values
-  call assemble_MPI_scalar_block(myrank,test_flag, &
-            NGLOB_OUTER_CORE, &
-            iproc_xi,iproc_eta,ichunk,addressing, &
-            iboolleft_xi_outer_core,iboolright_xi_outer_core,iboolleft_eta_outer_core,iboolright_eta_outer_core, &
-            npoin2D_faces_outer_core,npoin2D_xi_outer_core,npoin2D_eta_outer_core, &
-            iboolfaces_outer_core,iboolcorner_outer_core, &
-            iprocfrom_faces,iprocto_faces,imsg_type, &
-            iproc_master_corners,iproc_worker1_corners,iproc_worker2_corners, &
-            buffer_send_faces_scalar,buffer_received_faces_scalar,npoin2D_max_all_CM_IC, &
-            buffer_send_chunkcorn_scalar,buffer_recv_chunkcorn_scalar, &
-            NUMMSGS_FACES,NUM_MSG_TYPES,NCORNERSCHUNKS, &
-            NPROC_XI,NPROC_ETA,NGLOB1D_RADIAL(IREGION_OUTER_CORE), &
-            NGLOB2DMAX_XMIN_XMAX(IREGION_OUTER_CORE),NGLOB2DMAX_YMIN_YMAX(IREGION_OUTER_CORE),NGLOB2DMAX_XY,NCHUNKS)
-
-
-  ! removes own myrank id (+1)
-  test_flag(:) = test_flag(:) - ( myrank + 1.0)
-
-  ! debug: saves array
-  !write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_test_flag_outer_core_proc',myrank
-  !call write_VTK_glob_points(NGLOB_OUTER_CORE, &
-  !                      xstore_outer_core,ystore_outer_core,zstore_outer_core, &
-  !                      test_flag,filename)
-
-  allocate(dummy_i(NSPEC_OUTER_CORE),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating dummy_i')
-
-  ! 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, &
-                            max_nibool,MAX_NEIGHBOURS, &
-                            ibool_outer_core,&
-                            is_on_a_slice_edge_outer_core, &
-                            IREGION_OUTER_CORE,.false.,dummy_i,INCLUDE_CENTRAL_CUBE, &
-                            xstore_outer_core,ystore_outer_core,zstore_outer_core,NPROCTOT)
-
-  deallocate(test_flag)
-  deallocate(dummy_i)
-
-  ! stores MPI interfaces informations
-  allocate(my_neighbours_outer_core(num_interfaces_outer_core), &
-          nibool_interfaces_outer_core(num_interfaces_outer_core), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array my_neighbours_outer_core etc.')
-  my_neighbours_outer_core = -1
-  nibool_interfaces_outer_core = 0
-
-  ! copies interfaces arrays
-  if( num_interfaces_outer_core > 0 ) then
-    allocate(ibool_interfaces_outer_core(max_nibool_interfaces_outer_core,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
-
-    ! ranks of neighbour processes
-    my_neighbours_outer_core(:) = my_neighbours(1:num_interfaces_outer_core)
-    ! 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)
-  else
-    ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_outer_core = 0
-    allocate(ibool_interfaces_outer_core(0,0),stat=ier)
-  endif
-
-  ! debug: outputs MPI interface
-  if( DEBUG_INTERFACES ) then
-  do i=1,num_interfaces_outer_core
-    write(filename,'(a,i6.6,a,i2.2)') trim(OUTPUT_FILES)//'/MPI_points_outer_core_proc',myrank, &
-                    '_',my_neighbours_outer_core(i)
-    call write_VTK_data_points(NGLOB_OUTER_CORE, &
-                      xstore_outer_core,ystore_outer_core,zstore_outer_core, &
-                      ibool_interfaces_outer_core(1:nibool_interfaces_outer_core(i),i), &
-                      nibool_interfaces_outer_core(i),filename)
-  enddo
-  call sync_all()
-  endif
-
-  ! checks addressing
-  call test_MPI_neighbours(IREGION_OUTER_CORE, &
-                              num_interfaces_outer_core,max_nibool_interfaces_outer_core, &
-                              my_neighbours_outer_core,nibool_interfaces_outer_core, &
-                              ibool_interfaces_outer_core)
-
-  ! allocates MPI buffers
-  ! outer core
-  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), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_outer_core etc.')
-
-  ! checks with assembly of test fields
-  call test_MPI_oc()
-
-
-! inner core
-  if( myrank == 0 ) write(IMAIN,*) 'inner core mpi:'
-
-  allocate(test_flag(NGLOB_INNER_CORE), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating test_flag inner core')
-
-  ! sets flag to rank id (+1 to avoid problems with zero rank)
-  test_flag(:) = 0.0
-  do ispec=1,NSPEC_INNER_CORE
-    ! suppress fictitious elements in central cube
-    if(idoubling_inner_core(ispec) == IFLAG_IN_FICTITIOUS_CUBE) cycle
-    ! sets flags
-    do k = 1,NGLLZ
-      do j = 1,NGLLY
-        do i = 1,NGLLX
-          iglob = ibool_inner_core(i,j,k,ispec)
-          test_flag(iglob) = myrank + 1.0
-        enddo
-      enddo
-    enddo
-  enddo
-
-  ! assembles values
-  call assemble_MPI_scalar_block(myrank,test_flag, &
-            NGLOB_INNER_CORE, &
-            iproc_xi,iproc_eta,ichunk,addressing, &
-            iboolleft_xi_inner_core,iboolright_xi_inner_core,iboolleft_eta_inner_core,iboolright_eta_inner_core, &
-            npoin2D_faces_inner_core,npoin2D_xi_inner_core,npoin2D_eta_inner_core, &
-            iboolfaces_inner_core,iboolcorner_inner_core, &
-            iprocfrom_faces,iprocto_faces,imsg_type, &
-            iproc_master_corners,iproc_worker1_corners,iproc_worker2_corners, &
-            buffer_send_faces_scalar,buffer_received_faces_scalar,npoin2D_max_all_CM_IC, &
-            buffer_send_chunkcorn_scalar,buffer_recv_chunkcorn_scalar, &
-            NUMMSGS_FACES,NUM_MSG_TYPES,NCORNERSCHUNKS, &
-            NPROC_XI,NPROC_ETA,NGLOB1D_RADIAL(IREGION_INNER_CORE), &
-            NGLOB2DMAX_XMIN_XMAX(IREGION_INNER_CORE),NGLOB2DMAX_YMIN_YMAX(IREGION_INNER_CORE),NGLOB2DMAX_XY,NCHUNKS)
-
-  ! debug: saves array
-  !write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_test_flag_inner_core_A_proc',myrank
-  !call write_VTK_glob_points(NGLOB_INNER_CORE, &
-  !                      xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-  !                      test_flag,filename)
-
-  ! debug: idoubling inner core
-  if( DEBUG_INTERFACES ) then
-    write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_idoubling_inner_core_proc',myrank
-    call write_VTK_data_elem_i(NSPEC_INNER_CORE,NGLOB_INNER_CORE, &
-                            xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-                            ibool_inner_core, &
-                            idoubling_inner_core,filename)
-    call sync_all()
-  endif
-
-  ! including central cube
-  if(INCLUDE_CENTRAL_CUBE) then
-    ! user output
-    if( myrank == 0 ) write(IMAIN,*) 'inner core with central cube mpi:'
-
-    ! test_flag is a scalar, not a vector
-    ndim_assemble = 1
-
-    ! use central cube buffers to assemble the inner core mass matrix with the central cube
-    call assemble_MPI_central_cube_block(ichunk,nb_msgs_theor_in_cube, sender_from_slices_to_cube, &
-                 npoin2D_cube_from_slices, buffer_all_cube_from_slices, &
-                 buffer_slices, buffer_slices2, ibool_central_cube, &
-                 receiver_cube_from_slices, ibool_inner_core, &
-                 idoubling_inner_core, NSPEC_INNER_CORE, &
-                 ibelm_bottom_inner_core, NSPEC2D_BOTTOM(IREGION_INNER_CORE), &
-                 NGLOB_INNER_CORE, &
-                 test_flag,ndim_assemble, &
-                 iproc_eta,addressing,NCHUNKS,NPROC_XI,NPROC_ETA)
-  endif
-
-  ! removes own myrank id (+1)
-  test_flag = test_flag - ( myrank + 1.0)
-  where( test_flag < 0.0 ) test_flag = 0.0
-
-  ! debug: saves array
-  !write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_test_flag_inner_core_B_proc',myrank
-  !call write_VTK_glob_points(NGLOB_INNER_CORE, &
-  !                    xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-  !                    test_flag,filename)
-  !call sync_all()
-
-  ! in sequential order, for testing purpose
-  do i=0,NPROCTOT - 1
-    if( myrank == i ) then
-      ! gets new interfaces for inner_core without central cube yet
-      ! 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, &
-                            max_nibool,MAX_NEIGHBOURS, &
-                            ibool_inner_core,&
-                            is_on_a_slice_edge_inner_core, &
-                            IREGION_INNER_CORE,.false.,idoubling_inner_core,INCLUDE_CENTRAL_CUBE, &
-                            xstore_inner_core,ystore_inner_core,zstore_inner_core,NPROCTOT)
-
-    endif
-    call sync_all()
-  enddo
-
-
-  deallocate(test_flag)
-  call sync_all()
-
-  ! stores MPI interfaces informations
-  allocate(my_neighbours_inner_core(num_interfaces_inner_core), &
-          nibool_interfaces_inner_core(num_interfaces_inner_core), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array my_neighbours_inner_core etc.')
-  my_neighbours_inner_core = -1
-  nibool_interfaces_inner_core = 0
-
-  ! copies interfaces arrays
-  if( num_interfaces_inner_core > 0 ) then
-    allocate(ibool_interfaces_inner_core(max_nibool_interfaces_inner_core,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
-
-    ! ranks of neighbour processes
-    my_neighbours_inner_core(:) = my_neighbours(1:num_interfaces_inner_core)
-    ! 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)
-  else
-    ! dummy allocation (fortran90 should allow allocate statement with zero array size)
-    max_nibool_interfaces_inner_core = 0
-    allocate(ibool_interfaces_inner_core(0,0),stat=ier)
-  endif
-
-  ! debug: saves MPI interfaces
-  if( DEBUG_INTERFACES ) then
-  do i=1,num_interfaces_inner_core
-    write(filename,'(a,i6.6,a,i2.2)') trim(OUTPUT_FILES)//'/MPI_points_inner_core_proc',myrank, &
-                    '_',my_neighbours_inner_core(i)
-    call write_VTK_data_points(NGLOB_INNER_CORE, &
-                      xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-                      ibool_interfaces_inner_core(1:nibool_interfaces_inner_core(i),i), &
-                      nibool_interfaces_inner_core(i),filename)
-  enddo
-  call sync_all()
-  endif
-
-  ! checks addressing
-  call test_MPI_neighbours(IREGION_INNER_CORE, &
-                              num_interfaces_inner_core,max_nibool_interfaces_inner_core, &
-                              my_neighbours_inner_core,nibool_interfaces_inner_core, &
-                              ibool_interfaces_inner_core)
-
-  ! allocates MPI buffers
-  ! inner core
-  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), &
-          stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array buffer_send_vector_inner_core etc.')
-
-  ! checks with assembly of test fields
-  call test_MPI_ic()
-
-  ! synchronizes MPI processes
-  call sync_all()
-
-  ! frees temporary array
-  deallocate(ibool_neighbours)
-  deallocate(my_neighbours,nibool_neighbours)
-
-  end subroutine cmi_setup_MPIinterfaces
-
-!
-!-------------------------------------------------------------------------------------------------
-!
-
-  subroutine cmi_setup_InnerOuter()
-
-  use meshfem3D_par
-  use create_MPI_interfaces_par
-  implicit none
-
-  ! local parameters
-  real :: percentage_edge
-  integer :: ier,ispec,iinner,iouter
-  ! debug
-  character(len=150) :: filename
-  logical,parameter :: DEBUG_INTERFACES = .false.
-
-  ! stores inner / outer elements
-  !
-  ! note: arrays is_on_a_slice_edge_.. have flags set for elements which need to
-  !         communicate with other MPI processes
-
-  ! crust_mantle
-  nspec_outer_crust_mantle = count( is_on_a_slice_edge_crust_mantle )
-  nspec_inner_crust_mantle = NSPEC_CRUST_MANTLE - nspec_outer_crust_mantle
-
-  num_phase_ispec_crust_mantle = max(nspec_inner_crust_mantle,nspec_outer_crust_mantle)
-
-  allocate(phase_ispec_inner_crust_mantle(num_phase_ispec_crust_mantle,2),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array phase_ispec_inner_crust_mantle')
-
-  phase_ispec_inner_crust_mantle(:,:) = 0
-  iinner = 0
-  iouter = 0
-  do ispec=1,NSPEC_CRUST_MANTLE
-    if( is_on_a_slice_edge_crust_mantle(ispec) ) then
-      ! outer element
-      iouter = iouter + 1
-      phase_ispec_inner_crust_mantle(iouter,1) = ispec
-    else
-      ! inner element
-      iinner = iinner + 1
-      phase_ispec_inner_crust_mantle(iinner,2) = ispec
-    endif
-  enddo
-
-  ! outer_core
-  nspec_outer_outer_core = count( is_on_a_slice_edge_outer_core )
-  nspec_inner_outer_core = NSPEC_OUTER_CORE - nspec_outer_outer_core
-
-  num_phase_ispec_outer_core = max(nspec_inner_outer_core,nspec_outer_outer_core)
-
-  allocate(phase_ispec_inner_outer_core(num_phase_ispec_outer_core,2),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array phase_ispec_inner_outer_core')
-
-  phase_ispec_inner_outer_core(:,:) = 0
-  iinner = 0
-  iouter = 0
-  do ispec=1,NSPEC_OUTER_CORE
-    if( is_on_a_slice_edge_outer_core(ispec) ) then
-      ! outer element
-      iouter = iouter + 1
-      phase_ispec_inner_outer_core(iouter,1) = ispec
-    else
-      ! inner element
-      iinner = iinner + 1
-      phase_ispec_inner_outer_core(iinner,2) = ispec
-    endif
-  enddo
-
-  ! inner_core
-  nspec_outer_inner_core = count( is_on_a_slice_edge_inner_core )
-  nspec_inner_inner_core = NSPEC_INNER_CORE - nspec_outer_inner_core
-
-  num_phase_ispec_inner_core = max(nspec_inner_inner_core,nspec_outer_inner_core)
-
-  allocate(phase_ispec_inner_inner_core(num_phase_ispec_inner_core,2),stat=ier)
-  if( ier /= 0 ) call exit_mpi(myrank,'error allocating array phase_ispec_inner_inner_core')
-
-  phase_ispec_inner_inner_core(:,:) = 0
-  iinner = 0
-  iouter = 0
-  do ispec=1,NSPEC_INNER_CORE
-    if( is_on_a_slice_edge_inner_core(ispec) ) then
-      ! outer element
-      iouter = iouter + 1
-      phase_ispec_inner_inner_core(iouter,1) = ispec
-    else
-      ! inner element
-      iinner = iinner + 1
-      phase_ispec_inner_inner_core(iinner,2) = ispec
-    endif
-  enddo
-
-  ! user output
-  if(myrank == 0) then
-
-    write(IMAIN,*)
-    write(IMAIN,*) 'for overlapping of communications with calculations:'
-    write(IMAIN,*)
-
-    percentage_edge = 100. * nspec_outer_crust_mantle / real(NSPEC_CRUST_MANTLE)
-    write(IMAIN,*) 'percentage of edge elements in crust/mantle ',percentage_edge,'%'
-    write(IMAIN,*) 'percentage of volume elements in crust/mantle ',100. - percentage_edge,'%'
-    write(IMAIN,*)
-
-    percentage_edge = 100.* nspec_outer_outer_core / real(NSPEC_OUTER_CORE)
-    write(IMAIN,*) 'percentage of edge elements in outer core ',percentage_edge,'%'
-    write(IMAIN,*) 'percentage of volume elements in outer core ',100. - percentage_edge,'%'
-    write(IMAIN,*)
-
-    percentage_edge = 100. * nspec_outer_inner_core / real(NSPEC_INNER_CORE)
-    write(IMAIN,*) 'percentage of edge elements in inner core ',percentage_edge,'%'
-    write(IMAIN,*) 'percentage of volume elements in inner core ',100. - percentage_edge,'%'
-    write(IMAIN,*)
-
-  endif
-
-  ! debug: saves element flags
-  if( DEBUG_INTERFACES ) then
-    ! crust mantle
-    write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_innerouter_crust_mantle_proc',myrank
-    call write_VTK_data_elem_l(NSPEC_CRUST_MANTLE,NGLOB_CRUST_MANTLE, &
-                              xstore_crust_mantle,ystore_crust_mantle,zstore_crust_mantle, &
-                              ibool_crust_mantle, &
-                              is_on_a_slice_edge_crust_mantle,filename)
-    ! outer core
-    write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_innerouter_outer_core_proc',myrank
-    call write_VTK_data_elem_l(NSPEC_OUTER_CORE,NGLOB_OUTER_CORE, &
-                              xstore_outer_core,ystore_outer_core,zstore_outer_core, &
-                              ibool_outer_core, &
-                              is_on_a_slice_edge_outer_core,filename)
-    ! inner core
-    write(filename,'(a,i6.6)') trim(OUTPUT_FILES)//'/MPI_innerouter_inner_core_proc',myrank
-    call write_VTK_data_elem_l(NSPEC_INNER_CORE,NGLOB_INNER_CORE, &
-                              xstore_inner_core,ystore_inner_core,zstore_inner_core, &
-                              ibool_inner_core, &
-                              is_on_a_slice_edge_inner_core,filename)
-  endif
-
-  end subroutine cmi_setup_InnerOuter
-
-
-!
-!-------------------------------------------------------------------------------------------------
-!
-
-  subroutine cmi_setup_color_perm()
-
-  use meshfem3D_par
-  use create_MPI_interfaces_par
-  implicit none
-
-  ! local parameters
-  integer, dimension(:), allocatable :: perm
-  integer :: ier
-
-  ! user output
-  if(myrank == 0) then
-    write(IMAIN,*) 'mesh coloring: ',USE_MESH_COLORING_GPU
-  endif
-
-  ! crust mantle
-  ! initializes
-  num_colors_outer_crust_mantle = 0
-  num_colors_inner_crust_mantle = 0
-
-  ! mesh coloring
-  if( USE_MESH_COLORING_GPU ) then
-
-    ! user output
-    if(myrank == 0) write(IMAIN,*) '  coloring crust mantle... '
-
-    ! creates coloring of elements
-    allocate(perm(NSPEC_CRUST_MANTLE),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm crust mantle array')
-    perm(:) = 0
-
-    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle+num_colors_inner_crust_mantle),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_crust_mantle array')
-
-    deallocate(perm)
-  else
-    ! dummy array
-    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle+num_colors_inner_crust_mantle),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_crust_mantle array')
-  endif
-
-  ! outer core
-  ! initializes
-  num_colors_outer_outer_core = 0
-  num_colors_inner_outer_core = 0
-
-  ! mesh coloring
-  if( USE_MESH_COLORING_GPU ) then
-
-    ! user output
-    if(myrank == 0) write(IMAIN,*) '  coloring outer core... '
-
-    ! creates coloring of elements
-    allocate(perm(NSPEC_OUTER_CORE),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm outer core array')
-    perm(:) = 0
-
-    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+num_colors_inner_outer_core),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_outer_core array')
-
-    deallocate(perm)
-  else
-    ! dummy array
-    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+num_colors_inner_outer_core),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_outer_core array')
-  endif
-
-  ! inner core
-  ! initializes
-  num_colors_outer_inner_core = 0
-  num_colors_inner_inner_core = 0
-
-  ! mesh coloring
-  if( USE_MESH_COLORING_GPU ) then
-
-    ! user output
-    if(myrank == 0) write(IMAIN,*) '  coloring inner core... '
-
-    ! creates coloring of elements
-    allocate(perm(NSPEC_INNER_CORE),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm inner core array')
-    perm(:) = 0
-
-    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core+num_colors_inner_inner_core),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_inner_core array')
-
-    deallocate(perm)
-  else
-    ! dummy array
-    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core+num_colors_inner_inner_core),stat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_inner_core array')
-  endif
-
-  end subroutine cmi_setup_color_perm
-
-!
-!-------------------------------------------------------------------------------------------------
-!
-
   subroutine cmi_save_interfaces()
 
   use meshfem3D_par

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_mass_matrices.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_mass_matrices.f90	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_mass_matrices.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -124,7 +124,7 @@
   double precision :: elevation,height_oceans
   real(kind=CUSTOM_REAL) :: xixl,xiyl,xizl,etaxl,etayl,etazl,gammaxl,gammayl,gammazl,jacobianl
 
-  integer :: ispec,i,j,k,iglob
+  integer :: ispec,i,j,k,iglob,ier
   integer :: ix_oceans,iy_oceans,iz_oceans,ispec_oceans,ispec2D_top_crust
 
   ! initializes matrices
@@ -333,7 +333,8 @@
 
      ! read arrays for Stacey conditions
      open(unit=27,file=prname(1:len_trim(prname))//'stacey.bin', &
-          status='old',form='unformatted',action='read')
+          status='old',form='unformatted',action='read',iostat=ier)
+     if( ier /= 0 ) call exit_mpi(myrank,'error opening stacey.bin in create_mass_matrices')
      read(27) nimin
      read(27) nimax
      read(27) njmin
@@ -664,6 +665,7 @@
   endif
 
   ! check that mass matrix is positive
-  if(minval(rmassz(:)) <= 0.) call exit_MPI(myrank,'negative rmassz matrix term')
+  ! note: in fictitious elements it is still zero
+  if(minval(rmassz(:)) < 0._CUSTOM_REAL) call exit_MPI(myrank,'negative rmassz matrix term')
 
   end subroutine create_mass_matrices

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/create_regions_mesh.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -770,10 +770,10 @@
     !nspec_tiso = count(idoubling(1:nspec) == IFLAG_220_80) + count(idoubling(1:nspec) == IFLAG_80_MOHO)
     nspec_tiso = count(ispec_is_tiso(:))
 
-    ! mesh sorting and coloring
-    call setup_color_perm(myrank,iregion_code,nspec,nglob, &
-                              ibool,is_on_a_slice_edge,prname, &
-                              npoin2D_xi,npoin2D_eta)
+    ! daniel: deprecated - mesh sorting and coloring
+    !call setup_color_perm(myrank,iregion_code,nspec,nglob, &
+    !                          ibool,is_on_a_slice_edge,prname, &
+    !                          npoin2D_xi,npoin2D_eta)
 
     ! precomputes jacobian for 2d absorbing boundary surfaces
     call get_jacobian_boundaries(myrank,iboun,nspec,xstore,ystore,zstore, &

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-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/meshfem3D/setup_color_perm.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -25,231 +25,335 @@
 !
 !=====================================================================
 
-  subroutine setup_color_perm(myrank,iregion_code,nspec,nglob, &
-                              ibool,is_on_a_slice_edge,prname, &
-                              npoin2D_xi,npoin2D_eta)
 
-  use constants
-  use meshfem3D_par,only: NSTEP,DT,NPROC_XI,NPROC_ETA
-  implicit none
 
-  ! standard include of the MPI library
-  include 'mpif.h'
+  subroutine setup_color_perm()
 
-  integer :: myrank
-  integer :: iregion_code
+  use meshfem3D_par
+  use create_MPI_interfaces_par
+  implicit none
 
-  integer :: nspec,nglob
-  integer, dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
-
-  ! this for non blocking MPI
-  logical, dimension(nspec) :: is_on_a_slice_edge
-
-  ! name of the database file
-  character(len=150) :: prname
-
-  integer :: npoin2D_xi,npoin2D_eta
-
   ! local parameters
-  integer :: nb_colors_outer_elements,nb_colors_inner_elements,nspec_outer
   integer, dimension(:), allocatable :: perm
-  integer, dimension(:), allocatable :: first_elem_number_in_this_color
-  integer, dimension(:), allocatable :: num_of_elems_in_this_color
+  integer :: ier
 
-  integer :: icolor,ispec_counter
-  integer :: nspec_outer_min_global,nspec_outer_max_global
-  integer :: ispec,ier
+  ! user output
+  if(myrank == 0) then
+    write(IMAIN,*) 'mesh coloring: ',USE_MESH_COLORING_GPU
+  endif
 
-  !!!! David Michea: detection of the edges, coloring and permutation separately
-  allocate(perm(nspec))
+  ! crust mantle
+  ! initializes
+  num_colors_outer_crust_mantle = 0
+  num_colors_inner_crust_mantle = 0
 
-  ! implement mesh coloring for GPUs if needed, to create subsets of disconnected elements
-  ! to remove dependencies and the need for atomic operations in the sum of elemental contributions in the solver
-  if(USE_MESH_COLORING_GPU) then
+  ! mesh coloring
+  if( USE_MESH_COLORING_GPU ) then
 
     ! user output
-    if(myrank == 0 ) write(IMAIN,*) '  creating mesh coloring'
+    if(myrank == 0) write(IMAIN,*) '  coloring crust mantle... '
 
-    allocate(first_elem_number_in_this_color(MAX_NUMBER_OF_COLORS + 1))
+    ! creates coloring of elements
+    allocate(perm(NSPEC_CRUST_MANTLE),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm crust mantle array')
+    perm(:) = 0
 
-    call get_perm_color_faster(is_on_a_slice_edge,ibool,perm,nspec,nglob, &
-                              nb_colors_outer_elements,nb_colors_inner_elements,nspec_outer, &
-                              first_elem_number_in_this_color,myrank)
+    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle+num_colors_inner_crust_mantle),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_crust_mantle array')
 
-    ! for the last color, the next color is fictitious and its first (fictitious) element number is nspec + 1
-    first_elem_number_in_this_color(nb_colors_outer_elements + nb_colors_inner_elements + 1) = nspec + 1
+    deallocate(perm)
+  else
+    ! dummy array
+    allocate(num_elem_colors_crust_mantle(num_colors_outer_crust_mantle+num_colors_inner_crust_mantle),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_crust_mantle array')
+  endif
 
-    allocate(num_of_elems_in_this_color(nb_colors_outer_elements + nb_colors_inner_elements))
+  ! outer core
+  ! initializes
+  num_colors_outer_outer_core = 0
+  num_colors_inner_outer_core = 0
 
-    ! save mesh coloring
-    open(unit=99,file=prname(1:len_trim(prname))//'num_of_elems_in_this_color.dat', &
-         status='unknown',iostat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error opening num_of_elems_in_this_color file')
+  ! mesh coloring
+  if( USE_MESH_COLORING_GPU ) then
 
-    ! number of colors for outer elements
-    write(99,*) nb_colors_outer_elements
+    ! user output
+    if(myrank == 0) write(IMAIN,*) '  coloring outer core... '
 
-    ! number of colors for inner elements
-    write(99,*) nb_colors_inner_elements
+    ! creates coloring of elements
+    allocate(perm(NSPEC_OUTER_CORE),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm outer core array')
+    perm(:) = 0
 
-    ! number of elements in each color
-    do icolor = 1, nb_colors_outer_elements + nb_colors_inner_elements
-      num_of_elems_in_this_color(icolor) = first_elem_number_in_this_color(icolor+1) &
-                                          - first_elem_number_in_this_color(icolor)
-      write(99,*) num_of_elems_in_this_color(icolor)
-    enddo
-    close(99)
+    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+num_colors_inner_outer_core),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_outer_core array')
 
-    ! check that the sum of all the numbers of elements found in each color is equal
-    ! to the total number of elements in the mesh
-    if(sum(num_of_elems_in_this_color) /= nspec) then
-      print *,'nspec = ',nspec
-      print *,'total number of elements in all the colors of the mesh = ',sum(num_of_elems_in_this_color)
-      call exit_mpi(myrank,'incorrect total number of elements in all the colors of the mesh')
-    endif
+    deallocate(perm)
+  else
+    ! dummy array
+    allocate(num_elem_colors_outer_core(num_colors_outer_outer_core+num_colors_inner_outer_core),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_outer_core array')
+  endif
 
-    ! check that the sum of all the numbers of elements found in each color for the outer elements is equal
-    ! to the total number of outer elements found in the mesh
-    if(sum(num_of_elems_in_this_color(1:nb_colors_outer_elements)) /= nspec_outer) then
-      print *,'nspec_outer = ',nspec_outer
-      print *,'total number of elements in all the colors of the mesh for outer elements = ', &
-        sum(num_of_elems_in_this_color)
-      call exit_mpi(myrank,'incorrect total number of elements in all the colors of the mesh for outer elements')
-    endif
+  ! inner core
+  ! initializes
+  num_colors_outer_inner_core = 0
+  num_colors_inner_inner_core = 0
 
-    call MPI_ALLREDUCE(nspec_outer,nspec_outer_min_global,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ier)
-    call MPI_ALLREDUCE(nspec_outer,nspec_outer_max_global,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ier)
+  ! mesh coloring
+  if( USE_MESH_COLORING_GPU ) then
 
-    deallocate(first_elem_number_in_this_color)
-    deallocate(num_of_elems_in_this_color)
+    ! user output
+    if(myrank == 0) write(IMAIN,*) '  coloring inner core... '
 
-  else
-
-    !! DK DK for regular C + MPI version for CPUs: do not use colors but nonetheless put all the outer elements
-    !! DK DK first in order to be able to overlap non-blocking MPI communications with calculations
-
-    !! DK DK nov 2010, for Rosa Badia / StarSs:
-    !! no need for mesh coloring, but need to implement inner/outer subsets for non blocking MPI for StarSs
-    ispec_counter = 0
+    ! creates coloring of elements
+    allocate(perm(NSPEC_INNER_CORE),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating temporary perm inner core array')
     perm(:) = 0
 
-    ! first generate all the outer elements
-    do ispec = 1,nspec
-      if(is_on_a_slice_edge(ispec)) then
-        ispec_counter = ispec_counter + 1
-        perm(ispec) = ispec_counter
-      endif
-    enddo
+    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core+num_colors_inner_inner_core),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_inner_core array')
 
-    ! make sure we have detected some outer elements
-    if(ispec_counter <= 0) stop 'fatal error: no outer elements detected!'
-
-    ! store total number of outer elements
-    nspec_outer = ispec_counter
-
-    ! then generate all the inner elements
-    do ispec = 1,nspec
-      if(.not. is_on_a_slice_edge(ispec)) then
-        ispec_counter = ispec_counter + 1
-        perm(ispec) = ispec_counter
-      endif
-    enddo
-
-    ! test that all the elements have been used once and only once
-    if(ispec_counter /= nspec) stop 'fatal error: ispec_counter not equal to nspec'
-
-    ! do basic checks
-    if(minval(perm) /= 1) stop 'minval(perm) should be 1'
-    if(maxval(perm) /= nspec) stop 'maxval(perm) should be nspec'
-
-    call MPI_ALLREDUCE(nspec_outer,nspec_outer_min_global,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ier)
-    call MPI_ALLREDUCE(nspec_outer,nspec_outer_max_global,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ier)
-
-  endif ! USE_MESH_COLORING_GPU
-
-  !! DK DK and Manh Ha, Nov 2011: added this to use the new mesher in the CUDA or C / StarSs test codes
-
-  if (myrank == 0 .and. iregion_code == IREGION_CRUST_MANTLE) then
-    ! write a header file for the Fortran version of the solver
-    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_f90.h', &
-          status='unknown',iostat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error opening file values_from_mesher_f90.h')
-
-    write(99,*) 'integer, parameter :: NSPEC = ',nspec
-    write(99,*) 'integer, parameter :: NGLOB = ',nglob
-    !!! DK DK use 1000 time steps only for the scaling tests
-    write(99,*) 'integer, parameter :: NSTEP = 1000 !!!!!!!!!!! ',nstep
-    write(99,*) 'real(kind=4), parameter :: deltat = ',DT
-    write(99,*)
-    write(99,*) 'integer, parameter ::  NGLOB2DMAX_XMIN_XMAX = ',npoin2D_xi
-    write(99,*) 'integer, parameter ::  NGLOB2DMAX_YMIN_YMAX = ',npoin2D_eta
-    write(99,*) 'integer, parameter ::  NGLOB2DMAX_ALL = ',max(npoin2D_xi,npoin2D_eta)
-    write(99,*) 'integer, parameter ::  NPROC_XI = ',NPROC_XI
-    write(99,*) 'integer, parameter ::  NPROC_ETA = ',NPROC_ETA
-    write(99,*)
-    write(99,*) '! element number of the source and of the station'
-    write(99,*) '! after permutation of the elements by mesh coloring'
-    write(99,*) '! and inner/outer set splitting in the mesher'
-    write(99,*) 'integer, parameter :: NSPEC_SOURCE = ',perm(NSPEC/3)
-    write(99,*) 'integer, parameter :: RANK_SOURCE = 0'
-    write(99,*)
-    write(99,*) 'integer, parameter :: RANK_STATION = (NPROC_XI*NPROC_ETA - 1)'
-    write(99,*) 'integer, parameter :: NSPEC_STATION = ',perm(2*NSPEC/3)
-
-    ! save coordinates of the seismic source
-    !   write(99,*) xstore(2,2,2,10);
-    !   write(99,*) ystore(2,2,2,10);
-    !   write(99,*) zstore(2,2,2,10);
-
-    ! save coordinates of the seismic station
-    !   write(99,*) xstore(2,2,2,nspec-10);
-    !   write(99,*) ystore(2,2,2,nspec-10);
-    !   write(99,*) zstore(2,2,2,nspec-10);
-    close(99)
-
-    !! write a header file for the C version of the solver
-    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_C.h', &
-          status='unknown',iostat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error opening file values_from_mesher_C.h')
-
-    write(99,*) '#define NSPEC ',nspec
-    write(99,*) '#define NGLOB ',nglob
-    !!    write(99,*) '#define NSTEP ',nstep
-    !!! DK DK use 1000 time steps only for the scaling tests
-    write(99,*) '// #define NSTEP ',nstep
-    write(99,*) '#define NSTEP 1000'
-    ! put an "f" at the end to force single precision
-    write(99,"('#define deltat ',e18.10,'f')") DT
-    write(99,*) '#define NGLOB2DMAX_XMIN_XMAX ',npoin2D_xi
-    write(99,*) '#define NGLOB2DMAX_YMIN_YMAX ',npoin2D_eta
-    write(99,*) '#define NGLOB2DMAX_ALL ',max(npoin2D_xi,npoin2D_eta)
-    write(99,*) '#define NPROC_XI ',NPROC_XI
-    write(99,*) '#define NPROC_ETA ',NPROC_ETA
-    write(99,*)
-    write(99,*) '// element and MPI slice number of the source and the station'
-    write(99,*) '// after permutation of the elements by mesh coloring'
-    write(99,*) '// and inner/outer set splitting in the mesher'
-    write(99,*) '#define RANK_SOURCE 0'
-    write(99,*) '#define NSPEC_SOURCE ',perm(NSPEC/3)
-    write(99,*)
-    write(99,*) '#define RANK_STATION (NPROC_XI*NPROC_ETA - 1)'
-    write(99,*) '#define NSPEC_STATION ',perm(2*NSPEC/3)
-    close(99)
-
-    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_nspec_outer.h', &
-          status='unknown',iostat=ier)
-    if( ier /= 0 ) call exit_mpi(myrank,'error opening values_from_mesher_nspec_outer.h file')
-
-    write(99,*) '#define NSPEC_OUTER ',nspec_outer_max_global
-    write(99,*) '// NSPEC_OUTER_min = ',nspec_outer_min_global
-    write(99,*) '// NSPEC_OUTER_max = ',nspec_outer_max_global
-    close(99)
-
+    deallocate(perm)
+  else
+    ! dummy array
+    allocate(num_elem_colors_inner_core(num_colors_outer_inner_core+num_colors_inner_inner_core),stat=ier)
+    if( ier /= 0 ) call exit_mpi(myrank,'error allocating num_elem_colors_inner_core array')
   endif
 
-  !! DK DK and Manh Ha, Nov 2011: added this to use the new mesher in the CUDA or C / StarSs test codes
+  end subroutine setup_color_perm
 
-  deallocate(perm)
 
+!
+!-------------------------------------------------------------------------------------------------
+!
 
-  end subroutine setup_color_perm
+! daniel: deprecated ...
+!
+!  subroutine setup_color_perm(myrank,iregion_code,nspec,nglob, &
+!                              ibool,is_on_a_slice_edge,prname, &
+!                              npoin2D_xi,npoin2D_eta)
+!
+!  use constants
+!  use meshfem3D_par,only: NSTEP,DT,NPROC_XI,NPROC_ETA
+!  implicit none
+!
+!  ! standard include of the MPI library
+!  include 'mpif.h'
+!
+!  integer :: myrank
+!  integer :: iregion_code
+!
+!  integer :: nspec,nglob
+!  integer, dimension(NGLLX,NGLLY,NGLLZ,nspec) :: ibool
+!
+!  ! this for non blocking MPI
+!  logical, dimension(nspec) :: is_on_a_slice_edge
+!
+!  ! name of the database file
+!  character(len=150) :: prname
+!
+!  integer :: npoin2D_xi,npoin2D_eta
+!
+!  ! local parameters
+!  integer :: nb_colors_outer_elements,nb_colors_inner_elements,nspec_outer
+!  integer, dimension(:), allocatable :: perm
+!  integer, dimension(:), allocatable :: first_elem_number_in_this_color
+!  integer, dimension(:), allocatable :: num_of_elems_in_this_color
+!
+!  integer :: icolor,ispec_counter
+!  integer :: nspec_outer_min_global,nspec_outer_max_global
+!  integer :: ispec,ier
+!
+!  !!!! David Michea: detection of the edges, coloring and permutation separately
+!  allocate(perm(nspec))
+!
+!  ! implement mesh coloring for GPUs if needed, to create subsets of disconnected elements
+!  ! to remove dependencies and the need for atomic operations in the sum of elemental contributions in the solver
+!  if(USE_MESH_COLORING_GPU) then
+!
+!    ! user output
+!    if(myrank == 0 ) write(IMAIN,*) '  creating mesh coloring'
+!
+!    allocate(first_elem_number_in_this_color(MAX_NUMBER_OF_COLORS + 1))
+!
+!    call get_perm_color_faster(is_on_a_slice_edge,ibool,perm,nspec,nglob, &
+!                              nb_colors_outer_elements,nb_colors_inner_elements,nspec_outer, &
+!                              first_elem_number_in_this_color,myrank)
+!
+!    ! for the last color, the next color is fictitious and its first (fictitious) element number is nspec + 1
+!    first_elem_number_in_this_color(nb_colors_outer_elements + nb_colors_inner_elements + 1) = nspec + 1
+!
+!    allocate(num_of_elems_in_this_color(nb_colors_outer_elements + nb_colors_inner_elements))
+!
+!    ! save mesh coloring
+!    open(unit=99,file=prname(1:len_trim(prname))//'num_of_elems_in_this_color.dat', &
+!         status='unknown',iostat=ier)
+!    if( ier /= 0 ) call exit_mpi(myrank,'error opening num_of_elems_in_this_color file')
+!
+!    ! number of colors for outer elements
+!    write(99,*) nb_colors_outer_elements
+!
+!    ! number of colors for inner elements
+!    write(99,*) nb_colors_inner_elements
+!
+!    ! number of elements in each color
+!    do icolor = 1, nb_colors_outer_elements + nb_colors_inner_elements
+!      num_of_elems_in_this_color(icolor) = first_elem_number_in_this_color(icolor+1) &
+!                                          - first_elem_number_in_this_color(icolor)
+!      write(99,*) num_of_elems_in_this_color(icolor)
+!    enddo
+!    close(99)
+!
+!    ! check that the sum of all the numbers of elements found in each color is equal
+!    ! to the total number of elements in the mesh
+!    if(sum(num_of_elems_in_this_color) /= nspec) then
+!      print *,'nspec = ',nspec
+!      print *,'total number of elements in all the colors of the mesh = ',sum(num_of_elems_in_this_color)
+!      call exit_mpi(myrank,'incorrect total number of elements in all the colors of the mesh')
+!    endif
+!
+!    ! check that the sum of all the numbers of elements found in each color for the outer elements is equal
+!    ! to the total number of outer elements found in the mesh
+!    if(sum(num_of_elems_in_this_color(1:nb_colors_outer_elements)) /= nspec_outer) then
+!      print *,'nspec_outer = ',nspec_outer
+!      print *,'total number of elements in all the colors of the mesh for outer elements = ', &
+!        sum(num_of_elems_in_this_color)
+!      call exit_mpi(myrank,'incorrect total number of elements in all the colors of the mesh for outer elements')
+!    endif
+!
+!    call MPI_ALLREDUCE(nspec_outer,nspec_outer_min_global,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ier)
+!    call MPI_ALLREDUCE(nspec_outer,nspec_outer_max_global,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ier)
+!
+!    deallocate(first_elem_number_in_this_color)
+!    deallocate(num_of_elems_in_this_color)
+!
+!  else
+!
+!    !! DK DK for regular C + MPI version for CPUs: do not use colors but nonetheless put all the outer elements
+!    !! DK DK first in order to be able to overlap non-blocking MPI communications with calculations
+!
+!    !! DK DK nov 2010, for Rosa Badia / StarSs:
+!    !! no need for mesh coloring, but need to implement inner/outer subsets for non blocking MPI for StarSs
+!    ispec_counter = 0
+!    perm(:) = 0
+!
+!    ! first generate all the outer elements
+!    do ispec = 1,nspec
+!      if(is_on_a_slice_edge(ispec)) then
+!        ispec_counter = ispec_counter + 1
+!        perm(ispec) = ispec_counter
+!      endif
+!    enddo
+!
+!    ! make sure we have detected some outer elements
+!    if(ispec_counter <= 0) stop 'fatal error: no outer elements detected!'
+!
+!    ! store total number of outer elements
+!    nspec_outer = ispec_counter
+!
+!    ! then generate all the inner elements
+!    do ispec = 1,nspec
+!      if(.not. is_on_a_slice_edge(ispec)) then
+!        ispec_counter = ispec_counter + 1
+!        perm(ispec) = ispec_counter
+!      endif
+!    enddo
+!
+!    ! test that all the elements have been used once and only once
+!    if(ispec_counter /= nspec) stop 'fatal error: ispec_counter not equal to nspec'
+!
+!    ! do basic checks
+!    if(minval(perm) /= 1) stop 'minval(perm) should be 1'
+!    if(maxval(perm) /= nspec) stop 'maxval(perm) should be nspec'
+!
+!    call MPI_ALLREDUCE(nspec_outer,nspec_outer_min_global,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ier)
+!    call MPI_ALLREDUCE(nspec_outer,nspec_outer_max_global,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ier)
+!
+!  endif ! USE_MESH_COLORING_GPU
+!
+!  !! DK DK and Manh Ha, Nov 2011: added this to use the new mesher in the CUDA or C / StarSs test codes
+!
+!  if (myrank == 0 .and. iregion_code == IREGION_CRUST_MANTLE) then
+!    ! write a header file for the Fortran version of the solver
+!    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_f90.h', &
+!          status='unknown',iostat=ier)
+!    if( ier /= 0 ) call exit_mpi(myrank,'error opening file values_from_mesher_f90.h')
+!
+!    write(99,*) 'integer, parameter :: NSPEC = ',nspec
+!    write(99,*) 'integer, parameter :: NGLOB = ',nglob
+!    !!! DK DK use 1000 time steps only for the scaling tests
+!    write(99,*) 'integer, parameter :: NSTEP = 1000 !!!!!!!!!!! ',nstep
+!    write(99,*) 'real(kind=4), parameter :: deltat = ',DT
+!    write(99,*)
+!    write(99,*) 'integer, parameter ::  NGLOB2DMAX_XMIN_XMAX = ',npoin2D_xi
+!    write(99,*) 'integer, parameter ::  NGLOB2DMAX_YMIN_YMAX = ',npoin2D_eta
+!    write(99,*) 'integer, parameter ::  NGLOB2DMAX_ALL = ',max(npoin2D_xi,npoin2D_eta)
+!    write(99,*) 'integer, parameter ::  NPROC_XI = ',NPROC_XI
+!    write(99,*) 'integer, parameter ::  NPROC_ETA = ',NPROC_ETA
+!    write(99,*)
+!    write(99,*) '! element number of the source and of the station'
+!    write(99,*) '! after permutation of the elements by mesh coloring'
+!    write(99,*) '! and inner/outer set splitting in the mesher'
+!    write(99,*) 'integer, parameter :: NSPEC_SOURCE = ',perm(NSPEC/3)
+!    write(99,*) 'integer, parameter :: RANK_SOURCE = 0'
+!    write(99,*)
+!    write(99,*) 'integer, parameter :: RANK_STATION = (NPROC_XI*NPROC_ETA - 1)'
+!    write(99,*) 'integer, parameter :: NSPEC_STATION = ',perm(2*NSPEC/3)
+!
+!    ! save coordinates of the seismic source
+!    !   write(99,*) xstore(2,2,2,10);
+!    !   write(99,*) ystore(2,2,2,10);
+!    !   write(99,*) zstore(2,2,2,10);
+!
+!    ! save coordinates of the seismic station
+!    !   write(99,*) xstore(2,2,2,nspec-10);
+!    !   write(99,*) ystore(2,2,2,nspec-10);
+!    !   write(99,*) zstore(2,2,2,nspec-10);
+!    close(99)
+!
+!    !! write a header file for the C version of the solver
+!    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_C.h', &
+!          status='unknown',iostat=ier)
+!    if( ier /= 0 ) call exit_mpi(myrank,'error opening file values_from_mesher_C.h')
+!
+!    write(99,*) '#define NSPEC ',nspec
+!    write(99,*) '#define NGLOB ',nglob
+!    !!    write(99,*) '#define NSTEP ',nstep
+!    !!! DK DK use 1000 time steps only for the scaling tests
+!    write(99,*) '// #define NSTEP ',nstep
+!    write(99,*) '#define NSTEP 1000'
+!    ! put an "f" at the end to force single precision
+!    write(99,"('#define deltat ',e18.10,'f')") DT
+!    write(99,*) '#define NGLOB2DMAX_XMIN_XMAX ',npoin2D_xi
+!    write(99,*) '#define NGLOB2DMAX_YMIN_YMAX ',npoin2D_eta
+!    write(99,*) '#define NGLOB2DMAX_ALL ',max(npoin2D_xi,npoin2D_eta)
+!    write(99,*) '#define NPROC_XI ',NPROC_XI
+!    write(99,*) '#define NPROC_ETA ',NPROC_ETA
+!    write(99,*)
+!    write(99,*) '// element and MPI slice number of the source and the station'
+!    write(99,*) '// after permutation of the elements by mesh coloring'
+!    write(99,*) '// and inner/outer set splitting in the mesher'
+!    write(99,*) '#define RANK_SOURCE 0'
+!    write(99,*) '#define NSPEC_SOURCE ',perm(NSPEC/3)
+!    write(99,*)
+!    write(99,*) '#define RANK_STATION (NPROC_XI*NPROC_ETA - 1)'
+!    write(99,*) '#define NSPEC_STATION ',perm(2*NSPEC/3)
+!    close(99)
+!
+!    open(unit=99,file=prname(1:len_trim(prname))//'values_from_mesher_nspec_outer.h', &
+!          status='unknown',iostat=ier)
+!    if( ier /= 0 ) call exit_mpi(myrank,'error opening values_from_mesher_nspec_outer.h file')
+!
+!    write(99,*) '#define NSPEC_OUTER ',nspec_outer_max_global
+!    write(99,*) '// NSPEC_OUTER_min = ',nspec_outer_min_global
+!    write(99,*) '// NSPEC_OUTER_max = ',nspec_outer_max_global
+!    close(99)
+!
+!  endif
+!
+!  !! DK DK and Manh Ha, Nov 2011: added this to use the new mesher in the CUDA or C / StarSs test codes
+!
+!  deallocate(perm)
+!
+!
+!  end subroutine setup_color_perm

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-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/read_compute_parameters.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -232,9 +232,9 @@
 ! if doing benchmark runs to measure scaling of the code for a limited number of time steps only
   if (DO_BENCHMARK_RUN_ONLY) NSTEP = NSTEP_FOR_BENCHMARK
 
-!<YANGL
-  if ( NOISE_TOMOGRAPHY /= 0 )   NSTEP = 2*NSTEP-1   ! time steps needs to be doubled, due to +/- branches
-!>YANGL
+  ! noise tomography: 
+  ! time steps needs to be doubled, due to +/- branches
+  if ( NOISE_TOMOGRAPHY /= 0 )   NSTEP = 2*NSTEP-1
 
   ! subsets used to save seismograms must not be larger than the whole time series,
   ! otherwise we waste memory

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/write_c_binary.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/write_c_binary.c	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/shared/write_c_binary.c	2012-06-19 22:14:47 UTC (rev 20389)
@@ -280,7 +280,7 @@
 
   FILE *ft;
   int itemlen,remlen,donelen,ret;
-  void *buf;
+  char *buf;
 
   // file pointer
   ft = fp_abs[*fid];
@@ -317,7 +317,7 @@
   FILE *ft;
   int ret,itemlen,remlen,donelen;
   long long pos;
-  void *buf;
+  char *buf;
 
   // file pointer
   ft = fp_abs[*fid];

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_receivers.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_receivers.f90	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_receivers.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -197,7 +197,10 @@
           z_found_all(nrec,0:NPROCTOT_VAL-1), &
           final_distance_all(nrec,0:NPROCTOT_VAL-1),stat=ier)
   if( ier /= 0 ) call exit_MPI(myrank,'error allocating temporary receiver arrays')
-
+  ! initializes
+  final_distance(:) = HUGEVAL
+  final_distance_all(:,:) = HUGEVAL
+  
   ! read that STATIONS file on the master
   if(myrank == 0) then
     call get_value_string(STATIONS, 'solver.STATIONS', trim(rec_filename))
@@ -336,12 +339,14 @@
     do ispec=1,nspec
 
       ! exclude elements that are too far from target
-      iglob = ibool(MIDX,MIDY,MIDZ,ispec)
-      dist = dsqrt((x_target_rec - dble(xstore(iglob)))**2 &
-                 + (y_target_rec - dble(ystore(iglob)))**2 &
-                 + (z_target_rec - dble(zstore(iglob)))**2)
-      if(USE_DISTANCE_CRITERION .and. dist > typical_size) cycle
-
+      if( USE_DISTANCE_CRITERION ) then
+        iglob = ibool(MIDX,MIDY,MIDZ,ispec)
+        dist = dsqrt((x_target_rec - dble(xstore(iglob)))**2 &
+                   + (y_target_rec - dble(ystore(iglob)))**2 &
+                   + (z_target_rec - dble(zstore(iglob)))**2)
+        if(dist > typical_size) cycle
+      endif
+      
       ! loop only on points inside the element
       ! exclude edges to ensure this point is not shared with other elements
       do k=2,NGLLZ-1
@@ -598,6 +603,7 @@
       final_distance(irec) = distmin
     enddo
 
+    islice_selected_rec_found(:) = -1
     nrec_found = 0
     do irec=1,nrec
 
@@ -708,6 +714,8 @@
 
   endif    ! end of section executed by main process only
 
+  call sync_all()
+  
   ! deallocate arrays
   deallocate(epidist)
   deallocate(ix_initial_guess,iy_initial_guess,iz_initial_guess)

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-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/locate_sources.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -146,6 +146,7 @@
 
   ! make sure we clean the future final array
   ispec_selected_source(:) = 0
+  final_distance_source(:) = HUGEVAL
 
   ! get the base pathname for output files
   call get_value_string(OUTPUT_FILES, 'OUTPUT_FILES', 'OUTPUT_FILES')
@@ -208,10 +209,12 @@
             y_found_source(NSOURCES_SUBSET_current_size), &
             z_found_source(NSOURCES_SUBSET_current_size),stat=ier)
     if( ier /= 0 ) call exit_MPI(myrank,'error allocating temporary source arrays')
-
+    
     ! make sure we clean the subset array before the gather
     ispec_selected_source_subset(:) = 0
-
+    final_distance_source_subset(:) = HUGEVAL
+    final_distance_source_all(:,:) = HUGEVAL    
+    
     ! loop over sources within this subset
     do isource_in_this_subset = 1,NSOURCES_SUBSET_current_size
 
@@ -330,12 +333,14 @@
       do ispec = 1,nspec
 
         ! exclude elements that are too far from target
-        iglob = ibool(MIDX,MIDY,MIDZ,ispec)
-        dist = dsqrt((x_target_source - dble(xstore(iglob)))**2 &
-                   + (y_target_source - dble(ystore(iglob)))**2 &
-                   + (z_target_source - dble(zstore(iglob)))**2)
-        if(USE_DISTANCE_CRITERION .and. dist > typical_size) cycle
-
+        if( USE_DISTANCE_CRITERION ) then
+          iglob = ibool(MIDX,MIDY,MIDZ,ispec)
+          dist = dsqrt((x_target_source - dble(xstore(iglob)))**2 &
+                     + (y_target_source - dble(ystore(iglob)))**2 &
+                     + (z_target_source - dble(zstore(iglob)))**2)
+          if( dist > typical_size ) cycle
+        endif
+        
         ! define the interval in which we look for points
         if(USE_FORCE_POINT_SOURCE) then
           ! force sources will be put on an exact GLL point
@@ -578,6 +583,7 @@
         distmin = HUGEVAL
         do iprocloop = 0,NPROCTOT_VAL-1
           if(final_distance_source_all(isource_in_this_subset,iprocloop) < distmin) then
+            ! stores this slice infos
             distmin = final_distance_source_all(isource_in_this_subset,iprocloop)
             islice_selected_source(isource) = iprocloop
             ispec_selected_source(isource) = ispec_selected_source_all(isource_in_this_subset,iprocloop)
@@ -692,7 +698,7 @@
       enddo ! end of loop on all the sources within current source subset
 
     endif ! end of section executed by main process only
-
+    
     ! deallocate arrays specific to each subset
     deallocate(final_distance_source_subset)
     deallocate(ispec_selected_source_subset)
@@ -710,7 +716,8 @@
     write(IMAIN,*) 'maximum error in location of the sources: ',sngl(maxval(final_distance_source)),' km'
     write(IMAIN,*)
   endif
-
+  call sync_all()
+  
   ! main process broadcasts the results to all the slices
   call MPI_BCAST(islice_selected_source,NSOURCES,MPI_INTEGER,0,MPI_COMM_WORLD,ier)
   call MPI_BCAST(ispec_selected_source,NSOURCES,MPI_INTEGER,0,MPI_COMM_WORLD,ier)

Modified: seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_seismograms.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_seismograms.f90	2012-06-19 22:12:59 UTC (rev 20388)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/SPECFEM3D_GLOBE_SUNFLOWER/src/specfem3D/write_seismograms.f90	2012-06-19 22:14:47 UTC (rev 20389)
@@ -96,8 +96,10 @@
   ! write the current or final seismograms
   if(seismo_current == NTSTEP_BETWEEN_OUTPUT_SEISMOS .or. it == it_end) then
     if (SIMULATION_TYPE == 1 .or. SIMULATION_TYPE == 3) then
+      ! writes out seismogram files
       call write_seismograms_to_file()
 
+      ! user output
       if(myrank==0) then
         write(IMAIN,*)
         write(IMAIN,*) ' Total number of time steps written: ', it-it_begin+1
@@ -206,7 +208,7 @@
 
     if(total_seismos_local/= nrec_local) call exit_MPI(myrank,'incorrect total number of receivers saved')
 
-
+    ! user output
     if(myrank == 0) then
       write_time = MPI_WTIME() - write_time_begin
       write(IMAIN,*)
@@ -251,6 +253,12 @@
       islice_num_rec_local(:) = 0
       do irec = 1,nrec
         iproc = islice_selected_rec(irec)
+        ! checks iproc value
+        if( iproc < 0 .or. iproc >= NPROCTOT_VAL ) then
+          print*,'error :',myrank,'iproc = ',iproc,'NPROCTOT = ',NPROCTOT_VAL
+          call exit_mpi(myrank,'error iproc in islice_selected_rec')
+        endif
+        ! sums number of receivers for each slice
         islice_num_rec_local(iproc) = islice_num_rec_local(iproc) + 1
       enddo
 



More information about the CIG-COMMITS mailing list