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