[cig-commits] r22799 - in seismo/3D/SPECFEM3D/trunk: DATA src/generate_databases src/meshfem3D src/shared src/specfem3D

lefebvre at geodynamics.org lefebvre at geodynamics.org
Wed Sep 18 07:35:28 PDT 2013


Author: lefebvre
Date: 2013-09-18 07:35:28 -0700 (Wed, 18 Sep 2013)
New Revision: 22799

Added:
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/read_forward_arrays_adios.F90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/save_forward_arrays_adios.F90
Modified:
   seismo/3D/SPECFEM3D/trunk/DATA/Par_file
   seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases.f90
   seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases_par.f90
   seismo/3D/SPECFEM3D/trunk/src/meshfem3D/meshfem3D.f90
   seismo/3D/SPECFEM3D/trunk/src/shared/read_parameter_file.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/Makefile.in
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/finalize_simulation.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/initialize_simulation.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.F90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90
Log:
adios to read and write solver forward arrays.

Modified: seismo/3D/SPECFEM3D/trunk/DATA/Par_file
===================================================================
--- seismo/3D/SPECFEM3D/trunk/DATA/Par_file	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/DATA/Par_file	2013-09-18 14:35:28 UTC (rev 22799)
@@ -2,10 +2,10 @@
 #
 # forward or adjoint simulation
 # 1 = forward, 2 = adjoint, 3 = both simultaneously
-SIMULATION_TYPE                 = 1
+SIMULATION_TYPE                 = 3
 # 0 = earthquake simulation,  1/2/3 = three steps in noise simulation
 NOISE_TOMOGRAPHY                = 0
-SAVE_FORWARD                    = .true.
+SAVE_FORWARD                    = .false.
 
 # UTM projection parameters
 UTM_PROJECTION_ZONE             = 11
@@ -123,4 +123,5 @@
 ADIOS_ENABLED                   = .true.
 ADIOS_FOR_DATABASES             = .true.
 ADIOS_FOR_MESH                  = .true.
+ADIOS_FOR_FORWARD_ARRAYS        = .true.
 ADIOS_FOR_KERNELS               = .true.

Modified: seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -283,8 +283,9 @@
                         USE_RICKER_TIME_FUNCTION,OLSEN_ATTENUATION_RATIO,PML_CONDITIONS, &
                         PML_INSTEAD_OF_FREE_SURFACE,f0_FOR_PML,IMODEL,FULL_ATTENUATION_SOLID,TRAC_PATH)
 
-  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES, &
-                             ADIOS_FOR_MESH, ADIOS_FOR_KERNELS)
+  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES,       &
+                             ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MESH, &
+                             ADIOS_FOR_KERNELS)
 
 ! check that the code is running with the requested nb of processes
   if(sizeprocs /= NPROC) then

Modified: seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases_par.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases_par.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/generate_databases/generate_databases_par.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -70,7 +70,8 @@
   character(len=256) OUTPUT_FILES,LOCAL_PATH,TOMOGRAPHY_PATH,TRAC_PATH
 
   logical :: ADIOS_ENABLED
-  logical :: ADIOS_FOR_DATABASES, ADIOS_FOR_MESH, ADIOS_FOR_KERNELS
+  logical :: ADIOS_FOR_DATABASES, ADIOS_FOR_MESH, ADIOS_FOR_FORWARD_ARRAYS, &
+             ADIOS_FOR_KERNELS
 
 ! parameters deduced from parameters read from file
   integer :: NPROC

Modified: seismo/3D/SPECFEM3D/trunk/src/meshfem3D/meshfem3D.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/meshfem3D/meshfem3D.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/meshfem3D/meshfem3D.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -346,7 +346,7 @@
   integer MOVIE_TYPE,IMODEL
   character(len=256) OUTPUT_FILES,LOCAL_PATH,TOMOGRAPHY_PATH,TRAC_PATH
   logical :: ADIOS_ENABLED, ADIOS_FOR_DATABASES, ADIOS_FOR_MESH, &
-             ADIOS_FOR_KERNELS
+             ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_KERNELS
 
 ! ************** PROGRAM STARTS HERE **************
 
@@ -389,8 +389,9 @@
                         USE_RICKER_TIME_FUNCTION,OLSEN_ATTENUATION_RATIO,PML_CONDITIONS, &
                         PML_INSTEAD_OF_FREE_SURFACE,f0_FOR_PML,IMODEL,FULL_ATTENUATION_SOLID,TRAC_PATH)
 
-  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES, &
-                             ADIOS_FOR_MESH, ADIOS_FOR_KERNELS)
+  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES,       &
+                             ADIOS_FOR_FORWARD_ARRAYS, ADIOS_FOR_MESH, &
+                             ADIOS_FOR_KERNELS)
 
 ! read the mesh parameter file
 ! nullify(subregions,material_properties)

Modified: seismo/3D/SPECFEM3D/trunk/src/shared/read_parameter_file.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/shared/read_parameter_file.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/shared/read_parameter_file.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -388,26 +388,35 @@
 !!                            and read with the help of ADIOS.
 !! \param ADIOS_FOR_MESH flag to indicate if the mesh (generate database) is
 !!                       written using ADIOS.
