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