source: trunk/libIGCM/AA_pack_restart @ 832

Last change on this file since 832 was 832, checked in by sdipsl, 11 years ago
  • Trivial changes to accomodate new_libIGCM function defined here /ccc/cont003/home/dsm/p86mart/.bash_alias (ksh-->bash)

She transforms every cp and rm by IGCM_sys_Cp and IGCM_sys_Rm within IGCM_debug_Check. So we need to source sys before calling it.

  • 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 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   = PACKRESTART
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 PACKRESTART          # 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 PACKRESTART    # 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 PACKRESTART
52#-Q- lxiv8 #PBS -m a
53#-Q- lxiv8 #PBS -j oe
54#-Q- lxiv8 #PBS -q medium
55#-Q- lxiv8 #PBS -o PACKRESTART.$$
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. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
150. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
151#-------
152. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
153. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
154. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
155#-------
156( ${DEBUG_debug} ) && IGCM_debug_Check
157( ${DEBUG_debug} ) && IGCM_card_Check
158( ${DEBUG_debug} ) && IGCM_date_Check
159
160########################################################################
161
162#set -vx
163
164RUN_DIR=${RUN_DIR_PATH}
165IGCM_sys_MkdirWork ${RUN_DIR}
166IGCM_sys_Cd ${RUN_DIR}
167
168# ------------------------------------------------------------------
169# Test if all was right before proceeding further
170# ------------------------------------------------------------------
171IGCM_debug_Verif_Exit_Post
172
173if [ ${StandAlone} = true ] ; then
174    CARD_DIR=${SUBMIT_DIR}
175else
176    CARD_DIR=${RUN_DIR_PATH}
177    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
178    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
179    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
180    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
181fi
182
183#==================================
184# First of all
185#
186# Read libIGCM compatibility version in config.card
187# Read UserChoices section
188# Read Ensemble section
189# Read Post section
190# Define all netcdf output directories
191#==================================
192IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
193#
194IGCM_sys_TestDirArchive ${R_SAVE}
195[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
196
197#STORE_RESTART=/ccc/store/cont003/dsm/p86denv/.../RESTART
198STORE_RESTART=${R_SAVE}/RESTART
199IGCM_sys_MkdirArchive ${STORE_RESTART}
200
201#cd ${STORE_RESTART}
202#rm -f *
203
204# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
205JobName=${config_UserChoices_JobName}
206echo $JobName $R_BUFR $DateBegin $DateEnd
207
208# Clear txt file lists
209rm -f ${RUN_DIR}/liste_restart_files.txt
210rm -f ${RUN_DIR}/new_liste_restart_files.txt
211rm -f ${RUN_DIR}/liste_pack_*.txt
212
213# Create sorted restart list to work with
214find ${R_BUFR}/*/Restart -name "*.*" | sort >> ${RUN_DIR}/liste_restart_files.txt
215
216# Rename restart files we will work with using symlinks
217#gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
218gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
219
220# List renamed restart files
221find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_restart_files.txt
222
223# ------------------------------------------------------------------
224# Test if all was right before proceeding further
225# ------------------------------------------------------------------
226IGCM_debug_Verif_Exit_Post
227
228# Init loop
229date_begin_pack=${DateBegin}
230date_end_simulation=${DateEnd}
231number_pack=1
232
233IGCM_debug_PrintVariables 3 date_begin_pack
234IGCM_debug_PrintVariables 3 date_end_simulation
235
236# last restart of the previous period : to be deleted
237typeset date_end_previous
238date_end_previous=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} -1 )
239
240while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
241
242  IGCM_debug_PrintVariables 3 number_pack
243
244  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
245  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
246
247  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_restart_files.txt ); do
248    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_//" )
249    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
250    # warning demenagement. delete last restart of the previous pack
251    [  ${date_file} -eq ${date_end_previous} ] && echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
252    # echo pack number ${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      # warning demenagement. do not delete last restart of this pack
256      [ ${date_file} -eq ${date_end_pack} ] || echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
257    fi
258  done
259
260  # Create tar files
261  IGCM_debug_Print 1 "Tar ongoing"
262  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
263  # Save it
264  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar ${STORE_RESTART}
265  # Clean it
266  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar
267  # ------------------------------------------------------------------
268  # Test if all was right before proceeding cleaning
269  # ------------------------------------------------------------------
270  IGCM_debug_Verif_Exit_Post
271  # Clean links
272  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
273  # Clean files links pointed to
274  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
275  # Save the list of files that has been pack (tar)
276  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_RESTART}
277  IGCM_debug_Print 1 "Tar and cleaning done"
278
279  (( number_pack = number_pack + 1 ))
280
281  # Add 1 day to date_end_pack to have the new date_begin_pack
282  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
283
284done
285
286# Clean RUN_DIR_PATH (necessary for cesium and titane only)
287IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
288
289date
Note: See TracBrowser for help on using the repository browser.