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