[2] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sebastien Denvil, Martial Mancip |
---|
[373] | 5 | # Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[2] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | #=================================== |
---|
| 15 | function IGCM_config_Initialize |
---|
| 16 | { |
---|
[544] | 17 | IGCM_debug_PushStack "IGCM_config_Initialize" |
---|
[2] | 18 | |
---|
[544] | 19 | # Debug Print : |
---|
| 20 | echo |
---|
| 21 | IGCM_debug_Print 1 "IGCM_config_Initialize" |
---|
[2] | 22 | |
---|
[544] | 23 | if [ ! -r ${SUBMIT_DIR}/run.card ]; then |
---|
| 24 | #================================================# |
---|
| 25 | # The file run.card doesn't exist # |
---|
| 26 | #================================================# |
---|
| 27 | FirstInitialize=true |
---|
| 28 | #copy initial run.card |
---|
| 29 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card |
---|
| 30 | IGCM_debug_Print 2 "run.card copied from run.card.init" |
---|
| 31 | else |
---|
| 32 | FirstInitialize=false |
---|
| 33 | IGCM_debug_Print 2 "run.card exists" |
---|
| 34 | fi |
---|
[443] | 35 | |
---|
[544] | 36 | # Test modipsl tree existence. |
---|
| 37 | IGCM_sys_TestDir ${MODIPSL} |
---|
| 38 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
| 39 | IGCM_sys_TestDir ${libIGCM} |
---|
| 40 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
| 41 | IGCM_sys_TestDir ${R_EXE} |
---|
| 42 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
| 43 | IGCM_sys_TestDir ${SUBMIT_DIR} |
---|
| 44 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir" |
---|
[2] | 45 | |
---|
[544] | 46 | if ( $DEBUG_debug ) ; then |
---|
| 47 | echo "Keep trace of inital SUBMIT_DIR : " |
---|
| 48 | ls -lta ${SUBMIT_DIR} |
---|
| 49 | fi |
---|
[144] | 50 | |
---|
[544] | 51 | #================================== |
---|
[2] | 52 | |
---|
[544] | 53 | typeset option auxprint CompatibilityTag |
---|
| 54 | # Read libIGCM compatibility version in config.card |
---|
| 55 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Compatibility libIGCM |
---|
| 56 | eval CompatibilityTag=${config_Compatibility_libIGCM} > /dev/null 2>&1 |
---|
[2] | 57 | |
---|
[544] | 58 | if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then |
---|
| 59 | IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ." |
---|
| 60 | fi |
---|
[2] | 61 | |
---|
[544] | 62 | #================================== |
---|
| 63 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices |
---|
[2] | 64 | |
---|
[544] | 65 | for option in ${config_UserChoices[*]} ; do |
---|
| 66 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} |
---|
| 67 | done |
---|
| 68 | echo |
---|
| 69 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
| 70 | # Name Space of this experience |
---|
| 71 | if [ X${config_UserChoices_SpaceName} != X ] ; then |
---|
| 72 | IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName |
---|
| 73 | fi |
---|
| 74 | # Expericence class of the run |
---|
| 75 | if [ X${config_UserChoices_ExperimentName} != X ] ; then |
---|
| 76 | IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName |
---|
| 77 | fi |
---|
| 78 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
| 79 | if [ 3 -le ${Verbosity} ] ; then |
---|
| 80 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
| 81 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
| 82 | fi |
---|
| 83 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
| 84 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
| 85 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
| 86 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
| 87 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
[2] | 88 | |
---|
[544] | 89 | #================================== |
---|
[2] | 90 | |
---|
[544] | 91 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents |
---|
| 92 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 93 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
| 94 | done |
---|
[2] | 95 | |
---|
[544] | 96 | echo |
---|
| 97 | IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
| 98 | IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
[2] | 99 | |
---|
[544] | 100 | NbComponents=${#config_ListOfComponents[*]} |
---|
[2] | 101 | |
---|
[544] | 102 | #================================== |
---|
| 103 | # Define principal executable |
---|
| 104 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Executable |
---|
| 105 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name |
---|
| 106 | |
---|
| 107 | #================================== |
---|
| 108 | # Define Outputs Name |
---|
| 109 | IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" |
---|
| 110 | eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} |
---|
| 111 | IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" |
---|
| 112 | eval Exe_Output=out_${config_Executable_Name} |
---|
| 113 | IGCM_debug_Print 3 "Exe_Output = ${Exe_Output}" |
---|
[2] | 114 | |
---|
[544] | 115 | #================================== |
---|
[2] | 116 | |
---|
[544] | 117 | #===================================================================# |
---|
| 118 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
| 119 | # But available to any son functions # |
---|
| 120 | #===================================================================# |
---|
[2] | 121 | |
---|
[544] | 122 | # Convert yyyy-mm-dd date to gregorian yyyymmdd |
---|
| 123 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
| 124 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
[2] | 125 | |
---|
[544] | 126 | # Period Length In Days between DateBegin and DateEnd |
---|
| 127 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
| 128 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
| 129 | IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
| 130 | IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." |
---|
| 131 | IGCM_debug_Verif_Exit |
---|
| 132 | fi |
---|
[2] | 133 | |
---|
[544] | 134 | # Day and Year of Initial State (Given in julian format) |
---|
| 135 | InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) |
---|
| 136 | InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) |
---|
[2] | 137 | |
---|
[544] | 138 | #================================== |
---|
| 139 | # Restarts : Gerneral rule or local for each component ? |
---|
| 140 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts |
---|
[2] | 141 | |
---|
[544] | 142 | echo |
---|
| 143 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" |
---|
[2] | 144 | |
---|
[544] | 145 | for option in ${config_Restarts[*]} ; do |
---|
| 146 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} |
---|
| 147 | eval auxprint=\${config_Restarts_${option}} |
---|
| 148 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
| 149 | done |
---|
[2] | 150 | |
---|
[544] | 151 | #================================================================# |
---|
| 152 | # Test and Prepare directories # |
---|
| 153 | #================================================================# |
---|
[2] | 154 | |
---|
[544] | 155 | # ==> 4 kinds of input files : |
---|
| 156 | # 1) R_INIT : Initial State Files (Etat0, carteveg) |
---|
| 157 | # 2) R_BC : Boundary Conditions (Forcages, lai) |
---|
| 158 | # 3) Parameters files (allready define through ${SUBMIT_DIR}) |
---|
| 159 | # 4) Restarts files (allready define in IGCM_config_Initialize) |
---|
[2] | 160 | |
---|
[544] | 161 | # Here we offer the possibility to redefine R_INIT, R_BC |
---|
| 162 | # and PeriodNb through config.card |
---|
| 163 | R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} |
---|
| 164 | IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" |
---|
| 165 | IGCM_debug_Print 3 "R_INIT=${R_INIT}" |
---|
| 166 | R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} |
---|
| 167 | IGCM_debug_Print 3 "R_BC=${R_BC}" |
---|
| 168 | PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} |
---|
| 169 | IGCM_debug_Print 3 "Loop in main Job with ${PeriodNb} period(s)" |
---|
[2] | 170 | |
---|
[544] | 171 | # Test Archive input/output. |
---|
| 172 | IGCM_sys_TestDirArchive ${ARCHIVE} |
---|
| 173 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 174 | IGCM_sys_TestDirArchive ${R_IN} |
---|
| 175 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
[2] | 176 | |
---|
[544] | 177 | #==================================================== |
---|
| 178 | #R_SAVE : Job output directory |
---|
| 179 | if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then |
---|
| 180 | FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) |
---|
| 181 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
[587] | 182 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
[544] | 183 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 184 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 185 | else |
---|
| 186 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
[587] | 187 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
[544] | 188 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 189 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 190 | fi |
---|
[2] | 191 | |
---|
[544] | 192 | if ( ${FirstInitialize} ) ; then |
---|
| 193 | IGCM_sys_MkdirArchive ${R_SAVE} |
---|
| 194 | IGCM_sys_Mkdir ${R_BUFR} |
---|
| 195 | else |
---|
| 196 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 197 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" |
---|
[2] | 198 | |
---|
[544] | 199 | IGCM_sys_TestDir ${R_BUFR} |
---|
| 200 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" |
---|
[545] | 201 | |
---|
[544] | 202 | #Test state of run in run.card |
---|
| 203 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 204 | |
---|
| 205 | if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 206 | echo |
---|
| 207 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 208 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 209 | IGCM_debug_Exit |
---|
| 210 | IGCM_debug_Verif_Exit |
---|
[2] | 211 | fi |
---|
[544] | 212 | fi |
---|
[2] | 213 | |
---|
[544] | 214 | #================================== |
---|
[554] | 215 | # Read Post section: |
---|
[544] | 216 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post |
---|
[146] | 217 | |
---|
[544] | 218 | echo |
---|
| 219 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" |
---|
[146] | 220 | |
---|
[544] | 221 | for option in ${config_Post[*]} ; do |
---|
| 222 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} |
---|
| 223 | eval auxprint=\${config_Post_${option}} |
---|
| 224 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
| 225 | done |
---|
[146] | 226 | |
---|
[554] | 227 | #================================== |
---|
| 228 | # Define default value to keep compatibility with previous card: means before changes due to TGCC |
---|
| 229 | [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} |
---|
| 230 | |
---|
[544] | 231 | #==================================================== |
---|
| 232 | # Define REBUILD_DIR : where we store files needing rebuild process |
---|
| 233 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
| 234 | REBUILD_DIR=${R_SAVE}/TMP |
---|
| 235 | IGCM_sys_MkdirArchive ${REBUILD_DIR} |
---|
| 236 | else |
---|
| 237 | REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 238 | IGCM_sys_MkdirWork ${REBUILD_DIR} |
---|
| 239 | fi |
---|
[146] | 240 | |
---|
[544] | 241 | #==================================================== |
---|
| 242 | # Experience type : DEB(ug), DEV(elopment), RUN |
---|
| 243 | if [ X${JobType} != XRUN ] ; then |
---|
| 244 | echo |
---|
| 245 | echo "====================================================" |
---|
| 246 | echo "libIGCM JOB is NOT in RUN type mode." |
---|
| 247 | echo "!! OUTPUT files will NOT be PROTECTED !!" |
---|
| 248 | echo "Be carefull : you can ERASE the result of this job !" |
---|
[128] | 249 | |
---|
[544] | 250 | case ${JobType} in |
---|
| 251 | DEB) |
---|
| 252 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
| 253 | echo "DEBUG mode : no protection for output files." |
---|
| 254 | echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 255 | ;; |
---|
| 256 | DEV) |
---|
| 257 | echo "DEVelopment mode : no protection for output files." |
---|
| 258 | echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 259 | ;; |
---|
| 260 | esac |
---|
[166] | 261 | |
---|
[544] | 262 | if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
| 263 | if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then |
---|
| 264 | echo "------------" |
---|
| 265 | echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" |
---|
| 266 | echo " to PeriodLength : ${config_UserChoices_PeriodLength}" |
---|
| 267 | echo "------------" |
---|
| 268 | config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} |
---|
| 269 | fi |
---|
[128] | 270 | fi |
---|
[544] | 271 | echo "====================================================" |
---|
| 272 | echo |
---|
| 273 | fi |
---|
[128] | 274 | |
---|
[544] | 275 | #==================================================== |
---|
| 276 | #R_OUT_KSH : Storage place for job output |
---|
| 277 | #R_OUT_EXE : Storage place for binary used during simulation |
---|
| 278 | R_OUT_KSH=${R_SAVE}/Out |
---|
| 279 | R_OUT_EXE=${R_SAVE}/Exe |
---|
[166] | 280 | |
---|
[544] | 281 | #==================================================== |
---|
| 282 | #R_BUF_KSH : Buffer place for job output |
---|
| 283 | #R_BUF_EXE : Buffer place for binary used during simulation |
---|
| 284 | R_BUF_KSH=${R_BUFR}/Out |
---|
| 285 | R_BUF_EXE=${R_BUFR}/Exe |
---|
| 286 | |
---|
| 287 | IGCM_debug_PopStack "IGCM_config_Initialize" |
---|
[2] | 288 | } |
---|
| 289 | |
---|
| 290 | #=================================== |
---|
[118] | 291 | function IGCM_config_Analyse_PeriodLength |
---|
| 292 | { |
---|
[544] | 293 | IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" |
---|
[118] | 294 | |
---|
[544] | 295 | typeset i |
---|
[124] | 296 | |
---|
[544] | 297 | # Determine number of day(s) in PeriodLength : |
---|
| 298 | case ${config_UserChoices_PeriodLength} in |
---|
| 299 | *Y|*y) |
---|
| 300 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) |
---|
| 301 | IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" |
---|
| 302 | PeriodLengthInDays=0 |
---|
| 303 | i=0 |
---|
| 304 | until [ $i -ge $PeriodLengthInYears ] ; do |
---|
| 305 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) |
---|
| 306 | (( i=i+1 )) |
---|
| 307 | done |
---|
| 308 | ;; |
---|
| 309 | *M|*m) |
---|
| 310 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) |
---|
| 311 | IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" |
---|
| 312 | PeriodLengthInDays=0 |
---|
| 313 | i=0 |
---|
| 314 | until [ $i -ge $PeriodLengthInMonths ] ; do |
---|
| 315 | if [ $(( month + i )) -lt 13 ] ; then |
---|
| 316 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) |
---|
| 317 | else |
---|
| 318 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) |
---|
| 319 | fi |
---|
| 320 | (( i=i+1 )) |
---|
| 321 | done |
---|
| 322 | ;; |
---|
| 323 | *D|*d) |
---|
| 324 | PeriodLengthInMonths=0 |
---|
| 325 | PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; |
---|
| 326 | *) |
---|
| 327 | IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." |
---|
| 328 | IGCM_debug_Verif_Exit ;; |
---|
| 329 | esac |
---|
[118] | 330 | |
---|
[544] | 331 | IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" |
---|
[380] | 332 | } |
---|
[118] | 333 | |
---|
[380] | 334 | #=================================== |
---|
| 335 | function IGCM_config_Check |
---|
| 336 | { |
---|
[544] | 337 | IGCM_debug_PushStack "IGCM_config_Check" |
---|
[380] | 338 | |
---|
[544] | 339 | # If one of the following modulo is not zero : |
---|
| 340 | # we will issue an error then explain and exit in |
---|
| 341 | # AA_job IGCM_debug_Verif_Exit call before binary submission |
---|
[380] | 342 | |
---|
[544] | 343 | echo |
---|
| 344 | IGCM_debug_Print 1 "IGCM_config_Check" |
---|
| 345 | echo |
---|
| 346 | |
---|
| 347 | typeset i |
---|
| 348 | |
---|
[554] | 349 | # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency |
---|
[545] | 350 | if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then |
---|
[544] | 351 | AsynchronousRebuild=true |
---|
| 352 | IGCM_debug_Print 1 "Asynchronous rebuild has been activated." |
---|
[380] | 353 | echo |
---|
[544] | 354 | # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
| 355 | IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" |
---|
| 356 | IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength |
---|
[554] | 357 | IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency" |
---|
| 358 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency |
---|
[544] | 359 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" |
---|
| 360 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency |
---|
| 361 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" |
---|
| 362 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency |
---|
| 363 | else |
---|
| 364 | AsynchronousRebuild=false |
---|
| 365 | IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" |
---|
| 366 | IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" |
---|
[380] | 367 | echo |
---|
[554] | 368 | #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
[544] | 369 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" |
---|
| 370 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength |
---|
| 371 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" |
---|
| 372 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength |
---|
| 373 | fi |
---|
[380] | 374 | |
---|
[554] | 375 | # Check PackFrequency against other key frequencies |
---|
| 376 | # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero |
---|
| 377 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
| 378 | Pack=true |
---|
| 379 | # |
---|
| 380 | IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength" |
---|
| 381 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength |
---|
| 382 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency" |
---|
| 383 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency |
---|
| 384 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency" |
---|
| 385 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency |
---|
| 386 | else |
---|
| 387 | Pack=false |
---|
| 388 | fi |
---|
| 389 | |
---|
[544] | 390 | #modulo (TimeSeriesFrequency and all Chunck2D) must be zero |
---|
| 391 | NbJob=${#CHUNCK2D_SIZE[@]} |
---|
| 392 | i=0 |
---|
| 393 | until [ $i -ge $NbJob ]; do |
---|
| 394 | value=${CHUNCK2D_SIZE[${i}]} |
---|
| 395 | IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" |
---|
| 396 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
| 397 | case ${value} in |
---|
| 398 | *Y|*y) ;; |
---|
| 399 | *) IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" |
---|
| 400 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 401 | esac |
---|
| 402 | (( i=i+1 )) |
---|
| 403 | done |
---|
[387] | 404 | |
---|
[544] | 405 | #modulo (TimeSeriesFrequency and all Chunck3D) must be zero |
---|
| 406 | NbJob=${#CHUNCK3D_SIZE[@]} |
---|
| 407 | i=0 |
---|
| 408 | until [ $i -ge $NbJob ]; do |
---|
| 409 | value=${CHUNCK3D_SIZE[${i}]} |
---|
| 410 | IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" |
---|
| 411 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
| 412 | case ${value} in |
---|
| 413 | *Y|*y) ;; |
---|
| 414 | *) IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" |
---|
| 415 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 416 | esac |
---|
| 417 | (( i=i+1 )) |
---|
| 418 | done |
---|
[380] | 419 | |
---|
[544] | 420 | IGCM_debug_PopStack "IGCM_config_Check" |
---|
[118] | 421 | } |
---|
| 422 | |
---|
| 423 | #=================================== |
---|
[2] | 424 | function IGCM_config_PeriodStart |
---|
| 425 | { |
---|
[544] | 426 | IGCM_debug_PushStack "IGCM_config_PeriodStart" |
---|
[2] | 427 | |
---|
[544] | 428 | echo |
---|
| 429 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" |
---|
| 430 | echo |
---|
[2] | 431 | |
---|
[544] | 432 | if ( ${FirstInitialize} ) ; then |
---|
| 433 | #================================================# |
---|
| 434 | # Initialize date/period information # |
---|
| 435 | #================================================# |
---|
[2] | 436 | |
---|
[544] | 437 | IGCM_date_GetYearMonthDay $DateBegin year month day |
---|
| 438 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 439 | |
---|
[544] | 440 | eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 |
---|
| 441 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
| 442 | eval CumulPeriod=1 > /dev/null 2>&1 |
---|
[2] | 443 | |
---|
[544] | 444 | #=================================================# |
---|
| 445 | # Write updated run.card # |
---|
| 446 | #=================================================# |
---|
[2] | 447 | |
---|
[544] | 448 | #Correct run.card Configuration for this period |
---|
| 449 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 450 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 451 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
| 452 | if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then |
---|
| 453 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} |
---|
| 454 | fi |
---|
[427] | 455 | |
---|
[544] | 456 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
| 457 | |
---|
| 458 | else |
---|
| 459 | #================================================# |
---|
| 460 | # The file run.card allready exist # |
---|
| 461 | #================================================# |
---|
[2] | 462 | |
---|
[544] | 463 | #Test state of run in run.card |
---|
| 464 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 465 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 466 | echo |
---|
| 467 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 468 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 469 | echo |
---|
| 470 | IGCM_debug_Exit |
---|
| 471 | IGCM_debug_Verif_Exit |
---|
| 472 | fi |
---|
[2] | 473 | |
---|
[544] | 474 | #===================================# |
---|
| 475 | # Read updated run.card # |
---|
| 476 | #===================================# |
---|
[2] | 477 | |
---|
[544] | 478 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
| 479 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 480 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 481 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
[2] | 482 | |
---|
[544] | 483 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
| 484 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
| 485 | eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 |
---|
[2] | 486 | |
---|
[544] | 487 | LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) |
---|
[471] | 488 | |
---|
[544] | 489 | typeset LastDate |
---|
| 490 | set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) |
---|
| 491 | LastYearDateEnd=${LastDate[0]} |
---|
| 492 | LastMonthDateEnd=${LastDate[1]} |
---|
| 493 | LastDayDateEnd=${LastDate[2]} |
---|
[471] | 494 | |
---|
[544] | 495 | if [ ${Period} = 1 ]; then |
---|
| 496 | # save last Job output |
---|
| 497 | typeset LastPeriod iLastPeriod Last_Script_Output_Name |
---|
| 498 | (( LastPeriod=CumulPeriod-PeriodNb )) |
---|
| 499 | iLastPeriod=$( printf "%06d" ${LastPeriod} ) |
---|
| 500 | Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" |
---|
| 501 | Last_run_card="run.card.${iLastPeriod}" |
---|
| 502 | #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} |
---|
| 503 | #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 |
---|
| 504 | IGCM_debug_Print 2 "Try to save previous ksh job output" |
---|
| 505 | IGCM_sys_Cd ${SUBMIT_DIR}/ |
---|
| 506 | IGCM_sys_PutBuffer_Out ${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name}.$$ rw |
---|
[471] | 507 | |
---|
[544] | 508 | IGCM_card_CheckConflict run.card |
---|
| 509 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/${Last_run_card}.$$ rw |
---|
[471] | 510 | |
---|
[544] | 511 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 512 | else |
---|
| 513 | unset FileToBeDeleted |
---|
| 514 | fi |
---|
[2] | 515 | |
---|
[544] | 516 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 517 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 518 | |
---|
[544] | 519 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
[2] | 520 | |
---|
[544] | 521 | fi |
---|
| 522 | OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} |
---|
[522] | 523 | |
---|
[544] | 524 | # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
| 525 | # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) |
---|
| 526 | year_m1=$(( year - 1 )) |
---|
| 527 | year_p1=$(( year + 1 )) |
---|
| 528 | # Compute month_m1 (month minus 1M) |
---|
| 529 | # Compute yyyymm_m1 (yyyymm minus 1M) |
---|
| 530 | month_m1=$(( month - 1 )) |
---|
| 531 | if [ ${month_m1} = 0 ]; then |
---|
| 532 | month_m1=12 |
---|
| 533 | yyyymm_m1=${year_m1}12 |
---|
| 534 | elif [ ${month_m1} -le 9 ]; then |
---|
| 535 | month_m1=0${month_m1} |
---|
| 536 | yyyymm_m1=${year}${month_m1} |
---|
| 537 | else |
---|
| 538 | yyyymm_m1=${year}${month_m1} |
---|
| 539 | fi |
---|
| 540 | # Compute month_p1 (month plus 1M) |
---|
| 541 | # Compute yyyymm_p1 (yyyymm plus 1M) |
---|
| 542 | month_p1=$(( month + 1 )) |
---|
| 543 | if [ ${month_p1} = 13 ]; then |
---|
| 544 | month_p1=01 |
---|
| 545 | yyyymm_p1=${year_p1}01 |
---|
| 546 | elif [ ${month_p1} -le 9 ]; then |
---|
| 547 | month_p1=0${month_p1} |
---|
| 548 | yyyymm_p1=${year}${month_p1} |
---|
| 549 | else |
---|
| 550 | yyyymm_p1=${year}${month_p1} |
---|
| 551 | fi |
---|
| 552 | #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " |
---|
| 553 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " |
---|
| 554 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " |
---|
[522] | 555 | |
---|
[544] | 556 | # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
[522] | 557 | |
---|
[544] | 558 | #===================================================================# |
---|
| 559 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
| 560 | # But available to any son functions # |
---|
| 561 | #===================================================================# |
---|
[2] | 562 | |
---|
[544] | 563 | # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) |
---|
| 564 | (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) |
---|
[2] | 565 | |
---|
[544] | 566 | # Debug Print : |
---|
| 567 | IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" |
---|
| 568 | IGCM_debug_Print 1 "Year of simulation : ${year}" |
---|
| 569 | IGCM_debug_Print 1 "Month of simulation : ${month}" |
---|
| 570 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
| 571 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 572 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 573 | IGCM_debug_Print 1 "SimulationLengthInDays : ${SimulationLengthInDays}" |
---|
| 574 | IGCM_debug_Print 1 "ExperienceLengthInDays : ${ExperienceLengthInDays}" |
---|
[2] | 575 | |
---|
[544] | 576 | #================================================================# |
---|
| 577 | # Prepare variables available for comp_finalyze # |
---|
| 578 | #================================================================# |
---|
[2] | 579 | |
---|
[544] | 580 | # Period for save files |
---|
| 581 | eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 |
---|
[2] | 582 | |
---|
[544] | 583 | # Prefix for save files of this period |
---|
| 584 | eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod} > /dev/null 2>&1 |
---|
[2] | 585 | |
---|
[544] | 586 | # List of files that will be deleted in RUN_DIR after run |
---|
| 587 | [ -f stack ] && FileToBeDeleted[0]="stack" |
---|
[2] | 588 | |
---|
[544] | 589 | # Test if the same run as already been saved : |
---|
| 590 | if [ X${JobType} = XRUN ] ; then |
---|
| 591 | if [ ${DRYRUN} -le 0 ] ; then |
---|
| 592 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
| 593 | IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." |
---|
| 594 | IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" |
---|
| 595 | IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " |
---|
| 596 | IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." |
---|
| 597 | IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." |
---|
| 598 | IGCM_debug_Verif_Exit |
---|
| 599 | fi |
---|
[2] | 600 | fi |
---|
[544] | 601 | else |
---|
| 602 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
| 603 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." |
---|
| 604 | fi |
---|
| 605 | fi |
---|
[128] | 606 | |
---|
[544] | 607 | ExecutionFail=false |
---|
[473] | 608 | |
---|
[544] | 609 | IGCM_debug_PopStack "IGCM_config_PeriodStart" |
---|
[2] | 610 | } |
---|
| 611 | |
---|
| 612 | #=================================== |
---|
[523] | 613 | function IGCM_config_SaveSourceModifications |
---|
| 614 | { |
---|
[544] | 615 | IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 616 | |
---|
[544] | 617 | typeset ExeOutDateMax listVarEnv |
---|
| 618 | ExeOutDateMax=$1 |
---|
[523] | 619 | |
---|
[544] | 620 | listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" |
---|
| 621 | IGCM_sys_RshMaster "\ |
---|
[545] | 622 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ |
---|
[544] | 623 | export ExeOutDateMax=${ExeOutDateMax};\ |
---|
[545] | 624 | export R_OUT_EXE=${R_OUT_EXE};\ |
---|
| 625 | export PREFIX=${PREFIX};\ |
---|
| 626 | export SUBMIT_DIR=${SUBMIT_DIR};\ |
---|
| 627 | export listVarEnv=${listVarEnv};\ |
---|
| 628 | Script_Output=out_SaveSourceModifications;\ |
---|
| 629 | IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" |
---|
[523] | 630 | |
---|
[544] | 631 | IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 632 | } |
---|
| 633 | |
---|
| 634 | #=================================== |
---|
[2] | 635 | function IGCM_config_PeriodEnd |
---|
| 636 | { |
---|
[544] | 637 | IGCM_debug_PushStack "IGCM_config_PeriodEnd" |
---|
[2] | 638 | |
---|
[544] | 639 | echo |
---|
| 640 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd" |
---|
| 641 | echo |
---|
[2] | 642 | |
---|
[544] | 643 | #==================================# |
---|
| 644 | # Save Job output # |
---|
| 645 | #==================================# |
---|
| 646 | IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} |
---|
| 647 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" |
---|
[471] | 648 | |
---|
[544] | 649 | IGCM_card_CheckConflict run.card |
---|
| 650 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw |
---|
[2] | 651 | |
---|
[544] | 652 | IGCM_debug_Print 1 "Check components binary : size and creation date" |
---|
[457] | 653 | |
---|
[544] | 654 | typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize |
---|
| 655 | typeset comp i |
---|
| 656 | typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax |
---|
[2] | 657 | |
---|
[544] | 658 | #==================================# |
---|
| 659 | # Get last Exe Size # |
---|
| 660 | #==================================# |
---|
[2] | 661 | |
---|
[544] | 662 | (( i=0 )) |
---|
| 663 | if ( ${FirstInitialize} ) ; then |
---|
[457] | 664 | run_Log_LastExeSize="" |
---|
| 665 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[544] | 666 | run_Log_LastExeSize[$i]=0 |
---|
| 667 | (( i=i+1 )) |
---|
[457] | 668 | done |
---|
[544] | 669 | else |
---|
[457] | 670 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize |
---|
[544] | 671 | fi |
---|
| 672 | #==================================# |
---|
| 673 | # And Build ExeDate # |
---|
| 674 | #==================================# |
---|
[2] | 675 | |
---|
[544] | 676 | # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33 |
---|
| 677 | # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M") |
---|
| 678 | # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34 |
---|
| 679 | ExeDate="" |
---|
| 680 | NextExeSize="( " |
---|
| 681 | (( i=0 )) |
---|
| 682 | UpdateExe=false |
---|
| 683 | (( ExeSecDateMax = 0 )) |
---|
| 684 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[2] | 685 | |
---|
[457] | 686 | IGCM_debug_Print 3 ${comp} |
---|
[2] | 687 | |
---|
| 688 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 689 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
[124] | 690 | # Only if we really have an executable for the component : |
---|
[2] | 691 | if [ X${ExeNameIn} = X\"\" ] ; then |
---|
[544] | 692 | # If there is no exe file for this component |
---|
| 693 | (( ExeSize=0 )) |
---|
[2] | 694 | else |
---|
[544] | 695 | eval LS_bin=${R_EXE}/${ExeNameIn} |
---|
| 696 | IGCM_sys_FileSize ${LS_bin} ExeSize |
---|
[2] | 697 | |
---|
[544] | 698 | set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) |
---|
| 699 | if [ X${ExeDate} = X ] ; then |
---|
| 700 | # First component exe date |
---|
| 701 | ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 702 | else |
---|
| 703 | ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 704 | fi |
---|
| 705 | ExeDate=${ExeDate}_${LS_comp[7]} |
---|
[2] | 706 | fi |
---|
| 707 | |
---|
| 708 | if [ ${i} -eq 0 ] ; then |
---|
[544] | 709 | # First component |
---|
| 710 | NextExeSize="( "${ExeSize} |
---|
[2] | 711 | else |
---|
[544] | 712 | NextExeSize=${NextExeSize}", "${ExeSize} |
---|
[2] | 713 | fi |
---|
| 714 | eval LastCompExeSize=${run_Log_LastExeSize[$i]} |
---|
| 715 | (( i=i+1 )) |
---|
| 716 | |
---|
[457] | 717 | if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then |
---|
[544] | 718 | if ( ${FirstInitialize} ) ; then |
---|
| 719 | IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 720 | else |
---|
| 721 | IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" |
---|
| 722 | IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 723 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} |
---|
| 724 | fi |
---|
| 725 | eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw |
---|
| 726 | UpdateExe=true |
---|
[523] | 727 | |
---|
[544] | 728 | IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate |
---|
| 729 | if [ $ExeSecDateMax -lt $ExeSecDate ] ; then |
---|
| 730 | ExeSecDateMax=$ExeSecDate |
---|
| 731 | fi |
---|
[2] | 732 | fi |
---|
[544] | 733 | done |
---|
[2] | 734 | |
---|
[544] | 735 | # SD : switch off for now |
---|
| 736 | # if ( ${UpdateExe} ) ; then |
---|
| 737 | # echo "Launch SaveSourceModifications." |
---|
| 738 | # IGCM_config_SaveSourceModifications ${ExeSecDateMax} |
---|
| 739 | # fi |
---|
[523] | 740 | |
---|
[544] | 741 | NextExeSize=${NextExeSize}" )" |
---|
| 742 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" |
---|
[457] | 743 | |
---|
[544] | 744 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[2] | 745 | tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt |
---|
[164] | 746 | ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) |
---|
[2] | 747 | RET=$? |
---|
[57] | 748 | if [ $RET -eq 0 ] ; then |
---|
[544] | 749 | # ExeCpuLog variable contents 5 fields |
---|
| 750 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" | \ |
---|
| 751 | gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ |
---|
| 752 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card |
---|
[2] | 753 | fi |
---|
| 754 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" |
---|
[544] | 755 | fi |
---|
[2] | 756 | |
---|
[544] | 757 | # All was right ? no ? then we stop. |
---|
| 758 | IGCM_debug_Verif_Exit |
---|
[2] | 759 | |
---|
[544] | 760 | # If all was OK, we can delete all files not necessary for next Job |
---|
| 761 | echo |
---|
| 762 | IGCM_debug_Print 1 "Files that will be deleted before next period-run : " |
---|
[2] | 763 | |
---|
[544] | 764 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[139] | 765 | for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done |
---|
[544] | 766 | else |
---|
[2] | 767 | echo ${FileToBeDeleted[@]} |
---|
[544] | 768 | fi |
---|
[2] | 769 | |
---|
[544] | 770 | #=================================================# |
---|
| 771 | # Modification of libIGCM behaviour # |
---|
| 772 | #=================================================# |
---|
[119] | 773 | |
---|
[544] | 774 | # To use this function, one must copy libIGCM.card from ${libIGCM} directory |
---|
| 775 | # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, |
---|
| 776 | # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. |
---|
| 777 | if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then |
---|
[119] | 778 | echo |
---|
| 779 | echo "########################################################################" |
---|
| 780 | echo "!!! Modification of libIGCM behaviour !!!" |
---|
| 781 | echo |
---|
| 782 | |
---|
| 783 | IGCM_debug_Print 1 "DefineArrayFromOption : libIGCM_UserChanges in libIGCM.card" |
---|
| 784 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges |
---|
| 785 | IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} |
---|
| 786 | |
---|
| 787 | # Special treatments for libIGCM internals |
---|
| 788 | for option in ${libIGCM_UserChanges[*]} ; do |
---|
[544] | 789 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} |
---|
[119] | 790 | |
---|
[544] | 791 | echo "We will change : ${option}." |
---|
| 792 | eval echo "Previous value : " \${${option}} |
---|
| 793 | eval echo "Change to : " \${libIGCM_UserChanges_${option}} |
---|
| 794 | |
---|
| 795 | eval ${option}=\${libIGCM_UserChanges_${option}} |
---|
[119] | 796 | |
---|
[544] | 797 | case ${option} in |
---|
| 798 | config_UserChoices_DateEnd) |
---|
| 799 | IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd |
---|
| 800 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
[119] | 801 | |
---|
[544] | 802 | # Period Length In Days between DateBegin and DateEnd |
---|
| 803 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
| 804 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
| 805 | IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
| 806 | IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." |
---|
| 807 | IGCM_debug_Verif_Exit |
---|
| 808 | fi |
---|
| 809 | ;; |
---|
| 810 | config_UserChoices_PeriodLength) |
---|
| 811 | IGCM_debug_Print 1 "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" |
---|
| 812 | ;; |
---|
| 813 | PeriodNb) |
---|
| 814 | IGCM_debug_Print 1 "Loop in main Job with ${PeriodNb} period(s)" |
---|
| 815 | ;; |
---|
| 816 | config_Post_RebuildFrequency) |
---|
| 817 | IGCM_debug_Print 1 "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" |
---|
| 818 | IGCM_post_Configure |
---|
| 819 | ;; |
---|
| 820 | config_Post_TimeSeriesFrequency) |
---|
| 821 | IGCM_debug_Print 1 "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" |
---|
| 822 | IGCM_post_Configure |
---|
| 823 | ;; |
---|
| 824 | config_Post_SeasonalFrequency) |
---|
| 825 | IGCM_debug_Print 1 "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" |
---|
| 826 | IGCM_post_Configure |
---|
| 827 | ;; |
---|
| 828 | esac |
---|
| 829 | done |
---|
[119] | 830 | |
---|
[544] | 831 | echo |
---|
| 832 | echo "########################################################################" |
---|
| 833 | echo |
---|
| 834 | fi |
---|
[119] | 835 | |
---|
[544] | 836 | #=================================================# |
---|
| 837 | # Determine next computed period # |
---|
| 838 | #=================================================# |
---|
[2] | 839 | |
---|
[544] | 840 | PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) |
---|
| 841 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 842 | year_m1=$(( year - 1 )) |
---|
| 843 | year_p1=$(( year + 1 )) |
---|
| 844 | IGCM_config_Analyse_PeriodLength |
---|
| 845 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
[2] | 846 | |
---|
[544] | 847 | # Debug Print : |
---|
| 848 | echo |
---|
| 849 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" |
---|
| 850 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 851 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 852 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
[2] | 853 | |
---|
[544] | 854 | PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
| 855 | PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
[2] | 856 | |
---|
[544] | 857 | (( CumulPeriod = CumulPeriod + 1 )) |
---|
[2] | 858 | |
---|
[544] | 859 | # Debug Print : |
---|
| 860 | echo |
---|
| 861 | IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" |
---|
| 862 | IGCM_debug_Print 3 "PeriodDateEnd Human : ${PeriodDateEnd}" |
---|
| 863 | IGCM_debug_Print 3 "CumulPeriod : ${CumulPeriod}" |
---|
[2] | 864 | |
---|
[544] | 865 | #=================================================# |
---|
| 866 | # Write updated run.card # |
---|
| 867 | #=================================================# |
---|
[2] | 868 | |
---|
[544] | 869 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} |
---|
| 870 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 871 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 872 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
[2] | 873 | |
---|
[544] | 874 | if ( ${FirstInitialize} ) ; then |
---|
| 875 | # It's no more the first time |
---|
| 876 | FirstInitialize=false |
---|
| 877 | fi |
---|
[446] | 878 | |
---|
[544] | 879 | IGCM_debug_PopStack "IGCM_config_PeriodEnd" |
---|
[2] | 880 | } |
---|
| 881 | |
---|
| 882 | #=================================== |
---|
| 883 | function IGCM_config_Finalize |
---|
| 884 | { |
---|
[544] | 885 | IGCM_debug_PushStack "IGCM_config_Finalize" |
---|
[2] | 886 | |
---|
[544] | 887 | echo |
---|
| 888 | IGCM_debug_Print 1 "IGCM_config_Finalize" |
---|
| 889 | echo |
---|
[2] | 890 | |
---|
[544] | 891 | if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then |
---|
| 892 | #==========================# |
---|
| 893 | # End of entire simulation # |
---|
| 894 | #==========================# |
---|
[2] | 895 | |
---|
[544] | 896 | # Mail notification |
---|
| 897 | IGCM_sys_SendMail |
---|
[2] | 898 | |
---|
[544] | 899 | # |
---|
| 900 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" |
---|
| 901 | IGCM_debug_Print 1 "Normal End of computation." |
---|
| 902 | if ( $DEBUG_debug ) ; then |
---|
| 903 | echo |
---|
| 904 | IGCM_debug_Print 1 "Your files on ${R_SAVE} :" |
---|
| 905 | IGCM_sys_Tree ${R_SAVE} |
---|
[2] | 906 | |
---|
[544] | 907 | IGCM_debug_Print 1 "Your files on ${R_BUFR} :" |
---|
| 908 | IGCM_sys_Tree ${R_BUFR} |
---|
| 909 | fi |
---|
| 910 | else |
---|
| 911 | #=================# |
---|
| 912 | # Submit next job # |
---|
| 913 | #=================# |
---|
[2] | 914 | |
---|
[544] | 915 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
[2] | 916 | |
---|
[544] | 917 | # Name of next Ksh Script output : |
---|
| 918 | eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" |
---|
[2] | 919 | |
---|
[544] | 920 | IGCM_debug_Print 1 "Submit next job" |
---|
| 921 | # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR |
---|
| 922 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 923 | # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
| 924 | ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) |
---|
| 925 | [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) |
---|
| 926 | # Submit next job and come back |
---|
| 927 | IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} |
---|
| 928 | IGCM_sys_Cd - |
---|
| 929 | fi |
---|
[154] | 930 | |
---|
[544] | 931 | # Supress Non Deleted Boundary files |
---|
| 932 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 933 | IGCM_comp_DelFixeBoundaryFiles |
---|
| 934 | ls -la |
---|
| 935 | fi |
---|
| 936 | |
---|
| 937 | # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 938 | # Only for production run (No clean up in DEV or DEB mode) |
---|
| 939 | # and command sent from .. directory. |
---|
| 940 | IGCM_sys_Cd .. |
---|
| 941 | [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 942 | |
---|
| 943 | IGCM_debug_PopStack "IGCM_config_Finalize" |
---|
[2] | 944 | } |
---|
| 945 | |
---|
| 946 | #=================================== |
---|