exp_job_info.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. #set -xuve
  3. if [ $# -ne 3 ]; then
  4. echo "Wrong number of arguments"
  5. echo "E.g.: $0 <ARCH> <EXPID> <ESTIMATED RUNTIME>"
  6. exit 1
  7. fi
  8. ARCH=$1
  9. EXPID=$2
  10. estimated_time=$3 # sim (job) estimated computing time (in hours)
  11. case $ARCH in
  12. mn)
  13. rsrc=/gpfs/scratch/*/*
  14. error_file="err"
  15. out_file="out"
  16. ;;
  17. ithaca)
  18. rsrc=/scratch/cfu/*
  19. error_file="\.e"
  20. ;;
  21. ecmwf)
  22. rsrc=c2a:/scratch/ms
  23. error_file="err"
  24. ;;
  25. hector)
  26. rsrc=
  27. error_file=""
  28. ;;
  29. lindgren)
  30. rsrc=/cfs/klemming/scratch/*/*
  31. ;;
  32. jaguar)
  33. rsrc=
  34. error_file=""
  35. ;;
  36. *)
  37. echo "!!! $ARCH is not available !!!"
  38. exit 1
  39. ;;
  40. esac
  41. TYPE="sim"
  42. LOG_PATH="$rsrc/$EXPID/LOG_$EXPID"
  43. sdates=$(ls -1 ${LOG_PATH}/${EXPID}_*_${TYPE}_COMPLETED | cut -d '_' -f 3 | uniq)
  44. echo "Name,Queue,Run,Wasted,Failed"
  45. for s in $sdates; do
  46. mems_chunks=$(ls -1tr ${LOG_PATH}/${EXPID}_${s}_*_${TYPE}_COMPLETED | cut -d '_' -f 4-5 | uniq)
  47. for m_c in $mems_chunks; do
  48. job=${EXPID}_${s}_${m_c}_${TYPE}
  49. submit_time=$(ls -ltr ${LOG_PATH}/${job}.cmd | awk '{print $6 " " $7 " " $8}')
  50. submit_time=$(date --date="${submit_time}" +%s)
  51. failed_times=$(($(ls -1tr ${LOG_PATH}/${job}*${error_file} | wc -l) -1 ))
  52. start_time=$(grep "Started" $(ls -1tr ${LOG_PATH}/${job}*${out_file} | tail -n 1) | cut -d" " -f 3-)
  53. start_time=$(date --date="${start_time}" +%s)
  54. end_time=$(grep "Results" $(ls -1tr ${LOG_PATH}/${job}*${out_file} | tail -n 1) | cut -d" " -f 4-)
  55. end_time=$(date --date="${end_time}" +%s)
  56. queued_time=$(echo "scale=2; (${start_time}-${submit_time}) / 3600" | bc)
  57. run_time=$(echo "scale=2; (${end_time}-${start_time}) / 3600" | bc)
  58. wasted_time=$(echo "scale=2; ${run_time}-${estimated_time}" |bc)
  59. echo "${job},${queued_time},${run_time},${wasted_time},${failed_times}"
  60. done
  61. done