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