migrate_exp.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/bash
  2. #
  3. # OBJECTIVE:
  4. # In Autosubmit 2.x experiments three projects were cloned (model, templates and ocean_diagnostics).
  5. # New Autosubmit 3.x experiments only allow cloning one project (auto-ecearth).
  6. # Auto-ecearth is a single project containing model, templates and ocean_diagnostics among others.
  7. #
  8. # This script covers the need of having to run an Autosubmit 2.x experiment with Autosubmit 3.x.
  9. # It assumes that no auto-ecearth available version can reproduce what the old experiment was doing,
  10. # and it adapts a copy of that old experiment, reshuffling the configuration files and removing
  11. # unnecessary variables from the old templates to adapt them to the Autosubmit 3.x framework.
  12. #
  13. # DESCRIPTION:
  14. # This script will modify and adapt the experiment configuration file of the TARGET_EXPID
  15. # according to Autosubmit 3.x standard.
  16. #
  17. # This script will also clone model, templates and ocean_diagnostics
  18. # from ORIGINAL_EXPID into TARGET_EXPID "proj" folder.
  19. #
  20. # This script will also remove unnecessary template header/tailer variables.
  21. #
  22. # USE:
  23. # 1st step
  24. # --------
  25. # Before executing this script you must use the copy option of Autosubmit 3.x
  26. # e.g. autosubmit expid -y i000 -H ithaca -d "copied from original i000"
  27. #
  28. # 2nd step
  29. # --------
  30. # ./migrate_exp.sh ORIGINAL_EXPID TARGET_EXPID
  31. #
  32. # CONTACT:
  33. # Written by Domingo Manubens-Gil
  34. #
  35. # Institut Català de Ciències del Clima / Climate Forecasting Unit (IC3/CFU)
  36. # Created: November 13, 2014
  37. copy_from="$1"
  38. target_expid="$2"
  39. experiments_path="/home/dmanubens/debug/autosubmit"
  40. target_file="$experiments_path/$target_expid/conf/expdef_$target_expid.conf"
  41. set -ex
  42. if [[ -d $experiments_path/$target_expid/proj ]]; then
  43. cd $experiments_path/$target_expid/proj
  44. echo "Existing clone for model, templates and ocean_diagnostics..."
  45. else
  46. mkdir $experiments_path/$target_expid/proj
  47. cd $experiments_path/$target_expid/proj
  48. git clone $experiments_path/$copy_from/git/model model
  49. git clone $experiments_path/$copy_from/git/templates templates
  50. git clone $experiments_path/$copy_from/git/ocean_diagnostics ocean_diagnostics
  51. echo "Cloned successfully model, templates and ocean_diagnostics..."
  52. fi
  53. if grep -q TEMPLATE_NAME "$target_file" ; then
  54. template=$(grep TEMPLATE_NAME $target_file | awk '{print $3}')
  55. sed -i '/%HEADER%/d' templates/$template/*
  56. sed -i '/%HEADER%/d' templates/common/*
  57. sed -i '/%AS-HEADER-LOC%/d' templates/$template/*
  58. sed -i '/%AS-HEADER-LOC%/d' templates/common/*
  59. sed -i '/%AS-HEADER-REM%/d' templates/$template/*
  60. sed -i '/%AS-HEADER-REM%/d' templates/common/*
  61. sed -i '/%AS-TAILER-LOC%/d' templates/$template/*
  62. sed -i '/%AS-TAILER-LOC%/d' templates/common/*
  63. sed -i '/%AS-TAILER-REM%/d' templates/$template/*
  64. sed -i '/%AS-TAILER-REM%/d' templates/common/*
  65. echo "Unnecessary template header/tailer variables deleted..."
  66. else
  67. echo "No variables deleted..."
  68. fi
  69. if grep -q HPCPROJ "$target_file" ; then
  70. sed -i '/^HPCPROJ/ a\# HPCPROJ moved to queues.conf (Autosubmit 3.x migration)' $target_file
  71. sed -i '/^HPCPROJ/ d' $target_file
  72. sed -i '/^HPCUSER/ a\# HPCUSER moved to queues.conf (Autosubmit 3.x migration)' $target_file
  73. sed -i '/^HPCUSER/ d' $target_file
  74. sed -i '/^RERUN/ a\# RERUN moved to rerun section (Autosubmit 3.x migration)' $target_file
  75. sed -i '/^RERUN/ d' $target_file
  76. sed -i '/^CHUNKLIST/ a\# CHUNKLIST moved to rerun section (Autosubmit 3.x migration)' $target_file
  77. sed -i '/^CHUNKLIST/ d' $target_file
  78. sed -i '/^WALLCLOCK/ a\# WALLCLOCK moved to jobs.conf (Autosubmit 3.x migration)' $target_file
  79. sed -i '/^WALLCLOCK/ d' $target_file
  80. sed -i '/^NUMPROC/ a\# NUMPROC moved to jobs.conf (Autosubmit 3.x migration)' $target_file
  81. sed -i '/^NUMPROC/ d' $target_file
  82. echo "Unnecessary configuration variables deleted..."
  83. else
  84. echo "No configuration variables deleted..."
  85. fi
  86. if grep -q CALENDAR "$target_file" ; then
  87. echo "No configuration variables added..."
  88. else
  89. sed -i '/CHUNKINI =*/a \
  90. # Calendar used. LIST: standard, noleap \
  91. CALENDAR = standard \
  92. ' $target_file
  93. sed -i '/TEMPLATE_NAME =*/a \
  94. \
  95. [project] \
  96. # Select project type. STRING = git, svn, local, none \
  97. # If PROJECT_TYPE is set to none, Autosubmit self-contained dummy templates will be used \
  98. PROJECT_TYPE = local \
  99. \
  100. # If PROJECT_TYPE is not git, no need to change \
  101. [git] \
  102. # Repository URL STRING = "'"https://github.com/torvalds/linux.git"'" \
  103. PROJECT_ORIGIN = \
  104. # Select branch or tag, STRING, default = "'"master"'", help = {"'"master"'" (default), "'"develop"'", "'"v3.1b"'", ...} \
  105. PROJECT_BRANCH = \
  106. # type = STRING, default = leave empty, help = if model branch is a TAG leave empty \
  107. PROJECT_COMMIT = \
  108. \
  109. # If PROJECT_TYPE is not svn, no need to change \
  110. [svn] \
  111. # type = STRING, help = "'"https://svn.ec-earth.org/ecearth3"'" \
  112. PROJECT_URL = \
  113. # Select revision number. NUMERIC = 1778 \
  114. PROJECT_REVISION = \
  115. \
  116. # If PROJECT_TYPE is not local, no need to change \
  117. [local] \
  118. # type = STRING, help = /foo/bar/ecearth \
  119. PROJECT_PATH = /esnas/autosubmit/'$copy_from'/git \
  120. \
  121. # If PROJECT_TYPE is none, no need to change \
  122. [project_files] \
  123. # Where is PROJECT CONFIGURATION file location relative to project root path \
  124. FILE_PROJECT_CONF = ../conf/expdef_'$target_expid'.conf \
  125. \
  126. [rerun] \
  127. # Is a rerun or not? [Default: Do set FALSE]. BOOLEAN = TRUE, FALSE \
  128. RERUN = FALSE \
  129. # If RERUN = TRUE then supply the list of chunks to rerun \
  130. # LIST = "[ 19601101 [ fc0 [1 2 3 4] fc1 [1] ] 19651101 [ fc0 [16-30] ] ]" \
  131. CHUNKLIST = \
  132. ' $target_file
  133. echo "New needed configuration variables added succesfuly..."
  134. fi
  135. exit 0