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