[cig-commits] r20378 - seismo/3D/SPECFEM3D/trunk/src/specfem3D

cmorency at geodynamics.org cmorency at geodynamics.org
Sat Jun 16 19:02:32 PDT 2012


Author: cmorency
Date: 2012-06-16 19:02:31 -0700 (Sat, 16 Jun 2012)
New Revision: 20378

Modified:
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_add_sources_poroelastic.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_fluid.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_poroelastic.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_solid.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.f90
   seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90
Log:
Adjoint poroelastic implementation - in progress.


Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_add_sources_poroelastic.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_add_sources_poroelastic.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_add_sources_poroelastic.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -34,9 +34,12 @@
                         hdur,hdur_gaussian,tshift_cmt,dt,t0,sourcearrays, &
                         ispec_is_poroelastic,SIMULATION_TYPE,NSTEP,NGLOB_ADJOINT, &
                         nrec,islice_selected_rec,ispec_selected_rec, &
-                        nadj_rec_local,adj_sourcearrays )
+                        nadj_rec_local,adj_sourcearrays,b_accels,b_accelw, &
+                        NTSTEP_BETWEEN_READ_ADJSRC )
 
-  use specfem_par,only: PRINT_SOURCE_TIME_FUNCTION,stf_used_total
+  use specfem_par,only: PRINT_SOURCE_TIME_FUNCTION,stf_used_total, &
+                        xigll,yigll,zigll,xi_receiver,eta_receiver,gamma_receiver,&
+                        station_name,network_name,adj_source_file,nrec_local,number_receiver_global
   implicit none
 
   include "constants.h"
@@ -75,15 +78,20 @@
   integer:: nrec
   integer,dimension(nrec) :: islice_selected_rec,ispec_selected_rec
   integer:: nadj_rec_local
-  real(kind=CUSTOM_REAL),dimension(nadj_rec_local,NSTEP,NDIM,NGLLX,NGLLY,NGLLZ):: adj_sourcearrays
+  real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_ADJOINT) :: b_accels,b_accelw
+  logical :: ibool_read_adj_arrays
+  integer :: it_sub_adj,itime,NTSTEP_BETWEEN_READ_ADJSRC
+  real(kind=CUSTOM_REAL),dimension(nadj_rec_local,NTSTEP_BETWEEN_READ_ADJSRC,NDIM,NGLLX,NGLLY,NGLLZ):: adj_sourcearrays
 
 ! local parameters
   double precision :: f0
   double precision :: stf
+  real(kind=CUSTOM_REAL),dimension(:,:,:,:,:),allocatable:: adj_sourcearray
   real(kind=CUSTOM_REAL) stf_used,stf_used_total_all,time_source
   integer :: isource,iglob,i,j,k,ispec
-!  integer :: irec_local,irec
+  integer :: irec_local,irec
   real(kind=CUSTOM_REAL) :: phil,tortl,rhol_s,rhol_f,rhol_bar
+  integer :: ier
 
 ! plotting source time function
   if(PRINT_SOURCE_TIME_FUNCTION .and. .not. phase_is_inner ) then
@@ -133,7 +141,7 @@
               rhol_bar =  (1._CUSTOM_REAL - phil)*rhol_s + phil*rhol_f
 
               f0 = hdur(isource) !! using hdur as a FREQUENCY just to avoid changing CMTSOLUTION file format
-              t0 = 1.2d0/f0
+              !t0 = 1.2d0/f0
 
               if (it == 1 .and. myrank == 0) then
                 print *,'using a source of dominant frequency ',f0
@@ -143,16 +151,19 @@
               endif
 
               ! This is the expression of a Ricker; should be changed according maybe to the Par_file.
-              !stf_used = 1.d10 * comp_source_time_function_rickr(dble(it-1)*DT-t0-tshift_cmt(isource),f0)
-              stf_used = comp_source_time_function_gauss(dble(it-1)*DT-t0-tshift_cmt(isource),f0)
+              stf_used = FACTOR_FORCE_SOURCE * comp_source_time_function_rickr(dble(it-1)*DT-t0-tshift_cmt(isource),f0)
+              !stf_used = comp_source_time_function_gauss(dble(it-1)*DT-t0-tshift_cmt(isource),f0)
 
-              ! we use nu_source(:,3) here because we want a source normal to the surface.
+              ! we use a force in a single direction along one of the components:
+              !  x/y/z or E/N/Z-direction would correspond to 1/2/3 = COMPONENT_FORCE_SOURCE
+              ! e.g. nu_source(:,3) here would be a source normal to the surface (z-direction).
+              ! the source is applied to both solid and fluid phase: bulk source.
 ! solid phase
               accels(:,iglob) = accels(:,iglob)  &
-                               + (1._CUSTOM_REAL - phil/tortl) * sngl( nu_source(:,3,isource) ) * stf_used
+              + (1._CUSTOM_REAL - phil/tortl) * sngl( nu_source(COMPONENT_FORCE_SOURCE,:,isource) ) * stf_used
 ! fluid phase
               accelw(:,iglob) = accelw(:,iglob)  &
-                               + (1._CUSTOM_REAL - rhol_f/rhol_bar) * sngl( nu_source(:,3,isource) ) * stf_used
+              + (1._CUSTOM_REAL - rhol_f/rhol_bar) * sngl( nu_source(COMPONENT_FORCE_SOURCE,:,isource) ) * stf_used
 
             else
 
@@ -228,19 +239,221 @@
 
 ! adjoint simulations
   if (SIMULATION_TYPE == 2 .or. SIMULATION_TYPE == 3) then
