source: trunk/libIGCM/AA_pack_restart @ 1059

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