meta_launch_rhino.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. #
  3. # based on NSC script of K. Wyser, July 2016
  4. #
  5. set -ex
  6. usage() {
  7. echo
  8. echo "USAGE: ${0} -C <config> -R <experiment> (options)"
  9. echo
  10. echo " Available configs are:"
  11. for cc in ${list_conf}; do
  12. echo " * ${cc}"
  13. done
  14. echo
  15. echo "Options are:"
  16. echo
  17. echo " -i YEAR_START : first year to build climatolgy. Climatology is built if set."
  18. echo " -e YEAR_END : last year to build climatolgy. Climatology is built if set."
  19. echo
  20. exit
  21. }
  22. climato=0
  23. while getopts C:R:i:e: option ; do
  24. case $option in
  25. C) conf=${OPTARG} ;;
  26. R) expname=${OPTARG} ;;
  27. i) y1=${OPTARG} ;;
  28. e) y2=${OPTARG} ;;
  29. *) usage ;;
  30. esac
  31. done
  32. shift $((OPTIND-1))
  33. [[ -n $y1 && -n $y2 ]] && climato=1 # generate climato, and compare with it
  34. # -------- Checks before submitting
  35. cd ..
  36. # Available configs
  37. list_conf=$(\ls ./configs/config_*.sh | sed -e "s|./configs\/config_||g" -e s/'.sh'/''/g)
  38. # User configs, potentially in the directory from which barakuda.sh is called
  39. list_conf+=" $(\ls ./config_*.sh 2>/dev/null | sed -e "s|.\/config_||g" -e s/'.sh'/''/g)"
  40. [[ -z $conf ]] && usage
  41. [[ -z $expname ]] && usage
  42. job_name=b-$expname
  43. launch_cmd='sbatch -n 1 -c 12'
  44. # -------- Create diagnostics
  45. ll=$( $launch_cmd -J $job_name-1 barakuda.sh -C $conf -R $expname )
  46. echo $ll
  47. job1_id=$(echo $ll | awk '{print $4}')
  48. # -------- Create climatologies
  49. if (( $climato ))
  50. then
  51. ll=$( $launch_cmd -J $job_name-2 build_clim.sh -C $conf -R $expname -i $y1 -e $y2)
  52. echo $ll
  53. job2_id=$(echo $ll | awk '{print $4}')
  54. fi
  55. # -------- Create figures
  56. if (( $climato ))
  57. then
  58. $launch_cmd -d afterok:$job1_id:$job2_id -J $job_name-3 barakuda.sh -C $conf -R $expname -E
  59. else
  60. $launch_cmd -d afterok:$job1_id -J $job_name-3 barakuda.sh -C $conf -R $expname -e
  61. fi