[cig-commits] r12872 - seismo/3D/SPECFEM3D_GLOBE/trunk

leif at geodynamics.org leif at geodynamics.org
Fri Sep 12 13:14:21 PDT 2008


Author: leif
Date: 2008-09-12 13:14:20 -0700 (Fri, 12 Sep 2008)
New Revision: 12872

Modified:
   seismo/3D/SPECFEM3D_GLOBE/trunk/
Log:
Fixed syntax error.



Property changes on: seismo/3D/SPECFEM3D_GLOBE/trunk
___________________________________________________________________
Name: buildbot:script
   - #!/bin/sh

buildnumber=$1

CODE_DIR=`pwd`
export CODE_DIR

######################################################################
# configuration

bench_dir=/home/siemins/buildbot
forward_runs="forward"
kernel_runs="kernel"
runs="$forward_runs $kernel_runs"

CMTSOLUTION=${bench_dir}/DATA/CMTSOLUTION

#---------------------------------------------------------------------
# forward run

function get_forward_parameters {
    STATIONS=${bench_dir}/DATA/STATIONS

    SAVE_FORWARD=.false.
    NCHUNKS=6
    NPROC_XI=6
    NPROC_ETA=6
    MODEL=1D_transversely_isotropic_prem
    GRAVITY=.true.
    ATTENUATION=.true.
    RECORD_LENGTH_IN_MINUTES=50.0d0
}

function tweak_forward_parameters {
}

function run_forward_job {
    common_forward_job
}

#---------------------------------------------------------------------
# kernel run

function get_kernel_parameters {
    STATIONS=${bench_dir}/DATA/STATIONS_ADJOINT

    # the code opens a different filename for SIMULATION_TYPE != 1
    cp $STATIONS DATA/STATIONS_ADJOINT || exit $?

    SAVE_FORWARD=.true.
    NCHUNKS=6
    NPROC_XI=6
    NPROC_ETA=6
    MODEL=1D_isotropic_prem
    GRAVITY=.false.
    ATTENUATION=.false.
    RECORD_LENGTH_IN_MINUTES=12.0d0
}

function tweak_kernel_parameters {
    # for kernel computation: hdur = 9.0000 (Qinya's empirical rule for NEX=288)
    sed -e "s:^half .*:half duration    9.0000 :" < DATA/CMTSOLUTION > DATA/CMTSOLUTION.tmp || exit $?
    mv DATA/CMTSOLUTION.tmp DATA/CMTSOLUTION || exit $?
}

function run_kernel_job {
    common_kernel_job
}

######################################################################
# visualization