-    stop 'adjoint poroelastic simulation not implemented yet'
-  endif !adjoint
+ stop 'adjoint poroelastic simulation not implemented yet'
 
+! add adjoint source following elastic block by block consideration
+    ! read in adjoint sources block by block (for memory consideration)
+    ! e.g., in exploration experiments, both the number of receivers (nrec) and
+    ! the number of time steps (NSTEP) are huge,
+    ! which may cause problems since we have a large array:
+    !   adj_sourcearrays(nadj_rec_local,NSTEP,NDIM,NGLLX,NGLLY,NGLLZ)
+
+    ! figure out if we need to read in a chunk of the adjoint source at this
+    ! timestep
+    it_sub_adj = ceiling( dble(it)/dble(NTSTEP_BETWEEN_READ_ADJSRC) ) !chunk_number
+    ibool_read_adj_arrays = (((mod(it-1,NTSTEP_BETWEEN_READ_ADJSRC) == 0)) .and.  (nadj_rec_local > 0))
+
+    ! needs to read in a new chunk/block of the adjoint source
+    ! note that for each partition, we divide it into two parts --- boundaries
+    ! and interior --- indicated by 'phase_is_inner'
+    ! we first do calculations for the boudaries, and then start communication
+    ! with other partitions while calculate for the inner part
+    ! this must be done carefully, otherwise the adjoint sources may be added
+    ! twice
+    if (ibool_read_adj_arrays .and. (.not. phase_is_inner)) then
+
+      ! allocates temporary source array
+      allocate(adj_sourcearray(NTSTEP_BETWEEN_READ_ADJSRC,NDIM,NGLLX,NGLLY,NGLLZ),stat=ier)
+      if( ier /= 0 ) stop 'error allocating array adj_sourcearray'
+
+         !!! read ascii adjoint sources
+         irec_local = 0
+         do irec = 1, nrec
+           ! compute source arrays
+           if (myrank == islice_selected_rec(irec)) then
+             irec_local = irec_local + 1
+             ! reads in **sta**.**net**.**LH**.adj files
+             adj_source_file = trim(station_name(irec))//'.'//trim(network_name(irec))
+             call compute_arrays_adjoint_source(myrank,adj_source_file, &
+                       xi_receiver(irec),eta_receiver(irec),gamma_receiver(irec), &
+                       adj_sourcearray, xigll,yigll,zigll, &
+                       it_sub_adj,NSTEP,NTSTEP_BETWEEN_READ_ADJSRC)
+             do itime = 1,NTSTEP_BETWEEN_READ_ADJSRC
+               adj_sourcearrays(irec_local,itime,:,:,:,:) = adj_sourcearray(itime,:,:,:,:)
+             enddo
+
+           endif
+         enddo
+
+      deallocate(adj_sourcearray)
+
+    endif ! if(ibool_read_adj_arrays)
+
+    if( it < NSTEP ) then
+
+      ! receivers act as sources
+      irec_local = 0
+      do irec = 1,nrec
+
+        ! add the source (only if this proc carries the source)
+        if (myrank == islice_selected_rec(irec)) then
+          irec_local = irec_local + 1
+
+          ! checks if element is in phase_is_inner run
+          if (ispec_is_inner(ispec_selected_rec(irec)) .eqv. phase_is_inner) then
+
+            ! adds source array
+            do k = 1,NGLLZ
+              do j = 1,NGLLY
+                do i = 1,NGLLX
+                  iglob = ibool(i,j,k,ispec_selected_rec(irec))
+                        iglob = ibool(i,j,k,ispec)
+              ! get poroelastic parameters of current local GLL
+              phil = phistore(i,j,k,ispec_selected_rec(irec))
+              rhol_s = rhoarraystore(1,i,j,k,ispec_selected_rec(irec))
+              rhol_f = rhoarraystore(2,i,j,k,ispec_selected_rec(irec))
+              rhol_bar =  (1._CUSTOM_REAL - phil)*rhol_s + phil*rhol_f
+! adjoint source is in the solid phase only since this is the only measurement
+! available
+! solid phase
+                  accels(:,iglob) = accels(:,iglob)  &
+                       + adj_sourcearrays(irec_local, &
+                          NTSTEP_BETWEEN_READ_ADJSRC - mod(it-1,NTSTEP_BETWEEN_READ_ADJSRC), &
+                          :,i,j,k)
+!
+! fluid phase
+                  accelw(:,iglob) = accelw(:,iglob)  &
+                       - rhol_f/rhol_bar * adj_sourcearrays(irec_local, &
+                          NTSTEP_BETWEEN_READ_ADJSRC - mod(it-1,NTSTEP_BETWEEN_READ_ADJSRC), &
+                          :,i,j,k)
+                enddo
+              enddo
+            enddo
+
+          endif ! phase_is_inner
+        endif
+      enddo ! nrec
+
+    endif ! it
+
+  endif !adjoint : if (SIMULATION_TYPE == 2 .or. SIMULATION_TYPE == 3) then
+
+! note:  b_displ() is read in after Newmark time scheme, thus
+!           b_displ(it=1) corresponds to -t0 + (NSTEP-1)*DT.
+!           thus indexing is NSTEP - it , instead of NSTEP - it - 1
+
 ! adjoint simulations
   if (SIMULATION_TYPE == 3) then
-    stop 'adjoint poroelastic simulation not implemented yet'
 
