source: tags/libIGCM_v2.8/AA_pack_output @ 1456

Last change on this file since 1456 was 1290, checked in by sdipsl, 8 years ago
  • broadcast postProcessingStopLevel value to every jobs. Default value is zero.
  • 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.4 KB
Line 
1#-Q- curie ######################
2#-Q- curie ## CURIE   TGCC/CEA ##
3#-Q- curie ######################
4#-Q- curie #MSUB -r PACKOUTPUT     # Nom du job
5#-Q- curie #MSUB -eo
6#-Q- curie #MSUB -n 1              # Reservation du processus
7#-Q- curie #MSUB -T 36000          # 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- ada #!/bin/ksh
14#-Q- ada #######################
15#-Q- ada ## ADA         IDRIS ##
16#-Q- ada #######################
17#-Q- ada # @ job_type = serial
18#-Q- ada # @ requirements = (Feature == "prepost")
19#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
20#-Q- ada # @ wall_clock_limit = 10:00:00
21#-Q- ada # Nom du travail LoadLeveler
22#-Q- ada # @ job_name   = PACKOUTPUT
23#-Q- ada # Fichier de sortie standard du travail
24#-Q- ada # @ output     = $(job_name).$(jobid)
25#-Q- ada # Fichier de sortie d'erreur du travail
26#-Q- ada # @ error      =  $(job_name).$(jobid)
27#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
28#-Q- ada # @ notification = error
29#-Q- ada # @ environment  = $DEBUG_debug ; $BigBrother ; $postProcessingStopLevel ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $POST_DIR ; $Script_Post_Output ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER ; wall_clock_limit=$(wall_clock_limit)
30#-Q- ada # @ queue
31#-Q- lxiv8 ######################
32#-Q- lxiv8 ## OBELIX      LSCE ##
33#-Q- lxiv8 ######################
34#-Q- lxiv8 #PBS -N PACKOUTPUT
35#-Q- lxiv8 #PBS -m a
36#-Q- lxiv8 #PBS -j oe
37#-Q- lxiv8 #PBS -q medium
38#-Q- lxiv8 #PBS -o PACKOUTPUT.$$
39#-Q- lxiv8 #PBS -S /bin/ksh
40#-Q- ifort_CICLAD ######################
41#-Q- ifort_CICLAD ##   CICLAD    IPSL ##
42#-Q- ifort_CICLAD ######################
43#-Q- ifort_CICLAD #PBS -N PACKOUTPUT
44#-Q- ifort_CICLAD #PBS -m a
45#-Q- ifort_CICLAD #PBS -j oe
46#-Q- ifort_CICLAD #PBS -q std
47#-Q- ifort_CICLAD #PBS -S /bin/ksh
48#-Q- default #!/bin/ksh
49#-Q- default ##################
50#-Q- default ## DEFAULT HOST ##
51#-Q- default ##################
52
53#**************************************************************
54# Author: Sebastien Denvil
55# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
56# $Revision::                                          $ Revision of last commit
57# $Author::                                            $ Author of last commit
58# $Date::                                              $ Date of last commit
59# IPSL (2006)
60#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
61#
62#**************************************************************
63
64#set -eu
65#set -vx
66
67date
68
69#D- Task type (computing or post-processing)
70TaskType=post-processing
71
72########################################################################
73
74#D- Flag to determine if this job in a standalone mode
75#D- Default : value from AA_job if any
76StandAlone=${StandAlone:=true}
77
78#D- Path to libIGCM
79#D- Default : value from AA_job if any
80# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
81# WARNING you must check MirrorlibIGCM variable in sys library.
82# WARNING If this variable is true, you must use libIGCM_POST path instead
83# WARNING of your running libIGCM directory.
84libIGCM=${libIGCM:=::modipsl::/libIGCM}
85
86#-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
87MASTER=${MASTER:=ada|curie}
88
89#D- Flag to determine begin date for restart pack
90#D- Default : value from AA_job if any
91DateBegin=${DateBegin:=20000101}
92
93#D- Flag to determine end date for restart pack
94#D- Default : value from AA_job if any
95DateEnd=${DateEnd:=20691231}
96
97#D- Flag to determine pack period
98#D- Default : value from AA_job if any
99PeriodPack=${PeriodPack:=10Y}
100
101#D- Uncomment to run interactively
102#D- For testing purpose, will be remove
103#SUBMIT_DIR=${PWD}
104#RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test
105
106#D- Increased verbosity (1, 2, 3)
107#D- Default : value from AA_job if any
108Verbosity=${Verbosity:=3}
109
110#D- Low level debug : to bypass lib test checks and stack construction
111#D- Default : value from AA_job if any
112DEBUG_debug=${DEBUG_debug:=false}
113
114########################################################################
115
116. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
117. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
118. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
119#-------
120. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
121. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
122. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
123#-------
124RUN_DIR=${RUN_DIR_PATH}
125IGCM_sys_MkdirWork ${RUN_DIR}
126IGCM_sys_Cd ${RUN_DIR}
127#-------
128( ${DEBUG_debug} ) && IGCM_debug_Check
129( ${DEBUG_debug} ) && IGCM_card_Check
130( ${DEBUG_debug} ) && IGCM_date_Check
131
132########################################################################
133
134#set -vx
135
136# ------------------------------------------------------------------
137# Test if all was right before proceeding further
138# ------------------------------------------------------------------
139IGCM_debug_Verif_Exit
140
141if [ ${StandAlone} = true ] ; then
142    CARD_DIR=${SUBMIT_DIR}
143else
144    CARD_DIR=${RUN_DIR_PATH}
145    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
146    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
147    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
148    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
149fi
150
151#==================================
152# First of all
153#
154# Read libIGCM compatibility version in config.card
155# Read UserChoices section
156# Read Ensemble section
157# Read Post section
158# Define all netcdf output directories
159#==================================
160IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
161
162# ------------------------------------------------------------------
163# Activate BigBrother so as to supervise this job
164# ------------------------------------------------------------------
165IGCM_debug_BigBro_Initialize
166
167#==================================
168# Read ListOfComponents section
169# to drive the loop over find
170IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
171
172#==================================
173# Test and set up directories
174#==================================
175IGCM_sys_TestDirArchive ${R_SAVE}
176[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
177
178# Where to store used file list /!\ TEMPORARY /!\
179STORE_DEBUG=${R_SAVE}/DEBUG
180
181# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
182JobName=${config_UserChoices_JobName}
183echo $JobName $DateBegin $DateEnd
184
185# ------------------------------------------------------------------
186# Test if all was right before proceeding further
187# ------------------------------------------------------------------
188IGCM_debug_Verif_Exit
189
190IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength"
191IGCM_post_CheckModuloFrequency PeriodPack config_UserChoices_PeriodLength NbPeriodPerFrequency
192# ------------------------------------------------------------------
193# Test if all was right before proceeding further
194# ------------------------------------------------------------------
195IGCM_debug_Verif_Exit
196
197IGCM_debug_Print 1 "We must process ${NbPeriodPerFrequency} files for each pack"
198
199# Init loop
200date_begin_pack=${DateBegin}
201date_end_simulation=${DateEnd}
202number_pack=1
203
204IGCM_debug_PrintVariables 3 date_begin_pack
205IGCM_debug_PrintVariables 3 date_end_simulation
206
207while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
208
209  IGCM_debug_PrintVariables 3 number_pack
210  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
211  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
212
213  for comp in ${config_ListOfComponents[*]} ; do
214    dirList=$( find ${R_BUFR}/${comp}/Output -maxdepth 1 -mindepth 1 -type d )
215    for dir in ${dirList} ; do
216      # dirID is like ATM.Output.MO
217      dirID=$( echo $dir | sed "s:${R_BUFR}/::" | sed "s:/:.:g" )
218      # Sort what's in the directory
219      find ${dir} -type f -name "${JobName}*.nc" -ls | sort -k 11 > liste_files.${dirID}.txt
220      # How much file type. Example : 1M_histmthCOSP.nc, 1M_histmth.nc, 1M_histmthNMC.nc, 1M_paramLMDZ_phy.nc
221      # /!\ fileType include the .nc extension /!\
222      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 )
223      # Loop over the file type and pack them when in between date_begin_pack and date_end_pack
224      for myType in ${fileType} ; do
225        grep ${myType} liste_files.${dirID}.txt > liste_files.${dirID}.${myType}.txt
226        nbfile=0
227        for file in $( gawk '{print $11}' liste_files.${dirID}.${myType}.txt ); do
228          extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
229          date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
230          # echo pack n°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
231          if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
232            echo ${file} >> liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt
233            ncdump -h ${file} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> liste_variables_${myType}_${date_begin_pack}_${date_end_pack}.txt
234            (( nbfile = nbfile + 1 ))
235          fi
236        done
237
238        if [ ${nbfile} = 0 ] ; then
239          IGCM_debug_Print 1 "We found no file to process"
240          IGCM_debug_Print 1 "We should have found ${NbPeriodPerFrequency} files"
241          IGCM_debug_Print 1 "As some files can be produced only for some selected period we consider we can move to the next file type"
242          continue
243        fi
244
245        # Select list of variables to work with
246        list_var=$( cat liste_variables_${myType}_${date_begin_pack}_${date_end_pack}.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d ',' )
247        liste_file_tmp=$( for i in $( cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ) ; do basename $i ; done )
248        # Create packed files
249        IGCM_debug_Print 1 "Ncrcat ongoing for ${dir} and ${myType}"
250        if [ ! ${nbfile} = ${NbPeriodPerFrequency} ] ; then
251          IGCM_debug_Print 1 "Number of files to process is not equal to what it should be"
252          IGCM_debug_Print 1 "We found ${nbfile} files and it should have been ${NbPeriodPerFrequency} files"
253          IGCM_debug_Exit "ERROR in number of files to process. STOP HERE INCLUDING THE COMPUTING JOB"
254          IGCM_debug_Verif_Exit
255        fi
256        output=${JobName}_${date_begin_pack}_${date_end_pack}_${myType}
257        #cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt | xargs ncrcat -v ${list_var} -o ${output}
258        if [ X${list_var} = X ] ; then
259          IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
260        else
261          IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
262        fi
263        # ------------------------------------------------------------------
264        # Test if all was right before proceeding further
265        # ------------------------------------------------------------------
266        IGCM_debug_Verif_Exit
267        # Save it
268        IGCM_sys_Put_Out ${output} ${R_SAVE}/$( echo $dir | sed "s:${R_BUFR}/::" )/${output}
269        # Clean file produced by ncrcat
270        IGCM_sys_Rm ${output}
271        # ------------------------------------------------------------------
272        # Test if all was right before proceeding further
273        # ------------------------------------------------------------------
274        IGCM_debug_Verif_Exit
275        # Clean files used by ncrcat
276        cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt | xargs rm
277        # Save the list of files that has been pack (ncrcat)
278        #mv liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
279        IGCM_debug_Print 1 "Ncrcat and cleaning done for ${dir} and ${myType}"
280        echo
281      done
282    done
283  done
284  (( number_pack = number_pack + 1 ))
285  # Add 1 day to date_end_pack to have the new date_begin_pack
286  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
287done
288
289# Flush post-processing submission
290if [ -f ${R_BUFR}/FlushPost_${DateEnd}.ksh ] ; then
291  . ${R_BUFR}/FlushPost_${DateEnd}.ksh
292  IGCM_FlushPost
293  #IGCM_sys_Rm -f ${R_BUFR}/FlushPost_${DateEnd}.ksh
294fi
295
296# Clean RUN_DIR_PATH (necessary for cesium and titane only)
297IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
298
299# ------------------------------------------------------------------
300# Finalize BigBrother to inform that the jobs end
301# ------------------------------------------------------------------
302IGCM_debug_BigBro_Finalize
303
304date
Note: See TracBrowser for help on using the repository browser.