data_transfer.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/bin/bash
  2. #
  3. # nohup ./data_transfer.sh >& expid.log &
  4. #
  5. ##################################
  6. #### User Defined Variables ####
  7. ##################################
  8. # User must fill-in
  9. arch="" # choose platform (ithaca, mn-*, cfs-aux-4, ecmwf, ht-*, ar-*)
  10. model="" # choose model (ecearth, nemo)
  11. expid="" # supply expid: e.g. xxxx
  12. sdates="" # supply list of start dates: e.g. 19601101 19651101 ...
  13. members="" # supply list of members: e.g. fc0 fc1 fc2 ...
  14. remove=TRUE # remove output from source by default (if user want to kee the model output at HPC make it FALSE)
  15. # User may change
  16. types="logfiles MM PP diags REST restart ICM CMOR"
  17. dst1=/esnas/exp/$model # store logfiles, MM*
  18. dst2=/esnas/exp/$model/restartfiles # store REST*
  19. dst3=/esnas/exp/$model/rawfiles # store ICM*, ORCA, EXPID_* (raw data)
  20. dst4=/esnas/exp/$model/cmorfiles # store CMOR*
  21. ##### End of User Defined Variables ####
  22. #################################
  23. #### User Defined Funtions ####
  24. #################################
  25. function transfer1(){
  26. set -e
  27. dst=$1/$expid/$s/$m/$2
  28. if [[ $remove == TRUE ]]; then
  29. RSYNC="rsync -acv --remove-sent-files"
  30. else
  31. RSYNC="rsync -acv"
  32. fi
  33. for l in $list; do
  34. echo "tranfering file ... ${arch}:$l $dst"
  35. $RSYNC ${arch}:${l} $dst
  36. echo "done."
  37. echo
  38. echo
  39. done
  40. set +e
  41. }
  42. function transfer2(){
  43. dst=$1/$expid/$s/$m/$2
  44. for l in $list; do
  45. echo "tranfering file ... $src/$expid/$s/$m/$2/$l $dst/$l"
  46. ecaccess-file-get $src/$expid/$s/$m/$2/$l $dst/$l
  47. if [[ $? -eq 0 && $remove == TRUE ]]; then
  48. ecaccess-file-delete -force $src/$expid/$s/$m/$2/$l
  49. fi
  50. echo "done."
  51. echo
  52. echo
  53. done
  54. }
  55. #### End of the User Defined Functions ####
  56. ###################################
  57. #### Main Part of the Script ####
  58. ###################################
  59. date
  60. echo "platform is: $arch"
  61. echo "model is: $model"
  62. echo "expid is: $expid"
  63. echo "start dates: $sdates"
  64. echo "members per start date: $members"
  65. echo "remove output from HPC disks: $remove"
  66. for s in $sdates; do
  67. for m in $members; do
  68. rmtlist="ssh $arch ls -1"
  69. transfer="transfer1"
  70. case $arch in
  71. ithaca)
  72. src=/share/data/cfu/exp
  73. ;;
  74. mn-*)
  75. src=/gpfs/scratch/ecm86/ecm86010/exp
  76. ;;
  77. cfs-aux-4)
  78. src=/cfs/klemming/nobackup/a/asifsami/exp
  79. ;;
  80. ecmwf*)
  81. rmtlist="ecaccess-file-dir"
  82. transfer="transfer2"
  83. src=ec:/c3m/exp
  84. ;;
  85. ht-*)
  86. src=/work/pr1u1011/pr1u1011/pr1e1001/exp
  87. ;;
  88. ar-*)
  89. src=/work/pr1u1011/pr1u1011/shared/exp
  90. ;;
  91. *)
  92. echo "$arch is not a valid machine"
  93. ;;
  94. esac
  95. for typ in $types; do
  96. case $typ in
  97. logfiles)
  98. lswc=`$rmtlist $src/$expid/$s/$m/logfiles* | wc -l`
  99. if [[ $lswc -gt 0 ]]; then
  100. mkdir -p $dst1/$expid/$s/$m
  101. list=`$rmtlist $src/$expid/$s/$m/logfiles*`
  102. $transfer $dst1 ""
  103. fi
  104. ;;
  105. MM|PP|diags)
  106. lswc=`$rmtlist $src/$expid/$s/$m/outputs/${typ}* | wc -l`
  107. if [[ $lswc -gt 0 ]]; then
  108. mkdir -p $dst1/$expid/$s/$m/outputs
  109. list=`$rmtlist $src/$expid/$s/$m/outputs/${typ}*`
  110. $transfer $dst1 outputs
  111. fi
  112. ;;
  113. REST|restart)
  114. lswc=`$rmtlist $src/$expid/$s/$m/restarts/${typ}* | wc -l`
  115. if [[ $lswc -gt 0 ]]; then
  116. mkdir -p $dst2/$expid/$s/$m/restarts
  117. list=`$rmtlist $src/$expid/$s/$m/restarts/${typ}*`
  118. $transfer $dst2 restarts
  119. fi
  120. ;;
  121. ICM|ORCA|$(eval echo ${expid}_))
  122. lswc=`$rmtlist $src/$expid/$s/$m/outputs/${typ}* | wc -l`
  123. if [[ $lswc -gt 0 ]]; then
  124. mkdir -p $dst3/$expid/$s/$m/outputs
  125. list=`$rmtlist $src/$expid/$s/$m/outputs/${typ}*`
  126. $transfer $dst3 outputs
  127. fi
  128. ;;
  129. CMOR)
  130. lswc=`$rmtlist $src/$expid/$s/$m/outputs/${typ}* | wc -l`
  131. if [[ $lswc -gt 0 ]]; then
  132. mkdir -p $dst4/$expid/$s/$m/outputs
  133. list=`$rmtlist $src/$expid/$s/$m/outputs/${typ}*`
  134. $transfer $dst4 outputs
  135. fi
  136. ;;
  137. *)
  138. echo "$typ is not a valid data type"
  139. ;;
  140. esac
  141. done
  142. done
  143. done
  144. date
  145. #### End of the Main Part of Script ####