+!! \param ADIOS_FOR_FORWARD_ARRAYS flag to indicate if the solver forward arrays
+!!                                 are written using ADIOS.
+!! \param ADIOS_FOR_KERNELS flag to indicate if the kernels are saved using
+!!                          adios
 !! \author MPBL
-subroutine read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES, &
-                                 ADIOS_FOR_MESH, ADIOS_FOR_KERNELS) 
+subroutine read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES,       &
+                                 ADIOS_FOR_MESH, ADIOS_FOR_FORWARD_ARRAYS, &
+                                 ADIOS_FOR_KERNELS) 
   implicit none
   include "constants.h"
   
-  logical, intent(out) :: ADIOS_ENABLED, ADIOS_FOR_DATABASES, &
-                          ADIOS_FOR_MESH, ADIOS_FOR_KERNELS
+  logical, intent(out) :: ADIOS_ENABLED, ADIOS_FOR_DATABASES,       &
+                          ADIOS_FOR_MESH, ADIOS_FOR_FORWARD_ARRAYS, &
+                          ADIOS_FOR_KERNELS
 
   ! initialize flags to false
-  ADIOS_ENABLED       = .false.
-  ADIOS_FOR_DATABASES = .false.
-  ADIOS_FOR_MESH      = .false.
-  ADIOS_FOR_KERNELS   = .false.
+  ADIOS_ENABLED            = .false.
+  ADIOS_FOR_DATABASES      = .false.
+  ADIOS_FOR_MESH           = .false.
+  ADIOS_FOR_FORWARD_ARRAYS = .false.
+  ADIOS_FOR_KERNELS        = .false.
   ! opens file Par_file
   call open_parameter_file()
   call read_value_logical(ADIOS_ENABLED, 'solver.ADIOS_ENABLED')
   if (ADIOS_ENABLED) then
     call read_value_logical(ADIOS_FOR_DATABASES, 'solver.ADIOS_FOR_DATABASES')
     call read_value_logical(ADIOS_FOR_MESH, 'solver.ADIOS_FOR_MESH')
+    call read_value_logical(ADIOS_FOR_FORWARD_ARRAYS, &
+                           'solver.ADIOS_FOR_FORWARD_ARRAYS')
     call read_value_logical(ADIOS_FOR_KERNELS, 'solver.ADIOS_FOR_KERNELS')
   endif 
   call close_parameter_file()

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/Makefile.in	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/Makefile.in	2013-09-18 14:35:28 UTC (rev 22799)
@@ -286,6 +286,8 @@
 
 ADIOS_OBJECTS= \
 	$O/read_mesh_databases_adios.adios.o \
+	$O/save_forward_arrays_adios.adios.o \
+	$O/read_forward_arrays_adios.adios.o \
 	$O/save_kernels_adios.adios.o
 
 ADIOS_STUBS = \

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/finalize_simulation.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/finalize_simulation.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/finalize_simulation.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -47,52 +47,56 @@
   ! save last frame
 
   if (SIMULATION_TYPE == 1 .and. SAVE_FORWARD) then
-    open(unit=IOUT,file=prname(1:len_trim(prname))//'save_forward_arrays.bin',&
-          status='unknown',form='unformatted',iostat=ier)
-    if( ier /= 0 ) then
-      print*,'error: opening save_forward_arrays.bin'
-      print*,'path: ',prname(1:len_trim(prname))//'save_forward_arrays.bin'
-      call exit_mpi(myrank,'error opening file save_forward_arrays.bin')
-    endif
+    if (ADIOS_FOR_FORWARD_ARRAYS) then
+      call save_forward_arrays_adios()
+    else
+      open(unit=IOUT,file=prname(1:len_trim(prname))//'save_forward_arrays.bin',&
+            status='unknown',form='unformatted',iostat=ier)
+      if( ier /= 0 ) then
+        print*,'error: opening save_forward_arrays.bin'
+        print*,'path: ',prname(1:len_trim(prname))//'save_forward_arrays.bin'
+        call exit_mpi(myrank,'error opening file save_forward_arrays.bin')
+      endif
 
-    if( ACOUSTIC_SIMULATION ) then
-      write(IOUT) potential_acoustic
-      write(IOUT) potential_dot_acoustic
-      write(IOUT) potential_dot_dot_acoustic
-    endif
+      if( ACOUSTIC_SIMULATION ) then
+        write(IOUT) potential_acoustic
+        write(IOUT) potential_dot_acoustic
+        write(IOUT) potential_dot_dot_acoustic
+      endif
 
-    if( ELASTIC_SIMULATION ) then
-      write(IOUT) displ
-      write(IOUT) veloc
-      write(IOUT) accel
+      if( ELASTIC_SIMULATION ) then
+        write(IOUT) displ
+        write(IOUT) veloc
+        write(IOUT) accel
 