function visu_seismo {
    # 11/08/2008

    #### Plot seismograms with increasing distance for vertical, radial and transverse
    # must be used in ASCII/

    # set up station to display (increasing distance)
    cat >stations <<EOF
SPB.G
FDF.G
TRIS.G
SCZ.G
SFJD.IU
ECH.G
RAO.IU
ATD.G
AIS.G
WUS.G
INU.G
EOF

    nstation=`wc -l stations | awk '{print $1}'`

    # some plotting parameters
    gmtset DOTS_PR_INCH 600
    region_axes=-R-10/3000/0.01/0.10
    proj_axes=-JX18c/25c
    region_loc=-R-10/3000/-0.005/0.03
    proj=-JX18c

    channel_vertical=LHZ
    channel_radial=LHR
    channel_transverse=LHT

    for orientation in vertical radial transverse; do
        channel_var=channel_$orientation
        channel=${!channel_var}

        output=$orientation.ps
        output_pdf=$orientation.pdf

        psbasemap $proj_axes $region_axes -Ba500f500Swen -K -Y2c -X2c -P > $output
        # write axis label, title and legend
        echo "1400 0.0070 14 0 4 LT time [s]" > tmp
        pstext tmp $proj_axes $region_axes -O -K -N >> $output
        echo "1200 0.105 14 0 4 LT $orientation displacement" > tmp
        pstext tmp $proj_axes $region_axes -O -K -N >> $output
        echo "2000 0.013" > tmp
        echo "2250 0.013" >> tmp
        psxy tmp $region_axes $proj_axes -O -K -W1/0/0/255 >> $output
        echo "2300 0.014 14 0 4 LT normal-mode" > tmp
        pstext tmp $proj_axes $region_axes -O -K >> $output
        echo "2000 0.015" > tmp
        echo "2250 0.015" >> tmp
        psxy tmp $region_axes $proj_axes -O -K -W1/255/0/0 >> $output
        echo "2300 0.0155 14 0 4 LT sem" > tmp
        pstext tmp $proj_axes $region_axes -O -K >> $output

        i=1
        for file in `cat stations`; do
            file1="$file.$channel.qmxd.sac.ascii"
            file2="$file.$channel.semd.ascii.sac.ascii"
            echo "0 0.001 12 0 4 LT $file" > tmp
            if [ $i == 1 ]; then
                psxy $file1 $region_loc $proj -O -K -W1/0/0/255 >> $output
            else
                psxy $file1 $region_loc $proj -O -K -W1/0/0/255 -Y2.0c >> $output
            fi
            pstext tmp $region_loc $proj -O -K >>  $output
            if [ $i == $nstation ]; then
                psxy $file2 $region_loc $proj -O -W1/255/0/0 >> $output
            else
                psxy $file2 $region_loc $proj -O -K -W1/255/0/0 >> $output
            fi
            let i=i+1 
        done

        gmtset DOTS_PR_INCH 300
        ps2pdf $output $output_pdf

    done

    rm stations tmp


    #### Plot PKPdf seismograms 

    # some plotting parameters
    gmtset DOTS_PR_INCH 600
    output=pkpdf.ps
    output_pdf=pkpdf.pdf
    proj_axes=-JX18c/15c
    region_axes=-R127/233/900/1500
    region_loc=-R-0.0015/0.0015/900/1500
    proj=-JX1c/15c

    psbasemap $proj_axes $region_axes -Ba10f10/a100f100SWen -K -Y4c -X2c -P > $output

    # write title and axis labels 
    echo "165 860 14 0 4 LT epicentral distance [degrees]" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    echo "115 1180 14 90 4 LT time [s]" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    echo "170 1550 14 0 4 LT vertical displacement" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    # where plot the legend ?

    j=130
    while [ $j -lt 231 ]; do
        file1="S$j.DK.LHZ.qmxd.sac.ascii"
        awk '{print $2,$1}' $file1 > tmp
        if [ $j == 130 ]; then
            psxy tmp $region_loc $proj -O -K -W1/0/0/255 >> $output
        else
            psxy tmp $region_loc $proj -O -K -W1/0/0/255 -X0.34c >> $output
        fi
        file2="S$j.DK.LHZ.semd.ascii.sac.ascii"
        awk '{print $2,$1}' $file2 > tmp
        if [ $j == 230 ]; then
            psxy tmp $region_loc $proj -O -W1/255/0/0 >> $output
        else
            psxy tmp $region_loc $proj -O -K -W1/255/0/0 >> $output
        fi
        let j=j+2
    done

    gmtset DOTS_PR_INCH 300
    rm tmp
    ps2pdf $output $output_pdf
    rm vertical.ps radial.ps transverse.ps pkpdf.ps

}

######################################################################
# utilities

