[385] | 1 | #!/bin/ksh |
---|
[271] | 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sebastien Denvil |
---|
[396] | 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[271] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
[1283] | 13 | # ID of your genci project. Curie only : post-processing jobs need it to run properly |
---|
| 14 | #-Q- curie export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
[1437] | 15 | #-Q- irene export BRIDGE_MSUB_PROJECT=::default_project:: |
---|
[271] | 16 | |
---|
[1356] | 17 | #D- Task type DO NOT CHANGE (computing, post-processing or checking) |
---|
[1114] | 18 | TaskType=checking |
---|
[712] | 19 | |
---|
[1114] | 20 | #D- Low level debug : to perform lib test checks, stack construction and IO functions instrumentation |
---|
| 21 | DEBUG_debug=false |
---|
| 22 | |
---|
| 23 | #D- Messaging : all activities and call stacks will be sent to ipsl servers |
---|
| 24 | BigBrother=false |
---|
| 25 | |
---|
[387] | 26 | # Check that everything went well during seasonal average production |
---|
[271] | 27 | # Display a short report |
---|
[1028] | 28 | # Launch what's missing when a simulation has been completed PeriodState=Completed |
---|
[271] | 29 | |
---|
[554] | 30 | #D- Path to libIGCM |
---|
| 31 | #D- Default : value from AA_job if any |
---|
| 32 | # WARNING For StandAlone use : To run this script on some machine (ulam and cesium) |
---|
| 33 | # WARNING you must check MirrorlibIGCM variable in sys library. |
---|
| 34 | # WARNING If this variable is true, you must use libIGCM_POST path instead |
---|
| 35 | # WARNING of your running libIGCM directory. |
---|
[271] | 36 | libIGCM=${libIGCM:=::modipsl::/libIGCM} |
---|
| 37 | |
---|
[338] | 38 | # répertoire courrant |
---|
[271] | 39 | CURRENT_DIR=$( pwd ) |
---|
| 40 | |
---|
[338] | 41 | # Emplacement des cartes |
---|
[1283] | 42 | CARD_DIR=${CARD_DIR:=${CURRENT_DIR}} |
---|
[271] | 43 | |
---|
[344] | 44 | # répertoire de stockage des sorties des create_ts |
---|
[338] | 45 | POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript} |
---|
| 46 | |
---|
[271] | 47 | if [ ! -d ${CARD_DIR} ]; then |
---|
[785] | 48 | echo "No ${CARD_DIR}, we stop here" |
---|
| 49 | exit |
---|
[271] | 50 | fi |
---|
| 51 | |
---|
| 52 | ######################################################################## |
---|
| 53 | |
---|
[731] | 54 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 55 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 56 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 57 | #------- |
---|
| 58 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
| 59 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[832] | 60 | #------- |
---|
| 61 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
| 62 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
| 63 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
[271] | 64 | |
---|
| 65 | ######################################################################## |
---|
| 66 | |
---|
[362] | 67 | #set -vx |
---|
| 68 | |
---|
[1327] | 69 | echo "Hi I'm here to help you check and complete the seasonal average production" |
---|
| 70 | echo -e "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit? Answer no in this case\033[m" |
---|
| 71 | echo -e "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m" |
---|
| 72 | echo -n " Run for real (y/n) :" |
---|
| 73 | read ActionAnswer |
---|
| 74 | |
---|
| 75 | case ${ActionAnswer} in |
---|
| 76 | oui|OUI|o|y|yes|YES) |
---|
| 77 | echo "OK. I will submit jobs" |
---|
| 78 | action=true |
---|
| 79 | ;; |
---|
| 80 | non|NON|n|no|NO) |
---|
| 81 | echo "OK. I won't submit any jobs" |
---|
| 82 | action=false |
---|
| 83 | ;; |
---|
| 84 | *) |
---|
| 85 | echo "I did not recognize your answer. I will stop here." |
---|
| 86 | echo "Please answer: oui|OUI|o|y|yes|YES" |
---|
| 87 | echo "Or answer: non|NON|n|no|NO" |
---|
| 88 | exit |
---|
| 89 | ;; |
---|
| 90 | esac |
---|
| 91 | |
---|
[616] | 92 | #================================== |
---|
[271] | 93 | # First of all |
---|
[616] | 94 | # |
---|
[727] | 95 | # Read libIGCM compatibility version in config.card |
---|
| 96 | # Read UserChoices section |
---|
| 97 | # Read Ensemble section |
---|
| 98 | # Read Post section |
---|
| 99 | # Define all netcdf output directories |
---|
[616] | 100 | #================================== |
---|
[727] | 101 | IGCM_config_CommonConfiguration ${CARD_DIR}/config.card |
---|
[271] | 102 | |
---|
[616] | 103 | #================================== |
---|
[727] | 104 | # Read ListOfComponents section: |
---|
| 105 | IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents |
---|
[658] | 106 | |
---|
| 107 | #================================== |
---|
[727] | 108 | # Read SeasonalFrequency: |
---|
| 109 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency |
---|
[338] | 110 | |
---|
[1233] | 111 | #===================================# |
---|
| 112 | # Read updated run.card : |
---|
| 113 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodDateEnd |
---|
| 114 | |
---|
[616] | 115 | # |
---|
[908] | 116 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
[1233] | 117 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
[338] | 118 | |
---|
[908] | 119 | # |
---|
| 120 | if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then |
---|
| 121 | PeriodOffset=0 |
---|
| 122 | else |
---|
| 123 | PeriodOffset=${config_Post_SeasonalFrequencyOffset} |
---|
| 124 | fi |
---|
[362] | 125 | |
---|
[385] | 126 | IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin} |
---|
| 127 | IGCM_debug_Print 1 "DateEnd for SE_Checker : "${DateEnd} |
---|
[908] | 128 | IGCM_debug_Print 1 "Offset for SE_Checker : "${PeriodOffset} |
---|
[362] | 129 | echo |
---|
[385] | 130 | # |
---|
| 131 | [ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit |
---|
[271] | 132 | |
---|
[385] | 133 | freq=$( echo ${config_Post_SeasonalFrequency} | sed -e "s/[yY]//" ) |
---|
[271] | 134 | |
---|
[908] | 135 | an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 + PeriodOffset )) ) |
---|
| 136 | an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) ) |
---|
[385] | 137 | an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) ) |
---|
| 138 | |
---|
| 139 | # |
---|
| 140 | while [ ${an_fin} -le ${an_fin_all} ] ; do |
---|
| 141 | |
---|
[785] | 142 | countTotal=0 |
---|
| 143 | countGood=0 |
---|
| 144 | countBad=0 |
---|
[385] | 145 | |
---|
[785] | 146 | IGCM_debug_Print 1 " DateBegin/End for SE : ${an_deb}_${an_fin} " |
---|
[271] | 147 | |
---|
[785] | 148 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 149 | localcountBad=0 |
---|
| 150 | # Debug Print |
---|
| 151 | IGCM_debug_Print 1 ${comp} |
---|
[906] | 152 | # Define component |
---|
[785] | 153 | IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp} |
---|
| 154 | eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 |
---|
| 155 | |
---|
| 156 | # Read libIGCM compatibility version in ${compname}.card |
---|
| 157 | card=${CARD_DIR}/COMP/${compname}.card |
---|
| 158 | |
---|
| 159 | # Read and Build Output File stuff |
---|
| 160 | #IGCM_debug_Print 1 "DefineArrayFromOption : ${compname}_OutputFiles ${card}" |
---|
| 161 | IGCM_card_DefineArrayFromOption ${card} OutputFiles List |
---|
| 162 | ListFilesName=${compname}_OutputFiles_List |
---|
| 163 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
| 164 | # |
---|
| 165 | if [ X${FileName0} != X${NULL_STR} ] ; then |
---|
| 166 | # |
---|
| 167 | # INITIALISATION |
---|
| 168 | # |
---|
| 169 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
| 170 | typeset i=2 |
---|
| 171 | # |
---|
| 172 | until [ $i -gt $NbFiles ]; do |
---|
| 173 | # |
---|
| 174 | eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1 |
---|
| 175 | # |
---|
| 176 | if [ X${flag_post} != XNONE ] ; then |
---|
| 177 | # |
---|
| 178 | # Check if seasonal is required for this file |
---|
| 179 | # |
---|
| 180 | IGCM_card_DefineArrayFromSection ${card} ${flag_post} |
---|
| 181 | # |
---|
| 182 | # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default |
---|
| 183 | # |
---|
| 184 | # variable option allready typeset above |
---|
| 185 | for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do |
---|
| 186 | if [ ${option} = Seasonal ] ; then |
---|
| 187 | FoundSeasonal=true |
---|
| 188 | IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal |
---|
| 189 | fi |
---|
| 190 | done |
---|
| 191 | # |
---|
| 192 | if [ ! X${FoundSeasonal} = Xtrue ] ; then |
---|
| 193 | eval ${compname}_${flag_post}_Seasonal=ON |
---|
| 194 | fi |
---|
| 195 | # |
---|
| 196 | if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then |
---|
| 197 | (( i=i+3 )) |
---|
| 198 | continue |
---|
| 199 | fi |
---|
| 200 | # |
---|
| 201 | # CREATE LIST |
---|
| 202 | # |
---|
| 203 | FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' ) |
---|
| 204 | # |
---|
| 205 | DIRECTORY=${R_SAVE}/${comp}/Analyse/SE |
---|
| 206 | # |
---|
| 207 | TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc |
---|
| 208 | # |
---|
| 209 | (( countTotal = countTotal + 1 )) |
---|
[906] | 210 | IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1 |
---|
[785] | 211 | if [ ! $? = 0 ] ; then |
---|
| 212 | eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile} |
---|
| 213 | (( countBad = countBad + 1 )) |
---|
| 214 | (( localcountBad = localcountBad + 1 )) |
---|
| 215 | else |
---|
| 216 | (( countGood = countGood + 1 )) |
---|
| 217 | fi |
---|
| 218 | fi |
---|
| 219 | (( i=i+3 )) # to explore file list |
---|
| 220 | done # until [ $i -eq $NbFiles ] |
---|
[906] | 221 | fi # [ X${FileName0} != X${NULL_STR} ] |
---|
[785] | 222 | |
---|
| 223 | [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} ) |
---|
| 224 | done |
---|
| 225 | |
---|
| 226 | # create_se submit if files don't exist |
---|
| 227 | if [ $countGood != $countTotal ] ; then |
---|
[1327] | 228 | if [ ${action} = true ] ; then |
---|
[785] | 229 | |
---|
[1327] | 230 | IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}" |
---|
| 231 | |
---|
| 232 | listVarEnv="DEBUG_debug,BigBrother,libIGCM,SUBMIT_DIR,POST_DIR,Script_Post_Output,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG" |
---|
| 233 | export DEBUG_debug=${DEBUG_debug} |
---|
| 234 | export BigBrother=${BigBrother} |
---|
| 235 | export libIGCM=${libIGCM} |
---|
| 236 | export SUBMIT_DIR=${CARD_DIR} |
---|
| 237 | export POST_DIR=${POST_DIR} |
---|
| 238 | export DateBegin=${an_deb} |
---|
| 239 | export PeriodDateEnd=${an_fin}1231 |
---|
| 240 | export RebuildFrequency=${RebuildFrequency} |
---|
| 241 | export RESOL_ATM=${RESOL_ATM} |
---|
| 242 | export RESOL_SRF=${RESOL_SRF} |
---|
| 243 | export RESOL_SBG=${RESOL_SBG} |
---|
| 244 | export RESOL_OCE=${RESOL_OCE} |
---|
| 245 | export RESOL_ICE=${RESOL_ICE} |
---|
| 246 | export RESOL_MBG=${RESOL_MBG} |
---|
| 247 | export listVarEnv=${listVarEnv} |
---|
| 248 | export Script_Post_Output=create_se.${PeriodDateEnd} |
---|
| 249 | |
---|
| 250 | IGCM_sys_MkdirWork ${POST_DIR} |
---|
| 251 | IGCM_debug_Verif_Exit |
---|
| 252 | IGCM_sys_QsubPost create_se |
---|
| 253 | echo |
---|
| 254 | else |
---|
| 255 | # only dry run |
---|
| 256 | IGCM_debug_Print 2 -e "\033[1;31mI should NOW Submit create_se \033[m for period ${an_deb}-${an_fin}" |
---|
| 257 | echo |
---|
| 258 | fi |
---|
| 259 | else |
---|
| 260 | IGCM_debug_Print 2 -e "\033[1;32mFiles are OK for period ${an_deb}-${an_fin}.\033[m Nothing needs to be done for this period." |
---|
| 261 | echo |
---|
[785] | 262 | fi |
---|
| 263 | |
---|
| 264 | (( an_deb = an_deb + freq )) |
---|
| 265 | (( an_fin = an_fin + freq )) |
---|
| 266 | |
---|
[385] | 267 | done # while |
---|