-      if (ATTENUATION) then
-        if(FULL_ATTENUATION_SOLID) write(IOUT) R_trace  !ZN
-        write(IOUT) R_xx
-        write(IOUT) R_yy
-        write(IOUT) R_xy
-        write(IOUT) R_xz
-        write(IOUT) R_yz
-        if(FULL_ATTENUATION_SOLID) write(IOUT) epsilondev_trace !ZN
-        write(IOUT) epsilondev_xx
-        write(IOUT) epsilondev_yy
-        write(IOUT) epsilondev_xy
-        write(IOUT) epsilondev_xz
-        write(IOUT) epsilondev_yz
+        if (ATTENUATION) then
+          if(FULL_ATTENUATION_SOLID) write(IOUT) R_trace  !ZN
+          write(IOUT) R_xx
+          write(IOUT) R_yy
+          write(IOUT) R_xy
+          write(IOUT) R_xz
+          write(IOUT) R_yz
+          if(FULL_ATTENUATION_SOLID) write(IOUT) epsilondev_trace !ZN
+          write(IOUT) epsilondev_xx
+          write(IOUT) epsilondev_yy
+          write(IOUT) epsilondev_xy
+          write(IOUT) epsilondev_xz
+          write(IOUT) epsilondev_yz
+        endif
       endif
-    endif
 
-    if( POROELASTIC_SIMULATION ) then
-      write(IOUT) displs_poroelastic
-      write(IOUT) velocs_poroelastic
-      write(IOUT) accels_poroelastic
-      write(IOUT) displw_poroelastic
-      write(IOUT) velocw_poroelastic
-      write(IOUT) accelw_poroelastic
+      if( POROELASTIC_SIMULATION ) then
+        write(IOUT) displs_poroelastic
+        write(IOUT) velocs_poroelastic
+        write(IOUT) accels_poroelastic
+        write(IOUT) displw_poroelastic
+        write(IOUT) velocw_poroelastic
+        write(IOUT) accelw_poroelastic
+      endif
+
+      close(IOUT)
     endif
 
-    close(IOUT)
-
 ! adjoint simulations
   else if (SIMULATION_TYPE == 3) then
 

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/initialize_simulation.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/initialize_simulation.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/initialize_simulation.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -53,8 +53,9 @@
                         USE_RICKER_TIME_FUNCTION,OLSEN_ATTENUATION_RATIO,PML_CONDITIONS, &
                         PML_INSTEAD_OF_FREE_SURFACE,f0_FOR_PML,IMODEL,FULL_ATTENUATION_SOLID,TRAC_PATH)
 
-  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES, &
-                             ADIOS_FOR_MESH, ADIOS_FOR_KERNELS)
+  call read_adios_parameters(ADIOS_ENABLED, ADIOS_FOR_DATABASES,       &
+                             ADIOS_FOR_MESH, ADIOS_FOR_FORWARD_ARRAYS, &
+                             ADIOS_FOR_KERNELS)
 
 !! DK DK added this for now (March 2013) because CPML is not yet implemented for USE_DEVILLE_PRODUCTS;
 !! DK DK we will soon add it (in a month or so)

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.F90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.F90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.F90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -231,77 +231,83 @@
 ! note: this is done here after the Newmark time scheme, otherwise the indexing for sources
 !          and adjoint sources will become more complicated
 !          that is, index it for adjoint sources will match index NSTEP - 1 for backward/reconstructed wavefields
+  if (ADIOS_FOR_FORWARD_ARRAYS) then
+    call read_forward_arrays_adios()
+  else
+    ! reads in wavefields
+    open(unit=IIN,file=trim(prname)//'save_forward_arrays.bin',status='old',&
+          action='read',form='unformatted',iostat=ier)
+    if( ier /= 0 ) then
+      print*,'error: opening save_forward_arrays'
+      print*,'path: ',trim(prname)//'save_forward_arrays.bin'
+      call exit_mpi(myrank,'error open file save_forward_arrays.bin')
+    endif
 
-  ! reads in wavefields
-  open(unit=IIN,file=trim(prname)//'save_forward_arrays.bin',status='old',&
-        action='read',form='unformatted',iostat=ier)
-  if( ier /= 0 ) then
-    print*,'error: opening save_forward_arrays'
-    print*,'path: ',trim(prname)//'save_forward_arrays.bin'
-    call exit_mpi(myrank,'error open file save_forward_arrays.bin')
+    if( ACOUSTIC_SIMULATION ) then
+      read(IIN) b_potential_acoustic
+      read(IIN) b_potential_dot_acoustic
+      read(IIN) b_potential_dot_dot_acoustic
+    endif
+
+    ! elastic wavefields
+    if( ELASTIC_SIMULATION ) then
+      read(IIN) b_displ
+      read(IIN) b_veloc
+      read(IIN) b_accel
+      ! memory variables if attenuation
+      if( ATTENUATION ) then
+        if(FULL_ATTENUATION_SOLID) read(IIN) b_R_trace
+        read(IIN) b_R_xx
+        read(IIN) b_R_yy
+        read(IIN) b_R_xy
+        read(IIN) b_R_xz
+        read(IIN) b_R_yz
+        if(FULL_ATTENUATION_SOLID) read(IIN) b_epsilondev_trace
+        read(IIN) b_epsilondev_xx
+        read(IIN) b_epsilondev_yy
+        read(IIN) b_epsilondev_xy
+        read(IIN) b_epsilondev_xz
+        read(IIN) b_epsilondev_yz
+      endif ! ATTENUATION
+    endif
+
+    ! poroelastic wavefields
+    if( POROELASTIC_SIMULATION ) then
+      read(IIN) b_displs_poroelastic
+      read(IIN) b_velocs_poroelastic
+      read(IIN) b_accels_poroelastic
+      read(IIN) b_displw_poroelastic
+      read(IIN) b_velocw_poroelastic
+      read(IIN) b_accelw_poroelastic
+    endif
+
+    close(IIN)
   endif
 
