source: trunk/libIGCM/AA_pack_restart @ 1451

Last change on this file since 1451 was 1448, checked in by jgipsl, 6 years ago

Change in headers at irene : temporary remove option -m and use a workaround given by the TGCC. This change is done to avoid problems with resubmitting from job when submitting the main job from workdir.

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

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