function create_par_file {
    sed -e "
s:^SIMULATION_TYPE .*:SIMULATION_TYPE                 = 1:
s:^SAVE_FORWARD .*:SAVE_FORWARD                    = $SAVE_FORWARD:
s:^NCHUNKS .*:NCHUNKS                         = $NCHUNKS:
s:^ANGULAR_WIDTH_XI_IN_DEGREES .*:ANGULAR_WIDTH_XI_IN_DEGREES   = 90.d0 :
s:^ANGULAR_WIDTH_ETA_IN_DEGREES .*:ANGULAR_WIDTH_ETA_IN_DEGREES  = 90.d0 :
s:^NEX_XI .*:NEX_XI                          = 288 :
s:^NEX_ETA .*:NEX_ETA                         = 288 :
s:^NPROC_XI .*:NPROC_XI                        = $NPROC_XI :
s:^NPROC_ETA .*:NPROC_ETA                       = $NPROC_ETA :
s:^MODEL .*:MODEL                           = $MODEL :
s:^OCEANS .*:OCEANS                          = .false. :
s:^ELLIPTICITY .*:ELLIPTICITY                     = .false. :
s:^TOPOGRAPHY .*:TOPOGRAPHY                      = .false. :
s:^GRAVITY .*:GRAVITY                         = $GRAVITY :
s:^ROTATION .*:ROTATION                        = .false. :
s:^ATTENUATION .*:ATTENUATION                     = $ATTENUATION :
s:^ABSORBING_CONDITIONS .*:ABSORBING_CONDITIONS            = .false. :
s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES        = $RECORD_LENGTH_IN_MINUTES :
s:^MOVIE_SURFACE .*:MOVIE_SURFACE                   = .false. :
s:^MOVIE_VOLUME .*:MOVIE_VOLUME                    = .false. :
s:^SAVE_MESH_FILES .*:SAVE_MESH_FILES                 = .false. :
s:^NUMBER_OF_RUNS .*:NUMBER_OF_RUNS                  = 1 :
s:^LOCAL_PATH .*:LOCAL_PATH                      = $LOCAL_PATH :
s:^OUTPUT_SEISMOS_ASCII_TEXT .*:OUTPUT_SEISMOS_ASCII_TEXT       = .true. :
s:^ROTATE_SEISMOGRAMS_RT .*:ROTATE_SEISMOGRAMS_RT           = .false. :
s:^WRITE_SEISMOGRAMS_BY_MASTER .*:WRITE_SEISMOGRAMS_BY_MASTER     = .false. :
s:^SAVE_ALL_SEISMOS_IN_ONE_FILE .*:SAVE_ALL_SEISMOS_IN_ONE_FILE    = .false. :
s:^USE_BINARY_FOR_LARGE_FILE .*:USE_BINARY_FOR_LARGE_FILE       = .false. :
s:^PRINT_SOURCE_TIME_FUNCTION .*:PRINT_SOURCE_TIME_FUNCTION      = .false. :
" $CODE_DIR/DATA/Par_file > DATA/Par_file

}

function common_forward_job {

    bsub <<EOF
#!/bin/sh
#BSUB -J buildbot
#BSUB -q normal
#BSUB -W 2880
#BSUB -n $NPROC
#BSUB -a mpich_gm
#BSUB -o OUTPUT_FILES/%J.o
#BSUB -K

echo \$LSB_MCPU_HOSTS > OUTPUT_FILES/lsf_machines
cat OUTPUT_FILES/lsf_machines | xargs -n 2 echo | awk '{ print \$1 }' > OUTPUT_FILES/machines
shmux -M50 -Sall -c "mkdir -p $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xmeshfem3D
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

shmux -M 50 -S all -c "rm -rf $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

EOF

    if [ $? -ne 0 ]; then
        status=1
    fi
}