-  if( ACOUSTIC_SIMULATION ) then
-    read(IIN) b_potential_acoustic
-    read(IIN) b_potential_dot_acoustic
-    read(IIN) b_potential_dot_dot_acoustic
-
+  if(GPU_MODE) then
+    if( ACOUSTIC_SIMULATION ) then
     ! transfers fields onto GPU
-    if(GPU_MODE) then
       call transfer_b_fields_ac_to_device(NGLOB_AB,b_potential_acoustic, &
-                                          b_potential_dot_acoustic, b_potential_dot_dot_acoustic, Mesh_pointer)
+                                          b_potential_dot_acoustic,      &
+                                          b_potential_dot_dot_acoustic,  &
+                                          Mesh_pointer)
     endif
-  endif
-
-  ! elastic wavefields
-  if( ELASTIC_SIMULATION ) then
-    read(IIN) b_displ
-    read(IIN) b_veloc
-    read(IIN) b_accel
-
-    ! puts elastic wavefield to GPU
-    if(GPU_MODE) then
+    ! elastic wavefields
+    if( ELASTIC_SIMULATION ) then
+      ! puts elastic wavefield to GPU
       call transfer_b_fields_to_device(NDIM*NGLOB_AB,b_displ,b_veloc,b_accel,Mesh_pointer)
+      ! memory variables if attenuation
+      if( ATTENUATION ) then
+        call transfer_b_fields_att_to_device(Mesh_pointer,                    & 
+                           b_R_xx,b_R_yy,b_R_xy,b_R_xz,b_R_yz,                & 
+                           size(b_R_xx),                                      & 
+                           b_epsilondev_xx,b_epsilondev_yy,b_epsilondev_xy,   &
+                           b_epsilondev_xz,b_epsilondev_yz,                   & 
+                           size(b_epsilondev_xx))
+      endif
     endif
-
-    ! memory variables if attenuation
-    if( ATTENUATION ) then
-      if(FULL_ATTENUATION_SOLID) read(IIN) b_R_trace
-      read(IIN) b_R_xx
-      read(IIN) b_R_yy
-      read(IIN) b_R_xy
-      read(IIN) b_R_xz
-      read(IIN) b_R_yz
-      if(FULL_ATTENUATION_SOLID) read(IIN) b_epsilondev_trace
-      read(IIN) b_epsilondev_xx
-      read(IIN) b_epsilondev_yy
-      read(IIN) b_epsilondev_xy
-      read(IIN) b_epsilondev_xz
-      read(IIN) b_epsilondev_yz
-
-      ! puts elastic attenuation arrays to GPU
-      if(GPU_MODE) then
-          call transfer_b_fields_att_to_device(Mesh_pointer, &
-                    b_R_xx,b_R_yy,b_R_xy,b_R_xz,b_R_yz, &
-                    size(b_R_xx), &
-                    b_epsilondev_xx,b_epsilondev_yy,b_epsilondev_xy,b_epsilondev_xz,b_epsilondev_yz, &
-                    size(b_epsilondev_xx))
-      endif
-    endif ! ATTENUATION
   endif
 
-  ! poroelastic wavefields
-  if( POROELASTIC_SIMULATION ) then
-    read(IIN) b_displs_poroelastic
-    read(IIN) b_velocs_poroelastic
-    read(IIN) b_accels_poroelastic
-    read(IIN) b_displw_poroelastic
-    read(IIN) b_velocw_poroelastic
-    read(IIN) b_accelw_poroelastic
-  endif
-
-  close(IIN)
-
   end subroutine it_read_forward_arrays
 
 !=====================================================================

