prepare_atm_ic.cmd 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/ksh
  2. #
  3. #@ shell = /usr/bin/ksh
  4. #@ class = ns
  5. #@ job_type = serial
  6. #@ job_name = prepare_atm_ic
  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 = 24:00:00
  12. #@ queue
  13. #
  14. set -xuve
  15. date
  16. tar="/opt/freeware/bin/tar"
  17. # b0ga
  18. #grid=T255L62
  19. #expid=b0ga
  20. #src=ec:/xes/public/longrange/$expid
  21. # b0io
  22. grid=T255L91
  23. expid=b0io
  24. src=ec:/xes/public/longrange/$expid
  25. dst=ec:/c3m/ic/atmos/$grid/$expid
  26. cup=$(pwd)
  27. list=$cup/$expid
  28. # Gather the list of original ic's
  29. if [[ ! -a ${list} ]]; then
  30. emkdir -p $dst
  31. # b0gc
  32. #els $src > $list
  33. # b0io
  34. for y in $(seq 1993 2009); do
  35. months="05 11"
  36. for m in $months; do
  37. files=$(els $src/${y}${m}0100)
  38. for f in $files; do
  39. echo "${y}${m}0100/$f" >> $list
  40. done
  41. done
  42. done
  43. #exit
  44. fi
  45. tmp=$TMPDIR/prepare_atm_ic_$expid
  46. rm -rf $tmp
  47. mkdir -p $tmp
  48. cd $tmp
  49. # Prepare and store the ic's after reformatting properly
  50. for l in $(cat $list); do
  51. # start
  52. ecp $src/$l .
  53. ic=$(ls -1 *.tar | cut -d '.' -f 1)
  54. $tar -xvf $ic.tar
  55. for f in $(ls -1 $ic); do
  56. case $f in
  57. ICMSH*T|shml*|pua*) mv $ic/$f ICMSHXXXXINIT ;;
  58. ICMGG*T|ggsfc*|psu*) mv $ic/$f ICMGGXXXXINIT ;;
  59. ICMGG*UA|ggml*) mv $ic/$f ICMGGXXXXINIUA ;;
  60. ICMCL*T) mv $ic/$f ICMCLXXXXINIT ;;
  61. esac
  62. done
  63. case $expid in
  64. b0ga)
  65. exp=$(echo $ic | cut -d '_' -f 1)
  66. mem=$(echo $ic | cut -d '_' -f 4)
  67. ymds=$(echo $ic | cut -d '_' -f 5)
  68. ;;
  69. b0io)
  70. exp=$(echo $ic | cut -d '_' -f 1)
  71. mem=$(echo $ic | cut -d '_' -f 3)
  72. ymds=$(echo $ic | cut -d '_' -f 4)
  73. ;;
  74. *)
  75. echo "!!!caution!!!"
  76. exit 1
  77. ;;
  78. esac
  79. nic=${exp}_${mem}_${ymds} # new name of initial condition
  80. $tar -cvzf $nic.tar.gz *XXXX*
  81. ecp $nic.tar.gz $dst
  82. # end
  83. rm -rf *${ic}* *${nic}* *XXXX*
  84. cat ${list} | sed -e '1d' > ${list}.tmp
  85. mv ${list}.tmp ${list}
  86. done
  87. rm ${list}
  88. cd; rm -rf $tmp
  89. date