source: trunk/libIGCM/AA_pack_output @ 1465

Last change on this file since 1465 was 1465, checked in by acosce, 6 years ago

Add the choice by ins_job of number of cores for pack_output.
I don't modify the number of cores of pack_restart and pack_debug that actually well run on 4 cores.

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