Added: seismo/3D/SPECFEM3D/trunk/src/specfem3D/read_forward_arrays_adios.F90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/read_forward_arrays_adios.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/read_forward_arrays_adios.F90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -0,0 +1,370 @@
+!=====================================================================
+!
+!               S p e c f e m 3 D  V e r s i o n  2 . 1
+!               ---------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!    Princeton University, USA and CNRS / INRIA / University of Pau
+! (c) Princeton University / California Institute of Technology and CNRS / INRIA / University of Pau
+!                             July 2012
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+!
+! United States and French Government Sponsorship Acknowledged.
+
+!==============================================================================
+subroutine read_forward_arrays_adios()
+
+  use mpi
+  use adios_read_mod
+
+  use pml_par
+
+  use specfem_par
+  use specfem_par_elastic
+  use specfem_par_acoustic
+  use specfem_par_poroelastic
+
+  implicit none
+
+  real(kind=CUSTOM_REAL):: minl,maxl,min_all,max_all
+  integer :: ier,inum
+
+  character(len=256) :: database_name
+  integer(kind=8) :: handle
+
+  integer(kind=8), dimension(256),target :: selections
+  integer :: sel_num
+  integer(kind=8), pointer :: sel => null()
+  integer(kind=8), dimension(1) :: start, count_ad
+
+  integer :: local_dim_potential_acoustic,            & 
+             local_dim_potential_dot_acoustic,        & 
+             local_dim_potential_dot_dot_acoustic,    & 
+             local_dim_displ,                         & 
+             local_dim_veloc,                         & 
+             local_dim_accel,                         & 
+             local_dim_R_xx,                          & 
+             local_dim_R_yy,                          & 
+             local_dim_R_xy,                          & 
+             local_dim_R_xz,                          & 
+             local_dim_R_yz,                          & 
+             local_dim_epsilondev_xx,                 & 
+             local_dim_epsilondev_yy,                 & 
+             local_dim_epsilondev_xy,                 & 
+             local_dim_epsilondev_xz,                 & 
+             local_dim_epsilondev_yz,                 & 
+             local_dim_R_trace,                       & 
+             local_dim_epsilondev_trace,              & 
+             local_dim_displs_poroelastic,            & 
+             local_dim_velocs_poroelastic,            & 
+             local_dim_accels_poroelastic,            & 
+             local_dim_displw_poroelastic,            & 
+             local_dim_velocw_poroelastic,            & 
+             local_dim_accelw_poroelastic
+
+  !-------------------------------------.
+  ! Open ADIOS Database file, read mode |
+  !-------------------------------------'
+  sel_num = 0             
+
+  database_name = adjustl(LOCAL_PATH)
+  database_name = database_name(1:len_trim(database_name)) // "/forward_arrays.bp"
+
+  call adios_read_init_method (ADIOS_READ_METHOD_BP, MPI_COMM_WORLD, &
+                               "verbose=1", ier)
+  call adios_read_open_file (handle, database_name, 0, MPI_COMM_WORLD, ier)
+
+  !------------------------.
+  ! Get the 'chunks' sizes |
+  !------------------------'
+  if (ACOUSTIC_SIMULATION) then
+    call adios_get_scalar(handle, "potential_acoustic/local_dim",&
+                          local_dim_potential_acoustic,ier)
+    call adios_get_scalar(handle, "potential_dot_acoustic/local_dim",&
+                          local_dim_potential_dot_acoustic,ier)
+    call adios_get_scalar(handle, "potential_dot_dot_acoustic/local_dim",&
+                          local_dim_potential_dot_dot_acoustic,ier)
+  endif                          
+  if (ELASTIC_SIMULATION) then
+    call adios_get_scalar(handle, "displ/local_dim",&
+                          local_dim_displ,ier)
+    call adios_get_scalar(handle, "veloc/local_dim",&
+                          local_dim_veloc,ier)
+    call adios_get_scalar(handle, "accel/local_dim",&
+                          local_dim_accel,ier)
+    if (ATTENUATION) then
+      call adios_get_scalar(handle, "R_xx/local_dim",&
+                            local_dim_R_xx,ier)
+      call adios_get_scalar(handle, "R_yy/local_dim",&
+                            local_dim_R_yy,ier)
+      call adios_get_scalar(handle, "R_xy/local_dim",&
+                            local_dim_R_xy,ier)
+      call adios_get_scalar(handle, "R_xz/local_dim",&
+                            local_dim_R_xz,ier)
+      call adios_get_scalar(handle, "R_yz/local_dim",&
+                            local_dim_R_yz,ier)
+      call adios_get_scalar(handle, "epsilondev_xx/local_dim",&
+                            local_dim_epsilondev_xx,ier)
+      call adios_get_scalar(handle, "epsilondev_yy/local_dim",&
+                            local_dim_epsilondev_yy,ier)
+      call adios_get_scalar(handle, "epsilondev_xy/local_dim",&
+                            local_dim_epsilondev_xy,ier)
+      call adios_get_scalar(handle, "epsilondev_xz/local_dim",&
+                            local_dim_epsilondev_xz,ier)
+      call adios_get_scalar(handle, "epsilondev_yz/local_dim",&
+                            local_dim_epsilondev_yz,ier)
+      if (FULL_ATTENUATION_SOLID) then
+        call adios_get_scalar(handle, "R_trace/local_dim",&
+                              local_dim_R_trace,ier)
+        call adios_get_scalar(handle, "epsilondev_trace/local_dim",&
+                              local_dim_epsilondev_trace,ier)
+      endif
+    endif
+  endif
+  if (POROELASTIC_SIMULATION) then
+    call adios_get_scalar(handle, "displs_poroelastic/local_dim",&
+                          local_dim_displs_poroelastic,ier)
+    call adios_get_scalar(handle, "velocs_poroelastic/local_dim",&
+                          local_dim_velocs_poroelastic,ier)
+    call adios_get_scalar(handle, "accels_poroelastic/local_dim",&
+                          local_dim_accels_poroelastic,ier)
+    call adios_get_scalar(handle, "displw_poroelastic/local_dim",&
+                          local_dim_displw_poroelastic,ier)
+    call adios_get_scalar(handle, "velocw_poroelastic/local_dim",&
+                          local_dim_velocw_poroelastic,ier)
+    call adios_get_scalar(handle, "accelw_poroelastic/local_dim",&
+                          local_dim_accelw_poroelastic,ier)
+  endif
+
+  !-----------------------------------.
+  ! Read arrays from forward_arrays.bp |
+  !-----------------------------------'
+  if( ACOUSTIC_SIMULATION ) then
+    start(1) = local_dim_potential_acoustic * myrank
+    count_ad(1) = NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "potential_acoustic/array", 0, 1, &
+                             b_potential_acoustic, ier)
+
+    start(1) = local_dim_potential_dot_acoustic * myrank
+    count_ad(1) = NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "potential_dot_acoustic/array", 0, 1, &
+                             b_potential_dot_acoustic, ier)
+
+    start(1) = local_dim_potential_dot_dot_acoustic * myrank
+    count_ad(1) = NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "potential_dot_dot_acoustic/array", 0, 1, &
+                             b_potential_dot_dot_acoustic, ier)
+
+  endif
+
+  ! elastic wavefields
+  if( ELASTIC_SIMULATION ) then
+    start(1) = local_dim_displ * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "displ/array", 0, 1, &
+                             b_displ, ier)
+
+    start(1) = local_dim_veloc * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "veloc/array", 0, 1, &
+                             b_veloc, ier)
+
+    start(1) = local_dim_accel * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "accel/array", 0, 1, &
+                             b_accel, ier)
+
+    ! memory variables if attenuation
+    if( ATTENUATION ) then
+      start(1) = local_dim_R_xx * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB * N_SLS
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "R_xx/array", 0, 1, &
+                               b_R_xx, ier)
+
+      start(1) = local_dim_R_yy * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB * N_SLS
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "R_yy/array", 0, 1, &
+                               b_R_yy, ier)
+
+      start(1) = local_dim_R_xy * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB * N_SLS
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "R_xy/array", 0, 1, &
+                               b_R_xy, ier)
+
+      start(1) = local_dim_R_xz * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB * N_SLS
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "R_xz/array", 0, 1, &
+                               b_R_xz, ier)
+
+      start(1) = local_dim_R_yz * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB * N_SLS
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "R_yz/array", 0, 1, &
+                               b_R_yz, ier)
+
+      start(1) = local_dim_epsilondev_xx * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_ONLY
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "epsilondev_xx/array", 0, 1, &
+                               b_epsilondev_xx, ier)
+
+      start(1) = local_dim_epsilondev_yy * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_ONLY
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "epsilondev_yy/array", 0, 1, &
+                               b_epsilondev_yy, ier)
+
+      start(1) = local_dim_epsilondev_xy * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_ONLY
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "epsilondev_xy/array", 0, 1, &
+                               b_epsilondev_xy, ier)
+
+      start(1) = local_dim_epsilondev_xz * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_ONLY
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "epsilondev_xz/array", 0, 1, &
+                               b_epsilondev_xz, ier)
+
+      start(1) = local_dim_epsilondev_yz * myrank
+      count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_ONLY
+      sel_num = sel_num+1
+      sel => selections(sel_num)
+      call adios_selection_boundingbox (sel , 1, start, count_ad)
+      call adios_schedule_read(handle, sel, "epsilondev_yz/array", 0, 1, &
+                               b_epsilondev_yz, ier)
+
+      if(FULL_ATTENUATION_SOLID) then 
+        start(1) = local_dim_R_trace * myrank
+        count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB_kappa * N_SLS
+        sel_num = sel_num+1
+        sel => selections(sel_num)
+        call adios_selection_boundingbox (sel , 1, start, count_ad)
+        call adios_schedule_read(handle, sel, "R_trace/array", 0, 1, &
+                                 b_R_trace, ier)
+
+        start(1) = local_dim_epsilondev_trace * myrank
+        count_ad(1) = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_AB_kappa
+        sel_num = sel_num+1
+        sel => selections(sel_num)
+        call adios_selection_boundingbox (sel , 1, start, count_ad)
+        call adios_schedule_read(handle, sel, "epsilondev_trace/array", 0, 1, &
+                                 b_epsilondev_trace, ier)
+      endif
+    endif
+  endif
+
+  ! poroelastic wavefields
+  if( POROELASTIC_SIMULATION ) then
+    start(1) = local_dim_displs_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "displs_poroelastic/array", 0, 1, &
+                             b_displs_poroelastic, ier)
+
+    start(1) = local_dim_velocs_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "velocs_poroelastic/array", 0, 1, &
+                             b_velocs_poroelastic, ier)
+
+    start(1) = local_dim_accels_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "accels_poroelastic/array", 0, 1, &
+                             b_accels_poroelastic, ier)
+
+    start(1) = local_dim_displw_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "displw_poroelastic/array", 0, 1, &
+                             b_displw_poroelastic, ier)
+
+    start(1) = local_dim_velocw_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "velocw_poroelastic/array", 0, 1, &
+                             b_velocw_poroelastic, ier)
+
+    start(1) = local_dim_accelw_poroelastic * myrank
+    count_ad(1) = NDIM * NGLOB_ADJOINT
+    sel_num = sel_num+1
+    sel => selections(sel_num)
+    call adios_selection_boundingbox (sel , 1, start, count_ad)
+    call adios_schedule_read(handle, sel, "accelw_poroelastic/array", 0, 1, &
+                             b_accelw_poroelastic, ier)
+  endif
+
+  !---------------------------------------------------------------.
+  ! Perform the reads and close the ADIOS 'external_mesh.bp' file |
+  !---------------------------------------------------------------'
+  call adios_perform_reads(handle, ier)
+  call adios_read_close(handle,ier)
+  call adios_read_finalize_method(ADIOS_READ_METHOD_BP, ier)
+
+end subroutine read_forward_arrays_adios

