From 7761273c2b40ab8b43349db16b1d33792bc1dbb9 Mon Sep 17 00:00:00 2001 From: Daniel Peter Date: Tue, 3 Dec 2019 18:43:14 +0300 Subject: [PATCH] updates kernel script --- .../create_adjoint_sources.sh | 4 +- .../create_adjoint_sources.sh | 65 +++++++++++++++++-- .../create_alpha_kernel_vtk.sh | 9 +-- .../amplitude/create_adjsrc_amplitude.f90 | 12 +++- .../traveltime/create_adjsrc_traveltime.f90 | 10 ++- .../waveform/create_adjsrc_waveform.f90 | 7 +- 6 files changed, 85 insertions(+), 22 deletions(-) diff --git a/EXAMPLES/homogeneous_acoustic/create_adjoint_sources.sh b/EXAMPLES/homogeneous_acoustic/create_adjoint_sources.sh index 871ff5863..fa2447180 100755 --- a/EXAMPLES/homogeneous_acoustic/create_adjoint_sources.sh +++ b/EXAMPLES/homogeneous_acoustic/create_adjoint_sources.sh @@ -8,8 +8,8 @@ comp="MXP" en="semp" # window start/end time -t_start=32.0 -t_end=38.0 +t_start=9.0 # 32.0 +t_end=30.0 # 38.0 ################################################# diff --git a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_adjoint_sources.sh b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_adjoint_sources.sh index a59dcc293..f536a7110 100755 --- a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_adjoint_sources.sh +++ b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_adjoint_sources.sh @@ -1,25 +1,80 @@ #!/bin/bash +################################################# +# reference adjoint station +network="DB" +station="X20" +comp="BXX" +en="semd" + +# window start/end time +t_start=10.0 +t_end=25.0 + +################################################# + +# adjoint sources will be in folder SEM/ +currentdir=`pwd` mkdir -p SEM -#cp OUTPUT_FILES/X20.DB.BX*.semd SEM/ -if [ ! -e SEM/X20.DB.BXX.semd ]; then echo "please copy traces X20.DB.BX*.semd to SEM/"; exit 1; fi +# needs traces +sta=$network.$station +if [ ! -e OUTPUT_FILES/$sta.$comp.$en ]; then echo "please make sure trace OUTPUT_FILES/$sta.$comp.$en is available"; exit 1; fi + +rm -f SEM/$sta.* +cp -v OUTPUT_FILES/$sta.* SEM/ + +# compile adjoint_source tool +if [ ! -e xcreate_adjsrc_traveltime ]; then + # creates adjoint sources + cd ../../utils/adjoint_sources/traveltime + + # fortran compiler (as specified in Makefile) + FC=`grep '^FC .*' ../../../Makefile | cut -d = -f 2 | sed "s/^[ \t]*//"` + if [ "$FC" == "" ]; then echo "fortran compiler not found, exiting..."; exit 1; fi + CC=`grep '^CC .*' ../../../Makefile | cut -d = -f 2 | sed "s/^[ \t]*//"` + if [ "$CC" == "" ]; then echo "C compiler not found, exiting..."; exit 1; fi + + echo "compiling xcreate_adjsrc_traveltime:" + echo " using fortran compiler = $FC" + echo " using C compiler = $CC" + echo -#cp ~/SPECFEM3D_svn/utils/adjoint_sources/traveltime/xcreate_adjsrc_traveltime SEM/ + cp Makefile Makefile.host + sed -i "s:F90 .*:F90 = $FC:" Makefile.host + sed -i "s:CC .*:CC = $CC:" Makefile.host + + rm -rf xcreate_adjsrc_traveltime + make -f Makefile.host + # checks exit code + if [[ $? -ne 0 ]]; then exit 1; fi + + cp -v xcreate_adjsrc_traveltime $currentdir/SEM/ + cd $currentdir +fi if [ ! -e SEM/xcreate_adjsrc_traveltime ]; then echo "please make xcreate_adjsrc_traveltime and copy to SEM/"; exit 1; fi + +echo +echo "running adjoint source creation" +echo # creates adjoint sources cd SEM/ -./xcreate_adjsrc_traveltime 10.0 25.0 3 X20.DB.BX*.semd +./xcreate_adjsrc_traveltime $t_start $t_end 3 $sta.* # checks exit code if [[ $? -ne 0 ]]; then exit 1; fi -if [ ! -e X20.DB.BXZ.adj ]; then echo "error creating adjoint sources, please check..."; exit 1; fi +if [ ! -e $sta.$comp.adj ]; then echo "error creating adjoint sources, please check..."; exit 1; fi +echo # renames #rename .semd.adj .adj *semd.adj +# create STATIONS_ADJOINT file with adjoint source location +fgrep $station ../DATA/STATIONS > ./STATIONS_ADJOINT +cp -v ./STATIONS_ADJOINT ../DATA/ + cd ../ echo diff --git a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_alpha_kernel_vtk.sh b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_alpha_kernel_vtk.sh index ddee428e7..2445175ab 100755 --- a/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_alpha_kernel_vtk.sh +++ b/EXAMPLES/homogeneous_halfspace_HEX8_elastic_absorbing_Stacey_5sides/create_alpha_kernel_vtk.sh @@ -1,22 +1,17 @@ #!/bin/bash -mkdir -p bin.xcombine - # checks for executable -if [ ! -e bin.xcombine/xcombine_vol_data_vtk ]; then echo "please make xcombine_vol_data_vtk and copy executable to bin.xcombine"; exit 1; fi +if [ ! -e bin/xcombine_vol_data_vtk ]; then echo "please make xcombine_vol_data_vtk and copy executable to bin.xcombine"; exit 1; fi # checks for kernel files if [ ! -e OUTPUT_FILES/DATABASES_MPI/proc000000_alpha_kernel.bin ]; then echo "proc***alpha_kernel.bin missing in OUTPUT_FILES/DATABASES_MPI/"; exit 1; fi # creates kernel as vtk-file -cd bin.xcombine/ -./xcombine_vol_data_vtk 0 3 alpha_kernel ../OUTPUT_FILES/DATABASES_MPI/ ../OUTPUT_FILES/ 1 +./bin/xcombine_vol_data_vtk 0 3 alpha_kernel OUTPUT_FILES/DATABASES_MPI/ OUTPUT_FILES/ 1 # checks exit code if [[ $? -ne 0 ]]; then exit 1; fi -cd ../ - echo echo diff --git a/utils/adjoint_sources/amplitude/create_adjsrc_amplitude.f90 b/utils/adjoint_sources/amplitude/create_adjsrc_amplitude.f90 index bce6a1eba..e9136c7e6 100644 --- a/utils/adjoint_sources/amplitude/create_adjsrc_amplitude.f90 +++ b/utils/adjoint_sources/amplitude/create_adjsrc_amplitude.f90 @@ -87,7 +87,9 @@ program create_adjsrc_amplitude endif ! user output - print *, 'ifile = ', ifile, ' lrot = ', lrot + print *, 'xcreate_adjsrc_amplitude:' + print *, ' measurement window start/end = ',ts,'/',te + print *, ' component ifile = ', ifile, ' lrot = ', lrot print *, ' ' ! reads seismograms (ascii format) @@ -154,8 +156,12 @@ program create_adjsrc_amplitude if (abs(norm) > EPS) then adj(1:nstep) = out(1:nstep) * tw(1:nstep) / norm else - print *, 'norm < EPS for file '//trim(file(i)) - adj(:) = 0. + if (ifile /= 0 .and. ifile /= i) then + print *,' component set to zero' + else + print *, ' norm < EPS for file '//trim(file(i)) + endif + adj(:) = 0.0 endif data(i,:) = adj(:) diff --git a/utils/adjoint_sources/traveltime/create_adjsrc_traveltime.f90 b/utils/adjoint_sources/traveltime/create_adjsrc_traveltime.f90 index 180756c4d..db865264d 100644 --- a/utils/adjoint_sources/traveltime/create_adjsrc_traveltime.f90 +++ b/utils/adjoint_sources/traveltime/create_adjsrc_traveltime.f90 @@ -87,7 +87,9 @@ program create_adjsrc_traveltime endif ! user output - print *, 'ifile = ', ifile, ' lrot = ', lrot + print *, 'xcreate_adjsrc_traveltime:' + print *, ' measurement window start/end = ',ts,'/',te + print *, ' component ifile = ', ifile, ' lrot = ', lrot print *, ' ' ! reads seismograms (ascii format) @@ -159,7 +161,11 @@ program create_adjsrc_traveltime if (abs(norm) > EPS) then adj(1:nstep) = - out(1:nstep) * tw(1:nstep) / norm else - print *, 'norm < EPS for file '//trim(file(i)) + if (ifile /= 0 .and. ifile /= i) then + print *,' component set to zero' + else + print *, ' norm < EPS for file '//trim(file(i)) + endif adj(:) = 0.0 endif data(i,:) = adj(:) diff --git a/utils/adjoint_sources/waveform/create_adjsrc_waveform.f90 b/utils/adjoint_sources/waveform/create_adjsrc_waveform.f90 index c7f9556fb..e91e6f32e 100644 --- a/utils/adjoint_sources/waveform/create_adjsrc_waveform.f90 +++ b/utils/adjoint_sources/waveform/create_adjsrc_waveform.f90 @@ -114,7 +114,8 @@ program create_adjsrc_waveform ! user output print *, 'xcreate_adjsrc_waveform:' - print *, ' ifile = ', ifile, ' lrot = ', lrot + print *, ' measurement window start/end = ',ts,'/',te + print *, ' component ifile = ', ifile, ' lrot = ', lrot print *, ' single file = ',single_file ! gets directory from filename @@ -287,13 +288,13 @@ program create_adjsrc_waveform else ! user output if (single_file) then - if (comp(ifile) /= channel(3:3)) then + if (ifile /= 0 .and. comp(ifile) /= channel(3:3)) then print *,' component set to zero' else print *, ' norm < EPS for file '//trim(file(i)) endif else - if (ifile /= i) then + if (ifile /= 0 .and. ifile /= i) then print *,' component set to zero' else print *, ' norm < EPS for file '//trim(file(i))