[cig-commits] [commit] devel, master: Changes EXAMPLES/noise_uniform for improved consistency with the other test cases (e5dac00)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Jun 18 15:19:17 PDT 2014


Repository : https://github.com/geodynamics/specfem2d

On branches: devel,master
Link       : https://github.com/geodynamics/specfem2d/compare/fc67e6fd7ad890705b2b72b4b3c509accb22249e...e9ca46c40131588d89d7b0883250bc6584ce6b4c

>---------------------------------------------------------------

commit e5dac00b99a64b882ec1b585b0de9db7aa014f5d
Author: Ryan Modrak <rmodrak at princeton.edu>
Date:   Wed Aug 31 06:17:27 2011 +0000

    Changes EXAMPLES/noise_uniform for improved consistency with the other test cases


>---------------------------------------------------------------

e5dac00b99a64b882ec1b585b0de9db7aa014f5d
 noise_uniform/Par_file_noise_1 |  8 +++----
 noise_uniform/Par_file_noise_2 |  8 +++----
 noise_uniform/Par_file_noise_3 |  8 +++----
 noise_uniform/adj_cc.f90       | 44 +++++++++++++++++++++++---------------
 noise_uniform/clean            | 13 ++++++++++++
 noise_uniform/process.sh       | 48 +++++++++++++++++++-----------------------
 noise_uniform/replicate        | 41 ++++++++++++++++++++++++++++++++++++
 7 files changed, 115 insertions(+), 55 deletions(-)

diff --git a/noise_uniform/Par_file_noise_1 b/noise_uniform/Par_file_noise_1
index 7424a07..79b14b3 100644
--- a/noise_uniform/Par_file_noise_1
+++ b/noise_uniform/Par_file_noise_1
@@ -2,9 +2,9 @@
 title                           = Noise_2D
 
 # forward or adjoint simulation
-SIMULATION_TYPE                 = 1   # 1 = forward, 2 = adjoint + kernels
-NOISE_TOMOGRAPHY                = 1   # 0 = earthquake simulation, 1/2/3 = noise simulation
-SAVE_FORWARD                    = .false.  # save the last frame, needed for adjoint simulation
+SIMULATION_TYPE                 = 1
+NOISE_TOMOGRAPHY                = 1
+SAVE_FORWARD                    = .false.
 
 # parameters concerning partitioning
 nproc                           = 1              # number of processes
@@ -98,7 +98,7 @@ tangential_detection_curve_file = ./DATA/courbe_eros_nodes # file containing the
 # PARAMETERS FOR INTERNAL MESHING
 
 # file containing interfaces for internal mesh
-interfacesfile                  = ../EXAMPLES/noise_uniform/uniform.dat
+interfacesfile                  = uniform.dat
 
 # geometry of the model (origin lower-left corner = 0,0) and mesh description
 xmin                            = 0.d0           # abscissa of left side of the model
diff --git a/noise_uniform/Par_file_noise_2 b/noise_uniform/Par_file_noise_2
index 99216f7..48cfc53 100644
--- a/noise_uniform/Par_file_noise_2
+++ b/noise_uniform/Par_file_noise_2
@@ -2,9 +2,9 @@
 title                           = Noise_2D
 
 # forward or adjoint simulation
-SIMULATION_TYPE                 = 1   # 1 = forward, 2 = adjoint + kernels
-NOISE_TOMOGRAPHY                = 2   # 0 = earthquake simulation, 1/2/3 = noise simulation
-SAVE_FORWARD                    = .true.  # save the last frame, needed for adjoint simulation
+SIMULATION_TYPE                 = 1
+NOISE_TOMOGRAPHY                = 2
+SAVE_FORWARD                    = .true.
 
 # parameters concerning partitioning
 nproc                           = 1              # number of processes
@@ -98,7 +98,7 @@ tangential_detection_curve_file = ./DATA/courbe_eros_nodes # file containing the
 # PARAMETERS FOR INTERNAL MESHING
 
 # file containing interfaces for internal mesh
-interfacesfile                  = ../EXAMPLES/noise_uniform/uniform.dat
+interfacesfile                  = uniform.dat
 
 # geometry of the model (origin lower-left corner = 0,0) and mesh description
 xmin                            = 0.d0           # abscissa of left side of the model
