[622] | 1 | #-Q- curie ###################### |
---|
| 2 | #-Q- curie ## CURIE TGCC/CEA ## |
---|
| 3 | #-Q- curie ###################### |
---|
[837] | 4 | #-Q- curie #MSUB -r PACKRESTART # Nom du job |
---|
[1468] | 5 | #-Q- curie #MSUB -o PACKRESTART.out_%I |
---|
| 6 | #-Q- curie #MSUB -e PACKRESTART.out_%I |
---|
[622] | 7 | #-Q- curie #MSUB -n 1 # Reservation du processus |
---|
[880] | 8 | #-Q- curie #MSUB -T 7200 # Limite de temps elapsed du job |
---|
[1154] | 9 | #-Q- curie #MSUB -q ::default_node:: |
---|
[1274] | 10 | #-Q- curie #MSUB -c ::default_core:: |
---|
[704] | 11 | #-Q- curie #MSUB -Q normal |
---|
[837] | 12 | #-Q- curie #MSUB -A ::default_project:: |
---|
[681] | 13 | #-Q- curie set +x |
---|
[1433] | 14 | #-Q- irene ###################### |
---|
| 15 | #-Q- irene ## IRENE TGCC/CEA ## |
---|
| 16 | #-Q- irene ###################### |
---|
| 17 | #-Q- irene #MSUB -r PACKRESTART # Job name |
---|
[1468] | 18 | #-Q- irene #MSUB -o PACKRESTART.out_%I |
---|
| 19 | #-Q- irene #MSUB -e PACKRESTART.out_%I |
---|
[1433] | 20 | #-Q- irene #MSUB -n 1 # Number of cores |
---|
| 21 | #-Q- irene #MSUB -T 7200 # Maximum elapsed time |
---|
[1468] | 22 | #-Q- irene #MSUB -q ::default_node:: |
---|
| 23 | #-Q- irene #MSUB -c ::default_core:: |
---|
[1433] | 24 | #-Q- irene #MSUB -Q normal |
---|
[1468] | 25 | #-Q- irene #MSUB -A ::default_post_project:: |
---|
[1460] | 26 | #-Q- irene #MSUB -m store,work,scratch |
---|
[1433] | 27 | #-Q- irene set +x |
---|
[770] | 28 | #-Q- ada #!/bin/ksh |
---|
| 29 | #-Q- ada ####################### |
---|
[929] | 30 | #-Q- ada ## ADA IDRIS ## |
---|
[770] | 31 | #-Q- ada ####################### |
---|
[1409] | 32 | #-Q- ada # @ job_type = mpich |
---|
[848] | 33 | #-Q- ada # @ requirements = (Feature == "prepost") |
---|
[770] | 34 | #-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss |
---|
| 35 | #-Q- ada # @ wall_clock_limit = 10:00:00 |
---|
| 36 | #-Q- ada # Nom du travail LoadLeveler |
---|
| 37 | #-Q- ada # @ job_name = PACKRESTART |
---|
| 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 |
---|
[1395] | 44 | #-Q- ada # @ environment = $DEBUG_debug ; $BigBrother ; $postProcessingStopLevel ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $POST_DIR ; $Script_Post_Output ; $SUBMIT_DIR ; $PeriodDateBegin ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER ; wall_clock_limit=$(wall_clock_limit) |
---|
[770] | 45 | #-Q- ada # @ queue |
---|
[547] | 46 | #-Q- lxiv8 ###################### |
---|
| 47 | #-Q- lxiv8 ## OBELIX LSCE ## |
---|
| 48 | #-Q- lxiv8 ###################### |
---|
| 49 | #-Q- lxiv8 #PBS -N PACKRESTART |
---|
| 50 | #-Q- lxiv8 #PBS -m a |
---|
| 51 | #-Q- lxiv8 #PBS -j oe |
---|
| 52 | #-Q- lxiv8 #PBS -q medium |
---|
| 53 | #-Q- lxiv8 #PBS -o PACKRESTART.$$ |
---|
| 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 PACKRESTART |
---|
| 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 |
---|
[547] | 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 | |
---|
| 82 | date |
---|
| 83 | |
---|
[1356] | 84 | #D- Task type DO NOT CHANGE (computing, post-processing or checking) |
---|
[712] | 85 | TaskType=post-processing |
---|
| 86 | |
---|
[547] | 87 | ######################################################################## |
---|
| 88 | |
---|
| 89 | #D- Flag to determine if this job in a standalone mode |
---|
| 90 | #D- Default : value from AA_job if any |
---|
| 91 | StandAlone=${StandAlone:=true} |
---|
| 92 | |
---|
[554] | 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. |
---|
| 99 | libIGCM=${libIGCM:=::modipsl::/libIGCM} |
---|
| 100 | |
---|
| 101 | #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer. |
---|
[928] | 102 | MASTER=${MASTER:=ada|curie} |
---|
[554] | 103 | |
---|
[547] | 104 | #D- Flag to determine begin date for restart pack |
---|
| 105 | #D- Default : value from AA_job if any |
---|
[578] | 106 | DateBegin=${DateBegin:=20000101} |
---|
[547] | 107 | |
---|
| 108 | #D- Flag to determine end date for restart pack |
---|
| 109 | #D- Default : value from AA_job if any |
---|
[554] | 110 | DateEnd=${DateEnd:=20691231} |
---|
[547] | 111 | |
---|
| 112 | #D- Flag to determine pack period |
---|
| 113 | #D- Default : value from AA_job if any |
---|
[554] | 114 | PeriodPack=${PeriodPack:=10Y} |
---|
[547] | 115 | |
---|
[554] | 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 |
---|
[547] | 120 | |
---|
| 121 | #D- Increased verbosity (1, 2, 3) |
---|
| 122 | #D- Default : value from AA_job if any |
---|
| 123 | Verbosity=${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 |
---|
| 127 | DEBUG_debug=${DEBUG_debug:=false} |
---|
| 128 | |
---|
[554] | 129 | #D- Keep following comments for now. Will be remove. |
---|
| 130 | |
---|
[547] | 131 | #on veut archiver les fichiers restart |
---|
| 132 | #Dans le cadre du demenagement ils seront renommes |
---|
| 133 | #ATM/Restart/****.nc |
---|
| 134 | #OCE/Restart/****.nc |
---|
| 135 | #... |
---|
| 136 | #sous la forme |
---|
| 137 | #RESTART/ATM_****.nc |
---|
| 138 | #RESTART/OCE_****.nc |
---|
[590] | 139 | #Attention de bien conserver les dates d'origines |
---|
[547] | 140 | # |
---|
| 141 | #Dans le cadre de la production nouvelle chaine |
---|
| 142 | #ils auront directement le bon nom |
---|
| 143 | # |
---|
[590] | 144 | #On veut egalement que l'archive soit par periode de temps |
---|
| 145 | # cette periode est definie par la taille du pack donc connue |
---|
| 146 | # en entree du script (1M, 1Y, 5Y, 10Y etc...) |
---|
[547] | 147 | # |
---|
[590] | 148 | # $1= PATH/config_card d'une simulation avec |
---|
| 149 | # TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd |
---|
[554] | 150 | # $2=PeriodPack en M/m ou Y/y |
---|
[547] | 151 | |
---|
| 152 | ######################################################################## |
---|
| 153 | |
---|
| 154 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 155 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 156 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 157 | #------- |
---|
| 158 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
[731] | 159 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[547] | 160 | . ${libIGCM}/libIGCM_post/libIGCM_post.ksh |
---|
[832] | 161 | #------- |
---|
[1192] | 162 | RUN_DIR=${RUN_DIR_PATH} |
---|
| 163 | IGCM_sys_MkdirWork ${RUN_DIR} |
---|
| 164 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 165 | #------- |
---|
[832] | 166 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 167 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 168 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
[547] | 169 | |
---|
| 170 | ######################################################################## |
---|
| 171 | |
---|
| 172 | #set -vx |
---|
| 173 | |
---|
| 174 | # ------------------------------------------------------------------ |
---|
| 175 | # Test if all was right before proceeding further |
---|
| 176 | # ------------------------------------------------------------------ |
---|
[1206] | 177 | IGCM_debug_Verif_Exit |
---|
[547] | 178 | |
---|
| 179 | if [ ${StandAlone} = true ] ; then |
---|
| 180 | CARD_DIR=${SUBMIT_DIR} |
---|
| 181 | else |
---|
[647] | 182 | CARD_DIR=${RUN_DIR_PATH} |
---|
[640] | 183 | IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH} |
---|
| 184 | IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card ${RUN_DIR_PATH} |
---|
| 185 | IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP ${RUN_DIR_PATH} |
---|
| 186 | IGCM_sys_Get_Master ${SUBMIT_DIR}/POST ${RUN_DIR_PATH} |
---|
[547] | 187 | fi |
---|
| 188 | |
---|
[727] | 189 | #================================== |
---|
[547] | 190 | # First of all |
---|
| 191 | # |
---|
[727] | 192 | # Read libIGCM compatibility version in config.card |
---|
| 193 | # Read UserChoices section |
---|
| 194 | # Read Ensemble section |
---|
| 195 | # Read Post section |
---|
| 196 | # Define all netcdf output directories |
---|
| 197 | #================================== |
---|
| 198 | IGCM_config_CommonConfiguration ${CARD_DIR}/config.card |
---|
[1198] | 199 | |
---|
| 200 | # ------------------------------------------------------------------ |
---|
| 201 | # Activate BigBrother so as to supervise this job |
---|
| 202 | # ------------------------------------------------------------------ |
---|
| 203 | IGCM_debug_BigBro_Initialize |
---|
| 204 | |
---|
| 205 | #================================== |
---|
| 206 | # Test and set up directories |
---|
| 207 | #================================== |
---|
[547] | 208 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 209 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 210 | |
---|
[554] | 211 | STORE_RESTART=${R_SAVE}/RESTART |
---|
| 212 | IGCM_sys_MkdirArchive ${STORE_RESTART} |
---|
[547] | 213 | |
---|
[554] | 214 | # Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure) |
---|
[547] | 215 | JobName=${config_UserChoices_JobName} |
---|
[590] | 216 | echo $JobName $R_BUFR $DateBegin $DateEnd |
---|
[547] | 217 | |
---|
| 218 | # Clear txt file lists |
---|
| 219 | rm -f ${RUN_DIR}/liste_restart_files.txt |
---|
| 220 | rm -f ${RUN_DIR}/new_liste_restart_files.txt |
---|
| 221 | rm -f ${RUN_DIR}/liste_pack_*.txt |
---|
[1395] | 222 | rm -f ${RUN_DIR}/liste_pack_light_*.txt |
---|
[547] | 223 | |
---|
| 224 | # Create sorted restart list to work with |
---|
[636] | 225 | find ${R_BUFR}/*/Restart -name "*.*" | sort >> ${RUN_DIR}/liste_restart_files.txt |
---|
[547] | 226 | |
---|
[565] | 227 | # Rename restart files we will work with using symlinks |
---|
[547] | 228 | #gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt |
---|
| 229 | gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt |
---|
| 230 | |
---|
| 231 | # List renamed restart files |
---|
[636] | 232 | find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_restart_files.txt |
---|
[547] | 233 | |
---|
| 234 | # ------------------------------------------------------------------ |
---|
| 235 | # Test if all was right before proceeding further |
---|
| 236 | # ------------------------------------------------------------------ |
---|
[1206] | 237 | IGCM_debug_Verif_Exit |
---|
[547] | 238 | |
---|
[565] | 239 | # Init loop |
---|
| 240 | date_begin_pack=${DateBegin} |
---|
| 241 | date_end_simulation=${DateEnd} |
---|
[547] | 242 | number_pack=1 |
---|
| 243 | |
---|
| 244 | IGCM_debug_PrintVariables 3 date_begin_pack |
---|
| 245 | IGCM_debug_PrintVariables 3 date_end_simulation |
---|
| 246 | |
---|
[616] | 247 | # last restart of the previous period : to be deleted |
---|
| 248 | typeset date_end_previous |
---|
| 249 | date_end_previous=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} -1 ) |
---|
| 250 | |
---|
[547] | 251 | while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do |
---|
| 252 | |
---|
| 253 | IGCM_debug_PrintVariables 3 number_pack |
---|
| 254 | |
---|
[589] | 255 | DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} ) |
---|
[579] | 256 | date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) ) |
---|
[547] | 257 | |
---|
[565] | 258 | for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_restart_files.txt ); do |
---|
[547] | 259 | extract_date_file=$( echo ${file} | sed -e "s/.*${JobName}_//" ) |
---|
| 260 | date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' ) |
---|
[653] | 261 | # warning demenagement. delete last restart of the previous pack |
---|
[617] | 262 | [ ${date_file} -eq ${date_end_previous} ] && echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
[653] | 263 | # echo pack number ${number_pack} ${date_file} ${date_begin_pack} ${date_end_pack} |
---|
[590] | 264 | if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then |
---|
[617] | 265 | echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
[653] | 266 | # warning demenagement. do not delete last restart of this pack |
---|
[617] | 267 | [ ${date_file} -eq ${date_end_pack} ] || echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
[547] | 268 | fi |
---|
[1395] | 269 | # light pack list of restarts files that will be used |
---|
| 270 | if [ X${config_Post_LightRestartPack} = XTRUE ] ; then |
---|
| 271 | if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${PeriodDateBegin} ] ; then |
---|
| 272 | echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_light_${date_begin_pack}_${date_end_pack}.txt |
---|
| 273 | fi |
---|
| 274 | fi |
---|
[547] | 275 | done |
---|
| 276 | |
---|
[565] | 277 | # Create tar files |
---|
| 278 | IGCM_debug_Print 1 "Tar ongoing" |
---|
[1395] | 279 | if [ X${config_Post_LightRestartPack} = XTRUE ] ; then |
---|
[1400] | 280 | tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar --dereference --files-from ${RUN_DIR}/liste_pack_light_${date_begin_pack}_${date_end_pack}.txt |
---|
| 281 | else |
---|
[1395] | 282 | tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt |
---|
| 283 | fi |
---|
[1478] | 284 | # Test return code of tar |
---|
| 285 | [ $? != 0 ] && IGCM_debug_Exit "tar failed in pack_restart job" |
---|
[565] | 286 | # Save it |
---|
| 287 | IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar ${STORE_RESTART} |
---|
| 288 | # Clean it |
---|
| 289 | IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar |
---|
[765] | 290 | # ------------------------------------------------------------------ |
---|
| 291 | # Test if all was right before proceeding cleaning |
---|
| 292 | # ------------------------------------------------------------------ |
---|
[1206] | 293 | IGCM_debug_Verif_Exit |
---|
[565] | 294 | # Clean links |
---|
[617] | 295 | cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm |
---|
[565] | 296 | # Clean files links pointed to |
---|
[617] | 297 | cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm |
---|
[565] | 298 | # Save the list of files that has been pack (tar) |
---|
[632] | 299 | #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_RESTART} |
---|
[565] | 300 | IGCM_debug_Print 1 "Tar and cleaning done" |
---|
[547] | 301 | |
---|
| 302 | (( number_pack = number_pack + 1 )) |
---|
| 303 | |
---|
[565] | 304 | # Add 1 day to date_end_pack to have the new date_begin_pack |
---|
[578] | 305 | date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 ) |
---|
[565] | 306 | |
---|
[547] | 307 | done |
---|
[590] | 308 | |
---|
| 309 | # Clean RUN_DIR_PATH (necessary for cesium and titane only) |
---|
| 310 | IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH} |
---|
| 311 | |
---|
[1198] | 312 | # ------------------------------------------------------------------ |
---|
| 313 | # Finalize BigBrother to inform that the jobs end |
---|
| 314 | # ------------------------------------------------------------------ |
---|
| 315 | IGCM_debug_BigBro_Finalize |
---|
| 316 | |
---|
[590] | 317 | date |
---|