source: tags/libIGCM_v2.0_rc3/AA_pack_restart @ 1170

Last change on this file since 1170 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 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( ${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_RESTART=/ccc/store/cont003/dsm/p86denv/.../RESTART
197STORE_RESTART=${R_SAVE}/RESTART
198IGCM_sys_MkdirArchive ${STORE_RESTART}
199
200#cd ${STORE_RESTART}
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 $R_BUFR $DateBegin $DateEnd
206
207# Clear txt file lists
208rm -f ${RUN_DIR}/liste_restart_files.txt
209rm -f ${RUN_DIR}/new_liste_restart_files.txt
210rm -f ${RUN_DIR}/liste_pack_*.txt
211
212# Create sorted restart list to work with
213find ${R_BUFR}/*/Restart -name "*.*" | sort >> ${RUN_DIR}/liste_restart_files.txt
214
215# Rename restart files we will work with using symlinks
216#gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
217gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
218
219# List renamed restart files
220find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_restart_files.txt
221
222# ------------------------------------------------------------------
223# Test if all was right before proceeding further
224# ------------------------------------------------------------------
225IGCM_debug_Verif_Exit_Post
226
227# Init loop
228date_begin_pack=${DateBegin}
229date_end_simulation=${DateEnd}
230number_pack=1
231
232IGCM_debug_PrintVariables 3 date_begin_pack
233IGCM_debug_PrintVariables 3 date_end_simulation
234
235# last restart of the previous period : to be deleted
236typeset date_end_previous
237date_end_previous=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} -1 )
238
239while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
240
241  IGCM_debug_PrintVariables 3 number_pack
242
243  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
244  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
245
246  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_restart_files.txt ); do
247    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_//" )
248    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
249    # warning demenagement. delete last restart of the previous pack
250    [  ${date_file} -eq ${date_end_previous} ] && echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
251    # echo pack number ${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
252    if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
253      echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
254      # warning demenagement. do not delete last restart of this pack
255      [ ${date_file} -eq ${date_end_pack} ] || echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
256    fi
257  done
258
259  # Create tar files
260  IGCM_debug_Print 1 "Tar ongoing"
261  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
262  # Save it
263  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar ${STORE_RESTART}
264  # Clean it
265  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar
266  # ------------------------------------------------------------------
267  # Test if all was right before proceeding cleaning
268  # ------------------------------------------------------------------
269  IGCM_debug_Verif_Exit_Post
270  # Clean links
271  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
272  # Clean files links pointed to
273  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
274  # Save the list of files that has been pack (tar)
275  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_RESTART}
276  IGCM_debug_Print 1 "Tar and cleaning done"
277
278  (( number_pack = number_pack + 1 ))
279
280  # Add 1 day to date_end_pack to have the new date_begin_pack
281  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
282
283done
284
285# Clean RUN_DIR_PATH (necessary for cesium and titane only)
286IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
287
288date
Note: See TracBrowser for help on using the repository browser.