source: trunk/libIGCM/AA_pack_debug @ 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.7 KB
Line 
1#-Q- curie ######################
2#-Q- curie ## CURIE   TGCC/CEA ##
3#-Q- curie ######################
4#-Q- curie #MSUB -r PACKDEBUG      # 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   = PACKDEBUG
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 PACKDEBUG          # 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 PACKDEBUG    # 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 PACKDEBUG
53#-Q- lxiv8 #PBS -m a
54#-Q- lxiv8 #PBS -j oe
55#-Q- lxiv8 #PBS -q medium
56#-Q- lxiv8 #PBS -o PACKDEBUG.$$
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_DEBUG=/ccc/store/cont003/dsm/p86denv/.../DEBUG
199STORE_DEBUG=${R_SAVE}/DEBUG
200IGCM_sys_MkdirArchive ${STORE_DEBUG}
201
202#cd ${STORE_DEBUG}
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 $DateBegin $DateEnd
208
209# Clear txt file lists
210rm -f ${RUN_DIR}/liste_debug_files.txt
211rm -f ${RUN_DIR}/liste_out_files.txt
212rm -f ${RUN_DIR}/new_liste_debug_files.txt
213rm -f ${RUN_DIR}/liste_pack_*.txt
214
215# Create sorted debug list to work with
216find ${R_BUFR}/*/Debug -type f | sort >> ${RUN_DIR}/liste_debug_files.txt
217
218# Rename debug files we will work with using symlinks. use ???_ prefix ie NF-2
219#gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt
220gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt
221
222# Add out_ : output of execution files
223find ${R_BUFR}/Out -type f -name '*out_*' | sort >> ${RUN_DIR}/liste_out_files.txt
224
225# Rename out files we will work with using symlinks. use Out_ prefix ie NF-1
226gawk -F/ '{dest_name=$(NF-1)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_out_files.txt
227
228# List renamed debug files. Exclude Job_xxx files.
229find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_debug_files.txt
230
231# ------------------------------------------------------------------
232# Test if all was right before proceeding further
233# ------------------------------------------------------------------
234IGCM_debug_Verif_Exit_Post
235
236# Init loop
237date_begin_pack=${DateBegin}
238date_end_simulation=${DateEnd}
239number_pack=1
240
241IGCM_debug_PrintVariables 3 date_begin_pack
242IGCM_debug_PrintVariables 3 date_end_simulation
243
244while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
245
246  IGCM_debug_PrintVariables 3 number_pack
247
248  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
249  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
250
251  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_debug_files.txt ); do
252    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
253    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
254#   echo pack n°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
255    if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
256        echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
257        echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
258#    Will not work. Need to find a better ordering.
259#    elif [ ${date_file} -ge ${date_end_pack} ] ; then
260#      break
261    fi
262  done
263
264  # Create tar files
265  IGCM_debug_Print 1 "Tar ongoing"
266  tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
267  # Save it
268  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar ${STORE_DEBUG}
269  # Clean it
270  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar
271  # ------------------------------------------------------------------
272  # Test if all was right before proceeding cleaning
273  # ------------------------------------------------------------------
274  IGCM_debug_Verif_Exit_Post
275  # Clean links
276  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
277  # Clean files links pointed to
278  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
279  # Save the list of files that has been pack (tar)
280  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
281  IGCM_debug_Print 1 "Tar and cleaning done"
282
283  (( number_pack = number_pack + 1 ))
284
285  # Add 1 day to date_end_pack to have the new date_begin_pack
286  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
287
288done
289
290# Clean RUN_DIR_PATH (necessary for cesium and titane only)
291IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
292
293date
Note: See TracBrowser for help on using the repository browser.