copy-runtime.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env bash
  2. # local_setup.sh: Copies the runtime environment from the Autosubmit project
  3. # folder to the remote machine
  4. set -xvue
  5. PROJDEST=%PROJECT_DESTINATION%
  6. PROJDIR=%PROJDIR%
  7. HPCARCH=%HPCARCH%
  8. VERSION=%VERSION%
  9. how_many_retry_copy_file=5
  10. function ecaccess-file-put_with_check_and_retry(){
  11. source=$1
  12. destination=$2
  13. retry=0
  14. while [[ ${retry} -le ${how_many_retry_copy_file} ]]; do
  15. ecaccess-file-put ${source} ${destination}
  16. source_size=$(ls -lrt $source | awk '{print $5}')
  17. destination_size=$(ecaccess-file-size $destination)
  18. if [[ ${source_size} == ${destination_size} ]]; then
  19. echo "done."
  20. break
  21. else
  22. ((retry++))
  23. fi
  24. done
  25. if [[ ${retry} -eq how_many_retry_copy_file ]]; then
  26. echo "Transfer error: Source and destination files have not the same size. Exiting..."
  27. exit 1
  28. fi
  29. }
  30. #
  31. # Run ec-conf
  32. #
  33. cd %PROJDIR%/runtime/autosubmit
  34. #cd ${PROJDIR}/sources/runtime/autosubmit
  35. ln -sf ../classic/platform
  36. if [ ${HPCARCH} == 'ecmwf-xc40' ]
  37. then
  38. architecture=ecmwf-cca-intel
  39. module load ECAC
  40. ../../sources/util/ec-conf/ec-conf --platform ${architecture} -o PLT:ACTIVE:ECEARTH_SRC_DIR='${SCRATCH}/${exp_name}/auto-ecearth3/sources/sources' -o PLT:ACTIVE:RUN_DIR='${SCRATCH}/${exp_name}/${run_start_date}/${member}/runtime' -o PLT:ACTIVE:INI_DATA_DIR='${SCRATCH}/${exp_name}/${run_start_date}/${member}/inidata' config-run.xml
  41. #../../sources/util/ec-conf/ec-conf --platform ${architecture} -o PLT:ACTIVE:ECEARTH_SRC_DIR='${SCRATCH}/${exp_name}/auto-ecearth3/sources/sources' -o PLT:ACTIVE:RUN_DIR='${SCRATCH}/${exp_name}/${run_start_date}/${member}/runtime' -o PLT:ACTIVE:INI_DATA_DIR='/perm/ms/nl/nm6/ECE3-DATA' config-run.xml
  42. elif [ ${HPCARCH} == 'marenostrum4' ]
  43. then
  44. architecture=bsc-marenostrum4
  45. ../../sources/util/ec-conf/ec-conf --platform ${architecture} -o PLT:ACTIVE:INI_DATA_DIR="/gpfs/projects/bsc32/models/ecearth/${VERSION}/inidata" config-run.xml
  46. else
  47. error "Unsupported ec-conf architechture: ${HPCARCH}"
  48. exit 0
  49. fi
  50. #
  51. # Copy Model Sources
  52. #
  53. cd ${PROJDIR}; cd ..
  54. if [[ -d ${PROJDEST} ]]; then
  55. tar -zcvf ${PROJDEST}.tar.gz ${PROJDEST}
  56. else
  57. echo "!!! model not present !!!"
  58. exit 1
  59. fi
  60. # transfer model
  61. if [ ${HPCARCH} == 'ecmwf-xc40' ] ; then
  62. # ecaccess-file-mput -force ${PROJNAME}.tar.gz %HPCHOST%:%HPCROOTDIR%/
  63. module load ECAC
  64. ecaccess-file-mkdir %HPCHOST%:%HPCROOTDIR%/
  65. ecaccess-file-put_with_check_and_retry ${PROJDEST}.tar.gz %HPCHOST%:%HPCROOTDIR%/${PROJDEST}.tar.gz
  66. else
  67. rsync -avz ${PROJDEST}.tar.gz %HPCUSER%@%HPCHOST%:%HPCROOTDIR%/
  68. fi
  69. rm ${PROJDEST}.tar.gz