diff --git a/noise_uniform/Par_file_noise_3 b/noise_uniform/Par_file_noise_3
index 68b1d67..a90fba6 100644
--- a/noise_uniform/Par_file_noise_3
+++ b/noise_uniform/Par_file_noise_3
@@ -2,9 +2,9 @@
 title                           = Noise_2D
 
 # forward or adjoint simulation
-SIMULATION_TYPE                 = 2   # 1 = forward, 2 = adjoint + kernels
-NOISE_TOMOGRAPHY                = 3   # 0 = earthquake simulation, 1/2/3 = noise simulation
-SAVE_FORWARD                    = .false.  # save the last frame, needed for adjoint simulation
+SIMULATION_TYPE                 = 2
+NOISE_TOMOGRAPHY                = 3
+SAVE_FORWARD                    = .false.
 
 # parameters concerning partitioning
 nproc                           = 1              # number of processes
@@ -98,7 +98,7 @@ tangential_detection_curve_file = ./DATA/courbe_eros_nodes # file containing the
 # PARAMETERS FOR INTERNAL MESHING
 
 # file containing interfaces for internal mesh
-interfacesfile                  = ../EXAMPLES/noise_uniform/uniform.dat
+interfacesfile                  = uniform.dat
 
 # geometry of the model (origin lower-left corner = 0,0) and mesh description
 xmin                            = 0.d0           # abscissa of left side of the model
diff --git a/noise_uniform/adj_cc.f90 b/noise_uniform/adj_cc.f90
index 9e9e1a1..5406eff 100644
--- a/noise_uniform/adj_cc.f90
+++ b/noise_uniform/adj_cc.f90
@@ -5,19 +5,21 @@ implicit none
 ! flags
 logical, parameter :: use_filtering = .true.
 logical, parameter :: use_positive_branch = .false.
+logical, parameter :: use_custom_window = .false.
+logical, parameter :: reverse = .true.
+integer, parameter :: differentiate = 1
 
 ! FILTERING PARAMETERS
 real  freq_low,freq_high
-data  freq_low  / 1d-2 /
-data  freq_high / 1d1  /
+data  freq_low  / 1.d-2 /
+data  freq_high / 1.5d1  /
 
-! WINDOW PARAMETERS
+! CUSTOM WINDOW PARAMETERS
 real :: w_delay, w_width, w_tukey
-data w_delay / 1.25 /
-data w_width / 1.00 /
+data w_delay / 1.d0 /
+data w_width / 1.d2 /
 data w_tukey / 0.4 /
-!see explanation of 
-!window parameters, below
+!see explanation below
 
 ! time variables
 integer :: it, nt, nthalf
@@ -39,9 +41,7 @@ real :: F1,F2,D(8),G,DELT
 real :: alpha, beta
 
 
-
-
-! EXPLANATION OF WINDOW PARAMETERS
+! EXPLANATION OF CUSTOM WINDOW PARAMETERS
 
 !To select the desired branch of the cross-correlogram, we employ a Tukey window.  A Tukey taper is just a variant of a cosine taper.  We use three control parameters
 
@@ -57,6 +57,7 @@ real :: alpha, beta
 
 
 
+
 ! Get file info
 call getarg(1,file_in)
 call getlen(file_in,nt)
@@ -88,16 +89,20 @@ seismo_adj(:) = 0.0d0
 !!!!!!!!!! READ INPUT !!!!!!!!!!!!!!!!!!!!
 open(unit=1001,file=trim(file_in),status='old',action='read')
 do it = 1, nt
-    read(1001,*) t(it), seismo_1(nt-it+1)
+    if (.not. reverse) read(1001,*) t(it), seismo_1(it)
+    if (reverse) read(1001,*) t(it), seismo_1(nt-it+1)
 end do
 close(1001)
 
 
 !!!!!!!!!! DIFFERENTIATE !!!!!!!!!!!!!!!!!!!
-seismo_1(1) = 0.0
-seismo_1(nt) = 0.0
+seismo_2(1) = 0.0
+seismo_2(nt) = 0.0
 do it = 2, nt-1
