nsb

merge.sh

nsb
May 16th, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.15 KB | None | 0 0
  1. #! /bin/bash
  2. #
  3. # This script gathers all the files of the single consecutives runs
  4. # and puts them in one file. Then it runs the evaluation scripts
  5. #
  6.  
  7. base_dir=$(pwd)
  8. max_run=$(grep max_run= run_sim.sh | cut -c9-)
  9. num_sweeps=$(grep production options | awk ' {print $1}')
  10.  
  11. declare -a boxes=("1000" "400" "464")
  12. declare -a particles=("600" "384" "600")
  13. switches="0 0.0016 0.00016 0.0000016"
  14. #switches="0 0.0016 0.00016"
  15.  
  16. for switch in $switches
  17. do
  18.     for i in {0..2}
  19.     do
  20.         box=${boxes[$i]}
  21.         particle=${particles[$i]}
  22.         #echo $particle
  23.         mydir="${particle}in${box}w${switch}"
  24.  
  25.         echo "is there $mydir?"
  26.  
  27.         if [[ ! -d $mydir ]]; then
  28.             echo "no"
  29.             continue
  30.         fi
  31.         echo "yes"
  32.  
  33.         cd "${mydir}/1"
  34.         if [[ ! -f config.last ]]; then
  35.             continue
  36.         fi
  37.         echo "Entering $(pwd)..."
  38.         cp cluster_stat.dat ../cluster_stat.dat
  39.         cp movie ../movie
  40.         cp top.init ../
  41.         cp config.init ../ #?
  42.  
  43.         #Get the maximal and minmal sweeps in the files (or length of the number)
  44.         mov_max=$(($(grep sweep movie | awk '{print $2}' | tail -n1 | wc -m) -2))
  45.         mov_min=$(($(grep sweep movie | awk '{print $2}' | head -n1 | wc -m) -2))
  46.         cl_max=$(($(grep Sweep cluster_stat.dat | awk '{print $2}' | tail -n1 | wc -m) -1))
  47.         cl_min=$(($(grep Sweep cluster_stat.dat | awk '{print $2}' | head -n1 | wc -m) -1))
  48.        
  49.         for (( dir=2; dir <= $max_run; dir++ ))
  50.         do
  51.             cd ../$dir
  52.             if [[ -e config.last ]]; then
  53.                 echo "Entering $(pwd)..."
  54.                 sw=$((dir - 1))
  55.                 cp cluster_stat.dat{,.mod}
  56.                 cp movie{,.mod}
  57.  
  58.                 # Adjust the sweep. Only works if max. sweep is 10^n
  59.                 for((k=$mov_min; k < $mov_max; k++)); do
  60.                     diff=$(($mov_max - $k - 1))
  61.                     zeros=""
  62.                     for((z=0; z < $diff; z++)); do
  63.                         zeros=$zeros"0"
  64.                     done
  65.                     sed -i "s/sweep \([0-9]\{$k\}\); /sweep $sw$zeros\1; /" movie.mod
  66.                 done
  67.                 sed -i "s/sweep 1\([0]\{$(($mov_max -1))\}\); /sweep $((sw + 1))\1; /" movie.mod
  68.  
  69.                 for((k=$cl_min; k < $cl_max; k++)); do
  70.                     diff=$(($cl_max - $k - 1))
  71.                     zeros=""
  72.                     for((z=0; z < $diff; z++)); do
  73.                         zeros=$zeros"0"
  74.                     done
  75.                     sed -i "s/Sweep: \([0-9]\{$k\}\) /Sweep: $sw$zeros\1 /" cluster_stat.dat.mod
  76.                 done
  77.                 sed -i "s/Sweep: 1\([0]\{$(($cl_max -1))\}\) /Sweep: $((sw + 1))\1 /" cluster_stat.dat.mod
  78.  
  79.  
  80.                 cat cluster_stat.dat.mod >> ../cluster_stat.dat
  81.                 cat movie.mod >> ../movie
  82.                 rm cluster_stat.dat.mod
  83.                 rm movie.mod
  84.             fi
  85.         done              
  86.         cd ../
  87.         #sc2vmd
  88.         echo "Creating Plot for Cluster evolution..."
  89.         ../gp_cluster.sh cluster_stat.dat
  90.         echo "Creating Plot for fibre growth..."
  91.         ../fibres.R
  92.         cd $base_dir
  93.     done
  94. done
Advertisement
Add Comment
Please, Sign In to add comment