-    ! to avoid compiler warning
-    i = NGLOB_ADJOINT
-    i = adj_sourcearrays(1,1,1,1,1,1)
-    i = islice_selected_rec(1)
-    i = ispec_selected_rec(1)
-    
+    ! backward source reconstruction
+    do isource = 1,NSOURCES
+
+      ! add the source (only if this proc carries the source)
+      if(myrank == islice_selected_source(isource)) then
+
+        ispec = ispec_selected_source(isource)
+
+        if (ispec_is_inner(ispec) .eqv. phase_is_inner) then
+
+          if( ispec_is_poroelastic(ispec) ) then
+
+            if(USE_FORCE_POINT_SOURCE) then
+
+               ! note: for use_force_point_source xi/eta/gamma are in the range [1,NGLL*]
+               iglob = ibool(nint(xi_source(isource)), &
+                             nint(eta_source(isource)), &
+                             nint(gamma_source(isource)), &
+                             ispec_selected_source(isource))
+
+              ! get poroelastic parameters of current local GLL
+              phil = phistore(nint(xi_source(isource)), &
+                             nint(eta_source(isource)), &
+                             nint(gamma_source(isource)), &
+                             ispec_selected_source(isource))
+              tortl = tortstore(nint(xi_source(isource)), &
+                             nint(eta_source(isource)), &
+                             nint(gamma_source(isource)), &
+                             ispec_selected_source(isource))
+              rhol_s = rhoarraystore(1,nint(xi_source(isource)), &
+                             nint(eta_source(isource)), &
+                             nint(gamma_source(isource)), &
+                             ispec_selected_source(isource))
+              rhol_f = rhoarraystore(2,nint(xi_source(isource)), &
+                             nint(eta_source(isource)), &
+                             nint(gamma_source(isource)), &
+                             ispec_selected_source(isource))
+              rhol_bar =  (1._CUSTOM_REAL - phil)*rhol_s + phil*rhol_f
+
+               f0 = hdur(isource) !! using hdur as a FREQUENCY just to avoid changing CMTSOLUTION file format
+
+               !if (it == 1 .and. myrank == 0) then
+               !   write(IMAIN,*) 'using a source of dominant frequency ',f0
+               !   write(IMAIN,*) 'lambda_S at dominant frequency = ',3000./sqrt(3.)/f0
+               !   write(IMAIN,*) 'lambda_S at highest significant frequency = ',3000./sqrt(3.)/(2.5*f0)
+               !endif
+
+               ! This is the expression of a Ricker; should be changed according maybe to the Par_file.
+               ! should be the same than for the forward simulation (check above)
+               stf_used = FACTOR_FORCE_SOURCE * comp_source_time_function_rickr(dble(NSTEP-it)*DT-t0-tshift_cmt(isource),f0)
+
+               ! e.g. we use nu_source(:,3) here if we want a source normal to the surface.
+               ! note: time step is now at NSTEP-it
+               ! the source is applied to both solid and fluid phase: bulk source
+! solid phase
+              b_accels(:,iglob) = b_accels(:,iglob)  &
+              + (1._CUSTOM_REAL - phil/tortl) * sngl( nu_source(COMPONENT_FORCE_SOURCE,:,isource) ) * stf_used
+! fluid phase
+              b_accelw(:,iglob) = b_accelw(:,iglob)  &
+              + (1._CUSTOM_REAL - rhol_f/rhol_bar) * sngl( nu_source(COMPONENT_FORCE_SOURCE,:,isource) ) * stf_used
+
+            else
+
+              ! see note above: time step corresponds now to NSTEP-it
+              ! (also compare to it-1 for forward simulation)
+              !stf = comp_source_time_function(dble(NSTEP-it)*DT-t0-tshift_cmt(isource),hdur_gaussian(isource))
+              !t0 = 1.2d0/hdur(isource)
+              !stf = comp_source_time_function_rickr(dble(NSTEP-it)*DT-t0-tshift_cmt(isource),hdur(isource))
+              stf = comp_source_time_function_gauss(dble(NSTEP-it)*DT-t0-tshift_cmt(isource),hdur_gaussian(isource))
+
+              ! distinguish between single and double precision for reals
+              if(CUSTOM_REAL == SIZE_REAL) then
+                stf_used = sngl(stf)
+              else
+                stf_used = stf
+              endif
+
+              !  add source array
+              do k=1,NGLLZ
+                do j=1,NGLLY
+                  do i=1,NGLLX
+                    iglob = ibool(i,j,k,ispec_selected_source(isource))
+              ! get poroelastic parameters of current local GLL
+              phil = phistore(i,j,k,ispec_selected_source(isource))
+              tortl = tortstore(i,j,k,ispec_selected_source(isource))
+              rhol_s = rhoarraystore(1,i,j,k,ispec_selected_source(isource))
+              rhol_f = rhoarraystore(2,i,j,k,ispec_selected_source(isource))
+              rhol_bar =  (1._CUSTOM_REAL - phil)*rhol_s + phil*rhol_f
+! source in the solid phase only
+! solid phase
+                        b_accels(:,iglob) = b_accels(:,iglob) &
+                                 + sourcearrays(isource,:,i,j,k)*stf_used
+!                                 + (1._CUSTOM_REAL - phil/tortl)*sourcearrays(isource,:,i,j,k)*stf_used
+! fluid phase
+                        b_accelw(:,iglob) = b_accelw(:,iglob) &
+                                 - rhol_f/rhol_bar*sourcearrays(isource,:,i,j,k)*stf_used
+!                                 + (1._CUSTOM_REAL - rhol_f/rhol_bar)*sourcearrays(isource,:,i,j,k)*stf_used
+                  enddo
+                enddo
+              enddo
+            endif ! USE_FORCE_POINT_SOURCE
+
+            stf_used_total = stf_used_total + stf_used
+
+          endif ! elastic
+        endif ! phase_inner
+      endif ! myrank
+
+    enddo ! NSOURCES
   endif ! adjoint
 
   ! master prints out source time function to file

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_fluid.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_fluid.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_fluid.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -32,7 +32,7 @@
                         wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
                         kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
                         phistore,tortstore,jacobian,ibool,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT, &
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
                         num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
                         phase_ispec_inner_poroelastic )
 
