source: trunk/libIGCM/AA_pack_restart @ 837

Last change on this file since 837 was 837, checked in by labetoulle, 11 years ago

On Curie, ins_job sets up project ID. See #98.

Add

#-Q- curie #MSUB -A ::default_project::

to job headers, to be replaced by proper project ID by ins_job.

  • Property svn:keywords set to Revision Author Date
File size: 10.8 KB
Line 
1#-Q- curie ######################
2#-Q- curie ## CURIE   TGCC/CEA ##
3#-Q- curie ######################
4#-Q- curie #MSUB -r PACKRESTART    # Nom du job
5#-Q- curie #MSUB -eo
6#-Q- curie #MSUB -n 1              # Reservation du processus
7#-Q- curie #MSUB -T 86400          # Limite de temps elapsed du job
8#-Q- curie #MSUB -q xlarge
9#-Q- curie #MSUB -Q normal
10#-Q- curie #MSUB -A ::default_project::
11#-Q- curie set +x
12#-Q- ada #!/bin/ksh
13#-Q- ada #######################
14#-Q- ada ##   VARGAS   IDRIS  ##
15#-Q- ada #######################
16#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
17#-Q- ada # @ wall_clock_limit = 10:00:00
18#-Q- ada # Nom du travail LoadLeveler
19#-Q- ada # @ job_name   = PACKRESTART
20#-Q- ada # Fichier de sortie standard du travail
21#-Q- ada # @ output     = $(job_name).$(jobid)
22#-Q- ada # Fichier de sortie d'erreur du travail
23#-Q- ada # @ error      =  $(job_name).$(jobid)
24#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
25#-Q- ada # @ notification = error
26#-Q- ada # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
27#-Q- ada # @ queue
28#-Q- sx9mercure #!/bin/ksh
29#-Q- sx9mercure ######################
30#-Q- sx9mercure ## SX9MERCURE  CCRT ##
31#-Q- sx9mercure ######################
32#-Q- sx9mercure #PBS -N PACKRESTART          # Nom du job
33#-Q- sx9mercure #PBS -j o                    # regroupement des stdout et stderr
34#-Q- sx9mercure #PBS -S /usr/bin/ksh         # shell de soumission
35#-Q- sx9mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
36#-Q- sx9mercure #PBS -l elapstim_req=24:00:00  # Limite temps a 1 heures
37#-Q- sx9mercure #PBS -q scalaire
38#-Q- sx9mercure #PBS -r n
39#-Q- titane #!/bin/ksh
40#-Q- titane ######################
41#-Q- titane ## TITANE   CEA     ##
42#-Q- titane ######################
43#-Q- titane #MSUB -r PACKRESTART    # Nom du job
44#-Q- titane #MSUB -eo
45#-Q- titane #MSUB -n 1              # Reservation du processus
46#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job
47#-Q- titane #MSUB -q mono
48#-Q- titane #MSUB -E '-rn'
49#-Q- lxiv8 ######################
50#-Q- lxiv8 ## OBELIX      LSCE ##
51#-Q- lxiv8 ######################
52#-Q- lxiv8 #PBS -N PACKRESTART
53#-Q- lxiv8 #PBS -m a
54#-Q- lxiv8 #PBS -j oe
55#-Q- lxiv8 #PBS -q medium
56#-Q- lxiv8 #PBS -o PACKRESTART.$$
57#-Q- lxiv8 #PBS -S /bin/ksh
58#-Q- default #!/bin/ksh
59#-Q- default ##################
60#-Q- default ## DEFAULT HOST ##
61#-Q- default ##################
62
63#**************************************************************
64# Author: Sebastien Denvil
65# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
66# $Revision::                                          $ Revision of last commit
67# $Author::                                            $ Author of last commit
68# $Date::                                              $ Date of last commit
69# IPSL (2006)
70#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
71#
72#**************************************************************
73
74#set -eu
75#set -vx
76
77date
78
79#D- Task type (computing or post-processing)
80TaskType=post-processing
81
82########################################################################
83
84#D- Flag to determine if this job in a standalone mode
85#D- Default : value from AA_job if any
86StandAlone=${StandAlone:=true}
87
88#D- Path to libIGCM
89#D- Default : value from AA_job if any
90# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
91# WARNING you must check MirrorlibIGCM variable in sys library.
92# WARNING If this variable is true, you must use libIGCM_POST path instead
93# WARNING of your running libIGCM directory.
94libIGCM=${libIGCM:=::modipsl::/libIGCM}
95
96#-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
97MASTER=${MASTER:=mercure|titane|brodie|vargas}
98
99#D- Flag to determine begin date for restart pack
100#D- Default : value from AA_job if any
101DateBegin=${DateBegin:=20000101}
102
103#D- Flag to determine end date for restart pack
104#D- Default : value from AA_job if any
105DateEnd=${DateEnd:=20691231}
106
107#D- Flag to determine pack period
108#D- Default : value from AA_job if any
109PeriodPack=${PeriodPack:=10Y}
110
111#D- Uncomment to run interactively
112#D- For testing purpose, will be remove
113#SUBMIT_DIR=${PWD}
114#RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test
115
116#D- Increased verbosity (1, 2, 3)
117#D- Default : value from AA_job if any
118Verbosity=${Verbosity:=3}
119
120#D- Low level debug : to bypass lib test checks and stack construction
121#D- Default : value from AA_job if any
122DEBUG_debug=${DEBUG_debug:=false}
123
124#D- Keep following comments for now. Will be remove.
125
126#on veut archiver les fichiers restart
127#Dans le cadre du demenagement ils seront renommes
128#ATM/Restart/****.nc
129#OCE/Restart/****.nc
130#...
131#sous la forme
132#RESTART/ATM_****.nc
133#RESTART/OCE_****.nc
134#Attention de bien conserver les dates d'origines
135#
136#Dans le cadre de la production nouvelle chaine
137#ils auront directement le bon nom
138#
139#On veut egalement que l'archive soit par periode de temps
140# cette periode est definie par la taille du pack donc connue
141# en entree du script (1M, 1Y, 5Y, 10Y etc...)
142#
143# $1= PATH/config_card d'une simulation avec
144# TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd
145# $2=PeriodPack en M/m ou Y/y
146
147########################################################################
148
149. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
150. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
151. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
152#-------
153. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
154. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
155. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
156#-------
157( ${DEBUG_debug} ) && IGCM_debug_Check
158( ${DEBUG_debug} ) && IGCM_card_Check
159( ${DEBUG_debug} ) && IGCM_date_Check
160
161########################################################################
162
163#set -vx
164
165RUN_DIR=${RUN_DIR_PATH}
166IGCM_sys_MkdirWork ${RUN_DIR}
167IGCM_sys_Cd ${RUN_DIR}
168
169# ------------------------------------------------------------------
170# Test if all was right before proceeding further
171# ------------------------------------------------------------------
172IGCM_debug_Verif_Exit_Post
173
174if [ ${StandAlone} = true ] ; then
175    CARD_DIR=${SUBMIT_DIR}
176else
177    CARD_DIR=${RUN_DIR_PATH}
178    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
179    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
180    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
181    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
182fi
183
184#==================================
185# First of all
186#
187# Read libIGCM compatibility version in config.card
188# Read UserChoices section
189# Read Ensemble section
190# Read Post section
191# Define all netcdf output directories
192#==================================
193IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
194#
195IGCM_sys_TestDirArchive ${R_SAVE}
196[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
197
198#STORE_RESTART=/ccc/store/cont003/dsm/p86denv/.../RESTART
199STORE_RESTART=${R_SAVE}/RESTART
200IGCM_sys_MkdirArchive ${STORE_RESTART}
201
202#cd ${STORE_RESTART}
203#rm -f *
204
205# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
206JobName=${config_UserChoices_JobName}
207echo $JobName $R_BUFR $DateBegin $DateEnd
208
209# Clear txt file lists
210rm -f ${RUN_DIR}/liste_restart_files.txt
211rm -f ${RUN_DIR}/new_liste_restart_files.txt
212rm -f ${RUN_DIR}/liste_pack_*.txt
213
214# Create sorted restart list to work with
215find ${R_BUFR}/*/Restart -name "*.*" | sort >> ${RUN_DIR}/liste_restart_files.txt
216
217# Rename restart files we will work with using symlinks
218#gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
219gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
220
221# List renamed restart files
222find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_restart_files.txt
223
224# ------------------------------------------------------------------
225# Test if all was right before proceeding further
226# ------------------------------------------------------------------
227IGCM_debug_Verif_Exit_Post
228
229# Init loop
230date_begin_pack=${DateBegin}
231date_end_simulation=${DateEnd}
232number_pack=1
233
234IGCM_debug_PrintVariables 3 date_begin_pack
235IGCM_debug_PrintVariables 3 date_end_simulation
236
237# last restart of the previous period : to be deleted
238typeset date_end_previous
239date_end_previous=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} -1 )
240
241while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
242
243  IGCM_debug_PrintVariables 3 number_pack
244
245  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
246  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
247
248  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_restart_files.txt ); do
249    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_//" )
250    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
251    # warning demenagement. delete last restart of the previous pack
252    [  ${date_file} -eq ${date_end_previous} ] && echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
253    # echo pack number ${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
254    if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
255      echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
256      # warning demenagement. do not delete last restart of this pack
257      [ ${date_file} -eq ${date_end_pack} ] || echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
258    fi
259  done
260
261  # Create tar files
262  IGCM_debug_Print 1 "Tar ongoing"
263  tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
264  # Save it
265  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar ${STORE_RESTART}
266  # Clean it
267  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar
268  # ------------------------------------------------------------------
269  # Test if all was right before proceeding cleaning
270  # ------------------------------------------------------------------
271  IGCM_debug_Verif_Exit_Post
272  # Clean links
273  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
274  # Clean files links pointed to
275  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
276  # Save the list of files that has been pack (tar)
277  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_RESTART}
278  IGCM_debug_Print 1 "Tar and cleaning done"
279
280  (( number_pack = number_pack + 1 ))
281
282  # Add 1 day to date_end_pack to have the new date_begin_pack
283  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
284
285done
286
287# Clean RUN_DIR_PATH (necessary for cesium and titane only)
288IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
289
290date
Note: See TracBrowser for help on using the repository browser.