Skip to content

Commit

Permalink
updates kernel script
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeter committed Dec 3, 2019
1 parent e7b3968 commit 7761273
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 22 deletions.
4 changes: 2 additions & 2 deletions EXAMPLES/homogeneous_acoustic/create_adjoint_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

#################################################

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

12 changes: 9 additions & 3 deletions utils/adjoint_sources/amplitude/create_adjsrc_amplitude.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(:)

Expand Down
10 changes: 8 additions & 2 deletions utils/adjoint_sources/traveltime/create_adjsrc_traveltime.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(:)
Expand Down
7 changes: 4 additions & 3 deletions utils/adjoint_sources/waveform/create_adjsrc_waveform.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 7761273

Please sign in to comment.