@@ -83,10 +83,8 @@
 ! adjoint simulations
   integer :: SIMULATION_TYPE
   !integer :: NSPEC_BOUN
-  integer :: NGLOB_ADJOINT,NSPEC_ADJOINT
+  integer :: NSPEC_ADJOINT
 ! adjoint wavefields
-!  real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_ADJOINT):: b_displs_poroelastic,b_accels_poroelastic
-!  real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_ADJOINT):: b_displw_poroelastic
 !  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,NSPEC_ADJOINT) :: &
 !    mufr_kl, B_kl
 
@@ -224,14 +222,6 @@
               tempz2lw = 0.
               tempz3lw = 0.
 
-              if (SIMULATION_TYPE == 3) then
-                ! to do
-                stop 'compute_forces_fluid() : adjoint run not implemented yet'
-                ! to avoid compiler warning
-                l = NGLOB_ADJOINT
-                l = NSPEC_ADJOINT              
-              endif
-              
 ! first double loop over GLL points to compute and store gradients
           do l = 1,NGLLX
                 hp1 = hprime_xx(i,l)
@@ -242,9 +232,6 @@
                 tempx1lw = tempx1lw + displw_poroelastic(1,iglob)*hp1
                 tempy1lw = tempy1lw + displw_poroelastic(2,iglob)*hp1
                 tempz1lw = tempz1lw + displw_poroelastic(3,iglob)*hp1
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLY
@@ -256,9 +243,6 @@
                 tempx2lw = tempx2lw + displw_poroelastic(1,iglob)*hp2
                 tempy2lw = tempy2lw + displw_poroelastic(2,iglob)*hp2
                 tempz2lw = tempz2lw + displw_poroelastic(3,iglob)*hp2
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLZ
@@ -270,9 +254,6 @@
                 tempx3lw = tempx3lw + displw_poroelastic(1,iglob)*hp3
                 tempy3lw = tempy3lw + displw_poroelastic(2,iglob)*hp3
                 tempz3lw = tempz3lw + displw_poroelastic(3,iglob)*hp3
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
           enddo
 
               xixl = xix(i,j,k,ispec)
@@ -347,6 +328,7 @@
     sigmap = C_biot*duxdxl_plus_duydyl_plus_duzdzl + M_biot*dwxdxl_plus_dwydyl_plus_dwzdzl
 
           if(SIMULATION_TYPE == 3) then ! kernels calculation
+          l = NSPEC_ADJOINT ! to avoid compilation warning
           endif
 !  endif !if(VISCOATTENUATION)
 
@@ -381,9 +363,6 @@
           tempy3p(i,j,k) = jacobianl * sigmap*gammayl
           tempz3p(i,j,k) = jacobianl * sigmap*gammazl
 
-          if(SIMULATION_TYPE == 3) then ! adjoint calculation
-          endif
-
         enddo
       enddo
     enddo
@@ -419,9 +398,6 @@
               tempy3lw = 0.
               tempz3lw = 0.
 
-              if (SIMULATION_TYPE == 3) then
-              endif
-
               do l=1,NGLLX
                 fac1 = hprimewgll_xx(l,i)
                 tempx1ls = tempx1ls + tempx1(l,j,k)*fac1
@@ -430,9 +406,6 @@
                 tempx1lw = tempx1lw + tempx1p(l,j,k)*fac1
                 tempy1lw = tempy1lw + tempy1p(l,j,k)*fac1
                 tempz1lw = tempz1lw + tempz1p(l,j,k)*fac1
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLY
@@ -443,9 +416,6 @@
                 tempx2lw = tempx2lw + tempx2p(i,l,k)*fac2
                 tempy2lw = tempy2lw + tempy2p(i,l,k)*fac2
                 tempz2lw = tempz2lw + tempz2p(i,l,k)*fac2
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLZ
@@ -456,9 +426,6 @@
                 tempx3lw = tempx3lw + tempx3p(i,j,l)*fac3
                 tempy3lw = tempy3lw + tempy3p(i,j,l)*fac3
                 tempz3lw = tempz3lw + tempz3p(i,j,l)*fac3
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
               enddo
 
               fac1 = wgllwgll_yz(j,k)

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_poroelastic.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_poroelastic.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_poroelastic.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -61,7 +61,7 @@
                         wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
                         kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
                         phistore,tortstore,jacobian,ibool,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT, &
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
                         num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
                         phase_ispec_inner_poroelastic )
 
@@ -76,14 +76,43 @@
                         wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
                         kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
                         phistore,tortstore,jacobian,ibool,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT, &
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
                         num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
                         phase_ispec_inner_poroelastic )
 
 
     ! adjoint simulations: backward/reconstructed wavefield
     if( SIMULATION_TYPE == 3 ) then
