source: tags/libIGCM_v2.0_rc3/AA_pack_debug @ 998

Last change on this file since 998 was 770, checked in by sdipsl, 11 years ago

Adapat headers for ada.
Clean up old headers (platine, cesium, brodie, ...)

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