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

Last change on this file since 386 was 386, checked in by mafoipsl, 14 years ago

Add ulam header to facilitate post-processing on ulam directly.

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