- stop 'adjoint poroelastic simulation not implemented yet'
+stop 'adjoint poroelastic simulation not fully implemented yet'
+! solid phase
+
+    call compute_forces_solid( iphase, &
+                        NSPEC_AB,NGLOB_AB,b_displs_poroelastic,b_accels_poroelastic,&
+                        b_displw_poroelastic,b_velocw_poroelastic,&
+                        xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz, &
+                        hprime_xx,hprime_yy,hprime_zz,&
+                        hprimewgll_xx,hprimewgll_yy,hprimewgll_zz,&
+                        wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
+                        kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
+                        phistore,tortstore,jacobian,ibool,&
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
+                        num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
+                        phase_ispec_inner_poroelastic )
+
+! fluid phase
+
+    call compute_forces_fluid( iphase, &
+                        NSPEC_AB,NGLOB_AB,b_displw_poroelastic,b_accelw_poroelastic,&
+                        b_velocw_poroelastic,b_displs_poroelastic,&
+                        xix,xiy,xiz,etax,etay,etaz,gammax,gammay,gammaz, &
+                        hprime_xx,hprime_yy,hprime_zz,&
+                        hprimewgll_xx,hprimewgll_yy,hprimewgll_zz,&
+                        wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
+                        kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
+                        phistore,tortstore,jacobian,ibool,&
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
+                        num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
+                        phase_ispec_inner_poroelastic )
     endif
 
 
@@ -101,7 +130,7 @@
 
       ! adjoint simulations
       !if( SIMULATION_TYPE == 3 ) &
-! 'adjoint acoustic-poroelastic simulation not implemented yet'
+! chris:'adjoint acoustic-poroelastic simulation not implemented yet'
 !        call ccmpute_coupling_elastic_ac(NSPEC_ADJOINT,NGLOB_ADJOINT, &
 !                        ibool,b_accel,b_potential_dot_dot_acoustic, &
 !                        num_coupling_ac_el_faces, &
@@ -112,7 +141,6 @@
     endif
 
 ! elastic coupling
-    !print *,'entering elastic counpling'
     if( ELASTIC_SIMULATION ) then
       call compute_coupling_poroelastic_el(NSPEC_AB,NGLOB_AB,ibool,&
                         displs_poroelastic,accels_poroelastic,displw_poroelastic,&
@@ -133,10 +161,9 @@
                         coupling_el_po_normal, &
                         coupling_el_po_jacobian2Dw, &
                         ispec_is_inner,phase_is_inner)
-    !print *,'ok elastic counpling'
 
       ! adjoint simulations
-!chris: TO DO
+! chris:'adjoint elastic-poroelastic simulation not implemented yet'
 !      if( SIMULATION_TYPE == 3 ) &
 !        call compute_coupling_elastic_ac(NSPEC_ADJOINT,NGLOB_ADJOINT, &
 !                        ibool,b_accel,b_potential_dot_dot_acoustic, &
@@ -157,7 +184,8 @@
                         hdur,hdur_gaussian,tshift_cmt,dt,t0,sourcearrays, &
                         ispec_is_poroelastic,SIMULATION_TYPE,NSTEP,NGLOB_ADJOINT, &
                         nrec,islice_selected_rec,ispec_selected_rec, &
-                        nadj_rec_local,adj_sourcearrays)
+                        nadj_rec_local,adj_sourcearrays,b_accels_poroelastic,b_accelw_poroelastic, &
+                        NTSTEP_BETWEEN_READ_ADJSRC)
 
 ! assemble all the contributions between slices using MPI
     if( phase_is_inner .eqv. .false. ) then
@@ -174,18 +202,19 @@
 
       ! adjoint simulations
       if( SIMULATION_TYPE == 3 ) then
-! 'adjoint poroelastic simulation not implemented yet'
-!        call assemble_MPI_vector_ext_mesh_s(NPROC,NGLOB_ADJOINT,b_accel, &
-!                        b_buffer_send_vector_ext_mesh,b_buffer_recv_vector_ext_mesh, &
-!                        num_interfaces_ext_mesh,max_nibool_interfaces_ext_mesh, &
-!                        nibool_interfaces_ext_mesh,ibool_interfaces_ext_mesh,&
-!                        my_neighbours_ext_mesh, &
-!                        b_request_send_vector_ext_mesh,b_request_recv_vector_ext_mesh)
+      call assemble_MPI_vector_poro_s(NPROC,NGLOB_ADJOINT,b_accels_poroelastic, &
+                        b_accelw_poroelastic,&
+                        b_buffer_send_vector_ext_meshs,b_buffer_recv_vector_ext_meshs, &
+                        b_buffer_send_vector_ext_meshw,b_buffer_recv_vector_ext_meshw, &
+                        num_interfaces_ext_mesh,max_nibool_interfaces_ext_mesh, &
+                        nibool_interfaces_ext_mesh,ibool_interfaces_ext_mesh,&
+                        my_neighbours_ext_mesh, &
+                        b_request_send_vector_ext_meshs,b_request_recv_vector_ext_meshs, &
+                        b_request_send_vector_ext_meshw,b_request_recv_vector_ext_meshw)
       endif !adjoint
 
     else
       ! waits for send/receive requests to be completed and assembles values
