prepare_atm_nudging.cmd 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/ksh
  2. #
  3. #@ shell = /usr/bin/ksh
  4. #@ class = ns
  5. #@ job_type = serial
  6. #@ job_name = prepare_atm_nudging
  7. #@ output = $(job_name).$(jobid).log
  8. #@ error = $(job_name).$(jobid).log
  9. #@ notification = error
  10. #@ resources = ConsumableCpus(1) ConsumableMemory(1200mb)
  11. #@ wall_clock_limit = 48:00:00
  12. #@ queue
  13. #
  14. set -xuve
  15. date
  16. tar="/opt/freeware/bin/tar"
  17. grid=T255L91
  18. expid=b0ir
  19. mem=fc0
  20. src=ec:/xes/public/longrange/$expid
  21. dst=ec:/c3m/nudging/atmos/$grid/$expid
  22. cup=$(pwd)
  23. list=$cup/$expid
  24. # Gather the list of original atm nudging ref. files
  25. if [[ ! -a ${list} ]]; then
  26. emkdir -p $dst
  27. els -1 $src/* | cut -d '_' -f 4 | cut -c 1-6 | uniq >> $list
  28. fi
  29. tmp=$TMPDIR/prepare_atm_nudging_$expid
  30. rm -rf $tmp
  31. mkdir -p $tmp
  32. cd $tmp
  33. # Prepare and store the nudging ref. files after reformatting properly: e.g star with b0ir_reference_fc0_201003mmdd_1.tar and end up b0ir_fc0_201003.tar.gz
  34. for l in $(cat $list); do
  35. rm -rf final; mkdir final
  36. ff=${expid}_${mem}_${l}.tar.gz
  37. ecp "$src/${expid}_reference_${mem}_${l}*" .
  38. for f in $(ls -1 ${expid}_reference_${mem}_${l}* | cut -d '.' -f 1); do
  39. nf=$(echo $f | cut -d '_' -f 4)
  40. $tar -xvf $f.tar
  41. mv $f/sh* final/${nf}sh
  42. mv $f/gg* final/${nf}gg
  43. done
  44. cd final
  45. $tar -cvzf ../$ff *${l}*
  46. emv ../$ff $dst
  47. cd ..
  48. rm -rf *_reference_*
  49. cat ${list} | sed -e '1d' > ${list}.tmp
  50. mv ${list}.tmp ${list}
  51. done
  52. rm ${list}
  53. cd; rm -rf $tmp
  54. date