source: tags/libIGCM_v2.0/AA_pack_restart @ 1170

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