-    seismo_2(it) = ( seismo_2(it+1) - seismo_1(it-1) ) / (2*dt)
+    if (differentiate == 0) seismo_2(it) = seismo_1(it)
+    if (differentiate == 1) seismo_2(it) = ( seismo_1(it+1) - seismo_1(it-1) ) / (2*dt)
+    if (differentiate == 2) seismo_2(it) = ( seismo_1(it+1) - 2 * seismo_1(it) + seismo_1(it-1) ) / dt**2
+
 end do
 
 
@@ -125,8 +130,13 @@ end if
 
 
 !!!!!!!!!! WINDOW !!!!!!!!!!!!!!!!!!!!
-it_off = floor(w_delay/dt)
-it_wdt = 2*floor(w_width/(2.*dt))
+if (use_custom_window) then
+  it_off = floor(w_delay/dt)
+  it_wdt = 2*floor(w_width/(2.*dt))
+else
+  it_off = int(nthalf/2)
+  it_wdt = int(nthalf) + 1
+endif
 alpha = w_tukey
 
 if (use_positive_branch) then
@@ -179,7 +189,7 @@ write(*,*) ''
 write(*,*) 'Writing to file: '//trim(file_in)//'.adj'
 
 do it = 1,nt
-    write(1002,*), t(it), seismo_adj(it)
+    write(1002,'(f16.12,1pe18.8)'), t(it), seismo_adj(it)
 end do
 close(1002)
 
diff --git a/noise_uniform/clean b/noise_uniform/clean
new file mode 100755
index 0000000..652cdce
--- /dev/null
+++ b/noise_uniform/clean
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# runs all three noise tomography simulations
+#
+
+echo "Cleaning up."
+
+rm -rf DATA SEM NOISE_TOMOGRAPHY OUTPUT_FILES OUTPUT_ALL &> /dev/null
+rm xmeshfem2D xspecfem2D &> /dev/null
+rm adj_run &> /dev/null
+rm log.* &> /dev/null
+
+
diff --git a/noise_uniform/process.sh b/noise_uniform/process.sh
index 8726c3d..fa0b721 100755
--- a/noise_uniform/process.sh
+++ b/noise_uniform/process.sh
@@ -1,31 +1,27 @@
 #!/bin/sh
 
