source: trunk/libIGCM/AA_pack_output @ 1516

Last change on this file since 1516 was 1501, checked in by acosce, 4 years ago

change in post treatment Jean Zay job header to add jobid in the log out file

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