-! solid phase
       call assemble_MPI_vector_poro_w(NPROC,NGLOB_AB,accels_poroelastic, &
                         accelw_poroelastic,&
                         buffer_recv_vector_ext_mesh_s,buffer_recv_vector_ext_mesh_w, &
@@ -197,12 +226,14 @@
 
       ! adjoint simulations
       if( SIMULATION_TYPE == 3 ) then
-! 'adjoint poroelastic simulation not implemented yet'
-!        call assemble_MPI_vector_ext_mesh_w(NPROC,NGLOB_ADJOINT,b_accel, &
-!                        b_buffer_recv_vector_ext_mesh,num_interfaces_ext_mesh,&
-!                        max_nibool_interfaces_ext_mesh, &
-!                        nibool_interfaces_ext_mesh,ibool_interfaces_ext_mesh, &
-!                        b_request_send_vector_ext_mesh,b_request_recv_vector_ext_mesh)
+      call assemble_MPI_vector_poro_w(NPROC,NGLOB_ADJOINT,b_accels_poroelastic, &
+                        b_accelw_poroelastic,&
+                        b_buffer_recv_vector_ext_meshs,b_buffer_recv_vector_ext_meshw, &
+                        num_interfaces_ext_mesh,&
+                        max_nibool_interfaces_ext_mesh, &
+                        nibool_interfaces_ext_mesh,ibool_interfaces_ext_mesh, &
+                        b_request_send_vector_ext_meshs,b_request_recv_vector_ext_meshs, &
+                        b_request_send_vector_ext_meshw,b_request_recv_vector_ext_meshw)
       endif !adjoint
 
     endif
@@ -223,10 +254,9 @@
 
   ! adjoint simulations
   if (SIMULATION_TYPE == 3) then
-! 'adjoint poroelastic simulation not implemented yet'
-!    b_accels_poroelastic(1,:) = b_accels_poroelastic(1,:)*rmass_solid_poroelastic(:)
-!    b_accels_poroelastic(2,:) = b_accels_poroelastic(2,:)*rmass_solid_poroelastic(:)
-!    b_accels_poroelastic(3,:) = b_accels_poroelastic(3,:)*rmass_solid_poroelastic(:)
+    b_accels_poroelastic(1,:) = b_accels_poroelastic(1,:)*rmass_solid_poroelastic(:)
+    b_accels_poroelastic(2,:) = b_accels_poroelastic(2,:)*rmass_solid_poroelastic(:)
+    b_accels_poroelastic(3,:) = b_accels_poroelastic(3,:)*rmass_solid_poroelastic(:)
   endif !adjoint
 
 ! fluid phase
@@ -237,10 +267,9 @@
 
   ! adjoint simulations
   if (SIMULATION_TYPE == 3) then
-! 'adjoint poroelastic simulation not implemented yet'
-!    b_accelw_poroelastic(1,:) = b_accelw_poroelastic(1,:)*rmass_fluid_poroelastic(:)
-!    b_accelw_poroelastic(2,:) = b_accelw_poroelastic(2,:)*rmass_fluid_poroelastic(:)
-!    b_accelw_poroelastic(3,:) = b_accelw_poroelastic(3,:)*rmass_fluid_poroelastic(:)
+    b_accelw_poroelastic(1,:) = b_accelw_poroelastic(1,:)*rmass_fluid_poroelastic(:)
+    b_accelw_poroelastic(2,:) = b_accelw_poroelastic(2,:)*rmass_fluid_poroelastic(:)
+    b_accelw_poroelastic(3,:) = b_accelw_poroelastic(3,:)*rmass_fluid_poroelastic(:)
   endif !adjoint
 
 ! updates velocities
@@ -267,28 +296,26 @@
 
   ! adjoint simulations
 ! solid phase
-!  if (SIMULATION_TYPE == 3) b_velocs_poroelastic(:,:) = b_velocs_poroelastic(:,:) + &
-!                               b_deltatover2*b_accels_poroelastic(:,:)
+  if (SIMULATION_TYPE == 3) b_velocs_poroelastic(:,:) = b_velocs_poroelastic(:,:) + &
+                               b_deltatover2*b_accels_poroelastic(:,:)
 
 ! fluid phase
-!  if (SIMULATION_TYPE == 3) b_velocw_poroelastic(:,:) = b_velocw_poroelastic(:,:) + &
-!                               b_deltatover2*b_accelw_poroelastic(:,:)
+  if (SIMULATION_TYPE == 3) b_velocw_poroelastic(:,:) = b_velocw_poroelastic(:,:) + &
+                               b_deltatover2*b_accelw_poroelastic(:,:)
 
 
 
 ! elastic coupling
-   !print*, 'entering assembling displacements'
     if( ELASTIC_SIMULATION ) &
       call compute_continuity_disp_po_el(NSPEC_AB,NGLOB_AB,ibool,&
                         accel,veloc,&
                         accels_poroelastic,velocs_poroelastic,&
                         accelw_poroelastic,velocw_poroelastic,&
                         rmass,rmass_solid_poroelastic,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT,&
+                        SIMULATION_TYPE,NSPEC_ADJOINT,&
                         num_coupling_el_po_faces,&
                         coupling_el_po_ispec,coupling_el_po_ijk,&
                         deltatover2)
-   !print*, 'ok assembling displacements'
 
 
 end subroutine compute_forces_poroelastic
@@ -301,7 +328,7 @@
                         accels_poroelastic,velocs_poroelastic,&
                         accelw_poroelastic,velocw_poroelastic,&
                         rmass,rmass_solid_poroelastic,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT,&
+                        SIMULATION_TYPE,NSPEC_ADJOINT,&
                         num_coupling_el_po_faces,&
                         coupling_el_po_ispec,coupling_el_po_ijk,&
                         deltatover2)
@@ -324,7 +351,7 @@
   integer, dimension(NGLLX,NGLLY,NGLLZ,NSPEC_AB),intent(in) :: ibool
 
   integer :: SIMULATION_TYPE
-  integer :: NGLOB_ADJOINT,NSPEC_ADJOINT
+  integer :: NSPEC_ADJOINT
 
 ! elastic-poroelastic coupling surface
   integer :: num_coupling_el_po_faces
@@ -335,7 +362,7 @@
 
 ! local variables
   integer, dimension(NGLOB_AB) :: icount
-  integer :: ispec,i,j,k,iglob,igll,iface
+  integer :: ispec,i,j,k,l,iglob,igll,iface
 
      icount(:)=ZERO
 
@@ -396,14 +423,10 @@
           velocw_poroelastic(2,iglob) = 0.d0
           velocw_poroelastic(3,iglob) = 0.d0
 
