source: branches/libIGCM_MPI_OpenMP/AA_pack_output

Last change on this file was 605, checked in by mafoipsl, 12 years ago

Tttttt use elapstim_req instead of cpu_time on mercure front-end.

  • Property svn:keywords set to Revision Author Date
File size: 14.4 KB
Line 
1#-Q- cesium #!/bin/ksh
2#-Q- cesium ######################
3#-Q- cesium ## CESIUM   CEA ##
4#-Q- cesium ######################
5#-Q- cesium #MSUB -r PACKOUTPUT    # Nom du job
6#-Q- cesium #MSUB -N 1              # Reservation du noeud
7#-Q- cesium #MSUB -n 1              # Reservation du processus
8#-Q- cesium #MSUB -T 86400          # Limite de temps elapsed du job
9#-Q- cesium #MSUB -E "-j o"
10#-Q- cesium #MSUB -E "-S /bin/ksh"
11#-Q- platine #!/usr/bin/ksh
12#-Q- platine ###################
13#-Q- platine ## PLATINE   CEA ##
14#-Q- platine ###################
15#-Q- platine #BSUB -J PACKOUTPUT            # Nom du job
16#-Q- platine #BSUB -N                        # message a la fin du job
17#-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
18#-Q- platine #BSUB -W 4:00                   # Limite temps
19#-Q- platine #BSUB -q post                   # Passage en queue post
20#-Q- platine #BSUB -L /bin/ksh
21#-Q- sx8brodie #!/bin/ksh
22#-Q- sx8brodie #######################
23#-Q- sx8brodie ## SX8BRODIE   IDRIS ##
24#-Q- sx8brodie #######################
25#-Q- sx8brodie # Temps Elapsed max. d'une requete hh:mm:ss
26#-Q- sx8brodie # @ wall_clock_limit = 10:00:00
27#-Q- sx8brodie # Nom du travail LoadLeveler
28#-Q- sx8brodie # @ job_name   = PACKOUTPUT
29#-Q- sx8brodie # Fichier de sortie standard du travail
30#-Q- sx8brodie # @ output     = $(job_name).$(jobid)
31#-Q- sx8brodie # Fichier de sortie d'erreur du travail
32#-Q- sx8brodie # @ error      =  $(job_name).$(jobid)
33#-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
34#-Q- sx8brodie # @ notification = error
35#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
36#-Q- sx8brodie # @ queue
37#-Q- aix6 #!/bin/ksh
38#-Q- aix6 #######################
39#-Q- aix6 ##   VARGAS   IDRIS  ##
40#-Q- aix6 #######################
41#-Q- aix6 # Temps Elapsed max. d'une requete hh:mm:ss
42#-Q- aix6 # @ wall_clock_limit = 10:00:00
43#-Q- aix6 # Nom du travail LoadLeveler
44#-Q- aix6 # @ job_name   = PACKOUTPUT
45#-Q- aix6 # Fichier de sortie standard du travail
46#-Q- aix6 # @ output     = $(job_name).$(jobid)
47#-Q- aix6 # Fichier de sortie d'erreur du travail
48#-Q- aix6 # @ error      =  $(job_name).$(jobid)
49#-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
50#-Q- aix6 # @ notification = error
51#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
52#-Q- aix6 # @ queue
53#-Q- ulam #!/bin/ksh
54#-Q- ulam #######################
55#-Q- ulam ##   VARGAS   IDRIS  ##
56#-Q- ulam #######################
57#-Q- ulam # Temps Elapsed max. d'une requete hh:mm:ss
58#-Q- ulam # @ wall_clock_limit = 10:00:00
59#-Q- ulam # Nom du travail LoadLeveler
60#-Q- ulam # @ job_name   = PACKOUTPUT
61#-Q- ulam # Fichier de sortie standard du travail
62#-Q- ulam # @ output     = $(job_name).$(jobid)
63#-Q- ulam # Fichier de sortie d'erreur du travail
64#-Q- ulam # @ error      =  $(job_name).$(jobid)
65#-Q- ulam # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
66#-Q- ulam # @ notification = error
67#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
68#-Q- ulam # @ queue
69#-Q- sx8mercure #!/bin/ksh
70#-Q- sx8mercure ######################
71#-Q- sx8mercure ## SX8MERCURE   CEA ##
72#-Q- sx8mercure ######################
73#-Q- sx8mercure #PBS -N PACKOUTPUT          # Nom du job
74#-Q- sx8mercure #PBS -j o                    # regroupement des stdout et stderr
75#-Q- sx8mercure #PBS -S /usr/bin/ksh         # shell de soumission
76#-Q- sx8mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
77#-Q- sx8mercure #PBS -l cputim_job=24:00:00  # Limite temps a 1 heures
78#-Q- sx8mercure #PBS -q scalaire
79#-Q- sx9mercure #!/bin/ksh
80#-Q- sx9mercure ######################
81#-Q- sx9mercure ## SX9MERCURE  CCRT ##
82#-Q- sx9mercure ######################
83#-Q- sx9mercure #PBS -N PACKOUTPUT          # Nom du job
84#-Q- sx9mercure #PBS -j o                    # regroupement des stdout et stderr
85#-Q- sx9mercure #PBS -S /usr/bin/ksh         # shell de soumission
86#-Q- sx9mercure #PBS -l memsz_job=1gb        # Limite memoire a 1 Go
87#-Q- sx9mercure #PBS -l elapstim_req=24:00:00  # Limite temps a 1 heures
88#-Q- sx9mercure #PBS -q scalaire
89#-Q- titane #!/bin/ksh
90#-Q- titane ######################
91#-Q- titane ## TITANE   CEA     ##
92#-Q- titane ######################
93#-Q- titane #MSUB -r PACKOUTPUT    # Nom du job
94#-Q- titane #MSUB -eo
95#-Q- titane #MSUB -n 1              # Reservation du processus
96#-Q- titane #MSUB -T 86400          # Limite de temps elapsed du job
97#-Q- titane #MSUB -q mono
98#-Q- lxiv8 ######################
99#-Q- lxiv8 ## OBELIX      LSCE ##
100#-Q- lxiv8 ######################
101#-Q- lxiv8 #PBS -N PACKOUTPUT
102#-Q- lxiv8 #PBS -m a
103#-Q- lxiv8 #PBS -j oe
104#-Q- lxiv8 #PBS -q medium
105#-Q- lxiv8 #PBS -o PACKOUTPUT.$$
106#-Q- lxiv8 #PBS -S /bin/ksh
107#-Q- default #!/bin/ksh
108#-Q- default ##################
109#-Q- default ## DEFAULT HOST ##
110#-Q- default ##################
111
112#**************************************************************
113# Author: Sebastien Denvil
114# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
115# $Revision::                                          $ Revision of last commit
116# $Author::                                            $ Author of last commit
117# $Date::                                              $ Date of last commit
118# IPSL (2006)
119#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
120#
121#**************************************************************
122
123#set -eu
124#set -vx
125
126date
127
128########################################################################
129
130#D- Flag to determine if this job in a standalone mode
131#D- Default : value from AA_job if any
132StandAlone=${StandAlone:=true}
133
134#D- Path to libIGCM
135#D- Default : value from AA_job if any
136# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
137# WARNING you must check MirrorlibIGCM variable in sys library.
138# WARNING If this variable is true, you must use libIGCM_POST path instead
139# WARNING of your running libIGCM directory.
140libIGCM=${libIGCM:=::modipsl::/libIGCM}
141
142#-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
143MASTER=${MASTER:=mercure|titane|brodie|vargas}
144
145#D- Flag to determine begin date for restart pack
146#D- Default : value from AA_job if any
147DateBegin=${DateBegin:=20000101}
148
149#D- Flag to determine end date for restart pack
150#D- Default : value from AA_job if any
151DateEnd=${DateEnd:=20691231}
152
153#D- Flag to determine pack period
154#D- Default : value from AA_job if any
155PeriodPack=${PeriodPack:=10Y}
156
157#D- Uncomment to run interactively
158#D- For testing purpose, will be remove
159#SUBMIT_DIR=${PWD}
160#RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test
161
162#D- Increased verbosity (1, 2, 3)
163#D- Default : value from AA_job if any
164Verbosity=${Verbosity:=3}
165
166#D- Low level debug : to bypass lib test checks and stack construction
167#D- Default : value from AA_job if any
168DEBUG_debug=${DEBUG_debug:=false}
169
170########################################################################
171
172. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
173( ${DEBUG_debug} ) && IGCM_debug_Check
174. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
175( ${DEBUG_debug} ) && IGCM_card_Check
176. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
177( ${DEBUG_debug} ) && IGCM_date_Check
178#-------
179. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
180. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
181
182########################################################################
183
184#set -vx
185
186RUN_DIR=${RUN_DIR_PATH}
187IGCM_sys_MkdirWork ${RUN_DIR}
188IGCM_sys_Cd ${RUN_DIR}
189
190# ------------------------------------------------------------------
191# Test if all was right before proceeding further
192# ------------------------------------------------------------------
193IGCM_debug_Verif_Exit_Post
194
195if [ ${StandAlone} = true ] ; then
196    CARD_DIR=${SUBMIT_DIR}
197else
198    CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} )
199    IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH}
200fi
201
202#====================================================
203# First of all
204#
205# Read config.card
206
207IGCM_card_DefineArrayFromSection     ${CARD_DIR}/config.card UserChoices
208typeset option
209for option in ${config_UserChoices[*]} ; do
210  IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option}
211done
212#
213echo
214IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
215IGCM_debug_PrintVariables 3 config_UserChoices_JobName
216IGCM_debug_PrintVariables 3 config_UserChoices_LongName
217IGCM_debug_PrintVariables 3 config_UserChoices_TagName
218IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName
219IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName
220IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType
221IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin
222IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
223IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength
224echo
225
226# Get ListOfComponents to drive the loop over find
227IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
228
229#====================================================
230#R_SAVE : Job output storage directory
231#R_BUFR : Job output buffered directory
232
233if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
234  FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
235  R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
236  R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
237else
238  R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
239  R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
240fi
241IGCM_sys_TestDirArchive ${R_SAVE}
242[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
243
244# Where to store used file list /!\ TEMPORARY /!\
245STORE_DEBUG=${R_SAVE}/DEBUG
246
247# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
248JobName=${config_UserChoices_JobName}
249echo $JobName $DateBegin $DateEnd
250
251# ------------------------------------------------------------------
252# Test if all was right before proceeding further
253# ------------------------------------------------------------------
254IGCM_debug_Verif_Exit_Post
255
256# Init loop
257date_begin_pack=${DateBegin}
258date_end_simulation=${DateEnd}
259number_pack=1
260
261IGCM_debug_PrintVariables 3 date_begin_pack
262IGCM_debug_PrintVariables 3 date_end_simulation
263
264while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
265
266  IGCM_debug_PrintVariables 3 number_pack
267  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
268  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
269
270  for comp in ${config_ListOfComponents[*]} ; do
271    dirList=$( find ${R_BUFR}/${comp}/Output -maxdepth 1 -mindepth 1 -type d )
272    for dir in ${dirList} ; do
273      # dirID is like ATM.Output.MO
274      dirID=$( echo $dir | sed "s:${R_BUFR}/::" | sed "s:/:.:g" )
275      # Sort what's in the directory
276      find ${dir} -type f -name "${JobName}*.nc" -ls | sort -k 11 > liste_files.${dirID}.txt
277      # How much file type. Example : 1M_histmthCOSP.nc, 1M_histmth.nc, 1M_histmthNMC.nc, 1M_paramLMDZ_phy.nc
278      # /!\ fileType include the .nc extension /!\
279      fileType=$( gawk '{print $11}' liste_files.${dirID}.txt | gawk -F$dir/ '{print $2}' | sed "s:${JobName}_[0-9]\{8,9\}_[0-9]\{8,9\}_::g" | sort | uniq )
280      # Loop over the file type and pack them when in between date_begin_pack and date_end_pack
281      for myType in ${fileType} ; do
282        grep ${myType} liste_files.${dirID}.txt > liste_files.${dirID}.${myType}.txt
283        nbfile=0
284        for file in $( gawk '{print $11}' liste_files.${dirID}.${myType}.txt ); do
285          extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
286          date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
287          # echo pack n°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
288          if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
289            echo ${file} >> liste_pack_${myType}_${number_pack}.txt
290            ncdump -h ${file} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> liste_variables_${myType}_${number_pack}.txt
291            (( nbfile = nbfile + 1 ))
292          fi
293        done
294        # Select list of variables to work with
295        list_var=$( cat liste_variables_${myType}_${number_pack}.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d ',' )
296        liste_file_tmp=$( for i in $( cat liste_pack_${myType}_${number_pack}.txt ) ; do basename $i ; done )
297        # Create packed files
298        IGCM_debug_Print 1 "Ncrcat ongoing for ${dir} and ${myType}"
299        output=${JobName}_${date_begin_pack}_${date_end_pack}_${myType}
300        #cat liste_pack_${myType}_${number_pack}.txt | xargs ncrcat -v ${list_var} -o ${output}
301        if [ X${list_var} = X ] ; then
302          IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
303        else
304          IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
305        fi
306        # ------------------------------------------------------------------
307        # Test if all was right before proceeding further
308        # ------------------------------------------------------------------
309        IGCM_debug_Verif_Exit_Post
310        # Save it
311        IGCM_sys_Put_Out ${output} ${R_SAVE}/$( echo $dir | sed "s:${R_BUFR}/::" )/${output}
312        # ------------------------------------------------------------------
313        # Test if all was right before proceeding further
314        # ------------------------------------------------------------------
315        IGCM_debug_Verif_Exit_Post
316        # Clean file produced by ncrcat
317        IGCM_sys_Rm ${output}
318        # Clean files used by ncrcat
319        cat liste_pack_${myType}_${number_pack}.txt | xargs rm
320        # Save the list of files that has been pack (ncrcat)
321        mv liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
322        IGCM_debug_Print 1 "Ncrcat and cleaning done for ${dir} and ${myType}"
323      done
324    done
325  done
326  (( number_pack = number_pack + 1 ))
327  # Add 1 day to date_end_pack to have the new date_begin_pack
328  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
329done
330
331# Clean RUN_DIR_PATH (necessary for cesium and titane only)
332IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
333
334date
Note: See TracBrowser for help on using the repository browser.