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