source: tags/libIGCM_v1_9/AA_move-and-rename @ 1170

Last change on this file since 1170 was 350, checked in by mmaipsl, 14 years ago

Add move of simple Output files (for OCE mesh mask).
Correct REBUILD move.

File size: 19.5 KB
Line 
1#-Q- cesium #!/bin/ksh
2#-Q- cesium ######################
3#-Q- cesium ## CESIUM   CEA ##
4#-Q- cesium ######################
5#-Q- cesium #MSUB -r MoveJob             # Nom du job               
6#-Q- cesium #MSUB -N 1              # Reservation du noeud
7#-Q- cesium #MSUB -n 1              # Reservation du processus
8#-Q- cesium #MSUB -T 86400          # Limite de temps elapsed du job
9#-Q- cesium #MSUB -E "-j o"
10#-Q- cesium #MSUB -E "-S /bin/ksh"
11#-Q- platine #!/usr/bin/ksh
12#-Q- platine ###################
13#-Q- platine ## PLATINE   CEA ##
14#-Q- platine ###################
15#-Q- platine #BSUB -J MoveJob                     # Nom du job
16#-Q- platine #BSUB -N                        # message a la fin du job
17#-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
18#-Q- platine #BSUB -W 1:00                   # Limite temps
19#-Q- platine #BSUB -q post                   # Passage en queue post
20#-Q- sx8brodie #!/bin/ksh
21#-Q- sx8brodie #######################
22#-Q- sx8brodie ## SX8BRODIE   IDRIS ##
23#-Q- sx8brodie #######################
24#-Q- sx8brodie # Temps Elapsed max. d'une requete hh:mm:ss
25#-Q- sx8brodie # @ wall_clock_limit = 20:00:00
26#-Q- sx8brodie # Nom du travail LoadLeveler
27#-Q- sx8brodie # @ job_name   = MoveJob
28#-Q- sx8brodie # Fichier de sortie standard du travail       
29#-Q- sx8brodie # @ output     = $(job_name).$(jobid)
30#-Q- sx8brodie # Fichier de sortie d'erreur du travail
31#-Q- sx8brodie # @ error      =  $(job_name).$(jobid)
32#-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
33#-Q- sx8brodie # @ notification = error
34#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $StandAlone ; $reponse
35#-Q- aix6 #!/bin/ksh
36#-Q- aix6 #######################
37#-Q- aix6 ##   VARGAS   IDRIS  ##
38#-Q- aix6 #######################
39#-Q- aix6 # Temps Elapsed max. d'une requete hh:mm:ss
40#-Q- aix6 # @ wall_clock_limit = 20:00:00
41#-Q- aix6 # Nom du travail LoadLeveler
42#-Q- aix6 # @ job_name   = MoveJob
43#-Q- aix6 # Fichier de sortie standard du travail
44#-Q- aix6 # @ output     = $(job_name).$(jobid)
45#-Q- aix6 # Fichier de sortie d'erreur du travail
46#-Q- aix6 # @ error      =  $(job_name).$(jobid)
47#-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
48#-Q- aix6 # @ notification = error
49#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $MASTER ; $RebuildFrequency ; $StandAlone ; $reponse
50#-Q- aix6 # @ queue
51#-Q- sx8brodie # @ queue
52#-Q- sx8mercure #!/bin/ksh
53#-Q- sx8mercure ######################
54#-Q- sx8mercure ## SX8MERCURE   CEA ##
55#-Q- sx8mercure ######################
56#-Q- sx8mercure #PBS -N MoveJob                   # Nom du job
57#-Q- sx8mercure #PBS -j o                    # regroupement des stdout et stderr
58#-Q- sx8mercure #PBS -S /usr/bin/ksh         # shell de soumission
59#-Q- sx8mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
60#-Q- sx8mercure #PBS -l cputim_job=24:00:00   # Limite temps a 2 heures
61#-Q- sx8mercure #PBS -q scalaire
62#-Q- sx9mercure #!/bin/ksh
63#-Q- sx9mercure #########################
64#-Q- sx9mercure ## CESIUM FOR SX9  CEA ##
65#-Q- sx9mercure #########################
66#-Q- sx9mercure #MSUB -r MoveJob             # Nom du job               
67#-Q- sx9mercure #MSUB -N 1              # Reservation du noeud
68#-Q- sx9mercure #MSUB -n 1              # Reservation du processus
69#-Q- sx9mercure #MSUB -T 86400          # Limite de temps elapsed du job
70#-Q- sx9mercure #MSUB -E "-j o"
71#-Q- sx9mercure #MSUB -E "-S /bin/ksh"
72#-Q- titane #!/bin/ksh
73#-Q- titane ######################
74#-Q- titane ## TITANE   CEA ##
75#-Q- titane ######################
76#-Q- titane #MSUB -r MoveJob             # Nom du job               
77#-Q- titane #MSUB -N 1              # Reservation du noeud
78#-Q- titane #MSUB -n 1              # Reservation du processus
79#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job
80#-Q- titane #MSUB -E "-j o"
81#-Q- titane #MSUB -E "-S /bin/ksh"
82#-Q- titane ##MSUB -e nco.out        # Sortie standard
83#-Q- titane ##MSUB -o nco.out        # Sortie standard
84#-Q- lxiv8 ######################
85#-Q- lxiv8 ## OBELIX      LSCE ##
86#-Q- lxiv8 ######################
87#-Q- lxiv8 #PBS -N MoveJob
88#-Q- lxiv8 #PBS -m a
89#-Q- lxiv8 #PBS -j oe
90#-Q- lxiv8 #PBS -q medium
91#-Q- lxiv8 #PBS -o MoveJob.$$
92#-Q- lxiv8 #PBS -S /bin/ksh
93#-Q- default #!/bin/ksh
94#-Q- default ##################
95#-Q- default ## DEFAULT HOST ##
96#-Q- default ##################
97
98#**************************************************************
99# Author: Martial Mancip
100# Contact: Martial.Mancip@ipsl.jussieu.fr
101# $Date: $
102# $Author: $
103# $Revision: $
104# IPSL (2006)
105#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
106# History:
107# Modification:
108#
109#**************************************************************
110
111# Change SpaceName/ExperimentName/JobName names and path for a simulation during the run.
112# !! Be careful that the job is suspended before using this script !!
113# You may call this script with those four variables already defined, or modify directly
114# default values under here :
115
116# New Name Space of this experience
117NEW_SpaceName=${NEW_SpaceName:=DEVT}
118
119# New Expericence class of the run
120NEW_ExperimentName=${NEW_ExperimentName:=NEWExperimentName}
121
122# New JobName of the run
123NEW_JobName=${NEW_JobName:=NEWJobName}
124
125SUBMIT_DIR=${SUBMIT_DIR:=my_path_to_my_SUBMIT_DIR}
126
127# verbosity
128Verbosity=3
129
130########################################################################
131
132# Chemin vers MODIPSL
133MODIPSL=${MODIPSL:=::modipsl::}
134
135# Chemin vers libIGCM
136libIGCM=${libIGCM:=${MODIPSL}/libIGCM}
137# Attention : à changer si la machine de post-traitement n'est pas la frontale du serveur de calcul !
138#             voir précence de la variable MirrorlibIGCM dans votre couche systÚme.
139
140
141DEBUG_sys=false
142DEBUG_debug=false
143
144########################################################################
145
146. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh ;
147. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh     #; IGCM_debug_Check
148. ${libIGCM}/libIGCM_card/libIGCM_card.ksh   #; IGCM_card_Check
149. ${libIGCM}/libIGCM_date/libIGCM_date.ksh   #; IGCM_date_Check
150. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
151
152########################################################################
153# define local functions
154
155# Function to replace OLD JobName in file
156
157function REPLACE_sed
158{
159    IGCM_debug_PushStack "REPLACE_sed"
160   
161    FILEIN=${1}
162    FILEOUT=$( basename ${FILEIN} )
163
164    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
165        ${1} > ${RUN_DIR_PATH}/${FILEOUT}
166    RET=$?
167
168    touch --reference=${1} ${RUN_DIR_PATH}/${FILEOUT}
169    IGCM_sys_Mv ${RUN_DIR_PATH}/${FILEOUT} ${2}
170    chmod --reference=${1} ${2}/${FILEOUT}
171
172    IGCM_sys_Rm -f ${1}
173
174    IGCM_debug_Print 3 "REPLACE_sed : ${1} ${2}"
175   
176    IGCM_debug_PopStack "REPLACE_sed"
177    return $RET
178}
179
180function MOVE_and_RENAME_files
181{
182    IGCM_debug_PushStack "MOVE_and_RENAME_files"
183
184    typeset VAR_files FILE_OUT
185
186    VAR_files=${1}
187    eval VAR1=\${${VAR_files[0]}}
188
189    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" )
190    IGCM_debug_Print 3 "MOVE_and_RENAME_files all : ${VAR1}"
191    IGCM_debug_Print 3 "    to     ${FILE_OUT}." 
192
193    (( ifile = 0 ))
194    for file_o in ${FILE_OUT[@]} ; do
195        eval IGCM_sys_Mv \${${VAR_files}[${ifile}]} ${file_o}
196        (( ifile = ifile + 1 ))
197    done   
198    RET=$?
199
200    IGCM_debug_PopStack "MOVE_and_RENAME_files"
201    return $RET
202}
203
204function MY_DODS_Cp
205{
206    IGCM_debug_PushStack "MY_DODS_Cp"
207
208    typeset old_JobName old_R_DODS
209    IGCM_sys_Cd ${NEW_R_SAVE}
210    old_JobName=${config_UserChoices_JobName}
211    old_R_DODS=${R_DODS}
212    old_R_SAVE=${R_SAVE}
213
214    config_UserChoices_JobName=${NEW_JobName}
215    R_DODS=${NEW_R_DODS}
216    R_SAVE=${NEW_R_SAVE}
217
218    IGCM_sys_Dods_Cp ${1}
219    IGCM_debug_Print 3 "MY_DODS_Cp : ${config_UserChoices_JobName}/${1}"
220    IGCM_sys_Cd ${RUN_DIR_PATH}
221
222    config_UserChoices_JobName=${old_JobName}
223    R_DODS=${old_R_DODS}
224    R_SAVE=${old_R_SAVE}
225
226    IGCM_debug_PopStack "MY_DODS_Cp"
227}
228
229function MY_DODS_Rm
230{
231    IGCM_debug_PushStack "MY_DODS_Rm"
232    DEBUG_debug=false
233
234    IGCM_sys_Cd ${R_SAVE}
235    IGCM_sys_Dods_Rm ${1}
236    IGCM_debug_Print 3 "MY_DODS_Rm : ${config_UserChoices_JobName}/${1}"
237    IGCM_sys_Cd ${RUN_DIR_PATH}
238
239    IGCM_debug_PopStack "MY_DODS_Rm"
240}
241########################################################################
242
243if [ ! -d ${SUBMIT_DIR} ]; then
244    IGCM_debug_Print 1 "No ${SUBMIT_DIR}, we stop here"
245    exit 1
246fi
247
248# We temporary change ${run_Configuration_PeriodState} to
249if [ -f ${SUBMIT_DIR}/run.card ] ; then
250    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
251    if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
252        old_run_Configuration_PeriodState=${run_Configuration_PeriodState}
253        IGCM_debug_PrintVariables 2 old_run_Configuration_PeriodState
254        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
255    fi
256fi
257
258IGCM_config_Initialize
259
260if [ -f ${SUBMIT_DIR}/run.card ] ; then
261    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
262    IGCM_debug_PrintVariables 2 run_Configuration_OldPrefix
263    if [ X${old_run_Configuration_PeriodState} != X"Completed" ] ; then
264        DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) )
265    else
266        DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
267    fi
268else
269    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
270fi
271
272IGCM_debug_Print 1 ""
273IGCM_debug_Print 1 "DateEnd for MoveJob_Checker : " ${DateEnd}
274IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
275IGCM_debug_Print 1 "YearEnd MonthEnd for TimeSeries_Checker : " ${YearEnd} ${MonthEnd}
276IGCM_debug_Print 1 ""
277
278#set -vx
279
280#====================================================
281#DEFINE NEW_R_SAVE
282if [ X${config_UserChoices_SpaceName} != X ] ; then
283    NEW_SAVE=${config_UserChoices_TagName}/${NEW_SpaceName}
284else
285    NEW_SAVE=${config_UserChoices_TagName}
286fi
287if [ X${config_UserChoices_ExperimentName} != X ] ; then
288    NEW_SAVE=${NEW_SAVE}/${NEW_ExperimentName}
289fi
290
291NEW_R_SAVE=${R_OUT}/${NEW_SAVE}/${NEW_JobName}
292
293IGCM_debug_Print 1 "Move ${R_SAVE} to ${NEW_R_SAVE}"
294if [ -d ${NEW_R_SAVE} ] ; then
295    IGCM_debug_Print 1 "ERROR : ${NEW_R_SAVE} directory already exist !"
296    IGCM_debug_Print 1 "We won't try to  We stop here."
297    exit 1
298fi
299IGCM_sys_MkdirArchive ${NEW_R_SAVE}
300
301#DEFINE NEW_R_DODS
302NEW_R_DODS=${NEW_SAVE}/${NEW_JobName}
303
304# Define NEW_REBUILD_DIR
305if [ -d ${REBUILD_DIR} ] ; then
306    if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
307        NEW_REBUILD_DIR=${NEW_R_SAVE}/TMP
308        IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}
309    else
310        NEW_REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${NEW_JobName}
311        IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}
312    fi
313fi
314
315#====================================================
316# SAVE LOCAL WORKING DIR
317IGCM_sys_Cd ${RUN_DIR_PATH}
318
319#====================================================
320#Exe
321IGCM_debug_Print 1 "Move Exe"
322set +A listfiles -- $( find ${R_SAVE}/Exe -type f )
323
324IGCM_sys_MkdirArchive ${NEW_R_SAVE}/Exe
325MOVE_and_RENAME_files "listfiles"
326
327#====================================================
328#Out
329IGCM_debug_Print 1 "Move Out"
330OutinDir=${R_SAVE}/Out
331OutNEWDir=${NEW_R_SAVE}/Out
332IGCM_sys_MkdirArchive ${OutNEWDir}
333
334# Change JobName and copy run.card
335if [ -f ${OutinDir}/run.card ] ; then
336    REPLACE_sed ${OutinDir}/run.card ${OutNEWDir}
337fi
338
339# Just copy historical run.card
340unset listfiles
341set +A listfiles -- $( find ${OutinDir} -type f -name "run.card\.[0-9]*\.[0-9]*" )
342if [ ${#listfiles[*]} -gt 0 ] ; then
343    IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir}
344    IGCM_sys_Rm -f ${listfiles[*]}
345fi
346
347# Move and Rename OLD Script_Output
348unset listfiles
349set +A listfiles -- $( find ${OutinDir} -type f -name "Script_Output_*\.[0-9]*\.[0-9]*" )
350MOVE_and_RENAME_files "listfiles"
351
352# Move and Rename OLD Executable Output
353unset listfiles
354set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_${config_Executable_Name}" )
355MOVE_and_RENAME_files "listfiles"
356
357#====================================================
358IGCM_debug_Print 1 "For components"
359IGCM_debug_Print 1 "=============="
360
361#====================================================
362#Output
363# loop over components and frequencies
364IGCM_debug_Print 1 "Move Output"
365for comp in ${config_ListOfComponents[*]} ; do
366    IGCM_debug_Print 2 "------------------"
367    IGCM_debug_Print 2 "for component ${comp}"
368
369    unset FREQDIR
370    set +A FREQDIR -- $( find ${R_SAVE}/${comp}/Output -type d -not -name "*Output" )
371
372    IGCM_debug_Print 3 "List of WriteFrequencies : ${FREQDIR[*]}"
373
374    for ThisfreqDir in ${FREQDIR[*]} ; do
375        freq=$( basename ${ThisfreqDir} )
376        IGCM_debug_Print 2 "${freq}."
377
378        NEW_freqDir=${NEW_R_SAVE}/${comp}/Output/${freq}
379        IGCM_sys_MkdirArchive ${NEW_freqDir}
380
381        unset listfiles
382        set +A listfiles -- $( find ${ThisfreqDir} -type f )
383       
384        MOVE_and_RENAME_files "listfiles"
385    done
386
387    unset COMPFILES
388    set +A COMPFILES -- $( find ${R_SAVE}/${comp}/Output -type f )
389   
390    if [ ${#COMPFILES[*]} -gt 0 ] ; then
391        IGCM_debug_Print 2 "simple Output FILES : ${COMPFILES[*]}."
392
393        MOVE_and_RENAME_files "COMPFILES"
394    fi
395done
396
397#====================================================
398#Restart
399# loop over components
400IGCM_debug_Print 1 "Move Restart"
401for comp in ${config_ListOfComponents[*]} ; do
402    IGCM_debug_Print 2 "------------------"
403    IGCM_debug_Print 2 "for component ${comp}"
404
405    ThisRestDir=${R_SAVE}/${comp}/Restart
406    NEW_RestDir=${NEW_R_SAVE}/${comp}/Restart
407    IGCM_sys_MkdirArchive ${NEW_RestDir}
408
409    unset listfiles
410    set +A listfiles -- $( find ${ThisRestDir} -type f )
411   
412    MOVE_and_RENAME_files "listfiles"
413done
414
415#====================================================
416#DEBUG
417# Move and Rename OLD Executable Output
418# loop over components
419IGCM_debug_Print 1 "Move Debug"
420for comp in ${config_ListOfComponents[*]} ; do
421    IGCM_debug_Print 2 "------------------"
422    IGCM_debug_Print 2 "for component ${comp}"
423
424    ThisDebugDir=${R_SAVE}/${comp}/Debug
425    NEW_DebugDir=${NEW_R_SAVE}/${comp}/Debug
426    IGCM_sys_MkdirArchive ${NEW_DebugDir}
427
428    unset listfiles
429    set +A listfiles -- $( find ${ThisDebugDir} -type f )
430   
431    MOVE_and_RENAME_files "listfiles"
432done
433
434#====================================================
435#POST
436# loop over components and frequencies
437IGCM_debug_Print 1 "Move Analyse"
438for comp in ${config_ListOfComponents[*]} ; do
439    IGCM_debug_Print 2 "------------------"
440    IGCM_debug_Print 2 "for component ${comp}"
441   
442    if [ -d ${R_SAVE}/${comp}/Analyse ] ; then
443        unset TSDIR
444        set +A TSDIR -- $( find ${R_SAVE}/${comp}/Analyse -name "TS_*" -type d )
445       
446        for ThisTSDir in ${TSDIR[*]} ; do
447            TS_Dir=$( basename ${ThisTSDir} )
448            IGCM_debug_Print 2 "${TS_Dir}."
449           
450            NEW_TSDir=${NEW_R_SAVE}/${comp}/Analyse/${TS_Dir}
451            IGCM_sys_MkdirArchive ${NEW_TSDir}
452           
453            MY_DODS_Rm ${comp}/Analyse/${TS_Dir}
454           
455            unset listfiles
456            set +A listfiles -- $( find ${ThisTSDir} -type f )
457           
458            MOVE_and_RENAME_files "listfiles"
459           
460            MY_DODS_Cp ${comp}/Analyse/${TS_Dir}
461        done
462
463        ThisSEDir=${R_SAVE}/${comp}/Analyse/SE
464        IGCM_sys_TestDirArchive ${ThisSEDir}
465        if [ $? = 0 ] ; then
466            IGCM_debug_Print 2 "SE."
467            NEW_SEDir=${NEW_R_SAVE}/${comp}/Analyse/SE
468            IGCM_sys_MkdirArchive ${NEW_SEDir}
469           
470            MY_DODS_Rm ${comp}/Analyse/SE
471           
472            unset listfiles
473            set +A listfiles -- $( find ${ThisSEDir} -type f )
474           
475            MOVE_and_RENAME_files "listfiles"
476           
477            MY_DODS_Cp ${comp}/Analyse/SE
478        fi
479
480        MY_DODS_Rm ${comp}/Analyse
481        MY_DODS_Rm ${comp}
482    else
483        IGCM_debug_Print 2 "nothing to do without Analyse."
484    fi
485
486done
487
488#====================================================
489#GRAPHS
490IGCM_debug_Print 1 "Move ATLAS"
491R_ATLAS=ATLAS
492IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS}
493if [ $? = 0 ] ; then
494#    REPLACE_sed ${NEW_R_SAVE}/${R_ATLAS}/*/*/index.html ${NEW_R_SAVE}/${R_ATLAS}
495
496    MY_DODS_Rm ${R_ATLAS}
497
498    IGCM_sys_Mv ${R_SAVE}/${R_ATLAS} ${NEW_R_SAVE}/${R_ATLAS}
499
500    MY_DODS_Cp ${R_ATLAS}
501fi
502
503IGCM_debug_Print 1 "Move MONITORING"
504R_MONITORING=MONITORING
505IGCM_sys_TestDirArchive ${R_SAVE}/${R_MONITORING}
506if [ $? = 0 ] ; then
507    IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING}
508    REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING}
509    REPLACE_sed ${R_SAVE}/${R_MONITORING}/run.card ${NEW_R_SAVE}/${R_MONITORING}
510    REPLACE_sed ${R_SAVE}/${R_MONITORING}/config.card ${NEW_R_SAVE}/${R_MONITORING}
511    IGCM_sys_Cp -rp ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE}
512
513    MY_DODS_Rm ${R_MONITORING}
514    IGCM_sys_Rm -rf ${R_SAVE}/${R_MONITORING}
515
516    MY_DODS_Cp ${R_MONITORING}
517fi
518
519
520#====================================================
521#REBUILD
522
523if [ -d ${REBUILD_DIR} ] ; then
524
525    IGCM_debug_Print 1 "Move REBUILD"
526    set +A LISTREBUILDS -- $( find ${REBUILD_DIR} -type d  -not -name "*${config_UserChoices_JobName}" -a -not -name "*TMP" )
527
528    for ThisREBDir in ${LISTREBUILDS[*]} ; do
529        rebdir=$( basename ${ThisREBDir} )
530        IGCM_debug_Print 2 "${rebdir}."
531        if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
532            IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}/${rebdir}
533        else
534            IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}/${rebdir}
535        fi
536        REPLACE_sed ${REBUILD_DIR}/${rebdir}/rebuild.ksh ${NEW_REBUILD_DIR}/${rebdir}
537        IGCM_sys_Mv -f ${REBUILD_DIR}/${rebdir}/* ${NEW_REBUILD_DIR}/${rebdir}/
538    done
539fi
540
541#====================================================
542#List OLD R_SAVE and Ask for erase it !
543
544IGCM_debug_Print 1 "ls of SAVE DIR :"
545ls --color -lR ${R_SAVE}
546
547echo "\033[1;31mPlease verify that ALL OLD DIRECTORY LISTED IS COMPLETLY EMPTY !"
548echo "\033[1;32mIf It is NOT EMPTY, you can TRY AGAIN this script."
549echo "\033[1;31mDo you REALLY want to erase all this directory ?"
550echo -n " Your answer (y/n) : \033[m"
551if [ X${reponse} = X ] ; then
552    read reponse
553fi
554case ${reponse} in
555           
556    oui|OUI|o|y|yes|YES)
557        echo "OK. It will be erased."
558        IGCM_sys_Rm -Rf ${R_SAVE}
559        echo "done."
560        ;;
561    non|NON|n|no|NO)
562        echo "Nothing to do !"
563        ;;
564esac
565
566
567#############################################################################################################
568# Edit config.card, run.card and Job_${NewJobName}
569
570IGCM_debug_Print 1 "edit config.card"
571if [ X${config_UserChoices_SpaceName} != X ] ; then
572    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices SpaceName ${NEW_SpaceName}
573fi
574if [ X${config_UserChoices_ExperimentName} != X ] ; then
575    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices ExperimentName ${NEW_ExperimentName}
576fi
577IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices JobName ${NEW_JobName}
578
579if [ -f ${SUBMIT_DIR}/run.card ] ; then
580    IGCM_debug_Print 1 "edit run.card"
581    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
582        ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card
583    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card
584
585    if [ X${old_run_Configuration_PeriodState} != X ] ; then
586        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState ${old_run_Configuration_PeriodState}
587    fi
588fi
589
590if [ -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then
591    IGCM_debug_Print 1 "edit Job_${NEW_JobName}"
592    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
593        ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} > ${SUBMIT_DIR}/Job_${NEW_JobName}
594    chmod --reference=${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${NEW_JobName}
595    ls -la ${SUBMIT_DIR}/Job_${NEW_JobName}
596fi
Note: See TracBrowser for help on using the repository browser.