[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} |
---|
| 182 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 183 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 184 | else |
---|
| 185 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 186 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 187 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 188 | fi |
---|
[2] | 189 | |
---|
[544] | 190 | if ( ${FirstInitialize} ) ; then |
---|
| 191 | IGCM_sys_MkdirArchive ${R_SAVE} |
---|
| 192 | IGCM_sys_Mkdir ${R_BUFR} |
---|
| 193 | else |
---|
| 194 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 195 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" |
---|
[2] | 196 | |
---|
[544] | 197 | IGCM_sys_TestDir ${R_BUFR} |
---|
| 198 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" |
---|
| 199 | #Test state of run in run.card |
---|
| 200 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 201 | |
---|
| 202 | if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 203 | echo |
---|
| 204 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 205 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 206 | IGCM_debug_Exit |
---|
| 207 | IGCM_debug_Verif_Exit |
---|
[2] | 208 | fi |
---|
[544] | 209 | fi |
---|
[2] | 210 | |
---|
[544] | 211 | #================================== |
---|
| 212 | # Post : |
---|
| 213 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post |
---|
[146] | 214 | |
---|
[544] | 215 | echo |
---|
| 216 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" |
---|
[146] | 217 | |
---|
[544] | 218 | for option in ${config_Post[*]} ; do |
---|
| 219 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} |
---|
| 220 | eval auxprint=\${config_Post_${option}} |
---|
| 221 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
| 222 | done |
---|
[146] | 223 | |
---|
[544] | 224 | #==================================================== |
---|
| 225 | # Define REBUILD_DIR : where we store files needing rebuild process |
---|
| 226 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
| 227 | REBUILD_DIR=${R_SAVE}/TMP |
---|
| 228 | IGCM_sys_MkdirArchive ${REBUILD_DIR} |
---|
| 229 | else |
---|
| 230 | REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 231 | IGCM_sys_MkdirWork ${REBUILD_DIR} |
---|
| 232 | fi |
---|
[146] | 233 | |
---|
[544] | 234 | #==================================================== |
---|
| 235 | # Experience type : DEB(ug), DEV(elopment), RUN |
---|
| 236 | if [ X${JobType} != XRUN ] ; then |
---|
| 237 | echo |
---|
| 238 | echo "====================================================" |
---|
| 239 | echo "libIGCM JOB is NOT in RUN type mode." |
---|
| 240 | echo "!! OUTPUT files will NOT be PROTECTED !!" |
---|
| 241 | echo "Be carefull : you can ERASE the result of this job !" |
---|
[128] | 242 | |
---|
[544] | 243 | case ${JobType} in |
---|
| 244 | DEB) |
---|
| 245 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
| 246 | echo "DEBUG mode : no protection for output files." |
---|
| 247 | echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 248 | ;; |
---|
| 249 | DEV) |
---|
| 250 | echo "DEVelopment mode : no protection for output files." |
---|
| 251 | echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 252 | ;; |
---|
| 253 | esac |
---|
[166] | 254 | |
---|
[544] | 255 | if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
| 256 | if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then |
---|
| 257 | echo "------------" |
---|
| 258 | echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" |
---|
| 259 | echo " to PeriodLength : ${config_UserChoices_PeriodLength}" |
---|
| 260 | echo "------------" |
---|
| 261 | config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} |
---|
| 262 | fi |
---|
[128] | 263 | fi |
---|
[544] | 264 | echo "====================================================" |
---|
| 265 | echo |
---|
| 266 | fi |
---|
[128] | 267 | |
---|
[544] | 268 | #==================================================== |
---|
| 269 | #R_OUT_KSH : Storage place for job output |
---|
| 270 | #R_OUT_EXE : Storage place for binary used during simulation |
---|
| 271 | R_OUT_KSH=${R_SAVE}/Out |
---|
| 272 | R_OUT_EXE=${R_SAVE}/Exe |
---|
[166] | 273 | |
---|
[544] | 274 | #==================================================== |
---|
| 275 | #R_BUF_KSH : Buffer place for job output |
---|
| 276 | #R_BUF_EXE : Buffer place for binary used during simulation |
---|
| 277 | R_BUF_KSH=${R_BUFR}/Out |
---|
| 278 | R_BUF_EXE=${R_BUFR}/Exe |
---|
| 279 | |
---|
| 280 | IGCM_debug_PopStack "IGCM_config_Initialize" |
---|
[2] | 281 | } |
---|
| 282 | |
---|
| 283 | #=================================== |
---|
[118] | 284 | function IGCM_config_Analyse_PeriodLength |
---|
| 285 | { |
---|
[544] | 286 | IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" |
---|
[118] | 287 | |
---|
[544] | 288 | typeset i |
---|
[124] | 289 | |
---|
[544] | 290 | # Determine number of day(s) in PeriodLength : |
---|
| 291 | case ${config_UserChoices_PeriodLength} in |
---|
| 292 | *Y|*y) |
---|
| 293 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) |
---|
| 294 | IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" |
---|
| 295 | PeriodLengthInDays=0 |
---|
| 296 | i=0 |
---|
| 297 | until [ $i -ge $PeriodLengthInYears ] ; do |
---|
| 298 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) |
---|
| 299 | (( i=i+1 )) |
---|
| 300 | done |
---|
| 301 | ;; |
---|
| 302 | *M|*m) |
---|
| 303 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) |
---|
| 304 | IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" |
---|
| 305 | PeriodLengthInDays=0 |
---|
| 306 | i=0 |
---|
| 307 | until [ $i -ge $PeriodLengthInMonths ] ; do |
---|
| 308 | if [ $(( month + i )) -lt 13 ] ; then |
---|
| 309 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) |
---|
| 310 | else |
---|
| 311 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) |
---|
| 312 | fi |
---|
| 313 | (( i=i+1 )) |
---|
| 314 | done |
---|
| 315 | ;; |
---|
| 316 | *D|*d) |
---|
| 317 | PeriodLengthInMonths=0 |
---|
| 318 | PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; |
---|
| 319 | *) |
---|
| 320 | IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." |
---|
| 321 | IGCM_debug_Verif_Exit ;; |
---|
| 322 | esac |
---|
[118] | 323 | |
---|
[544] | 324 | IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" |
---|
[380] | 325 | } |
---|
[118] | 326 | |
---|
[380] | 327 | #=================================== |
---|
| 328 | function IGCM_config_Check |
---|
| 329 | { |
---|
[544] | 330 | IGCM_debug_PushStack "IGCM_config_Check" |
---|
[380] | 331 | |
---|
[544] | 332 | # If one of the following modulo is not zero : |
---|
| 333 | # we will issue an error then explain and exit in |
---|
| 334 | # AA_job IGCM_debug_Verif_Exit call before binary submission |
---|
[380] | 335 | |
---|
[544] | 336 | echo |
---|
| 337 | IGCM_debug_Print 1 "IGCM_config_Check" |
---|
| 338 | echo |
---|
| 339 | |
---|
| 340 | typeset i |
---|
| 341 | |
---|
| 342 | if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then |
---|
| 343 | AsynchronousRebuild=true |
---|
| 344 | IGCM_debug_Print 1 "Asynchronous rebuild has been activated." |
---|
[380] | 345 | echo |
---|
[544] | 346 | # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
| 347 | IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" |
---|
| 348 | IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength |
---|
| 349 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" |
---|
| 350 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency |
---|
| 351 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" |
---|
| 352 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency |
---|
| 353 | else |
---|
| 354 | AsynchronousRebuild=false |
---|
| 355 | IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" |
---|
| 356 | IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" |
---|
[380] | 357 | echo |
---|
[544] | 358 | #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero |
---|
| 359 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" |
---|
| 360 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength |
---|
| 361 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" |
---|
| 362 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength |
---|
| 363 | fi |
---|
[380] | 364 | |
---|
[544] | 365 | #modulo (TimeSeriesFrequency and all Chunck2D) must be zero |
---|
| 366 | NbJob=${#CHUNCK2D_SIZE[@]} |
---|
| 367 | i=0 |
---|
| 368 | until [ $i -ge $NbJob ]; do |
---|
| 369 | value=${CHUNCK2D_SIZE[${i}]} |
---|
| 370 | IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" |
---|
| 371 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
| 372 | case ${value} in |
---|
| 373 | *Y|*y) ;; |
---|
| 374 | *) IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" |
---|
| 375 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 376 | esac |
---|
| 377 | (( i=i+1 )) |
---|
| 378 | done |
---|
[387] | 379 | |
---|
[544] | 380 | #modulo (TimeSeriesFrequency and all Chunck3D) must be zero |
---|
| 381 | NbJob=${#CHUNCK3D_SIZE[@]} |
---|
| 382 | i=0 |
---|
| 383 | until [ $i -ge $NbJob ]; do |
---|
| 384 | value=${CHUNCK3D_SIZE[${i}]} |
---|
| 385 | IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" |
---|
| 386 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
| 387 | case ${value} in |
---|
| 388 | *Y|*y) ;; |
---|
| 389 | *) IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" |
---|
| 390 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 391 | esac |
---|
| 392 | (( i=i+1 )) |
---|
| 393 | done |
---|
[380] | 394 | |
---|
[544] | 395 | IGCM_debug_PopStack "IGCM_config_Check" |
---|
[118] | 396 | } |
---|
| 397 | |
---|
| 398 | #=================================== |
---|
[2] | 399 | function IGCM_config_PeriodStart |
---|
| 400 | { |
---|
[544] | 401 | IGCM_debug_PushStack "IGCM_config_PeriodStart" |
---|
[2] | 402 | |
---|
[544] | 403 | echo |
---|
| 404 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" |
---|
| 405 | echo |
---|
[2] | 406 | |
---|
[544] | 407 | if ( ${FirstInitialize} ) ; then |
---|
| 408 | #================================================# |
---|
| 409 | # Initialize date/period information # |
---|
| 410 | #================================================# |
---|
[2] | 411 | |
---|
[544] | 412 | IGCM_date_GetYearMonthDay $DateBegin year month day |
---|
| 413 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 414 | |
---|
[544] | 415 | eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 |
---|
| 416 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
| 417 | eval CumulPeriod=1 > /dev/null 2>&1 |
---|
[2] | 418 | |
---|
[544] | 419 | #=================================================# |
---|
| 420 | # Write updated run.card # |
---|
| 421 | #=================================================# |
---|
[2] | 422 | |
---|
[544] | 423 | #Correct run.card Configuration for this period |
---|
| 424 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 425 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 426 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
| 427 | if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then |
---|
| 428 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} |
---|
| 429 | fi |
---|
[427] | 430 | |
---|
[544] | 431 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
| 432 | |
---|
| 433 | else |
---|
| 434 | #================================================# |
---|
| 435 | # The file run.card allready exist # |
---|
| 436 | #================================================# |
---|
[2] | 437 | |
---|
[544] | 438 | #Test state of run in run.card |
---|
| 439 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 440 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
| 441 | echo |
---|
| 442 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 443 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 444 | echo |
---|
| 445 | IGCM_debug_Exit |
---|
| 446 | IGCM_debug_Verif_Exit |
---|
| 447 | fi |
---|
[2] | 448 | |
---|
[544] | 449 | #===================================# |
---|
| 450 | # Read updated run.card # |
---|
| 451 | #===================================# |
---|
[2] | 452 | |
---|
[544] | 453 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
| 454 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 455 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 456 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
[2] | 457 | |
---|
[544] | 458 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
| 459 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
| 460 | eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 |
---|
[2] | 461 | |
---|
[544] | 462 | LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) |
---|
[471] | 463 | |
---|
[544] | 464 | typeset LastDate |
---|
| 465 | set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) |
---|
| 466 | LastYearDateEnd=${LastDate[0]} |
---|
| 467 | LastMonthDateEnd=${LastDate[1]} |
---|
| 468 | LastDayDateEnd=${LastDate[2]} |
---|
[471] | 469 | |
---|
[544] | 470 | if [ ${Period} = 1 ]; then |
---|
| 471 | # save last Job output |
---|
| 472 | typeset LastPeriod iLastPeriod Last_Script_Output_Name |
---|
| 473 | (( LastPeriod=CumulPeriod-PeriodNb )) |
---|
| 474 | iLastPeriod=$( printf "%06d" ${LastPeriod} ) |
---|
| 475 | Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" |
---|
| 476 | Last_run_card="run.card.${iLastPeriod}" |
---|
| 477 | #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} |
---|
| 478 | #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 |
---|
| 479 | IGCM_debug_Print 2 "Try to save previous ksh job output" |
---|
| 480 | IGCM_sys_Cd ${SUBMIT_DIR}/ |
---|
| 481 | IGCM_sys_PutBuffer_Out ${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name}.$$ rw |
---|
[471] | 482 | |
---|
[544] | 483 | IGCM_card_CheckConflict run.card |
---|
| 484 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/${Last_run_card}.$$ rw |
---|
[471] | 485 | |
---|
[544] | 486 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 487 | else |
---|
| 488 | unset FileToBeDeleted |
---|
| 489 | fi |
---|
[2] | 490 | |
---|
[544] | 491 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 492 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 493 | |
---|
[544] | 494 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
[2] | 495 | |
---|
[544] | 496 | fi |
---|
| 497 | OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} |
---|
[522] | 498 | |
---|
[544] | 499 | # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
| 500 | # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) |
---|
| 501 | year_m1=$(( year - 1 )) |
---|
| 502 | year_p1=$(( year + 1 )) |
---|
| 503 | # Compute month_m1 (month minus 1M) |
---|
| 504 | # Compute yyyymm_m1 (yyyymm minus 1M) |
---|
| 505 | month_m1=$(( month - 1 )) |
---|
| 506 | if [ ${month_m1} = 0 ]; then |
---|
| 507 | month_m1=12 |
---|
| 508 | yyyymm_m1=${year_m1}12 |
---|
| 509 | elif [ ${month_m1} -le 9 ]; then |
---|
| 510 | month_m1=0${month_m1} |
---|
| 511 | yyyymm_m1=${year}${month_m1} |
---|
| 512 | else |
---|
| 513 | yyyymm_m1=${year}${month_m1} |
---|
| 514 | fi |
---|
| 515 | # Compute month_p1 (month plus 1M) |
---|
| 516 | # Compute yyyymm_p1 (yyyymm plus 1M) |
---|
| 517 | month_p1=$(( month + 1 )) |
---|
| 518 | if [ ${month_p1} = 13 ]; then |
---|
| 519 | month_p1=01 |
---|
| 520 | yyyymm_p1=${year_p1}01 |
---|
| 521 | elif [ ${month_p1} -le 9 ]; then |
---|
| 522 | month_p1=0${month_p1} |
---|
| 523 | yyyymm_p1=${year}${month_p1} |
---|
| 524 | else |
---|
| 525 | yyyymm_p1=${year}${month_p1} |
---|
| 526 | fi |
---|
| 527 | #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " |
---|
| 528 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " |
---|
| 529 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " |
---|
[522] | 530 | |
---|
[544] | 531 | # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
[522] | 532 | |
---|
[544] | 533 | #===================================================================# |
---|
| 534 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
| 535 | # But available to any son functions # |
---|
| 536 | #===================================================================# |
---|
[2] | 537 | |
---|
[544] | 538 | # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) |
---|
| 539 | (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) |
---|
[2] | 540 | |
---|
[544] | 541 | # Debug Print : |
---|
| 542 | IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" |
---|
| 543 | IGCM_debug_Print 1 "Year of simulation : ${year}" |
---|
| 544 | IGCM_debug_Print 1 "Month of simulation : ${month}" |
---|
| 545 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
| 546 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 547 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 548 | IGCM_debug_Print 1 "SimulationLengthInDays : ${SimulationLengthInDays}" |
---|
| 549 | IGCM_debug_Print 1 "ExperienceLengthInDays : ${ExperienceLengthInDays}" |
---|
[2] | 550 | |
---|
[544] | 551 | #================================================================# |
---|
| 552 | # Prepare variables available for comp_finalyze # |
---|
| 553 | #================================================================# |
---|
[2] | 554 | |
---|
[544] | 555 | # Period for save files |
---|
| 556 | eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 |
---|
[2] | 557 | |
---|
[544] | 558 | # Prefix for save files of this period |
---|
| 559 | eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod} > /dev/null 2>&1 |
---|
[2] | 560 | |
---|
[544] | 561 | # List of files that will be deleted in RUN_DIR after run |
---|
| 562 | [ -f stack ] && FileToBeDeleted[0]="stack" |
---|
[2] | 563 | |
---|
[544] | 564 | # Test if the same run as already been saved : |
---|
| 565 | if [ X${JobType} = XRUN ] ; then |
---|
| 566 | if [ ${DRYRUN} -le 0 ] ; then |
---|
| 567 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
| 568 | IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." |
---|
| 569 | IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" |
---|
| 570 | IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " |
---|
| 571 | IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." |
---|
| 572 | IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." |
---|
| 573 | IGCM_debug_Verif_Exit |
---|
| 574 | fi |
---|
[2] | 575 | fi |
---|
[544] | 576 | else |
---|
| 577 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
| 578 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." |
---|
| 579 | fi |
---|
| 580 | fi |
---|
[128] | 581 | |
---|
[544] | 582 | ExecutionFail=false |
---|
[473] | 583 | |
---|
[544] | 584 | IGCM_debug_PopStack "IGCM_config_PeriodStart" |
---|
[2] | 585 | } |
---|
| 586 | |
---|
| 587 | #=================================== |
---|
[523] | 588 | function IGCM_config_SaveSourceModifications |
---|
| 589 | { |
---|
[544] | 590 | IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 591 | |
---|
[544] | 592 | typeset ExeOutDateMax listVarEnv |
---|
| 593 | ExeOutDateMax=$1 |
---|
[523] | 594 | |
---|
[544] | 595 | listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" |
---|
| 596 | IGCM_sys_RshMaster "\ |
---|
[529] | 597 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ |
---|
[544] | 598 | export ExeOutDateMax=${ExeOutDateMax};\ |
---|
[523] | 599 | export R_OUT_EXE=${R_OUT_EXE};\ |
---|
| 600 | export PREFIX=${PREFIX};\ |
---|
| 601 | export SUBMIT_DIR=${SUBMIT_DIR};\ |
---|
| 602 | export listVarEnv=${listVarEnv};\ |
---|
| 603 | Script_Output=out_SaveSourceModifications;\ |
---|
[529] | 604 | IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" |
---|
[523] | 605 | |
---|
[544] | 606 | IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 607 | } |
---|
| 608 | |
---|
| 609 | #=================================== |
---|
[2] | 610 | function IGCM_config_PeriodEnd |
---|
| 611 | { |
---|
[544] | 612 | IGCM_debug_PushStack "IGCM_config_PeriodEnd" |
---|
[2] | 613 | |
---|
[544] | 614 | echo |
---|
| 615 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd" |
---|
| 616 | echo |
---|
[2] | 617 | |
---|
[544] | 618 | #==================================# |
---|
| 619 | # Save Job output # |
---|
| 620 | #==================================# |
---|
| 621 | IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} |
---|
| 622 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" |
---|
[471] | 623 | |
---|
[544] | 624 | IGCM_card_CheckConflict run.card |
---|
| 625 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw |
---|
[2] | 626 | |
---|
[544] | 627 | IGCM_debug_Print 1 "Check components binary : size and creation date" |
---|
[457] | 628 | |
---|
[544] | 629 | typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize |
---|
| 630 | typeset comp i |
---|
| 631 | typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax |
---|
[2] | 632 | |
---|
[544] | 633 | #==================================# |
---|
| 634 | # Get last Exe Size # |
---|
| 635 | #==================================# |
---|
[2] | 636 | |
---|
[544] | 637 | (( i=0 )) |
---|
| 638 | if ( ${FirstInitialize} ) ; then |
---|
[457] | 639 | run_Log_LastExeSize="" |
---|
| 640 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[544] | 641 | run_Log_LastExeSize[$i]=0 |
---|
| 642 | (( i=i+1 )) |
---|
[457] | 643 | done |
---|
[544] | 644 | else |
---|
[457] | 645 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize |
---|
[544] | 646 | fi |
---|
| 647 | #==================================# |
---|
| 648 | # And Build ExeDate # |
---|
| 649 | #==================================# |
---|
[2] | 650 | |
---|
[544] | 651 | # 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 |
---|
| 652 | # 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") |
---|
| 653 | # 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 |
---|
| 654 | ExeDate="" |
---|
| 655 | NextExeSize="( " |
---|
| 656 | (( i=0 )) |
---|
| 657 | UpdateExe=false |
---|
| 658 | (( ExeSecDateMax = 0 )) |
---|
| 659 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[2] | 660 | |
---|
[457] | 661 | IGCM_debug_Print 3 ${comp} |
---|
[2] | 662 | |
---|
| 663 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 664 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
[124] | 665 | # Only if we really have an executable for the component : |
---|
[2] | 666 | if [ X${ExeNameIn} = X\"\" ] ; then |
---|
[544] | 667 | # If there is no exe file for this component |
---|
| 668 | (( ExeSize=0 )) |
---|
[2] | 669 | else |
---|
[544] | 670 | eval LS_bin=${R_EXE}/${ExeNameIn} |
---|
| 671 | IGCM_sys_FileSize ${LS_bin} ExeSize |
---|
[2] | 672 | |
---|
[544] | 673 | set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) |
---|
| 674 | if [ X${ExeDate} = X ] ; then |
---|
| 675 | # First component exe date |
---|
| 676 | ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 677 | else |
---|
| 678 | ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 679 | fi |
---|
| 680 | ExeDate=${ExeDate}_${LS_comp[7]} |
---|
[2] | 681 | fi |
---|
| 682 | |
---|
| 683 | if [ ${i} -eq 0 ] ; then |
---|
[544] | 684 | # First component |
---|
| 685 | NextExeSize="( "${ExeSize} |
---|
[2] | 686 | else |
---|
[544] | 687 | NextExeSize=${NextExeSize}", "${ExeSize} |
---|
[2] | 688 | fi |
---|
| 689 | eval LastCompExeSize=${run_Log_LastExeSize[$i]} |
---|
| 690 | (( i=i+1 )) |
---|
| 691 | |
---|
[457] | 692 | if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then |
---|
[544] | 693 | if ( ${FirstInitialize} ) ; then |
---|
| 694 | IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 695 | else |
---|
| 696 | IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" |
---|
| 697 | IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 698 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} |
---|
| 699 | fi |
---|
| 700 | eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw |
---|
| 701 | UpdateExe=true |
---|
[523] | 702 | |
---|
[544] | 703 | IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate |
---|
| 704 | if [ $ExeSecDateMax -lt $ExeSecDate ] ; then |
---|
| 705 | ExeSecDateMax=$ExeSecDate |
---|
| 706 | fi |
---|
[2] | 707 | fi |
---|
[544] | 708 | done |
---|
[2] | 709 | |
---|
[544] | 710 | # SD : switch off for now |
---|
| 711 | # if ( ${UpdateExe} ) ; then |
---|
| 712 | # echo "Launch SaveSourceModifications." |
---|
| 713 | # IGCM_config_SaveSourceModifications ${ExeSecDateMax} |
---|
| 714 | # fi |
---|
[523] | 715 | |
---|
[544] | 716 | NextExeSize=${NextExeSize}" )" |
---|
| 717 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" |
---|
[457] | 718 | |
---|
[544] | 719 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[2] | 720 | tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt |
---|
[164] | 721 | ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) |
---|
[2] | 722 | RET=$? |
---|
[57] | 723 | if [ $RET -eq 0 ] ; then |
---|
[544] | 724 | # ExeCpuLog variable contents 5 fields |
---|
| 725 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" | \ |
---|
| 726 | gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ |
---|
| 727 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card |
---|
[2] | 728 | fi |
---|
| 729 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" |
---|
[544] | 730 | fi |
---|
[2] | 731 | |
---|
[544] | 732 | # All was right ? no ? then we stop. |
---|
| 733 | IGCM_debug_Verif_Exit |
---|
[2] | 734 | |
---|
[544] | 735 | # If all was OK, we can delete all files not necessary for next Job |
---|
| 736 | echo |
---|
| 737 | IGCM_debug_Print 1 "Files that will be deleted before next period-run : " |
---|
[2] | 738 | |
---|
[544] | 739 | if [ ${DRYRUN} -le 2 ] ; then |
---|
[139] | 740 | for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done |
---|
[544] | 741 | else |
---|
[2] | 742 | echo ${FileToBeDeleted[@]} |
---|
[544] | 743 | fi |
---|
[2] | 744 | |
---|
[544] | 745 | #=================================================# |
---|
| 746 | # Modification of libIGCM behaviour # |
---|
| 747 | #=================================================# |
---|
[119] | 748 | |
---|
[544] | 749 | # To use this function, one must copy libIGCM.card from ${libIGCM} directory |
---|
| 750 | # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, |
---|
| 751 | # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. |
---|
| 752 | if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then |
---|
[119] | 753 | echo |
---|
| 754 | echo "########################################################################" |
---|
| 755 | echo "!!! Modification of libIGCM behaviour !!!" |
---|
| 756 | echo |
---|
| 757 | |
---|
| 758 | IGCM_debug_Print 1 "DefineArrayFromOption : libIGCM_UserChanges in libIGCM.card" |
---|
| 759 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges |
---|
| 760 | IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} |
---|
| 761 | |
---|
| 762 | # Special treatments for libIGCM internals |
---|
| 763 | for option in ${libIGCM_UserChanges[*]} ; do |
---|
[544] | 764 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} |
---|
[119] | 765 | |
---|
[544] | 766 | echo "We will change : ${option}." |
---|
| 767 | eval echo "Previous value : " \${${option}} |
---|
| 768 | eval echo "Change to : " \${libIGCM_UserChanges_${option}} |
---|
| 769 | |
---|
| 770 | eval ${option}=\${libIGCM_UserChanges_${option}} |
---|
[119] | 771 | |
---|
[544] | 772 | case ${option} in |
---|
| 773 | config_UserChoices_DateEnd) |
---|
| 774 | IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd |
---|
| 775 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
[119] | 776 | |
---|
[544] | 777 | # Period Length In Days between DateBegin and DateEnd |
---|
| 778 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
| 779 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
| 780 | IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
| 781 | IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." |
---|
| 782 | IGCM_debug_Verif_Exit |
---|
| 783 | fi |
---|
| 784 | ;; |
---|
| 785 | config_UserChoices_PeriodLength) |
---|
| 786 | IGCM_debug_Print 1 "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" |
---|
| 787 | ;; |
---|
| 788 | PeriodNb) |
---|
| 789 | IGCM_debug_Print 1 "Loop in main Job with ${PeriodNb} period(s)" |
---|
| 790 | ;; |
---|
| 791 | config_Post_RebuildFrequency) |
---|
| 792 | IGCM_debug_Print 1 "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" |
---|
| 793 | IGCM_post_Configure |
---|
| 794 | ;; |
---|
| 795 | config_Post_TimeSeriesFrequency) |
---|
| 796 | IGCM_debug_Print 1 "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize" |
---|
| 797 | IGCM_post_Configure |
---|
| 798 | ;; |
---|
| 799 | config_Post_SeasonalFrequency) |
---|
| 800 | IGCM_debug_Print 1 "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize" |
---|
| 801 | IGCM_post_Configure |
---|
| 802 | ;; |
---|
| 803 | esac |
---|
| 804 | done |
---|
[119] | 805 | |
---|
[544] | 806 | echo |
---|
| 807 | echo "########################################################################" |
---|
| 808 | echo |
---|
| 809 | fi |
---|
[119] | 810 | |
---|
[544] | 811 | #=================================================# |
---|
| 812 | # Determine next computed period # |
---|
| 813 | #=================================================# |
---|
[2] | 814 | |
---|
[544] | 815 | PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) |
---|
| 816 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 817 | year_m1=$(( year - 1 )) |
---|
| 818 | year_p1=$(( year + 1 )) |
---|
| 819 | IGCM_config_Analyse_PeriodLength |
---|
| 820 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
[2] | 821 | |
---|
[544] | 822 | # Debug Print : |
---|
| 823 | echo |
---|
| 824 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" |
---|
| 825 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 826 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 827 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
[2] | 828 | |
---|
[544] | 829 | PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
| 830 | PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
[2] | 831 | |
---|
[544] | 832 | (( CumulPeriod = CumulPeriod + 1 )) |
---|
[2] | 833 | |
---|
[544] | 834 | # Debug Print : |
---|
| 835 | echo |
---|
| 836 | IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" |
---|
| 837 | IGCM_debug_Print 3 "PeriodDateEnd Human : ${PeriodDateEnd}" |
---|
| 838 | IGCM_debug_Print 3 "CumulPeriod : ${CumulPeriod}" |
---|
[2] | 839 | |
---|
[544] | 840 | #=================================================# |
---|
| 841 | # Write updated run.card # |
---|
| 842 | #=================================================# |
---|
[2] | 843 | |
---|
[544] | 844 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} |
---|
| 845 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 846 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 847 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
[2] | 848 | |
---|
[544] | 849 | if ( ${FirstInitialize} ) ; then |
---|
| 850 | # It's no more the first time |
---|
| 851 | FirstInitialize=false |
---|
| 852 | fi |
---|
[446] | 853 | |
---|
[544] | 854 | IGCM_debug_PopStack "IGCM_config_PeriodEnd" |
---|
[2] | 855 | } |
---|
| 856 | |
---|
| 857 | #=================================== |
---|
| 858 | function IGCM_config_Finalize |
---|
| 859 | { |
---|
[544] | 860 | IGCM_debug_PushStack "IGCM_config_Finalize" |
---|
[2] | 861 | |
---|
[544] | 862 | echo |
---|
| 863 | IGCM_debug_Print 1 "IGCM_config_Finalize" |
---|
| 864 | echo |
---|
[2] | 865 | |
---|
[544] | 866 | if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then |
---|
| 867 | #==========================# |
---|
| 868 | # End of entire simulation # |
---|
| 869 | #==========================# |
---|
[2] | 870 | |
---|
[544] | 871 | # Mail notification |
---|
| 872 | IGCM_sys_SendMail |
---|
[2] | 873 | |
---|
[544] | 874 | # |
---|
| 875 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" |
---|
| 876 | IGCM_debug_Print 1 "Normal End of computation." |
---|
| 877 | if ( $DEBUG_debug ) ; then |
---|
| 878 | echo |
---|
| 879 | IGCM_debug_Print 1 "Your files on ${R_SAVE} :" |
---|
| 880 | IGCM_sys_Tree ${R_SAVE} |
---|
[2] | 881 | |
---|
[544] | 882 | IGCM_debug_Print 1 "Your files on ${R_BUFR} :" |
---|
| 883 | IGCM_sys_Tree ${R_BUFR} |
---|
| 884 | fi |
---|
| 885 | else |
---|
| 886 | #=================# |
---|
| 887 | # Submit next job # |
---|
| 888 | #=================# |
---|
[2] | 889 | |
---|
[544] | 890 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
[2] | 891 | |
---|
[544] | 892 | # Name of next Ksh Script output : |
---|
| 893 | eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" |
---|
[2] | 894 | |
---|
[544] | 895 | IGCM_debug_Print 1 "Submit next job" |
---|
| 896 | # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR |
---|
| 897 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 898 | # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
| 899 | ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) |
---|
| 900 | [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) |
---|
| 901 | # Submit next job and come back |
---|
| 902 | IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} |
---|
| 903 | IGCM_sys_Cd - |
---|
| 904 | fi |
---|
[154] | 905 | |
---|
[544] | 906 | # Supress Non Deleted Boundary files |
---|
| 907 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 908 | IGCM_comp_DelFixeBoundaryFiles |
---|
| 909 | ls -la |
---|
| 910 | fi |
---|
| 911 | |
---|
| 912 | # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 913 | # Only for production run (No clean up in DEV or DEB mode) |
---|
| 914 | # and command sent from .. directory. |
---|
| 915 | IGCM_sys_Cd .. |
---|
| 916 | [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 917 | |
---|
| 918 | IGCM_debug_PopStack "IGCM_config_Finalize" |
---|
[2] | 919 | } |
---|
| 920 | |
---|
| 921 | #=================================== |
---|