-         if(SIMULATION_TYPE == 3) then
-          ! to do
-          stop 'compute_continuity_disp_po_el() : adjoint run not implemented yet'
-          
-          ! dummy to avoid compiler warnings
-          i = NGLOB_ADJOINT    
-          j = NSPEC_ADJOINT          
-         endif
+   if(SIMULATION_TYPE == 3) then
+!chris: to do
+   l = NSPEC_ADJOINT ! to avoid compilation warnings
+   endif
 
         endif !if(icount(iglob) ==1)
      enddo ! igll

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_solid.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_solid.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/compute_forces_solid.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -32,7 +32,7 @@
                         wgllwgll_xy,wgllwgll_xz,wgllwgll_yz,wxgll,wygll,wzgll,  &
                         kappaarraystore,rhoarraystore,mustore,etastore,permstore, &
                         phistore,tortstore,jacobian,ibool,&
-                        SIMULATION_TYPE,NGLOB_ADJOINT,NSPEC_ADJOINT, &
+                        SIMULATION_TYPE,NSPEC_ADJOINT, &
                         num_phase_ispec_poroelastic,nspec_inner_poroelastic,nspec_outer_poroelastic,&
                         phase_ispec_inner_poroelastic )
 
@@ -82,10 +82,8 @@
 ! adjoint simulations
   integer :: SIMULATION_TYPE
   !integer :: NSPEC_BOUN
-  integer :: NGLOB_ADJOINT,NSPEC_ADJOINT
+  integer :: NSPEC_ADJOINT
 ! adjoint wavefields
-!  real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_ADJOINT):: b_displs_poroelastic,b_accels_poroelastic
-!  real(kind=CUSTOM_REAL), dimension(NDIM,NGLOB_ADJOINT):: b_displw_poroelastic
 !  real(kind=CUSTOM_REAL), dimension(NGLLX,NGLLY,NGLLZ,NSPEC_ADJOINT) :: &
 !    mufr_kl, B_kl
 
@@ -224,14 +222,6 @@
               tempz2lw = 0.
               tempz3lw = 0.
 
-              if (SIMULATION_TYPE == 3) then
-                ! to do
-                stop 'compute_forces_solid() : adjoint run not implemented yet'
-                ! to avoid compiler warning
-                l = NGLOB_ADJOINT
-                l = NSPEC_ADJOINT
-              endif
-
 ! first double loop over GLL points to compute and store gradients
           do l = 1,NGLLX
                 hp1 = hprime_xx(i,l)
@@ -242,9 +232,6 @@
                 tempx1lw = tempx1lw + displw_poroelastic(1,iglob)*hp1
                 tempy1lw = tempy1lw + displw_poroelastic(2,iglob)*hp1
                 tempz1lw = tempz1lw + displw_poroelastic(3,iglob)*hp1
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLY
@@ -256,9 +243,6 @@
                 tempx2lw = tempx2lw + displw_poroelastic(1,iglob)*hp2
                 tempy2lw = tempy2lw + displw_poroelastic(2,iglob)*hp2
                 tempz2lw = tempz2lw + displw_poroelastic(3,iglob)*hp2
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
     !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLZ
@@ -270,9 +254,6 @@
                 tempx3lw = tempx3lw + displw_poroelastic(1,iglob)*hp3
                 tempy3lw = tempy3lw + displw_poroelastic(2,iglob)*hp3
                 tempz3lw = tempz3lw + displw_poroelastic(3,iglob)*hp3
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif ! adjoint
           enddo
 
               xixl = xix(i,j,k,ispec)
@@ -346,10 +327,10 @@
 
     sigmap = C_biot*duxdxl_plus_duydyl_plus_duzdzl + M_biot*dwxdxl_plus_dwydyl_plus_dwzdzl
 
-          if(SIMULATION_TYPE == 3) then ! kernels calculation
-          endif
 !  endif !if(ATTENUATION)
 
+          if(SIMULATION_TYPE == 3) then ! kernels calculation
+          l = NSPEC_ADJOINT ! to avoid compilation warnings
 ! kernels calculation
 !   if(isolver == 2) then
 !          iglob = ibool(i,j,ispec)
@@ -374,6 +355,7 @@
 !                  2._CUSTOM_REAL * dsxz * b_dsxz - &
 !                 1._CUSTOM_REAL/3._CUSTOM_REAL * (dux_dxl + duz_dzl) * (b_dux_dxl + b_duz_dzl) ) * mul_fr
 !   endif
+          endif
 
 
 ! weak formulation term based on stress tensor (non-symmetric form)
@@ -445,9 +427,6 @@
               tempy3lw = 0.
               tempz3lw = 0.
 
-              if (SIMULATION_TYPE == 3) then
-              endif
-
               do l=1,NGLLX
                 fac1 = hprimewgll_xx(l,i)
                 tempx1ls = tempx1ls + tempx1(l,j,k)*fac1
@@ -456,9 +435,6 @@
                 tempx1lw = tempx1lw + tempx1p(l,j,k)*fac1
                 tempy1lw = tempy1lw + tempy1p(l,j,k)*fac1
                 tempz1lw = tempz1lw + tempz1p(l,j,k)*fac1
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLY
@@ -469,9 +445,6 @@
                 tempx2lw = tempx2lw + tempx2p(i,l,k)*fac2
                 tempy2lw = tempy2lw + tempy2p(i,l,k)*fac2
                 tempz2lw = tempz2lw + tempz2p(i,l,k)*fac2
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          enddo
 
                 !!! can merge these loops because NGLLX = NGLLY = NGLLZ          do l=1,NGLLZ
