[622] | 1 | #-Q- curie ###################### |
---|
| 2 | #-Q- curie ## CURIE TGCC/CEA ## |
---|
| 3 | #-Q- curie ###################### |
---|
[837] | 4 | #-Q- curie #MSUB -r PACKDEBUG # Nom du job |
---|
[622] | 5 | #-Q- curie #MSUB -eo |
---|
| 6 | #-Q- curie #MSUB -n 1 # Reservation du processus |
---|
[880] | 7 | #-Q- curie #MSUB -T 3600 # Limite de temps elapsed du job |
---|
[1154] | 8 | #-Q- curie #MSUB -q ::default_node:: |
---|
[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 ####################### |
---|
[929] | 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 = PACKDEBUG |
---|
| 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 |
---|
[1201] | 28 | #-Q- ada # @ environment = $DEBUG_debug ; $BigBrother ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $POST_DIR ; $Script_Post_Output ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER ; wall_clock_limit=$(wall_clock_limit) |
---|
[770] | 29 | #-Q- ada # @ queue |
---|
[547] | 30 | #-Q- lxiv8 ###################### |
---|
| 31 | #-Q- lxiv8 ## OBELIX LSCE ## |
---|
| 32 | #-Q- lxiv8 ###################### |
---|
| 33 | #-Q- lxiv8 #PBS -N PACKDEBUG |
---|
| 34 | #-Q- lxiv8 #PBS -m a |
---|
| 35 | #-Q- lxiv8 #PBS -j oe |
---|
| 36 | #-Q- lxiv8 #PBS -q medium |
---|
| 37 | #-Q- lxiv8 #PBS -o PACKDEBUG.$$ |
---|
| 38 | #-Q- lxiv8 #PBS -S /bin/ksh |
---|
[1184] | 39 | #-Q- ifort_CICLAD ###################### |
---|
| 40 | #-Q- ifort_CICLAD ## CICLAD IPSL ## |
---|
| 41 | #-Q- ifort_CICLAD ###################### |
---|
| 42 | #-Q- ifort_CICLAD #PBS -N PACKDEBUG |
---|
| 43 | #-Q- ifort_CICLAD #PBS -m a |
---|
| 44 | #-Q- ifort_CICLAD #PBS -j oe |
---|
| 45 | #-Q- ifort_CICLAD #PBS -q std |
---|
| 46 | #-Q- ifort_CICLAD #PBS -S /bin/ksh |
---|
[547] | 47 | #-Q- default #!/bin/ksh |
---|
| 48 | #-Q- default ################## |
---|
| 49 | #-Q- default ## DEFAULT HOST ## |
---|
| 50 | #-Q- default ################## |
---|
| 51 | |
---|
| 52 | #************************************************************** |
---|
| 53 | # Author: Sebastien Denvil |
---|
| 54 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
| 55 | # $Revision:: $ Revision of last commit |
---|
| 56 | # $Author:: $ Author of last commit |
---|
| 57 | # $Date:: $ Date of last commit |
---|
| 58 | # IPSL (2006) |
---|
| 59 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 60 | # |
---|
| 61 | #************************************************************** |
---|
| 62 | |
---|
| 63 | #set -eu |
---|
| 64 | #set -vx |
---|
| 65 | |
---|
| 66 | date |
---|
| 67 | |
---|
[712] | 68 | #D- Task type (computing or post-processing) |
---|
| 69 | TaskType=post-processing |
---|
| 70 | |
---|
[547] | 71 | ######################################################################## |
---|
| 72 | |
---|
| 73 | #D- Flag to determine if this job in a standalone mode |
---|
| 74 | #D- Default : value from AA_job if any |
---|
| 75 | StandAlone=${StandAlone:=true} |
---|
| 76 | |
---|
[554] | 77 | #D- Path to libIGCM |
---|
| 78 | #D- Default : value from AA_job if any |
---|
| 79 | # WARNING For StandAlone use : To run this script on some machine (ulam and cesium) |
---|
| 80 | # WARNING you must check MirrorlibIGCM variable in sys library. |
---|
| 81 | # WARNING If this variable is true, you must use libIGCM_POST path instead |
---|
| 82 | # WARNING of your running libIGCM directory. |
---|
| 83 | libIGCM=${libIGCM:=::modipsl::/libIGCM} |
---|
| 84 | |
---|
| 85 | #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer. |
---|
[928] | 86 | MASTER=${MASTER:=ada|curie} |
---|
[554] | 87 | |
---|
[547] | 88 | #D- Flag to determine begin date for restart pack |
---|
| 89 | #D- Default : value from AA_job if any |
---|
[578] | 90 | DateBegin=${DateBegin:=20000101} |
---|
[547] | 91 | |
---|
| 92 | #D- Flag to determine end date for restart pack |
---|
| 93 | #D- Default : value from AA_job if any |
---|
[554] | 94 | DateEnd=${DateEnd:=20691231} |
---|
[547] | 95 | |
---|
| 96 | #D- Flag to determine pack period |
---|
| 97 | #D- Default : value from AA_job if any |
---|
[554] | 98 | PeriodPack=${PeriodPack:=10Y} |
---|
[547] | 99 | |
---|
[554] | 100 | #D- Uncomment to run interactively |
---|
| 101 | #D- For testing purpose, will be remove |
---|
| 102 | #SUBMIT_DIR=${PWD} |
---|
| 103 | #RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test |
---|
[547] | 104 | |
---|
| 105 | #D- Increased verbosity (1, 2, 3) |
---|
| 106 | #D- Default : value from AA_job if any |
---|
| 107 | Verbosity=${Verbosity:=3} |
---|
| 108 | |
---|
| 109 | #D- Low level debug : to bypass lib test checks and stack construction |
---|
| 110 | #D- Default : value from AA_job if any |
---|
| 111 | DEBUG_debug=${DEBUG_debug:=false} |
---|
| 112 | |
---|
[554] | 113 | #D- Keep following comments for now. Will be remove. |
---|
| 114 | |
---|
[547] | 115 | #on veut archiver les fichiers restart |
---|
| 116 | #Dans le cadre du demenagement ils seront renommes |
---|
| 117 | #ATM/Restart/****.nc |
---|
| 118 | #OCE/Restart/****.nc |
---|
| 119 | #... |
---|
| 120 | #sous la forme |
---|
| 121 | #RESTART/ATM_****.nc |
---|
| 122 | #RESTART/OCE_****.nc |
---|
[590] | 123 | #Attention de bien conserver les dates d'origines |
---|
[547] | 124 | # |
---|
| 125 | #Dans le cadre de la production nouvelle chaine |
---|
| 126 | #ils auront directement le bon nom |
---|
| 127 | # |
---|
[590] | 128 | #On veut egalement que l'archive soit par periode de temps |
---|
| 129 | # cette periode est definie par la taille du pack donc connue |
---|
| 130 | # en entree du script (1M, 1Y, 5Y, 10Y etc...) |
---|
[547] | 131 | # |
---|
[590] | 132 | # $1= PATH/config_card d'une simulation avec |
---|
| 133 | # TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd |
---|
[554] | 134 | # $2=PeriodPack en M/m ou Y/y |
---|
[547] | 135 | |
---|
| 136 | ######################################################################## |
---|
| 137 | |
---|
| 138 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 139 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 140 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 141 | #------- |
---|
| 142 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
[731] | 143 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[547] | 144 | . ${libIGCM}/libIGCM_post/libIGCM_post.ksh |
---|
[832] | 145 | #------- |
---|
[1192] | 146 | RUN_DIR=${RUN_DIR_PATH} |
---|
| 147 | IGCM_sys_MkdirWork ${RUN_DIR} |
---|
| 148 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 149 | #------- |
---|
[832] | 150 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 151 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 152 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
[547] | 153 | |
---|
| 154 | ######################################################################## |
---|
| 155 | |
---|
| 156 | #set -vx |
---|
| 157 | |
---|
| 158 | # ------------------------------------------------------------------ |
---|
| 159 | # Test if all was right before proceeding further |
---|
| 160 | # ------------------------------------------------------------------ |
---|
| 161 | IGCM_debug_Verif_Exit_Post |
---|
| 162 | |
---|
| 163 | if [ ${StandAlone} = true ] ; then |
---|
| 164 | CARD_DIR=${SUBMIT_DIR} |
---|
| 165 | else |
---|
[647] | 166 | CARD_DIR=${RUN_DIR_PATH} |
---|
[640] | 167 | IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH} |
---|
| 168 | IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card ${RUN_DIR_PATH} |
---|
| 169 | IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP ${RUN_DIR_PATH} |
---|
| 170 | IGCM_sys_Get_Master ${SUBMIT_DIR}/POST ${RUN_DIR_PATH} |
---|
[547] | 171 | fi |
---|
| 172 | |
---|
[727] | 173 | #================================== |
---|
[547] | 174 | # First of all |
---|
| 175 | # |
---|
[727] | 176 | # Read libIGCM compatibility version in config.card |
---|
| 177 | # Read UserChoices section |
---|
| 178 | # Read Ensemble section |
---|
| 179 | # Read Post section |
---|
| 180 | # Define all netcdf output directories |
---|
| 181 | #================================== |
---|
| 182 | IGCM_config_CommonConfiguration ${CARD_DIR}/config.card |
---|
[658] | 183 | |
---|
[1198] | 184 | # ------------------------------------------------------------------ |
---|
| 185 | # Activate BigBrother so as to supervise this job |
---|
| 186 | # ------------------------------------------------------------------ |
---|
| 187 | IGCM_debug_BigBro_Initialize |
---|
| 188 | |
---|
| 189 | #================================== |
---|
| 190 | # Test and set up directories |
---|
| 191 | #================================== |
---|
[547] | 192 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 193 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 194 | |
---|
[554] | 195 | STORE_DEBUG=${R_SAVE}/DEBUG |
---|
| 196 | IGCM_sys_MkdirArchive ${STORE_DEBUG} |
---|
[547] | 197 | |
---|
[554] | 198 | # Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure) |
---|
[547] | 199 | JobName=${config_UserChoices_JobName} |
---|
[590] | 200 | echo $JobName $DateBegin $DateEnd |
---|
[547] | 201 | |
---|
| 202 | # Clear txt file lists |
---|
| 203 | rm -f ${RUN_DIR}/liste_debug_files.txt |
---|
[616] | 204 | rm -f ${RUN_DIR}/liste_out_files.txt |
---|
[547] | 205 | rm -f ${RUN_DIR}/new_liste_debug_files.txt |
---|
| 206 | rm -f ${RUN_DIR}/liste_pack_*.txt |
---|
| 207 | |
---|
| 208 | # Create sorted debug list to work with |
---|
[590] | 209 | find ${R_BUFR}/*/Debug -type f | sort >> ${RUN_DIR}/liste_debug_files.txt |
---|
[547] | 210 | |
---|
[616] | 211 | # Rename debug files we will work with using symlinks. use ???_ prefix ie NF-2 |
---|
[547] | 212 | #gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt |
---|
| 213 | gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt |
---|
| 214 | |
---|
[616] | 215 | # Add out_ : output of execution files |
---|
| 216 | find ${R_BUFR}/Out -type f -name '*out_*' | sort >> ${RUN_DIR}/liste_out_files.txt |
---|
[547] | 217 | |
---|
[616] | 218 | # Rename out files we will work with using symlinks. use Out_ prefix ie NF-1 |
---|
| 219 | gawk -F/ '{dest_name=$(NF-1)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_out_files.txt |
---|
| 220 | |
---|
| 221 | # List renamed debug files. Exclude Job_xxx files. |
---|
[617] | 222 | find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_debug_files.txt |
---|
[616] | 223 | |
---|
[547] | 224 | # ------------------------------------------------------------------ |
---|
| 225 | # Test if all was right before proceeding further |
---|
| 226 | # ------------------------------------------------------------------ |
---|
| 227 | IGCM_debug_Verif_Exit_Post |
---|
| 228 | |
---|
[565] | 229 | # Init loop |
---|
| 230 | date_begin_pack=${DateBegin} |
---|
| 231 | date_end_simulation=${DateEnd} |
---|
[547] | 232 | number_pack=1 |
---|
| 233 | |
---|
| 234 | IGCM_debug_PrintVariables 3 date_begin_pack |
---|
| 235 | IGCM_debug_PrintVariables 3 date_end_simulation |
---|
| 236 | |
---|
| 237 | while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do |
---|
| 238 | |
---|
| 239 | IGCM_debug_PrintVariables 3 number_pack |
---|
| 240 | |
---|
[589] | 241 | DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} ) |
---|
[579] | 242 | date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) ) |
---|
[547] | 243 | |
---|
[565] | 244 | for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_debug_files.txt ); do |
---|
[547] | 245 | extract_date_file=$( echo ${file} | sed -e "s/.*${JobName}_[0-9]*_//" ) |
---|
| 246 | date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' ) |
---|
[590] | 247 | # echo pack n°${number_pack} ${date_file} ${date_begin_pack} ${date_end_pack} |
---|
| 248 | if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then |
---|
[617] | 249 | echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
| 250 | echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
[547] | 251 | fi |
---|
| 252 | done |
---|
| 253 | |
---|
[565] | 254 | # Create tar files |
---|
| 255 | IGCM_debug_Print 1 "Tar ongoing" |
---|
[617] | 256 | tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
[565] | 257 | # Save it |
---|
| 258 | IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar ${STORE_DEBUG} |
---|
| 259 | # Clean it |
---|
| 260 | IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar |
---|
[765] | 261 | # ------------------------------------------------------------------ |
---|
| 262 | # Test if all was right before proceeding cleaning |
---|
| 263 | # ------------------------------------------------------------------ |
---|
| 264 | IGCM_debug_Verif_Exit_Post |
---|
[565] | 265 | # Clean links |
---|
[617] | 266 | cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm |
---|
[565] | 267 | # Clean files links pointed to |
---|
[617] | 268 | cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm |
---|
[565] | 269 | # Save the list of files that has been pack (tar) |
---|
[632] | 270 | #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG} |
---|
[565] | 271 | IGCM_debug_Print 1 "Tar and cleaning done" |
---|
[547] | 272 | |
---|
| 273 | (( number_pack = number_pack + 1 )) |
---|
| 274 | |
---|
[565] | 275 | # Add 1 day to date_end_pack to have the new date_begin_pack |
---|
[578] | 276 | date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) |
---|
[565] | 277 | |
---|
[547] | 278 | done |
---|
[590] | 279 | |
---|
| 280 | # Clean RUN_DIR_PATH (necessary for cesium and titane only) |
---|
| 281 | IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH} |
---|
| 282 | |
---|
[1198] | 283 | # ------------------------------------------------------------------ |
---|
| 284 | # Finalize BigBrother to inform that the jobs end |
---|
| 285 | # ------------------------------------------------------------------ |
---|
| 286 | IGCM_debug_BigBro_Finalize |
---|
| 287 | |
---|
[590] | 288 | date |
---|