copy-runtime.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. how_many_retry_copy_file=5
  9. function ecaccess-file-put_with_check_and_retry(){
  10. source=$1
  11. destination=$2
  12. retry=0
  13. while [[ ${retry} -le ${how_many_retry_copy_file} ]]; do
  14. ecaccess-file-put ${source} ${destination}
  15. source_size=$(ls -lrt $source | awk '{print $5}')
  16. destination_size=$(ecaccess-file-size $destination)
  17. if [[ ${source_size} == ${destination_size} ]]; then
  18. echo "done."
  19. break
  20. else
  21. ((retry++))
  22. fi
  23. done
  24. if [[ ${retry} -eq how_many_retry_copy_file ]]; then
  25. echo "Transfer error: Source and destination files have not the same size. Exiting..."
  26. exit 1
  27. fi
  28. }
  29. #
  30. # Run ec-conf
  31. #
  32. cd %PROJDIR%/runtime/autosubmit
  33. #cd ${PROJDIR}/sources/runtime/autosubmit
  34. ln -sf ../classic/platform
  35. if [ ${HPCARCH} == 'ecmwf-xc40' ]
  36. then
  37. architecture=ecmwf-cca-intel
  38. module load ECAC
  39. ../../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
  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='/perm/ms/nl/nm6/ECE3-DATA' config-run.xml
  41. elif [ ${HPCARCH} == 'marenostrum4' ]
  42. then
  43. architecture=bsc-marenostrum4
  44. ../../sources/util/ec-conf/ec-conf --platform ${architecture} config-run.xml
  45. else
  46. error "Unsupported ec-conf architechture: ${HPCARCH}"
  47. exit 0
  48. fi
  49. #
  50. # Copy Model Sources
  51. #
  52. cd ${PROJDIR}; cd ..
  53. if [[ -d ${PROJDEST} ]]; then
  54. tar -zcvf ${PROJDEST}.tar.gz ${PROJDEST}
  55. else
  56. echo "!!! model not present !!!"
  57. exit 1
  58. fi
  59. # transfer model
  60. if [ ${HPCARCH} == 'ecmwf-xc40' ] ; then
  61. # ecaccess-file-mput -force ${PROJNAME}.tar.gz %HPCHOST%:%HPCROOTDIR%/
  62. module load ECAC
  63. ecaccess-file-mkdir %HPCHOST%:%HPCROOTDIR%/
  64. ecaccess-file-put_with_check_and_retry ${PROJDEST}.tar.gz %HPCHOST%:%HPCROOTDIR%/${PROJDEST}.tar.gz
  65. else
  66. rsync -avz ${PROJDEST}.tar.gz %HPCUSER%@%HPCHOST%:%HPCROOTDIR%/
  67. fi
  68. rm ${PROJDEST}.tar.gz