@@ -482,9 +455,6 @@
                 tempx3lw = tempx3lw + tempx3p(i,j,l)*fac3
                 tempy3lw = tempy3lw + tempy3p(i,j,l)*fac3
                 tempz3lw = tempz3lw + tempz3p(i,j,l)*fac3
-                ! adjoint simulations
-                if (SIMULATION_TYPE == 3) then
-                endif
               enddo
 
               fac1 = wgllwgll_yz(j,k)

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/iterate_time.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -87,7 +87,7 @@
     ! restores last time snapshot saved for backward/reconstruction of wavefields
     ! note: this must be read in after the Newmark time scheme
     if( SIMULATION_TYPE == 3 .and. it == 1 ) then
-     call it_read_foward_arrays()
+     call it_read_forward_arrays()
     endif
 
     ! write the seismograms with time shift
@@ -395,6 +395,20 @@
       b_veloc(:,:) = b_veloc(:,:) + b_deltatover2*b_accel(:,:)
       b_accel(:,:) = 0._CUSTOM_REAL
     endif
+    ! poroelastic backward fields
+    if( POROELASTIC_SIMULATION ) then
+    ! solid phase
+    b_displs_poroelastic(:,:) = b_displs_poroelastic(:,:) + b_deltat*b_velocs_poroelastic(:,:) + &
+                              b_deltatsqover2*b_accels_poroelastic(:,:)
+    b_velocs_poroelastic(:,:) = b_velocs_poroelastic(:,:) + b_deltatover2*b_accels_poroelastic(:,:)
+    b_accels_poroelastic(:,:) = 0._CUSTOM_REAL
+
+    ! fluid phase
+    b_displw_poroelastic(:,:) = b_displw_poroelastic(:,:) + b_deltat*b_velocw_poroelastic(:,:) + &
+                              b_deltatsqover2*b_accelw_poroelastic(:,:)
+    b_velocw_poroelastic(:,:) = b_velocw_poroelastic(:,:) + b_deltatover2*b_accelw_poroelastic(:,:)
+    b_accelw_poroelastic(:,:) = 0._CUSTOM_REAL
+    endif
   endif
 
 ! adjoint simulations: moho kernel
@@ -408,7 +422,7 @@
 
 !=====================================================================
 
-  subroutine it_read_foward_arrays()
+  subroutine it_read_forward_arrays()
 
   use specfem_par
   use specfem_par_acoustic
@@ -460,9 +474,19 @@
 
   endif
 
+  ! poroelastic wavefields
+  if( POROELASTIC_SIMULATION ) then
+    read(27) b_displs_poroelastic
+    read(27) b_velocs_poroelastic
+    read(27) b_accels_poroelastic
+    read(27) b_displw_poroelastic
+    read(27) b_velocw_poroelastic
+    read(27) b_accelw_poroelastic
+  endif
+
   close(27)
 
-  end subroutine it_read_foward_arrays
+  end subroutine it_read_forward_arrays
 
 !=====================================================================
 

Modified: seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90
===================================================================
--- seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90	2012-06-15 22:53:17 UTC (rev 20377)
+++ seismo/3D/SPECFEM3D/trunk/src/specfem3D/specfem3D_par.f90	2012-06-17 02:02:31 UTC (rev 20378)
@@ -431,8 +431,6 @@
 ! displacement, velocity, acceleration
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: accels_poroelastic,velocs_poroelastic,displs_poroelastic
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: accelw_poroelastic,velocw_poroelastic,displw_poroelastic
-  real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: b_accels_poroelastic,b_velocs_poroelastic,b_displs_poroelastic
-  real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: b_accelw_poroelastic,b_velocw_poroelastic,b_displw_poroelastic
 
 ! material properties
 !  real(kind=CUSTOM_REAL), dimension(:,:,:,:), allocatable :: mustore
@@ -457,6 +455,34 @@
 
   logical :: POROELASTIC_SIMULATION
 
+! ADJOINT poroelastic
+
+  ! (backward/reconstructed) wavefields
+  real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: b_accels_poroelastic,b_velocs_poroelastic,b_displs_poroelastic
+  real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: b_accelw_poroelastic,b_velocw_poroelastic,b_displw_poroelastic
+
+  ! adjoint kernels [primary kernels, density kernels, wavespeed kernels]
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: rhot_kl, rhof_kl, sm_kl, eta_kl, mufr_kl, B_kl, &
+    C_kl, M_kl, rhob_kl, rhofb_kl, phi_kl, Bb_kl, Cb_kl, Mb_kl, mufrb_kl, &
+    rhobb_kl, rhofbb_kl, phib_kl, cpI_kl, cpII_kl, cs_kl, ratio_kl
+
+  ! approximate hessian
+  !real(kind=CUSTOM_REAL), dimension(:,:,:,:), allocatable :: hess_kl
+
+  ! absorbing stacey wavefield parts
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_absorb_fields_poroelastic,b_absorb_fieldw_poroelastic
+  integer :: b_reclen_fields,b_reclen_fieldw
+
+  ! for assembling backward field
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_send_vector_ext_meshs
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_send_vector_ext_meshw
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_recv_vector_ext_meshs
+  real(kind=CUSTOM_REAL), dimension(:,:,:), allocatable :: b_buffer_recv_vector_ext_meshw
+  integer, dimension(:), allocatable :: b_request_send_vector_ext_meshs
+  integer, dimension(:), allocatable :: b_request_send_vector_ext_meshw
+  integer, dimension(:), allocatable :: b_request_recv_vector_ext_meshs
+  integer, dimension(:), allocatable :: b_request_recv_vector_ext_meshw
+
 end module specfem_par_poroelastic
 
 



More information about the CIG-COMMITS mailing list