[387] | 1 | #!/bin/ksh |
---|
[342] | 2 | |
---|
| 3 | #************************************************************** |
---|
[350] | 4 | # Author: Martial Mancip |
---|
[373] | 5 | # Contact: Martial.Mancip__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[342] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | # Change SpaceName/ExperimentName/JobName names and path for a simulation during the run. |
---|
| 15 | # !! Be careful that the job is suspended before using this script !! |
---|
| 16 | # You may call this script with those four variables already defined, or modify directly |
---|
| 17 | # default values under here : |
---|
| 18 | |
---|
| 19 | # New Name Space of this experience |
---|
| 20 | NEW_SpaceName=${NEW_SpaceName:=DEVT} |
---|
| 21 | |
---|
| 22 | # New Expericence class of the run |
---|
| 23 | NEW_ExperimentName=${NEW_ExperimentName:=NEWExperimentName} |
---|
| 24 | |
---|
| 25 | # New JobName of the run |
---|
| 26 | NEW_JobName=${NEW_JobName:=NEWJobName} |
---|
| 27 | |
---|
| 28 | SUBMIT_DIR=${SUBMIT_DIR:=my_path_to_my_SUBMIT_DIR} |
---|
| 29 | |
---|
| 30 | # verbosity |
---|
| 31 | Verbosity=3 |
---|
| 32 | |
---|
| 33 | ######################################################################## |
---|
| 34 | |
---|
[571] | 35 | # Path to modipsl |
---|
[342] | 36 | MODIPSL=${MODIPSL:=::modipsl::} |
---|
| 37 | |
---|
[571] | 38 | #D- Path to libIGCM |
---|
| 39 | #D- Default : value from AA_job if any |
---|
| 40 | # WARNING For StandAlone use : To run this script on some machine (ulam and cesium) |
---|
| 41 | # WARNING you must check MirrorlibIGCM variable in sys library. |
---|
| 42 | # WARNING If this variable is true, you must use libIGCM_POST path instead |
---|
| 43 | # WARNING of your running libIGCM directory. |
---|
| 44 | libIGCM=${libIGCM:=::modipsl::/libIGCM} |
---|
[342] | 45 | |
---|
| 46 | DEBUG_sys=false |
---|
| 47 | DEBUG_debug=false |
---|
| 48 | |
---|
| 49 | ######################################################################## |
---|
| 50 | |
---|
| 51 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ; |
---|
| 52 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh #; IGCM_debug_Check |
---|
| 53 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh #; IGCM_card_Check |
---|
| 54 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh #; IGCM_date_Check |
---|
| 55 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
| 56 | |
---|
| 57 | ######################################################################## |
---|
| 58 | # define local functions |
---|
| 59 | |
---|
| 60 | # Function to replace OLD JobName in file |
---|
| 61 | |
---|
| 62 | function REPLACE_sed |
---|
| 63 | { |
---|
| 64 | IGCM_debug_PushStack "REPLACE_sed" |
---|
[509] | 65 | typeset RET |
---|
[342] | 66 | |
---|
| 67 | FILEIN=${1} |
---|
| 68 | FILEOUT=$( basename ${FILEIN} ) |
---|
| 69 | |
---|
| 70 | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \ |
---|
| 71 | ${1} > ${RUN_DIR_PATH}/${FILEOUT} |
---|
| 72 | RET=$? |
---|
| 73 | |
---|
| 74 | touch --reference=${1} ${RUN_DIR_PATH}/${FILEOUT} |
---|
| 75 | IGCM_sys_Mv ${RUN_DIR_PATH}/${FILEOUT} ${2} |
---|
| 76 | chmod --reference=${1} ${2}/${FILEOUT} |
---|
| 77 | |
---|
| 78 | IGCM_sys_Rm -f ${1} |
---|
| 79 | |
---|
| 80 | IGCM_debug_Print 3 "REPLACE_sed : ${1} ${2}" |
---|
| 81 | |
---|
| 82 | IGCM_debug_PopStack "REPLACE_sed" |
---|
| 83 | return $RET |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | function MOVE_and_RENAME_files |
---|
| 87 | { |
---|
| 88 | IGCM_debug_PushStack "MOVE_and_RENAME_files" |
---|
| 89 | |
---|
[509] | 90 | typeset VAR_files FILE_OUT file i RET |
---|
[342] | 91 | |
---|
| 92 | VAR_files=${1} |
---|
| 93 | eval VAR1=\${${VAR_files[0]}} |
---|
| 94 | |
---|
[509] | 95 | if [ X$( echo ${NEW_R_SAVE} | grep ${config_UserChoices_JobName} ) != X ]; then |
---|
| 96 | set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" ) |
---|
| 97 | ((i=0)) |
---|
| 98 | for file in ${FILE_OUT[@]} ; do |
---|
| 99 | FILE_OUT[$i]=$( dirname $file )/$( echo $( basename $file ) | sed -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" ) |
---|
| 100 | (( i = i + 1 )) |
---|
| 101 | done |
---|
| 102 | else |
---|
| 103 | set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" ) |
---|
| 104 | fi |
---|
[342] | 105 | IGCM_debug_Print 3 "MOVE_and_RENAME_files all : ${VAR1}" |
---|
| 106 | IGCM_debug_Print 3 " to ${FILE_OUT}." |
---|
| 107 | |
---|
| 108 | (( ifile = 0 )) |
---|
| 109 | for file_o in ${FILE_OUT[@]} ; do |
---|
| 110 | eval IGCM_sys_Mv \${${VAR_files}[${ifile}]} ${file_o} |
---|
[509] | 111 | RET=$? |
---|
[342] | 112 | (( ifile = ifile + 1 )) |
---|
| 113 | done |
---|
| 114 | |
---|
| 115 | IGCM_debug_PopStack "MOVE_and_RENAME_files" |
---|
| 116 | return $RET |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | function MY_DODS_Cp |
---|
| 120 | { |
---|
| 121 | IGCM_debug_PushStack "MY_DODS_Cp" |
---|
| 122 | |
---|
[349] | 123 | typeset old_JobName old_R_DODS |
---|
[342] | 124 | IGCM_sys_Cd ${NEW_R_SAVE} |
---|
| 125 | old_JobName=${config_UserChoices_JobName} |
---|
[349] | 126 | old_R_DODS=${R_DODS} |
---|
| 127 | old_R_SAVE=${R_SAVE} |
---|
| 128 | |
---|
[342] | 129 | config_UserChoices_JobName=${NEW_JobName} |
---|
[349] | 130 | R_DODS=${NEW_R_DODS} |
---|
| 131 | R_SAVE=${NEW_R_SAVE} |
---|
| 132 | |
---|
[342] | 133 | IGCM_sys_Dods_Cp ${1} |
---|
| 134 | IGCM_debug_Print 3 "MY_DODS_Cp : ${config_UserChoices_JobName}/${1}" |
---|
| 135 | IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
[349] | 136 | |
---|
[342] | 137 | config_UserChoices_JobName=${old_JobName} |
---|
[349] | 138 | R_DODS=${old_R_DODS} |
---|
| 139 | R_SAVE=${old_R_SAVE} |
---|
[342] | 140 | |
---|
| 141 | IGCM_debug_PopStack "MY_DODS_Cp" |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | function MY_DODS_Rm |
---|
| 145 | { |
---|
| 146 | IGCM_debug_PushStack "MY_DODS_Rm" |
---|
| 147 | DEBUG_debug=false |
---|
| 148 | |
---|
| 149 | IGCM_sys_Cd ${R_SAVE} |
---|
| 150 | IGCM_sys_Dods_Rm ${1} |
---|
| 151 | IGCM_debug_Print 3 "MY_DODS_Rm : ${config_UserChoices_JobName}/${1}" |
---|
| 152 | IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
| 153 | |
---|
| 154 | IGCM_debug_PopStack "MY_DODS_Rm" |
---|
| 155 | } |
---|
| 156 | ######################################################################## |
---|
| 157 | |
---|
| 158 | if [ ! -d ${SUBMIT_DIR} ]; then |
---|
[349] | 159 | IGCM_debug_Print 1 "No ${SUBMIT_DIR}, we stop here" |
---|
[342] | 160 | exit 1 |
---|
| 161 | fi |
---|
| 162 | |
---|
| 163 | # We temporary change ${run_Configuration_PeriodState} to |
---|
| 164 | if [ -f ${SUBMIT_DIR}/run.card ] ; then |
---|
| 165 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 166 | if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 167 | old_run_Configuration_PeriodState=${run_Configuration_PeriodState} |
---|
| 168 | IGCM_debug_PrintVariables 2 old_run_Configuration_PeriodState |
---|
| 169 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
| 170 | fi |
---|
| 171 | fi |
---|
| 172 | |
---|
| 173 | IGCM_config_Initialize |
---|
| 174 | |
---|
| 175 | if [ -f ${SUBMIT_DIR}/run.card ] ; then |
---|
| 176 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
| 177 | IGCM_debug_PrintVariables 2 run_Configuration_OldPrefix |
---|
| 178 | if [ X${old_run_Configuration_PeriodState} != X"Completed" ] ; then |
---|
| 179 | DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) ) |
---|
| 180 | else |
---|
| 181 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
| 182 | fi |
---|
| 183 | else |
---|
| 184 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
| 185 | fi |
---|
| 186 | |
---|
| 187 | IGCM_debug_Print 1 "" |
---|
| 188 | IGCM_debug_Print 1 "DateEnd for MoveJob_Checker : " ${DateEnd} |
---|
| 189 | IGCM_date_GetYearMonth ${DateEnd} YearEnd MonthEnd |
---|
| 190 | IGCM_debug_Print 1 "YearEnd MonthEnd for TimeSeries_Checker : " ${YearEnd} ${MonthEnd} |
---|
| 191 | IGCM_debug_Print 1 "" |
---|
| 192 | |
---|
| 193 | #set -vx |
---|
| 194 | |
---|
| 195 | #==================================================== |
---|
| 196 | #DEFINE NEW_R_SAVE |
---|
| 197 | if [ X${config_UserChoices_SpaceName} != X ] ; then |
---|
| 198 | NEW_SAVE=${config_UserChoices_TagName}/${NEW_SpaceName} |
---|
| 199 | else |
---|
| 200 | NEW_SAVE=${config_UserChoices_TagName} |
---|
| 201 | fi |
---|
| 202 | if [ X${config_UserChoices_ExperimentName} != X ] ; then |
---|
| 203 | NEW_SAVE=${NEW_SAVE}/${NEW_ExperimentName} |
---|
| 204 | fi |
---|
| 205 | |
---|
| 206 | NEW_R_SAVE=${R_OUT}/${NEW_SAVE}/${NEW_JobName} |
---|
| 207 | |
---|
| 208 | IGCM_debug_Print 1 "Move ${R_SAVE} to ${NEW_R_SAVE}" |
---|
| 209 | if [ -d ${NEW_R_SAVE} ] ; then |
---|
[349] | 210 | IGCM_debug_Print 1 "ERROR : ${NEW_R_SAVE} directory already exist !" |
---|
| 211 | IGCM_debug_Print 1 "We won't try to We stop here." |
---|
[342] | 212 | exit 1 |
---|
| 213 | fi |
---|
| 214 | IGCM_sys_MkdirArchive ${NEW_R_SAVE} |
---|
| 215 | |
---|
[436] | 216 | # ------------------------------------------------------------------ |
---|
| 217 | # Test if all was right before proceeding further |
---|
| 218 | # ------------------------------------------------------------------ |
---|
| 219 | IGCM_debug_Verif_Exit_Post |
---|
| 220 | |
---|
[342] | 221 | #DEFINE NEW_R_DODS |
---|
[349] | 222 | NEW_R_DODS=${NEW_SAVE}/${NEW_JobName} |
---|
[342] | 223 | |
---|
| 224 | # Define NEW_REBUILD_DIR |
---|
| 225 | if [ -d ${REBUILD_DIR} ] ; then |
---|
| 226 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
| 227 | NEW_REBUILD_DIR=${NEW_R_SAVE}/TMP |
---|
| 228 | IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR} |
---|
| 229 | else |
---|
| 230 | NEW_REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${NEW_JobName} |
---|
| 231 | IGCM_sys_MkdirWork ${NEW_REBUILD_DIR} |
---|
| 232 | fi |
---|
| 233 | fi |
---|
| 234 | |
---|
| 235 | #==================================================== |
---|
| 236 | # SAVE LOCAL WORKING DIR |
---|
| 237 | IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
| 238 | |
---|
| 239 | #==================================================== |
---|
| 240 | #Exe |
---|
| 241 | IGCM_debug_Print 1 "Move Exe" |
---|
| 242 | set +A listfiles -- $( find ${R_SAVE}/Exe -type f ) |
---|
| 243 | |
---|
| 244 | IGCM_sys_MkdirArchive ${NEW_R_SAVE}/Exe |
---|
| 245 | MOVE_and_RENAME_files "listfiles" |
---|
| 246 | |
---|
| 247 | #==================================================== |
---|
| 248 | #Out |
---|
| 249 | IGCM_debug_Print 1 "Move Out" |
---|
| 250 | OutinDir=${R_SAVE}/Out |
---|
| 251 | OutNEWDir=${NEW_R_SAVE}/Out |
---|
| 252 | IGCM_sys_MkdirArchive ${OutNEWDir} |
---|
| 253 | |
---|
| 254 | # Change JobName and copy run.card |
---|
[350] | 255 | if [ -f ${OutinDir}/run.card ] ; then |
---|
[509] | 256 | sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ |
---|
| 257 | ${OutinDir}/run.card > ${RUN_DIR_PATH}/run.card |
---|
| 258 | RET=$? |
---|
| 259 | if [ ${RET} = 0 ] ; then |
---|
| 260 | IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${OutNEWDir} |
---|
| 261 | IGCM_sys_Rm -f ${OutinDir}/run.card |
---|
| 262 | fi |
---|
[350] | 263 | fi |
---|
[342] | 264 | |
---|
| 265 | # Just copy historical run.card |
---|
| 266 | unset listfiles |
---|
| 267 | set +A listfiles -- $( find ${OutinDir} -type f -name "run.card\.[0-9]*\.[0-9]*" ) |
---|
[349] | 268 | if [ ${#listfiles[*]} -gt 0 ] ; then |
---|
| 269 | IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir} |
---|
[509] | 270 | RET=$? |
---|
| 271 | if [ ${RET} = 0 ] ; then |
---|
| 272 | IGCM_sys_Rm -f ${listfiles[*]} |
---|
| 273 | fi |
---|
[349] | 274 | fi |
---|
[342] | 275 | |
---|
| 276 | # Move and Rename OLD Script_Output |
---|
| 277 | unset listfiles |
---|
| 278 | set +A listfiles -- $( find ${OutinDir} -type f -name "Script_Output_*\.[0-9]*\.[0-9]*" ) |
---|
| 279 | MOVE_and_RENAME_files "listfiles" |
---|
| 280 | |
---|
| 281 | # Move and Rename OLD Executable Output |
---|
| 282 | unset listfiles |
---|
| 283 | set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_${config_Executable_Name}" ) |
---|
| 284 | MOVE_and_RENAME_files "listfiles" |
---|
[509] | 285 | unset listfiles |
---|
| 286 | set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_execution" ) |
---|
| 287 | MOVE_and_RENAME_files "listfiles" |
---|
[342] | 288 | |
---|
| 289 | #==================================================== |
---|
| 290 | IGCM_debug_Print 1 "For components" |
---|
| 291 | IGCM_debug_Print 1 "==============" |
---|
| 292 | |
---|
| 293 | #==================================================== |
---|
| 294 | #Output |
---|
| 295 | # loop over components and frequencies |
---|
| 296 | IGCM_debug_Print 1 "Move Output" |
---|
| 297 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 298 | IGCM_debug_Print 2 "------------------" |
---|
| 299 | IGCM_debug_Print 2 "for component ${comp}" |
---|
| 300 | |
---|
| 301 | unset FREQDIR |
---|
| 302 | set +A FREQDIR -- $( find ${R_SAVE}/${comp}/Output -type d -not -name "*Output" ) |
---|
| 303 | |
---|
| 304 | IGCM_debug_Print 3 "List of WriteFrequencies : ${FREQDIR[*]}" |
---|
| 305 | |
---|
| 306 | for ThisfreqDir in ${FREQDIR[*]} ; do |
---|
| 307 | freq=$( basename ${ThisfreqDir} ) |
---|
| 308 | IGCM_debug_Print 2 "${freq}." |
---|
| 309 | |
---|
| 310 | NEW_freqDir=${NEW_R_SAVE}/${comp}/Output/${freq} |
---|
| 311 | IGCM_sys_MkdirArchive ${NEW_freqDir} |
---|
| 312 | |
---|
| 313 | unset listfiles |
---|
| 314 | set +A listfiles -- $( find ${ThisfreqDir} -type f ) |
---|
| 315 | |
---|
| 316 | MOVE_and_RENAME_files "listfiles" |
---|
| 317 | done |
---|
[350] | 318 | |
---|
| 319 | unset COMPFILES |
---|
| 320 | set +A COMPFILES -- $( find ${R_SAVE}/${comp}/Output -type f ) |
---|
| 321 | |
---|
| 322 | if [ ${#COMPFILES[*]} -gt 0 ] ; then |
---|
| 323 | IGCM_debug_Print 2 "simple Output FILES : ${COMPFILES[*]}." |
---|
| 324 | |
---|
| 325 | MOVE_and_RENAME_files "COMPFILES" |
---|
| 326 | fi |
---|
[342] | 327 | done |
---|
| 328 | |
---|
| 329 | #==================================================== |
---|
| 330 | #Restart |
---|
| 331 | # loop over components |
---|
| 332 | IGCM_debug_Print 1 "Move Restart" |
---|
| 333 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 334 | IGCM_debug_Print 2 "------------------" |
---|
| 335 | IGCM_debug_Print 2 "for component ${comp}" |
---|
| 336 | |
---|
| 337 | ThisRestDir=${R_SAVE}/${comp}/Restart |
---|
| 338 | NEW_RestDir=${NEW_R_SAVE}/${comp}/Restart |
---|
| 339 | IGCM_sys_MkdirArchive ${NEW_RestDir} |
---|
| 340 | |
---|
| 341 | unset listfiles |
---|
| 342 | set +A listfiles -- $( find ${ThisRestDir} -type f ) |
---|
| 343 | |
---|
| 344 | MOVE_and_RENAME_files "listfiles" |
---|
| 345 | done |
---|
| 346 | |
---|
| 347 | #==================================================== |
---|
| 348 | #DEBUG |
---|
| 349 | # Move and Rename OLD Executable Output |
---|
| 350 | # loop over components |
---|
| 351 | IGCM_debug_Print 1 "Move Debug" |
---|
| 352 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 353 | IGCM_debug_Print 2 "------------------" |
---|
| 354 | IGCM_debug_Print 2 "for component ${comp}" |
---|
| 355 | |
---|
| 356 | ThisDebugDir=${R_SAVE}/${comp}/Debug |
---|
| 357 | NEW_DebugDir=${NEW_R_SAVE}/${comp}/Debug |
---|
| 358 | IGCM_sys_MkdirArchive ${NEW_DebugDir} |
---|
| 359 | |
---|
| 360 | unset listfiles |
---|
| 361 | set +A listfiles -- $( find ${ThisDebugDir} -type f ) |
---|
| 362 | |
---|
| 363 | MOVE_and_RENAME_files "listfiles" |
---|
| 364 | done |
---|
| 365 | |
---|
| 366 | #==================================================== |
---|
| 367 | #POST |
---|
| 368 | # loop over components and frequencies |
---|
| 369 | IGCM_debug_Print 1 "Move Analyse" |
---|
| 370 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 371 | IGCM_debug_Print 2 "------------------" |
---|
| 372 | IGCM_debug_Print 2 "for component ${comp}" |
---|
| 373 | |
---|
| 374 | if [ -d ${R_SAVE}/${comp}/Analyse ] ; then |
---|
| 375 | unset TSDIR |
---|
| 376 | set +A TSDIR -- $( find ${R_SAVE}/${comp}/Analyse -name "TS_*" -type d ) |
---|
| 377 | |
---|
| 378 | for ThisTSDir in ${TSDIR[*]} ; do |
---|
| 379 | TS_Dir=$( basename ${ThisTSDir} ) |
---|
| 380 | IGCM_debug_Print 2 "${TS_Dir}." |
---|
| 381 | |
---|
| 382 | NEW_TSDir=${NEW_R_SAVE}/${comp}/Analyse/${TS_Dir} |
---|
| 383 | IGCM_sys_MkdirArchive ${NEW_TSDir} |
---|
| 384 | |
---|
| 385 | MY_DODS_Rm ${comp}/Analyse/${TS_Dir} |
---|
| 386 | |
---|
| 387 | unset listfiles |
---|
| 388 | set +A listfiles -- $( find ${ThisTSDir} -type f ) |
---|
| 389 | |
---|
| 390 | MOVE_and_RENAME_files "listfiles" |
---|
| 391 | |
---|
| 392 | MY_DODS_Cp ${comp}/Analyse/${TS_Dir} |
---|
| 393 | done |
---|
| 394 | |
---|
| 395 | ThisSEDir=${R_SAVE}/${comp}/Analyse/SE |
---|
| 396 | IGCM_sys_TestDirArchive ${ThisSEDir} |
---|
| 397 | if [ $? = 0 ] ; then |
---|
| 398 | IGCM_debug_Print 2 "SE." |
---|
| 399 | NEW_SEDir=${NEW_R_SAVE}/${comp}/Analyse/SE |
---|
| 400 | IGCM_sys_MkdirArchive ${NEW_SEDir} |
---|
| 401 | |
---|
| 402 | MY_DODS_Rm ${comp}/Analyse/SE |
---|
| 403 | |
---|
| 404 | unset listfiles |
---|
| 405 | set +A listfiles -- $( find ${ThisSEDir} -type f ) |
---|
| 406 | |
---|
| 407 | MOVE_and_RENAME_files "listfiles" |
---|
| 408 | |
---|
| 409 | MY_DODS_Cp ${comp}/Analyse/SE |
---|
| 410 | fi |
---|
[349] | 411 | |
---|
| 412 | MY_DODS_Rm ${comp}/Analyse |
---|
| 413 | MY_DODS_Rm ${comp} |
---|
[342] | 414 | else |
---|
| 415 | IGCM_debug_Print 2 "nothing to do without Analyse." |
---|
| 416 | fi |
---|
| 417 | |
---|
| 418 | done |
---|
| 419 | |
---|
| 420 | #==================================================== |
---|
| 421 | #GRAPHS |
---|
| 422 | IGCM_debug_Print 1 "Move ATLAS" |
---|
| 423 | R_ATLAS=ATLAS |
---|
| 424 | IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS} |
---|
| 425 | if [ $? = 0 ] ; then |
---|
| 426 | # REPLACE_sed ${NEW_R_SAVE}/${R_ATLAS}/*/*/index.html ${NEW_R_SAVE}/${R_ATLAS} |
---|
| 427 | |
---|
| 428 | MY_DODS_Rm ${R_ATLAS} |
---|
| 429 | |
---|
[346] | 430 | IGCM_sys_Mv ${R_SAVE}/${R_ATLAS} ${NEW_R_SAVE}/${R_ATLAS} |
---|
| 431 | |
---|
[342] | 432 | MY_DODS_Cp ${R_ATLAS} |
---|
| 433 | fi |
---|
| 434 | |
---|
| 435 | IGCM_debug_Print 1 "Move MONITORING" |
---|
| 436 | R_MONITORING=MONITORING |
---|
| 437 | IGCM_sys_TestDirArchive ${R_SAVE}/${R_MONITORING} |
---|
| 438 | if [ $? = 0 ] ; then |
---|
| 439 | IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING} |
---|
| 440 | REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING} |
---|
[509] | 441 | sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ |
---|
| 442 | ${R_SAVE}/${R_MONITORING}/run.card > ${RUN_DIR_PATH}/run.card |
---|
| 443 | IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${NEW_R_SAVE}/${R_MONITORING} |
---|
| 444 | RET=$? |
---|
| 445 | if [ ${RET} = 0 ] ; then |
---|
| 446 | IGCM_sys_Rm -f ${R_SAVE}/${R_MONITORING}/run.card |
---|
| 447 | fi |
---|
[346] | 448 | REPLACE_sed ${R_SAVE}/${R_MONITORING}/config.card ${NEW_R_SAVE}/${R_MONITORING} |
---|
| 449 | IGCM_sys_Cp -rp ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE} |
---|
[342] | 450 | |
---|
| 451 | MY_DODS_Rm ${R_MONITORING} |
---|
[346] | 452 | IGCM_sys_Rm -rf ${R_SAVE}/${R_MONITORING} |
---|
[342] | 453 | |
---|
| 454 | MY_DODS_Cp ${R_MONITORING} |
---|
| 455 | fi |
---|
| 456 | |
---|
| 457 | |
---|
| 458 | #==================================================== |
---|
| 459 | #REBUILD |
---|
| 460 | |
---|
| 461 | if [ -d ${REBUILD_DIR} ] ; then |
---|
| 462 | |
---|
| 463 | IGCM_debug_Print 1 "Move REBUILD" |
---|
[350] | 464 | set +A LISTREBUILDS -- $( find ${REBUILD_DIR} -type d -not -name "*${config_UserChoices_JobName}" -a -not -name "*TMP" ) |
---|
[342] | 465 | |
---|
[350] | 466 | for ThisREBDir in ${LISTREBUILDS[*]} ; do |
---|
| 467 | rebdir=$( basename ${ThisREBDir} ) |
---|
[342] | 468 | IGCM_debug_Print 2 "${rebdir}." |
---|
| 469 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
| 470 | IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}/${rebdir} |
---|
| 471 | else |
---|
| 472 | IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}/${rebdir} |
---|
| 473 | fi |
---|
| 474 | REPLACE_sed ${REBUILD_DIR}/${rebdir}/rebuild.ksh ${NEW_REBUILD_DIR}/${rebdir} |
---|
[350] | 475 | IGCM_sys_Mv -f ${REBUILD_DIR}/${rebdir}/* ${NEW_REBUILD_DIR}/${rebdir}/ |
---|
[342] | 476 | done |
---|
| 477 | fi |
---|
| 478 | |
---|
| 479 | #==================================================== |
---|
| 480 | #List OLD R_SAVE and Ask for erase it ! |
---|
| 481 | |
---|
| 482 | IGCM_debug_Print 1 "ls of SAVE DIR :" |
---|
| 483 | ls --color -lR ${R_SAVE} |
---|
| 484 | |
---|
| 485 | echo "\033[1;31mPlease verify that ALL OLD DIRECTORY LISTED IS COMPLETLY EMPTY !" |
---|
| 486 | echo "\033[1;32mIf It is NOT EMPTY, you can TRY AGAIN this script." |
---|
| 487 | echo "\033[1;31mDo you REALLY want to erase all this directory ?" |
---|
| 488 | echo -n " Your answer (y/n) : \033[m" |
---|
[346] | 489 | if [ X${reponse} = X ] ; then |
---|
| 490 | read reponse |
---|
| 491 | fi |
---|
[342] | 492 | case ${reponse} in |
---|
| 493 | |
---|
| 494 | oui|OUI|o|y|yes|YES) |
---|
| 495 | echo "OK. It will be erased." |
---|
| 496 | IGCM_sys_Rm -Rf ${R_SAVE} |
---|
| 497 | echo "done." |
---|
| 498 | ;; |
---|
| 499 | non|NON|n|no|NO) |
---|
| 500 | echo "Nothing to do !" |
---|
| 501 | ;; |
---|
| 502 | esac |
---|
| 503 | |
---|
| 504 | |
---|
| 505 | ############################################################################################################# |
---|
| 506 | # Edit config.card, run.card and Job_${NewJobName} |
---|
| 507 | |
---|
| 508 | IGCM_debug_Print 1 "edit config.card" |
---|
| 509 | if [ X${config_UserChoices_SpaceName} != X ] ; then |
---|
| 510 | IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices SpaceName ${NEW_SpaceName} |
---|
| 511 | fi |
---|
| 512 | if [ X${config_UserChoices_ExperimentName} != X ] ; then |
---|
| 513 | IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices ExperimentName ${NEW_ExperimentName} |
---|
| 514 | fi |
---|
| 515 | IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices JobName ${NEW_JobName} |
---|
| 516 | |
---|
| 517 | if [ -f ${SUBMIT_DIR}/run.card ] ; then |
---|
| 518 | IGCM_debug_Print 1 "edit run.card" |
---|
[509] | 519 | sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ |
---|
[342] | 520 | ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card |
---|
| 521 | IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card |
---|
| 522 | |
---|
| 523 | if [ X${old_run_Configuration_PeriodState} != X ] ; then |
---|
| 524 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState ${old_run_Configuration_PeriodState} |
---|
| 525 | fi |
---|
| 526 | fi |
---|
| 527 | |
---|
| 528 | if [ -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then |
---|
| 529 | IGCM_debug_Print 1 "edit Job_${NEW_JobName}" |
---|
| 530 | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \ |
---|
| 531 | ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} > ${SUBMIT_DIR}/Job_${NEW_JobName} |
---|
| 532 | chmod --reference=${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${NEW_JobName} |
---|
| 533 | ls -la ${SUBMIT_DIR}/Job_${NEW_JobName} |
---|
| 534 | fi |
---|