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

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

Correct AA_move-and-rename script. DODS calls are OK now.
Suppress sed on HEADER.html files because they are added by dods_cp command.

File size: 19.2 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: 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    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
335REPLACE_sed ${OutinDir}/run.card ${OutNEWDir}
336
337# Just copy historical run.card
338unset listfiles
339set +A listfiles -- $( find ${OutinDir} -type f -name "run.card\.[0-9]*\.[0-9]*" )
340if [ ${#listfiles[*]} -gt 0 ] ; then
341    IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir}
342    IGCM_sys_Rm -f ${listfiles[*]}
343fi
344
345# Move and Rename OLD Script_Output
346unset listfiles
347set +A listfiles -- $( find ${OutinDir} -type f -name "Script_Output_*\.[0-9]*\.[0-9]*" )
348MOVE_and_RENAME_files "listfiles"
349
350# Move and Rename OLD Executable Output
351unset listfiles
352set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_${config_Executable_Name}" )
353MOVE_and_RENAME_files "listfiles"
354
355#====================================================
356IGCM_debug_Print 1 "For components"
357IGCM_debug_Print 1 "=============="
358
359#====================================================
360#Output
361# loop over components and frequencies
362IGCM_debug_Print 1 "Move Output"
363for comp in ${config_ListOfComponents[*]} ; do
364    IGCM_debug_Print 2 "------------------"
365    IGCM_debug_Print 2 "for component ${comp}"
366
367    unset FREQDIR
368    set +A FREQDIR -- $( find ${R_SAVE}/${comp}/Output -type d -not -name "*Output" )
369
370    IGCM_debug_Print 3 "List of WriteFrequencies : ${FREQDIR[*]}"
371
372    for ThisfreqDir in ${FREQDIR[*]} ; do
373        freq=$( basename ${ThisfreqDir} )
374        IGCM_debug_Print 2 "${freq}."
375
376        NEW_freqDir=${NEW_R_SAVE}/${comp}/Output/${freq}
377        IGCM_sys_MkdirArchive ${NEW_freqDir}
378
379        unset listfiles
380        set +A listfiles -- $( find ${ThisfreqDir} -type f )
381       
382        MOVE_and_RENAME_files "listfiles"
383    done
384done
385
386#====================================================
387#Restart
388# loop over components
389IGCM_debug_Print 1 "Move Restart"
390for comp in ${config_ListOfComponents[*]} ; do
391    IGCM_debug_Print 2 "------------------"
392    IGCM_debug_Print 2 "for component ${comp}"
393
394    ThisRestDir=${R_SAVE}/${comp}/Restart
395    NEW_RestDir=${NEW_R_SAVE}/${comp}/Restart
396    IGCM_sys_MkdirArchive ${NEW_RestDir}
397
398    unset listfiles
399    set +A listfiles -- $( find ${ThisRestDir} -type f )
400   
401    MOVE_and_RENAME_files "listfiles"
402done
403
404#====================================================
405#DEBUG
406# Move and Rename OLD Executable Output
407# loop over components
408IGCM_debug_Print 1 "Move Debug"
409for comp in ${config_ListOfComponents[*]} ; do
410    IGCM_debug_Print 2 "------------------"
411    IGCM_debug_Print 2 "for component ${comp}"
412
413    ThisDebugDir=${R_SAVE}/${comp}/Debug
414    NEW_DebugDir=${NEW_R_SAVE}/${comp}/Debug
415    IGCM_sys_MkdirArchive ${NEW_DebugDir}
416
417    unset listfiles
418    set +A listfiles -- $( find ${ThisDebugDir} -type f )
419   
420    MOVE_and_RENAME_files "listfiles"
421done
422
423#====================================================
424#POST
425# loop over components and frequencies
426IGCM_debug_Print 1 "Move Analyse"
427for comp in ${config_ListOfComponents[*]} ; do
428    IGCM_debug_Print 2 "------------------"
429    IGCM_debug_Print 2 "for component ${comp}"
430   
431    if [ -d ${R_SAVE}/${comp}/Analyse ] ; then
432        unset TSDIR
433        set +A TSDIR -- $( find ${R_SAVE}/${comp}/Analyse -name "TS_*" -type d )
434       
435        for ThisTSDir in ${TSDIR[*]} ; do
436            TS_Dir=$( basename ${ThisTSDir} )
437            IGCM_debug_Print 2 "${TS_Dir}."
438           
439            NEW_TSDir=${NEW_R_SAVE}/${comp}/Analyse/${TS_Dir}
440            IGCM_sys_MkdirArchive ${NEW_TSDir}
441           
442            MY_DODS_Rm ${comp}/Analyse/${TS_Dir}
443           
444            unset listfiles
445            set +A listfiles -- $( find ${ThisTSDir} -type f )
446           
447            MOVE_and_RENAME_files "listfiles"
448           
449            MY_DODS_Cp ${comp}/Analyse/${TS_Dir}
450        done
451
452        ThisSEDir=${R_SAVE}/${comp}/Analyse/SE
453        IGCM_sys_TestDirArchive ${ThisSEDir}
454        if [ $? = 0 ] ; then
455            IGCM_debug_Print 2 "SE."
456            NEW_SEDir=${NEW_R_SAVE}/${comp}/Analyse/SE
457            IGCM_sys_MkdirArchive ${NEW_SEDir}
458           
459            MY_DODS_Rm ${comp}/Analyse/SE
460           
461            unset listfiles
462            set +A listfiles -- $( find ${ThisSEDir} -type f )
463           
464            MOVE_and_RENAME_files "listfiles"
465           
466            MY_DODS_Cp ${comp}/Analyse/SE
467        fi
468
469        MY_DODS_Rm ${comp}/Analyse
470        MY_DODS_Rm ${comp}
471    else
472        IGCM_debug_Print 2 "nothing to do without Analyse."
473    fi
474
475done
476
477#====================================================
478#GRAPHS
479IGCM_debug_Print 1 "Move ATLAS"
480R_ATLAS=ATLAS
481IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS}
482if [ $? = 0 ] ; then
483#    REPLACE_sed ${NEW_R_SAVE}/${R_ATLAS}/*/*/index.html ${NEW_R_SAVE}/${R_ATLAS}
484
485    MY_DODS_Rm ${R_ATLAS}
486
487    IGCM_sys_Mv ${R_SAVE}/${R_ATLAS} ${NEW_R_SAVE}/${R_ATLAS}
488
489    MY_DODS_Cp ${R_ATLAS}
490fi
491
492IGCM_debug_Print 1 "Move MONITORING"
493R_MONITORING=MONITORING
494IGCM_sys_TestDirArchive ${R_SAVE}/${R_MONITORING}
495if [ $? = 0 ] ; then
496    IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING}
497    REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING}
498    REPLACE_sed ${R_SAVE}/${R_MONITORING}/run.card ${NEW_R_SAVE}/${R_MONITORING}
499    REPLACE_sed ${R_SAVE}/${R_MONITORING}/config.card ${NEW_R_SAVE}/${R_MONITORING}
500    IGCM_sys_Cp -rp ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE}
501
502    MY_DODS_Rm ${R_MONITORING}
503    IGCM_sys_Rm -rf ${R_SAVE}/${R_MONITORING}
504
505    MY_DODS_Cp ${R_MONITORING}
506fi
507
508
509#====================================================
510#REBUILD
511
512if [ -d ${REBUILD_DIR} ] ; then
513
514    IGCM_debug_Print 1 "Move REBUILD"
515    set +A LISTREBUILDS -- $( find ${REBUILD_DIR} -type d  -not -name "*${config_UserChoices_JobName}" )
516
517    for rebdir in ${LISTREBUILDS[*]} ; do
518        IGCM_debug_Print 2 "${rebdir}."
519        if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
520            IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}/${rebdir}
521        else
522            IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}/${rebdir}
523        fi
524        REPLACE_sed ${REBUILD_DIR}/${rebdir}/rebuild.ksh ${NEW_REBUILD_DIR}/${rebdir}
525        IGCM_sys_Mv -f ${REBUILD_DIR}/${rebdir} ${NEW_REBUILD_DIR}
526    done
527fi
528
529#====================================================
530#List OLD R_SAVE and Ask for erase it !
531
532IGCM_debug_Print 1 "ls of SAVE DIR :"
533ls --color -lR ${R_SAVE}
534
535echo "\033[1;31mPlease verify that ALL OLD DIRECTORY LISTED IS COMPLETLY EMPTY !"
536echo "\033[1;32mIf It is NOT EMPTY, you can TRY AGAIN this script."
537echo "\033[1;31mDo you REALLY want to erase all this directory ?"
538echo -n " Your answer (y/n) : \033[m"
539if [ X${reponse} = X ] ; then
540    read reponse
541fi
542case ${reponse} in
543           
544    oui|OUI|o|y|yes|YES)
545        echo "OK. It will be erased."
546        IGCM_sys_Rm -Rf ${R_SAVE}
547        echo "done."
548        ;;
549    non|NON|n|no|NO)
550        echo "Nothing to do !"
551        ;;
552esac
553
554
555#############################################################################################################
556# Edit config.card, run.card and Job_${NewJobName}
557
558IGCM_debug_Print 1 "edit config.card"
559if [ X${config_UserChoices_SpaceName} != X ] ; then
560    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices SpaceName ${NEW_SpaceName}
561fi
562if [ X${config_UserChoices_ExperimentName} != X ] ; then
563    IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices ExperimentName ${NEW_ExperimentName}
564fi
565IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices JobName ${NEW_JobName}
566
567if [ -f ${SUBMIT_DIR}/run.card ] ; then
568    IGCM_debug_Print 1 "edit run.card"
569    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
570        ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card
571    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card
572
573    if [ X${old_run_Configuration_PeriodState} != X ] ; then
574        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState ${old_run_Configuration_PeriodState}
575    fi
576fi
577
578if [ -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then
579    IGCM_debug_Print 1 "edit Job_${NEW_JobName}"
580    sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
581        ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} > ${SUBMIT_DIR}/Job_${NEW_JobName}
582    chmod --reference=${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${NEW_JobName}
583    ls -la ${SUBMIT_DIR}/Job_${NEW_JobName}
584fi
Note: See TracBrowser for help on using the repository browser.