function common_kernel_job {

    bsub <<EOF
#!/bin/sh
#BSUB -J buildbot
#BSUB -q normal
#BSUB -W 2880
#BSUB -n $NPROC
#BSUB -a mpich_gm
#BSUB -o OUTPUT_FILES/%J.o
#BSUB -K

echo \$LSB_MCPU_HOSTS > OUTPUT_FILES/lsf_machines
cat OUTPUT_FILES/lsf_machines | xargs -n 2 echo | awk '{ print \$1 }' > OUTPUT_FILES/machines
shmux -M50 -Sall -c "mkdir -p $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xmeshfem3D
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

# collect the seismograms in SEM
mkdir SEM
for f in OUTPUT_FILES/*.semd.ascii; do
    mv \$f SEM/`basename \$f .semd.ascii`.for
done

# prepare adjoint source
#SCZ is at 71.5 degrees from source 
${bench_dir}/UTILS/xcut_velocity 592 644 3 SEM/SCZ*.for
for f in SEM/*.for.ad; do
    mv \$f SEM/`basename \$f .for.ad`.adj
done

# launch adjoint simulation
$CODE_DIR/UTILS/change_simulation_type.pl -b
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

# get the slices for a depth-section in the source-receiver plane
mkdir MESH
cd MESH
$CODE_DIR/UTILS/collect_database/copy_m_globe_database.pl ${bench_dir}/DATA/slices ../OUTPUT_FILES/lsf_machines alpha_kernel \$LSB_JOBID
cd ..

# copy the adjoint seismograms
mkdir SEM_ADJOINT
mv OUTPUT_FILES/*.ascii SEM_ADJOINT

shmux -M 50 -S all -c "rm -rf $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

EOF

    if [ $? -ne 0 ]; then
        status=1
    fi
}

######################################################################
# build and run

echo Build $buildnumber

status=0

mkdir output || exit $?

if [ ! -d $bench_dir ]; then
    # We are not running on a cluster; simply build the code.
    ./configure
    status=$?
    if [ $status -eq 0 ]; then
        make
        status=$?
    fi
    mv config.log output || exit $?
    tar cvzf output.bbl output || exit $?
    exit $status
fi

for run in $runs; do
    cd $CODE_DIR || exit $?
    mkdir output/$run || exit $?
    cd output/$run || exit $?
    mkdir DATA OUTPUT_FILES obj || exit $?
    get_${run}_parameters
    cp $CMTSOLUTION DATA/CMTSOLUTION || exit $?
    cp $STATIONS DATA/STATIONS || exit $?
    LOCAL_PATH=/scratch/buildbot-$buildnumber-$run
    create_par_file
    for pathname in $CODE_DIR/DATA/*; do
        filename=`basename $pathname`
        if [ ! -e DATA/$filename ]; then
            ln -s $pathname DATA || exit $?
        fi
    done
    tweak_${run}_parameters

    # Currently, BuildBot always sets FC to 'mpif90';
    # force it to 'ifort' in order to get the right flags.
    $CODE_DIR/configure FC=ifort
    if [ $? -eq 0 ]; then
        make
        if [ $? -ne 0 ]; then
            status=1
        fi
    else
        status=1
    fi

    NPROC=$(( $NCHUNKS * $NPROC_XI * $NPROC_ETA ))
    run_${run}_job

done

######################################################################
# postprocessing

SACAUX=/home/lqy/Tools/utils/sac2000/aux
export SACAUX

PATH=/home/lqy/Tools/utils/sac2000/bin:/opt/GMT4.0/bin:/opt/seismo-util/bin:$PATH
export PATH

set -x
date

for run in $forward_runs; do
    cd $CODE_DIR/output/$run || exit $?

    mkdir SEM || exit $?
    mv OUTPUT_FILES/*sem* SEM || exit $?

    mkdir QMXD || exit $?
    ln -s ${bench_dir}/QMXD/*qmxd QMXD || exit $?
    cp ${bench_dir}/QMXD/ref_misfit QMXD || exit $?

    sed -e "s:^half .*:half duration   15.0000 :" < DATA/CMTSOLUTION > DATA/CMTSOLUTION.tmp || exit $?
    mv DATA/CMTSOLUTION.tmp DATA/CMTSOLUTION || exit $?

    # cut - filter - resample
    $CODE_DIR/UTILS/seis_process/process_syn.pl -m DATA/CMTSOLUTION -a DATA/STATIONS -l 0/2900 -t 16/500 -s 4 QMXD/*.qmxd || exit $?
    $CODE_DIR/UTILS/seis_process/process_syn.pl -m DATA/CMTSOLUTION -a DATA/STATIONS -l 0/2900 -t 16/500 -s 4 SEM/*.semd.ascii || exit $?

    # rotate to LHR LHT LHZ
    rotate.pl -l 0 -L 2900 QMXD/*.LHE.qmxd.sac || exit $?
    rotate.pl -l 0 -L 2900 SEM/*.LHE.semd.ascii.sac || exit $?

    # convert sac into ascii
    mkdir SAC ASCII || exit $?
    mv QMXD/*.sac SAC || exit $?
    mv SEM/*.sac SAC || exit $?
    cd SAC || exit $?
    for file in *.sac; do
        sac2asc $file > ../ASCII/$file.ascii || exit $?
    done
    cd .. || exit $?
    rm -rf SAC

    # compare SEM and QMXD
    cp QMXD/ref_misfit ASCII || exit $?
    cd ASCII || exit $?
    ls *LHZ*qmxd* > tmp || exit $?
    awk 'BEGIN { FS = ".LHZ" } ; { print $1 }' tmp >  files_to_be_processed || exit $?
    rm tmp

    ${bench_dir}/UTILS/xmisfit 0 > xmisfit.out || exit $?
    error_count=`cat xmisfit.out | grep -v "Files processed" | grep -v "rms for " | wc -l | awk '{print $1}'`
    if [ $error_count -ne 0 ]; then
        status=1
    fi

    visu_seismo
    mv *.pdf ../OUTPUT_FILES

done

date

cd $CODE_DIR || exit $?
tar cvzf output.bbl output/*/config.log output/*/OUTPUT_FILES/output_*.txt output/*/ASCII/xmisfit.out output/*/OUTPUT_FILES/*.pdf || exit $?
exit $status



   + #!/bin/sh

buildnumber=$1

CODE_DIR=`pwd`
export CODE_DIR

######################################################################
# configuration

bench_dir=/home/siemins/buildbot
forward_runs="forward"
kernel_runs="kernel"
runs="$forward_runs $kernel_runs"

CMTSOLUTION=${bench_dir}/DATA/CMTSOLUTION

#---------------------------------------------------------------------
# forward run

function get_forward_parameters {
    STATIONS=${bench_dir}/DATA/STATIONS

    SAVE_FORWARD=.false.
    NCHUNKS=6
    NPROC_XI=6
    NPROC_ETA=6
    MODEL=1D_transversely_isotropic_prem
    GRAVITY=.true.
    ATTENUATION=.true.
    RECORD_LENGTH_IN_MINUTES=50.0d0
}

function tweak_forward_parameters {
    true
}

function run_forward_job {
    common_forward_job
}

#---------------------------------------------------------------------
# kernel run

function get_kernel_parameters {
    STATIONS=${bench_dir}/DATA/STATIONS_ADJOINT

    # the code opens a different filename for SIMULATION_TYPE != 1
    cp $STATIONS DATA/STATIONS_ADJOINT || exit $?

    SAVE_FORWARD=.true.
    NCHUNKS=6
    NPROC_XI=6
    NPROC_ETA=6
    MODEL=1D_isotropic_prem
    GRAVITY=.false.
    ATTENUATION=.false.
    RECORD_LENGTH_IN_MINUTES=12.0d0
}

function tweak_kernel_parameters {
    # for kernel computation: hdur = 9.0000 (Qinya's empirical rule for NEX=288)
    sed -e "s:^half .*:half duration    9.0000 :" < DATA/CMTSOLUTION > DATA/CMTSOLUTION.tmp || exit $?
    mv DATA/CMTSOLUTION.tmp DATA/CMTSOLUTION || exit $?
}

function run_kernel_job {
    common_kernel_job
}

######################################################################
# visualization

function visu_seismo {
    # 11/08/2008

    #### Plot seismograms with increasing distance for vertical, radial and transverse
    # must be used in ASCII/

    # set up station to display (increasing distance)
    cat >stations <<EOF
SPB.G
FDF.G
TRIS.G
SCZ.G
SFJD.IU
ECH.G
RAO.IU
ATD.G
AIS.G
WUS.G
INU.G
EOF

    nstation=`wc -l stations | awk '{print $1}'`

    # some plotting parameters
    gmtset DOTS_PR_INCH 600
    region_axes=-R-10/3000/0.01/0.10
    proj_axes=-JX18c/25c
    region_loc=-R-10/3000/-0.005/0.03
    proj=-JX18c

    channel_vertical=LHZ
    channel_radial=LHR
    channel_transverse=LHT

    for orientation in vertical radial transverse; do
        channel_var=channel_$orientation
        channel=${!channel_var}

        output=$orientation.ps
        output_pdf=$orientation.pdf

        psbasemap $proj_axes $region_axes -Ba500f500Swen -K -Y2c -X2c -P > $output
        # write axis label, title and legend
        echo "1400 0.0070 14 0 4 LT time [s]" > tmp
        pstext tmp $proj_axes $region_axes -O -K -N >> $output
        echo "1200 0.105 14 0 4 LT $orientation displacement" > tmp
        pstext tmp $proj_axes $region_axes -O -K -N >> $output
        echo "2000 0.013" > tmp
        echo "2250 0.013" >> tmp
        psxy tmp $region_axes $proj_axes -O -K -W1/0/0/255 >> $output
        echo "2300 0.014 14 0 4 LT normal-mode" > tmp
        pstext tmp $proj_axes $region_axes -O -K >> $output
        echo "2000 0.015" > tmp
        echo "2250 0.015" >> tmp
        psxy tmp $region_axes $proj_axes -O -K -W1/255/0/0 >> $output
        echo "2300 0.0155 14 0 4 LT sem" > tmp
        pstext tmp $proj_axes $region_axes -O -K >> $output

        i=1
        for file in `cat stations`; do
            file1="$file.$channel.qmxd.sac.ascii"
            file2="$file.$channel.semd.ascii.sac.ascii"
            echo "0 0.001 12 0 4 LT $file" > tmp
            if [ $i == 1 ]; then
                psxy $file1 $region_loc $proj -O -K -W1/0/0/255 >> $output
            else
                psxy $file1 $region_loc $proj -O -K -W1/0/0/255 -Y2.0c >> $output
            fi
            pstext tmp $region_loc $proj -O -K >>  $output
            if [ $i == $nstation ]; then
                psxy $file2 $region_loc $proj -O -W1/255/0/0 >> $output
            else
                psxy $file2 $region_loc $proj -O -K -W1/255/0/0 >> $output
            fi
            let i=i+1 
        done

        gmtset DOTS_PR_INCH 300
        ps2pdf $output $output_pdf

    done

    rm stations tmp


    #### Plot PKPdf seismograms 

    # some plotting parameters
    gmtset DOTS_PR_INCH 600
    output=pkpdf.ps
    output_pdf=pkpdf.pdf
    proj_axes=-JX18c/15c
    region_axes=-R127/233/900/1500
    region_loc=-R-0.0015/0.0015/900/1500
    proj=-JX1c/15c

    psbasemap $proj_axes $region_axes -Ba10f10/a100f100SWen -K -Y4c -X2c -P > $output

    # write title and axis labels 
    echo "165 860 14 0 4 LT epicentral distance [degrees]" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    echo "115 1180 14 90 4 LT time [s]" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    echo "170 1550 14 0 4 LT vertical displacement" > tmp
    pstext tmp $proj_axes $region_axes -O -K -N >> $output
    # where plot the legend ?

    j=130
    while [ $j -lt 231 ]; do
        file1="S$j.DK.LHZ.qmxd.sac.ascii"
        awk '{print $2,$1}' $file1 > tmp
        if [ $j == 130 ]; then
            psxy tmp $region_loc $proj -O -K -W1/0/0/255 >> $output
        else
            psxy tmp $region_loc $proj -O -K -W1/0/0/255 -X0.34c >> $output
        fi
        file2="S$j.DK.LHZ.semd.ascii.sac.ascii"
        awk '{print $2,$1}' $file2 > tmp
        if [ $j == 230 ]; then
            psxy tmp $region_loc $proj -O -W1/255/0/0 >> $output
        else
            psxy tmp $region_loc $proj -O -K -W1/255/0/0 >> $output
        fi
        let j=j+2
    done

    gmtset DOTS_PR_INCH 300
    rm tmp
    ps2pdf $output $output_pdf
    rm vertical.ps radial.ps transverse.ps pkpdf.ps

}

######################################################################
# utilities

function create_par_file {
    sed -e "
s:^SIMULATION_TYPE .*:SIMULATION_TYPE                 = 1:
s:^SAVE_FORWARD .*:SAVE_FORWARD                    = $SAVE_FORWARD:
s:^NCHUNKS .*:NCHUNKS                         = $NCHUNKS:
s:^ANGULAR_WIDTH_XI_IN_DEGREES .*:ANGULAR_WIDTH_XI_IN_DEGREES   = 90.d0 :
s:^ANGULAR_WIDTH_ETA_IN_DEGREES .*:ANGULAR_WIDTH_ETA_IN_DEGREES  = 90.d0 :
s:^NEX_XI .*:NEX_XI                          = 288 :
s:^NEX_ETA .*:NEX_ETA                         = 288 :
s:^NPROC_XI .*:NPROC_XI                        = $NPROC_XI :
s:^NPROC_ETA .*:NPROC_ETA                       = $NPROC_ETA :
s:^MODEL .*:MODEL                           = $MODEL :
s:^OCEANS .*:OCEANS                          = .false. :
s:^ELLIPTICITY .*:ELLIPTICITY                     = .false. :
s:^TOPOGRAPHY .*:TOPOGRAPHY                      = .false. :
s:^GRAVITY .*:GRAVITY                         = $GRAVITY :
s:^ROTATION .*:ROTATION                        = .false. :
s:^ATTENUATION .*:ATTENUATION                     = $ATTENUATION :
s:^ABSORBING_CONDITIONS .*:ABSORBING_CONDITIONS            = .false. :
s:^RECORD_LENGTH_IN_MINUTES .*:RECORD_LENGTH_IN_MINUTES        = $RECORD_LENGTH_IN_MINUTES :
s:^MOVIE_SURFACE .*:MOVIE_SURFACE                   = .false. :
s:^MOVIE_VOLUME .*:MOVIE_VOLUME                    = .false. :
s:^SAVE_MESH_FILES .*:SAVE_MESH_FILES                 = .false. :
s:^NUMBER_OF_RUNS .*:NUMBER_OF_RUNS                  = 1 :
s:^LOCAL_PATH .*:LOCAL_PATH                      = $LOCAL_PATH :
s:^OUTPUT_SEISMOS_ASCII_TEXT .*:OUTPUT_SEISMOS_ASCII_TEXT       = .true. :
s:^ROTATE_SEISMOGRAMS_RT .*:ROTATE_SEISMOGRAMS_RT           = .false. :
s:^WRITE_SEISMOGRAMS_BY_MASTER .*:WRITE_SEISMOGRAMS_BY_MASTER     = .false. :
s:^SAVE_ALL_SEISMOS_IN_ONE_FILE .*:SAVE_ALL_SEISMOS_IN_ONE_FILE    = .false. :
s:^USE_BINARY_FOR_LARGE_FILE .*:USE_BINARY_FOR_LARGE_FILE       = .false. :
s:^PRINT_SOURCE_TIME_FUNCTION .*:PRINT_SOURCE_TIME_FUNCTION      = .false. :
" $CODE_DIR/DATA/Par_file > DATA/Par_file

}

function common_forward_job {

    bsub <<EOF
#!/bin/sh
#BSUB -J buildbot
#BSUB -q normal
#BSUB -W 2880
#BSUB -n $NPROC
#BSUB -a mpich_gm
#BSUB -o OUTPUT_FILES/%J.o
#BSUB -K

echo \$LSB_MCPU_HOSTS > OUTPUT_FILES/lsf_machines
cat OUTPUT_FILES/lsf_machines | xargs -n 2 echo | awk '{ print \$1 }' > OUTPUT_FILES/machines
shmux -M50 -Sall -c "mkdir -p $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xmeshfem3D
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

shmux -M 50 -S all -c "rm -rf $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

EOF

    if [ $? -ne 0 ]; then
        status=1
    fi
}

function common_kernel_job {

    bsub <<EOF
#!/bin/sh
#BSUB -J buildbot
#BSUB -q normal
#BSUB -W 2880
#BSUB -n $NPROC
#BSUB -a mpich_gm
#BSUB -o OUTPUT_FILES/%J.o
#BSUB -K

echo \$LSB_MCPU_HOSTS > OUTPUT_FILES/lsf_machines
cat OUTPUT_FILES/lsf_machines | xargs -n 2 echo | awk '{ print \$1 }' > OUTPUT_FILES/machines
shmux -M50 -Sall -c "mkdir -p $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xmeshfem3D
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

# collect the seismograms in SEM
mkdir SEM
for f in OUTPUT_FILES/*.semd.ascii; do
    mv \$f SEM/`basename \$f .semd.ascii`.for
done

# prepare adjoint source
#SCZ is at 71.5 degrees from source 
${bench_dir}/UTILS/xcut_velocity 592 644 3 SEM/SCZ*.for
for f in SEM/*.for.ad; do
    mv \$f SEM/`basename \$f .for.ad`.adj
done

# launch adjoint simulation
$CODE_DIR/UTILS/change_simulation_type.pl -b
mpirun.lsf --gm-no-shmem --gm-copy-env \$PWD/xspecfem3D

# get the slices for a depth-section in the source-receiver plane
mkdir MESH
cd MESH
$CODE_DIR/UTILS/collect_database/copy_m_globe_database.pl ${bench_dir}/DATA/slices ../OUTPUT_FILES/lsf_machines alpha_kernel \$LSB_JOBID
cd ..

# copy the adjoint seismograms
mkdir SEM_ADJOINT
mv OUTPUT_FILES/*.ascii SEM_ADJOINT

shmux -M 50 -S all -c "rm -rf $LOCAL_PATH" - < OUTPUT_FILES/machines >/dev/null

EOF

    if [ $? -ne 0 ]; then
        status=1
    fi
}

######################################################################
# build and run

echo Build $buildnumber

status=0

mkdir output || exit $?

if [ ! -d $bench_dir ]; then
    # We are not running on a cluster; simply build the code.
    ./configure
    status=$?
    if [ $status -eq 0 ]; then
        make
        status=$?
    fi
    mv config.log output || exit $?
    tar cvzf output.bbl output || exit $?
    exit $status
fi

for run in $runs; do
    cd $CODE_DIR || exit $?
    mkdir output/$run || exit $?
    cd output/$run || exit $?
    mkdir DATA OUTPUT_FILES obj || exit $?
    get_${run}_parameters
    cp $CMTSOLUTION DATA/CMTSOLUTION || exit $?
    cp $STATIONS DATA/STATIONS || exit $?
    LOCAL_PATH=/scratch/buildbot-$buildnumber-$run
    create_par_file
    for pathname in $CODE_DIR/DATA/*; do
        filename=`basename $pathname`
        if [ ! -e DATA/$filename ]; then
            ln -s $pathname DATA || exit $?
        fi
    done
    tweak_${run}_parameters

    # Currently, BuildBot always sets FC to 'mpif90';
    # force it to 'ifort' in order to get the right flags.
    $CODE_DIR/configure FC=ifort
    if [ $? -eq 0 ]; then
        make
        if [ $? -ne 0 ]; then
            status=1
        fi
    else
        status=1
    fi

    NPROC=$(( $NCHUNKS * $NPROC_XI * $NPROC_ETA ))
    run_${run}_job

done

######################################################################
# postprocessing

SACAUX=/home/lqy/Tools/utils/sac2000/aux
export SACAUX

PATH=/home/lqy/Tools/utils/sac2000/bin:/opt/GMT4.0/bin:/opt/seismo-util/bin:$PATH
export PATH

set -x
date

for run in $forward_runs; do
    cd $CODE_DIR/output/$run || exit $?

    mkdir SEM || exit $?
    mv OUTPUT_FILES/*sem* SEM || exit $?

    mkdir QMXD || exit $?
    ln -s ${bench_dir}/QMXD/*qmxd QMXD || exit $?
    cp ${bench_dir}/QMXD/ref_misfit QMXD || exit $?

    sed -e "s:^half .*:half duration   15.0000 :" < DATA/CMTSOLUTION > DATA/CMTSOLUTION.tmp || exit $?
    mv DATA/CMTSOLUTION.tmp DATA/CMTSOLUTION || exit $?

    # cut - filter - resample
    $CODE_DIR/UTILS/seis_process/process_syn.pl -m DATA/CMTSOLUTION -a DATA/STATIONS -l 0/2900 -t 16/500 -s 4 QMXD/*.qmxd || exit $?
    $CODE_DIR/UTILS/seis_process/process_syn.pl -m DATA/CMTSOLUTION -a DATA/STATIONS -l 0/2900 -t 16/500 -s 4 SEM/*.semd.ascii || exit $?

    # rotate to LHR LHT LHZ
    rotate.pl -l 0 -L 2900 QMXD/*.LHE.qmxd.sac || exit $?
    rotate.pl -l 0 -L 2900 SEM/*.LHE.semd.ascii.sac || exit $?

    # convert sac into ascii
    mkdir SAC ASCII || exit $?
    mv QMXD/*.sac SAC || exit $?
    mv SEM/*.sac SAC || exit $?
    cd SAC || exit $?
    for file in *.sac; do
        sac2asc $file > ../ASCII/$file.ascii || exit $?
    done
    cd .. || exit $?
    rm -rf SAC

    # compare SEM and QMXD
    cp QMXD/ref_misfit ASCII || exit $?
    cd ASCII || exit $?
    ls *LHZ*qmxd* > tmp || exit $?
    awk 'BEGIN { FS = ".LHZ" } ; { print $1 }' tmp >  files_to_be_processed || exit $?
    rm tmp

    ${bench_dir}/UTILS/xmisfit 0 > xmisfit.out || exit $?
    error_count=`cat xmisfit.out | grep -v "Files processed" | grep -v "rms for " | wc -l | awk '{print $1}'`
    if [ $error_count -ne 0 ]; then
        status=1
    fi

    visu_seismo
    mv *.pdf ../OUTPUT_FILES

done

date

cd $CODE_DIR || exit $?
tar cvzf output.bbl output/*/config.log output/*/OUTPUT_FILES/output_*.txt output/*/ASCII/xmisfit.out output/*/OUTPUT_FILES/*.pdf || exit $?
exit $status






More information about the cig-commits mailing list