Added: seismo/3D/SPECFEM3D/trunk/src/specfem3D/save_forward_arrays_adios.F90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/save_forward_arrays_adios.F90	                        (rev 0)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/save_forward_arrays_adios.F90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -0,0 +1,280 @@
+!=====================================================================
+!
+!               S p e c f e m 3 D  V e r s i o n  2 . 1
+!               ---------------------------------------
+!
+!          Main authors: Dimitri Komatitsch and Jeroen Tromp
+!    Princeton University, USA and CNRS / INRIA / University of Pau
+! (c) Princeton University / California Institute of Technology and CNRS / INRIA / University of Pau
+!                             July 2012
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+!==============================================================================
+!> \file save_forward_arrays_adios.F90
+!!
+!! \author MPBL
+!==============================================================================
+
+!==============================================================================
+!> \def STRINGIFY_VAR(a)
+!! Macro taking a variable and returning the stringified variable and 
+!! the variable itself.
+!! STRINGIFY_VAR(x) expand as:
+!!   "x", x
+!! x being the variable name inside the code.
+#ifdef __INTEL_COMPILER
+#define STRINGIFY_VAR(a) #a, a
+#else
+#define STRINGIFY_VAR(a) "a", a
+#endif
+
+!==============================================================================
+subroutine save_forward_arrays_adios()
+
+  use mpi
+  use adios_helpers_mod
+  use specfem_par
+  use specfem_par_elastic
+  use specfem_par_acoustic
+  use specfem_par_poroelastic
+  use pml_par
+
+  implicit none
+
+  !--- Local parameters for ADIOS ---
+  character(len=256) :: output_name
+  character(len=64), parameter :: group_name  = "SPECFEM3D_DATABASES"
+  integer(kind=8) :: group, handle
+  integer(kind=8) :: groupsize, totalsize
+  integer :: local_dim
+  
+  !--- Variables to allreduce - wmax stands for world_max
+  integer :: nglob_wmax, nspec_wmax, NSPEC_ATTENUATION_wmax, &
+             NSPEC_STRAIN_wmax, NSPEC_ATTENUATION_kappa_wmax, N_SLS_wmax
+  integer, parameter :: num_vars = 2
+  integer, dimension(num_vars) :: max_global_values
+
+  integer :: ier
+
+  !-----------------------------------------------------------------.
+  ! Get maximum value for each variable used to define a local_dim. |
+  ! ADIOS write equally sized chunks for each processor.            |
+  !-----------------------------------------------------------------'
+  ! Filling a temporary array to avoid doing allreduces for each var.
+  max_global_values(1) = NGLOB_AB
+  max_global_values(2) =  NSPEC_ATTENUATION_AB
+  max_global_values(3) =  NSPEC_STRAIN_ONLY
+  max_global_values(4) =  NSPEC_ATTENUATION_AB_kappa
+  max_global_values(5) =  N_SLS
+
+  call MPI_Allreduce(MPI_IN_PLACE, max_global_values, num_vars, &
+                     MPI_INTEGER, MPI_MAX, MPI_COMM_WORLD, ier)
+  if( ier /= 0 ) call exit_MPI(myrank,'Allreduce to get max values failed.')
+
+  nglob_wmax                   = max_global_values(1)
+  NSPEC_ATTENUATION_wmax       = max_global_values(2)
+  NSPEC_STRAIN_wmax            = max_global_values(3)
+  NSPEC_ATTENUATION_kappa_wmax = max_global_values(4)
+  N_SLS_wmax                   = max_global_values(5)
+
+  !-----------------------------------.
+  ! Setup ADIOS for the current group |
+  !-----------------------------------'
+  groupsize = 0
+  output_name = LOCAL_PATH(1:len_trim(LOCAL_PATH))// "/forward_arrays.bp"
+  call adios_declare_group(group, group_name, "", 1, ier)
+  call adios_select_method(group, ADIOS_TRANSPORT_METHOD, "", "", ier)
+
+  !------------------------.
+  ! Define ADIOS Variables |
+  !------------------------'
+  call define_adios_scalar(group, groupsize, "", STRINGIFY_VAR(ngllx)) 
+  call define_adios_scalar(group, groupsize, "", STRINGIFY_VAR(nglly)) 
+  call define_adios_scalar(group, groupsize, "", STRINGIFY_VAR(ngllz)) 
+
+  call define_adios_scalar(group, groupsize, "", "nglob", NGLOB_AB) 
+  call define_adios_scalar(group, groupsize, "", &
+                           STRINGIFY_VAR(NSPEC_ATTENUATION_AB)) 
+  call define_adios_scalar(group, groupsize, "", &
+                           STRINGIFY_VAR(NSPEC_STRAIN_ONLY)) 
+  call define_adios_scalar(group, groupsize, "", &
+                           STRINGIFY_VAR(NSPEC_ATTENUATION_AB_kappa)) 
+  call define_adios_scalar(group, groupsize, "", &
+                           STRINGIFY_VAR(N_SLS)) 
+
+  if( ACOUSTIC_SIMULATION ) then
+    local_dim = nglob_wmax
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(potential_acoustic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(potential_dot_acoustic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(potential_dot_dot_acoustic))
+  endif
+  if (ELASTIC_SIMULATION) then
+    local_dim = NDIM * nglob_wmax
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(displ))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(veloc))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(accel))
+    if (ATTENUATION) then
+      local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_wmax * N_SLS_wmax
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(R_xx))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(R_yy))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(R_xy))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(R_xz))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(R_yz))
+      local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_wmax
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(epsilondev_xx))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(epsilondev_yy))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(epsilondev_xy))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(epsilondev_xz))
+      call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                       STRINGIFY_VAR(epsilondev_yz))
+      if (FULL_ATTENUATION_SOLID) then
+        local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_kappa_wmax &
+                  * N_SLS_wmax
+        call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                         STRINGIFY_VAR(R_trace))
+        local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_kappa_wmax
+        call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                         STRINGIFY_VAR(epsilondev_trace))
+      endif
+    endif
+  endif
+  if (POROELASTIC_SIMULATION) then
+    local_dim = NDIM * nglob_wmax
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(displs_poroelastic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(velocs_poroelastic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(accels_poroelastic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(displw_poroelastic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(velocw_poroelastic))
+    call define_adios_global_array1D(group, groupsize, local_dim, "", &
+                                     STRINGIFY_VAR(accelw_poroelastic))
+  endif
+
+  !------------------------------------------------------------.
+  ! Open an handler to the ADIOS file and setup the group size |
+  !------------------------------------------------------------'
+  call adios_open(handle, group_name, output_name, "w", &
+                  MPI_COMM_WORLD, ier);
+  call adios_group_size (handle, groupsize, totalsize, ier)
+
+  !------------------------------------------.
+  ! Write previously defined ADIOS variables |
+  !------------------------------------------'
+  call adios_write(handle, STRINGIFY_VAR(ngllx), ier)
+  call adios_write(handle, STRINGIFY_VAR(nglly), ier)
+  call adios_write(handle, STRINGIFY_VAR(ngllz), ier)
+
+  call adios_write(handle, "nglob", NGLOB_AB, ier)
+  call adios_write(handle, STRINGIFY_VAR(NSPEC_ATTENUATION_AB), ier)
+  call adios_write(handle, STRINGIFY_VAR(NSPEC_STRAIN_ONLY), ier)
+  call adios_write(handle, STRINGIFY_VAR(NSPEC_ATTENUATION_AB_kappa), ier)
+  call adios_write(handle, STRINGIFY_VAR(N_SLS), ier)
+
+  if( ACOUSTIC_SIMULATION ) then
+    local_dim = nglob_wmax
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(potential_acoustic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(potential_dot_acoustic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(potential_dot_dot_acoustic))
+  endif
+  if (ELASTIC_SIMULATION) then
+    local_dim = NDIM * nglob_wmax
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(displ))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(veloc))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(accel))
+    if (ATTENUATION) then
+      local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_wmax * N_SLS_wmax
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(R_xx))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(R_yy))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(R_xy))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(R_xz))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(R_yz))
+      local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_STRAIN_wmax
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(epsilondev_xx))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(epsilondev_yy))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(epsilondev_xy))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(epsilondev_xz))
+      call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                       STRINGIFY_VAR(epsilondev_yz))
+      if (FULL_ATTENUATION_SOLID) then
+        local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_kappa_wmax &
+                  * N_SLS_wmax
+        call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                         STRINGIFY_VAR(R_trace))
+        local_dim = NGLLX * NGLLY * NGLLZ * NSPEC_ATTENUATION_kappa_wmax
+        call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                         STRINGIFY_VAR(epsilondev_trace))
+      endif
+    endif
+  endif
+  if (POROELASTIC_SIMULATION) then
+    local_dim = NDIM * nglob_wmax
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(displs_poroelastic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(velocs_poroelastic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(accels_poroelastic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(displw_poroelastic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(velocw_poroelastic))
+    call write_adios_global_1d_array(handle, myrank, sizeprocs, local_dim, &
+                                     STRINGIFY_VAR(accelw_poroelastic))
+  endif
+
+  !----------------------------------.
+  ! Perform the actual write to disk |
+  !----------------------------------'
+  call adios_set_path(handle, "", ier)                          
+  call adios_close(handle, ier)
+
+end subroutine save_forward_arrays_adios

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90	2013-09-18 14:35:14 UTC (rev 22798)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90	2013-09-18 14:35:28 UTC (rev 22799)
@@ -203,7 +203,8 @@
   character(len=256) OUTPUT_FILES,LOCAL_PATH,TOMOGRAPHY_PATH,prname,dsmname,TRAC_PATH
 
   logical :: ADIOS_ENABLED
-  logical :: ADIOS_FOR_DATABASES, ADIOS_FOR_MESH, ADIOS_FOR_KERNELS
+  logical :: ADIOS_FOR_DATABASES, ADIOS_FOR_MESH, ADIOS_FOR_FORWARD_ARRAYS, &
+             ADIOS_FOR_KERNELS
 
 ! names of the data files for all the processors in MPI
   character(len=256) outputname



More information about the CIG-COMMITS mailing list