find_m 601 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. if [ $# != 3 ]; then
  3. echo "Usage: $0 g lgr lgc" >&2
  4. exit 1
  5. fi
  6. g=$1
  7. lgr=$2
  8. lgc=$3
  9. n=$((g<<lgr))
  10. gdir="g${g}_lgr${lgr}_lgc${lgc}_n${n}"
  11. mlow=0
  12. mhigh=$((n/5))
  13. runm() {
  14. m=$1
  15. h=$((n-m))
  16. mdir="m${m}_h${h}"
  17. ./run_m $g $lgr $lgc $m
  18. # Find the lowest b0 reported
  19. grep FINAL ${gdir}/${mdir}/k*.out | cut -d' ' -f2 | cut -d= -f2 | sort -n | head -1
  20. }
  21. while [ $((mhigh > $((mlow+1)) && (mhigh-mlow)*100 > mhigh)) = 1 ]; do
  22. mmid=$(((mhigh + mlow)/2))
  23. b0mid=$(runm $mmid)
  24. echo $mmid $b0mid
  25. if [ $b0mid \< 0.25 ]; then
  26. mlow=$mmid
  27. else
  28. mhigh=$mmid
  29. fi
  30. done
  31. echo $mlow > ${gdir}/m.out