source: trunk/libIGCM/AA_move-and-rename @ 342

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

Add a new usefull script to rename a whole configuration and results.
You just have to give four variable (inside or with an export) :

New Name Space of this experience : NEW_SpaceName
New Expericence class of the run : NEW_ExperimentName
New JobName? of the run : NEW_JobName
SUBMIT_DIR

File size: 18.7 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
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
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: Sebastien Denvil
100# Contact: Sebastien.Denvil@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    IGCM_sys_Cd ${NEW_R_SAVE}
209    old_JobName=${config_UserChoices_JobName}
210    config_UserChoices_JobName=${NEW_JobName}
211    IGCM_sys_Dods_Cp ${1}
212    IGCM_debug_Print 3 "MY_DODS_Cp : ${config_UserChoices_JobName}/${1}"
213    IGCM_sys_Cd ${RUN_DIR_PATH}
214    config_UserChoices_JobName=${old_JobName}
215
216    IGCM_debug_PopStack "MY_DODS_Cp"
217}
218
219function MY_DODS_Rm
220{
221    IGCM_debug_PushStack "MY_DODS_Rm"
222    DEBUG_debug=false
223
224    IGCM_sys_Cd ${R_SAVE}
225    IGCM_sys_Dods_Rm ${1}
226    IGCM_debug_Print 3 "MY_DODS_Rm : ${config_UserChoices_JobName}/${1}"
227    IGCM_sys_Cd ${RUN_DIR_PATH}
228
229    IGCM_debug_PopStack "MY_DODS_Rm"
230}
231########################################################################
232
233
234if [ ! -d ${SUBMIT_DIR} ]; then
235    IGCM_debug_Print 0 "No ${SUBMIT_DIR}, we stop here"
236    exit 1
237fi
238
239# We temporary change ${run_Configuration_PeriodState} to
240if [ -f ${SUBMIT_DIR}/run.card ] ; then
241    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
242    if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
243        old_run_Configuration_PeriodState=${run_Configuration_PeriodState}
244        IGCM_debug_PrintVariables 2 old_run_Configuration_PeriodState
245        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
246    fi
247fi
248
249IGCM_config_Initialize
250
251if [ -f ${SUBMIT_DIR}/run.card ] ; then
252    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
253    IGCM_debug_PrintVariables 2 run_Configuration_OldPrefix
254    if [ X${old_run_Configuration_PeriodState} != X"Completed" ] ; then
255        DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) )
256    else
257        DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
258    fi
259else
260    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
261fi
262
263IGCM_debug_Print 1 ""
264IGCM_debug_Print 1 "DateEnd for MoveJob_Checker : " ${DateEnd}
265IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
266IGCM_debug_Print 1 "YearEnd MonthEnd for TimeSeries_Checker : " ${YearEnd} ${MonthEnd}
267IGCM_debug_Print 1 ""
268
269#set -vx
270
271#====================================================
272#DEFINE NEW_R_SAVE
273if [ X${config_UserChoices_SpaceName} != X ] ; then
274    NEW_SAVE=${config_UserChoices_TagName}/${NEW_SpaceName}
275else
276    NEW_SAVE=${config_UserChoices_TagName}
277fi
278if [ X${config_UserChoices_ExperimentName} != X ] ; then
279    NEW_SAVE=${NEW_SAVE}/${NEW_ExperimentName}
280fi
281
282NEW_R_SAVE=${R_OUT}/${NEW_SAVE}/${NEW_JobName}
283
284IGCM_debug_Print 1 "Move ${R_SAVE} to ${NEW_R_SAVE}"
285if [ -d ${NEW_R_SAVE} ] ; then
286    IGCM_debug_Print 0 "ERROR : ${NEW_R_SAVE} directory already exist !"
287    IGCM_debug_Print 0 "We won't try to  We stop here."
288    exit 1
289fi
290IGCM_sys_MkdirArchive ${NEW_R_SAVE}
291
292#DEFINE NEW_R_DODS
293if [ -d ${R_DODS} ] ; then
294    NEW_R_DODS=${NEW_SAVE}
295fi
296
297# Define NEW_REBUILD_DIR
298if [ -d ${REBUILD_DIR} ] ; then
299    if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
300        NEW_REBUILD_DIR=${NEW_R_SAVE}/TMP
301        IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}
302    else
303        NEW_REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${NEW_JobName}
304        IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}
305    fi
306fi
307
308#====================================================
309# SAVE LOCAL WORKING DIR
310IGCM_sys_Cd ${RUN_DIR_PATH}
311
312#====================================================
313#Exe
314IGCM_debug_Print 1 "Move Exe"
315set +A listfiles -- $( find ${R_SAVE}/Exe -type f )
316
317IGCM_sys_MkdirArchive ${NEW_R_SAVE}/Exe
318MOVE_and_RENAME_files "listfiles"
319
320#====================================================
321#Out
322IGCM_debug_Print 1 "Move Out"
323OutinDir=${R_SAVE}/Out
324OutNEWDir=${NEW_R_SAVE}/Out
325IGCM_sys_MkdirArchive ${OutNEWDir}
326
327# Change JobName and copy run.card
328REPLACE_sed ${OutinDir}/run.card ${OutNEWDir}
329
330# Just copy historical run.card
331unset listfiles
332set +A listfiles -- $( find ${OutinDir} -type f -name "run.card\.[0-9]*\.[0-9]*" )
333IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir}
334IGCM_sys_Rm -f ${listfiles[*]}
335
336# Move and Rename OLD Script_Output
337unset listfiles
338set +A listfiles -- $( find ${OutinDir} -type f -name "Script_Output_*\.[0-9]*\.[0-9]*" )
339MOVE_and_RENAME_files "listfiles"
340
341# Move and Rename OLD Executable Output
342unset listfiles
343set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_${config_Executable_Name}" )
344MOVE_and_RENAME_files "listfiles"
345
346#====================================================
347IGCM_debug_Print 1 "For components"
348IGCM_debug_Print 1 "=============="
349
350#====================================================
351#Output
352# loop over components and frequencies
353IGCM_debug_Print 1 "Move Output"
354for comp in ${config_ListOfComponents[*]} ; do
355    IGCM_debug_Print 2 "------------------"
356    IGCM_debug_Print 2 "for component ${comp}"
357
358    unset FREQDIR
359    set +A FREQDIR -- $( find ${R_SAVE}/${comp}/Output -type d -not -name "*Output" )
360
361    IGCM_debug_Print 3 "List of WriteFrequencies : ${FREQDIR[*]}"
362
363    for ThisfreqDir in ${FREQDIR[*]} ; do
364        freq=$( basename ${ThisfreqDir} )
365        IGCM_debug_Print 2 "${freq}."
366
367        NEW_freqDir=${NEW_R_SAVE}/${comp}/Output/${freq}
368        IGCM_sys_MkdirArchive ${NEW_freqDir}
369
370        unset listfiles
371        set +A listfiles -- $( find ${ThisfreqDir} -type f )
372       
373        MOVE_and_RENAME_files "listfiles"
374    done
375done
376
377#====================================================
378#Restart
379# loop over components
380IGCM_debug_Print 1 "Move Restart"
381for comp in ${config_ListOfComponents[*]} ; do
382    IGCM_debug_Print 2 "------------------"
383    IGCM_debug_Print 2 "for component ${comp}"
384
385    ThisRestDir=${R_SAVE}/${comp}/Restart
386    NEW_RestDir=${NEW_R_SAVE}/${comp}/Restart
387    IGCM_sys_MkdirArchive ${NEW_RestDir}
388
389    unset listfiles
390    set +A listfiles -- $( find ${ThisRestDir} -type f )
391   
392    MOVE_and_RENAME_files "listfiles"
393done
394
395#====================================================
396#DEBUG
397# Move and Rename OLD Executable Output
398# loop over components
399IGCM_debug_Print 1 "Move Debug"
400for comp in ${config_ListOfComponents[*]} ; do
401    IGCM_debug_Print 2 "------------------"
402    IGCM_debug_Print 2 "for component ${comp}"
403
404    ThisDebugDir=${R_SAVE}/${comp}/Debug
405    NEW_DebugDir=${NEW_R_SAVE}/${comp}/Debug
406    IGCM_sys_MkdirArchive ${NEW_DebugDir}
407
408    unset listfiles
409    set +A listfiles -- $( find ${ThisDebugDir} -type f )
410   
411    MOVE_and_RENAME_files "listfiles"
412done
413
414#====================================================
415#POST
416# loop over components and frequencies
417IGCM_debug_Print 1 "Move Analyse"
418for comp in ${config_ListOfComponents[*]} ; do
419    IGCM_debug_Print 2 "------------------"
420    IGCM_debug_Print 2 "for component ${comp}"
421   
422    if [ -d ${R_SAVE}/${comp}/Analyse ] ; then
423        unset TSDIR
424        set +A TSDIR -- $( find ${R_SAVE}/${comp}/Analyse -name "TS_*" -type d )
425       
426        for ThisTSDir in ${TSDIR[*]} ; do
427            TS_Dir=$( basename ${ThisTSDir} )
428            IGCM_debug_Print 2 "${TS_Dir}."
429           
430            NEW_TSDir=${NEW_R_SAVE}/${comp}/Analyse/${TS_Dir}
431            IGCM_sys_MkdirArchive ${NEW_TSDir}
432           
433            MY_DODS_Rm ${comp}/Analyse/${TS_Dir}
434           
435            unset listfiles
436            set +A listfiles -- $( find ${ThisTSDir} -type f )
437           
438            MOVE_and_RENAME_files "listfiles"
439           
440            MY_DODS_Cp ${comp}/Analyse/${TS_Dir}
441        done
442
443        ThisSEDir=${R_SAVE}/${comp}/Analyse/SE
444        IGCM_sys_TestDirArchive ${ThisSEDir}
445        if [ $? = 0 ] ; then
446            IGCM_debug_Print 2 "SE."
447            NEW_SEDir=${NEW_R_SAVE}/${comp}/Analyse/SE
448            IGCM_sys_MkdirArchive ${NEW_SEDir}
449           
450            MY_DODS_Rm ${comp}/Analyse/SE
451           
452            unset listfiles
453            set +A listfiles -- $( find ${ThisSEDir} -type f )
454           
455            MOVE_and_RENAME_files "listfiles"
456           
457            MY_DODS_Cp ${comp}/Analyse/SE
458        fi
459    else
460        IGCM_debug_Print 2 "nothing to do without Analyse."
461    fi
462
463    MY_DODS_Rm ${comp}/Analyse
464    MY_DODS_Rm ${comp}
465done
466
467#====================================================
468#GRAPHS
469IGCM_debug_Print 1 "Move ATLAS"
470R_ATLAS=ATLAS
471IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS}
472if [ $? = 0 ] ; then
473    IGCM_sys_Mv ${R_SAVE}/${R_ATLAS} ${NEW_R_SAVE}/${R_ATLAS}
474#    REPLACE_sed ${NEW_R_SAVE}/${R_ATLAS}/*/*/index.html ${NEW_R_SAVE}/${R_ATLAS}
475
476    MY_DODS_Rm ${R_ATLAS}
477
478    MY_DODS_Cp ${R_ATLAS}
479fi
480
481IGCM_debug_Print 1 "Move MONITORING"
482R_MONITORING=MONITORING
483IGCM_sys_TestDirArchive ${R_SAVE}/${R_MONITORING}
484if [ $? = 0 ] ; then
485    IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING}
486    REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING}
487    IGCM_sys_Mv ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE}
488
489    MY_DODS_Rm ${R_MONITORING}
490
491    MY_DODS_Cp ${R_MONITORING}
492fi
493
494
495#====================================================
496#REBUILD
497
498if [ -d ${REBUILD_DIR} ] ; then
499
500    IGCM_debug_Print 1 "Move REBUILD"
501    set +A LISTREBUILDS -- $( find ${REBUILD_DIR} -type d  -not -name "*${config_UserChoices_JobName}" )
502
503    for rebdir in ${LISTREBUILDS[*]} ; do
504        IGCM_debug_Print 2 "${rebdir}."
505        if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
506            IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}/${rebdir}
507        else
508            IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}/${rebdir}
509        fi
510        REPLACE_sed ${REBUILD_DIR}/${rebdir}/rebuild.ksh ${NEW_REBUILD_DIR}/${rebdir}
511        IGCM_sys_Mv -f ${REBUILD_DIR}/${rebdir} ${NEW_REBUILD_DIR}
512    done
513fi
514
515#====================================================
516#List OLD R_SAVE and Ask for erase it !
517
518IGCM_debug_Print 1 "ls of SAVE DIR :"
519ls --color -lR ${R_SAVE}
520
521echo "\033[1;31mPlease verify that ALL OLD DIRECTORY LISTED IS COMPLETLY EMPTY !"
522echo "\033[1;32mIf It is NOT EMPTY, you can TRY AGAIN this script."
523echo "\033[1;31mDo you REALLY want to erase all this directory ?"
524echo -n " Your answer (y/n) : \033[m"
525read reponse
526case ${reponse} in
527           
528    oui|OUI|o|y|yes|YES)
529        echo "OK. It will be erased."
530        IGCM_sys_Rm -Rf ${R_SAVE}
531        echo "done."
532        ;;
533    non|NON|n|no|NO)
534        echo "Nothing to do !"
535        ;;
536esac
537
538
539#############################################################################################################
540# Edit config.card, run.card and Job_${NewJobName}
541
542IGCM_debug_Print 1 "edit config.card"
543if [ X${config_UserChoices_SpaceName} != X ] ; then
544    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices SpaceName ${NEW_SpaceName}
545fi
546if [ X${config_UserChoices_ExperimentName} != X ] ; then
547    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices ExperimentName ${NEW_ExperimentName}
548fi
549IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices JobName ${NEW_JobName}
550
551if [ -f ${SUBMIT_DIR}/run.card ] ; then
552    IGCM_debug_Print 1 "edit run.card"
553    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
554        ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card
555    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card
556
557    if [ X${old_run_Configuration_PeriodState} != X ] ; then
558        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState ${old_run_Configuration_PeriodState}
559    fi
560fi
561
562if [ -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then
563    IGCM_debug_Print 1 "edit Job_${NEW_JobName}"
564    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
565        ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} > ${SUBMIT_DIR}/Job_${NEW_JobName}
566    chmod --reference=${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${NEW_JobName}
567    ls -la ${SUBMIT_DIR}/Job_${NEW_JobName}
568fi
Note: See TracBrowser for help on using the repository browser.