-USAGE="USAGE:  submit  par_file_directory"
-if [ $# -eq 0 ]; then PAR_DIR=uniform; fi
-if [ $# -eq 1 ]; then PAR_DIR=$1; fi
-if [ $# -ne 0 ] && [ $# -ne 1 ]; then echo "$USAGE"; exit 1; fi
-
-
-PAR_DIR_FULL=$PWD/$PAR_DIR
-RUN_DIR=../..
-cd $RUN_DIR
-
+RUN_DIR=$PWD
 
 # prepare directories
-rm -rf   SEM NOISE_TOMOGRAPHY OUTPUT_FILES OUTPUT_ALL
-mkdir -p SEM NOISE_TOMOGRAPHY OUTPUT_FILES OUTPUT_ALL
+rm -rf   DATA SEM NOISE_TOMOGRAPHY OUTPUT_FILES OUTPUT_ALL
+mkdir -p DATA SEM NOISE_TOMOGRAPHY OUTPUT_FILES OUTPUT_ALL
 
 
 # prepare files
-cp $PAR_DIR_FULL/SOURCE_noise           DATA/SOURCE
-cp $PAR_DIR_FULL/STATIONS_target_noise  DATA/STATIONS_target
-#cp $PAR_DIR_FULL/S_squared              NOISE_TOMOGRAPHY
-echo 1 >                                NOISE_TOMOGRAPHY/irec_master
-
+cp SOURCE_noise           DATA/SOURCE
+cp STATIONS_target_noise  DATA/STATIONS_target
+cp S_squared              NOISE_TOMOGRAPHY
+cp uniform.dat            DATA/
+echo 1 >                  NOISE_TOMOGRAPHY/irec_master
+cd ../..
+make
+cd $RUN_DIR
+ln -s ../../bin/xmeshfem2D .
+ln -s ../../bin/xspecfem2D .
 
 #simulation 1
-cp $PAR_DIR_FULL/Par_file_noise_1  DATA/Par_file
-make; bin/xmeshfem2D; bin/xspecfem2D
+cp Par_file_noise_1  DATA/Par_file
+./xmeshfem2D; ./xspecfem2D
 mkdir OUTPUT_ALL/step_1
 mv OUTPUT_FILES/image*  OUTPUT_ALL/step_1
 mv OUTPUT_FILES/*.semd  OUTPUT_ALL/step_1
@@ -33,14 +29,14 @@ mv DATA/Par_file  OUTPUT_ALL/step_1
 
 
 #simulation 2
-cp $PAR_DIR_FULL/Par_file_noise_2  DATA/Par_file
-bin/xmeshfem2D; bin/xspecfem2D
+cp Par_file_noise_2  DATA/Par_file
+./xmeshfem2D; ./xspecfem2D
 mkdir OUTPUT_ALL/step_2
 
-ADJ_CODE=$PAR_DIR_FULL/adj_cc.f90
-gfortran $ADJ_CODE -o adj_cc
+ADJ_CODE=adj_cc.f90
+gfortran $ADJ_CODE -o adj_run
 cp OUTPUT_FILES/*.semd  SEM
-./adj_cc SEM/S0003.AA.BXY.semd
+./adj_run SEM/S0003.AA.BXY.semd
 
 cd SEM
 rename '.semd' '' *.adj
@@ -57,8 +53,8 @@ mv DATA/Par_file  OUTPUT_ALL/step_2
 
 
 #simulation 3
-cp $PAR_DIR_FULL/Par_file_noise_3  DATA/Par_file
-bin/xmeshfem2D; bin/xspecfem2D
+cp Par_file_noise_3  DATA/Par_file
+./xmeshfem2D; ./xspecfem2D
 mkdir OUTPUT_ALL/step_3
 mv OUTPUT_FILES/image*  OUTPUT_ALL/step_3
 mv OUTPUT_FILES/*.semd  OUTPUT_ALL/step_3
diff --git a/noise_uniform/replicate b/noise_uniform/replicate
new file mode 100755
index 0000000..086abdc
--- /dev/null
+++ b/noise_uniform/replicate
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]; then echo "Usage:  replicate  par_file  dir"; exit 1; fi
+
+if [ ! -e $1 ];  then echo "File not found: $1"; exit 1; fi
+if [ ! -d $2 ];  then echo "Directory not found: $2"; exit 1; fi
+
+FILE=$1
+DIR=$2
+
+FILE_BAK=$DIR/replicate.bak
+cp $FILE $FILE_BAK
+cd $DIR
+
+Line1=`grep ^SIMULATION_TYPE $FILE_BAK`
+Line2=`grep ^NOISE_TOMOGRAPHY $FILE_BAK`
+Line3=`grep ^SAVE_FORWARD $FILE_BAK`
+
+if [ `echo $Line1 | wc -l` -ne 1 ]; then echo "Error reading SIMULATION_TYPE."; exit 1; fi
+if [ `echo $Line2 | wc -l` -ne 1 ]; then echo "Error reading NOISE_TOMOGRAPHY."; exit 1; fi
+if [ `echo $Line3 | wc -l` -ne 1 ]; then echo "Error reading SAVE_FORWARD."; exit 1; fi
+
+
+#PAR_FILE_NOISE_1
+cp $FILE_BAK Par_file_noise_1
+sed -i -e "s:${Line1}:SIMULATION_TYPE                 = 1:"  Par_file_noise_1
+sed -i -e "s:${Line2}:NOISE_TOMOGRAPHY                = 1:"  Par_file_noise_1
+sed -i -e "s:${Line3}:SAVE_FORWARD                    = .false.:"  Par_file_noise_1
+
+#PAR_FILE_NOISE_2
+cp $FILE_BAK Par_file_noise_2
+sed -i -e "s:${Line1}:SIMULATION_TYPE                 = 1:"  Par_file_noise_2
+sed -i -e "s:${Line2}:NOISE_TOMOGRAPHY                = 2:"  Par_file_noise_2
+sed -i -e "s:${Line3}:SAVE_FORWARD                    = .true.:"  Par_file_noise_2
+
+#PAR_FILE_NOISE_3
+cp $FILE_BAK Par_file_noise_3
+sed -i -e "s:${Line1}:SIMULATION_TYPE                 = 2:"  Par_file_noise_3
+sed -i -e "s:${Line2}:NOISE_TOMOGRAPHY                = 3:"  Par_file_noise_3
+sed -i -e "s:${Line3}:SAVE_FORWARD                    = .false.:"  Par_file_noise_3
+



More information about the CIG-COMMITS mailing list