[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 | |
---|
[619] | 23 | if [ ! -r ${SUBMIT_DIR}/run.card ]; then |
---|
[544] | 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 |
---|
[619] | 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 | #================================== |
---|
[619] | 63 | # Read UserChoices section: |
---|
[544] | 64 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card UserChoices |
---|
[2] | 65 | |
---|
[544] | 66 | for option in ${config_UserChoices[*]} ; do |
---|
| 67 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option} |
---|
| 68 | done |
---|
| 69 | echo |
---|
| 70 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
[619] | 71 | # Name Space of this experience |
---|
[544] | 72 | if [ X${config_UserChoices_SpaceName} != X ] ; then |
---|
| 73 | IGCM_debug_PrintVariables 3 config_UserChoices_SpaceName |
---|
| 74 | fi |
---|
| 75 | # Expericence class of the run |
---|
| 76 | if [ X${config_UserChoices_ExperimentName} != X ] ; then |
---|
| 77 | IGCM_debug_PrintVariables 3 config_UserChoices_ExperimentName |
---|
| 78 | fi |
---|
| 79 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
| 80 | if [ 3 -le ${Verbosity} ] ; then |
---|
| 81 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
| 82 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
| 83 | fi |
---|
| 84 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
| 85 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
| 86 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
| 87 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
| 88 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
[2] | 89 | |
---|
[544] | 90 | #================================== |
---|
[619] | 91 | # Read Post section: |
---|
[591] | 92 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post |
---|
| 93 | echo |
---|
| 94 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Post" |
---|
[2] | 95 | |
---|
[591] | 96 | for option in ${config_Post[*]} ; do |
---|
| 97 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post ${option} |
---|
| 98 | eval auxprint=\${config_Post_${option}} |
---|
| 99 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
| 100 | done |
---|
| 101 | |
---|
| 102 | #================================== |
---|
[619] | 103 | # Define default value to keep compatibility with previous card: means before changes due to TGCC |
---|
[630] | 104 | if [ X${PackDefault} = Xtrue ] ; then |
---|
| 105 | [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} |
---|
| 106 | else |
---|
| 107 | config_Post_PackFrequency=NONE |
---|
| 108 | fi |
---|
[591] | 109 | |
---|
| 110 | #================================== |
---|
[619] | 111 | # Read ListOfComponents section: |
---|
[544] | 112 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents |
---|
| 113 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 114 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp} |
---|
| 115 | done |
---|
[2] | 116 | |
---|
[544] | 117 | echo |
---|
| 118 | IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
| 119 | IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
[2] | 120 | |
---|
[544] | 121 | NbComponents=${#config_ListOfComponents[*]} |
---|
[2] | 122 | |
---|
[544] | 123 | #================================== |
---|
| 124 | # Define principal executable |
---|
| 125 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Executable |
---|
| 126 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Executable Name |
---|
[619] | 127 | |
---|
[544] | 128 | #================================== |
---|
| 129 | # Define Outputs Name |
---|
| 130 | IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output" |
---|
| 131 | eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} |
---|
| 132 | IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}" |
---|
| 133 | eval Exe_Output=out_${config_Executable_Name} |
---|
| 134 | IGCM_debug_Print 3 "Exe_Output = ${Exe_Output}" |
---|
[2] | 135 | |
---|
[544] | 136 | #===================================================================# |
---|
| 137 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
| 138 | # But available to any son functions # |
---|
| 139 | #===================================================================# |
---|
[2] | 140 | |
---|
[544] | 141 | # Convert yyyy-mm-dd date to gregorian yyyymmdd |
---|
| 142 | DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} ) |
---|
[619] | 143 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
[2] | 144 | |
---|
[544] | 145 | # Period Length In Days between DateBegin and DateEnd |
---|
| 146 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
| 147 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
| 148 | IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
| 149 | IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates." |
---|
[619] | 150 | IGCM_debug_Verif_Exit |
---|
[544] | 151 | fi |
---|
[2] | 152 | |
---|
[544] | 153 | # Day and Year of Initial State (Given in julian format) |
---|
| 154 | InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 )) |
---|
| 155 | InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 )) |
---|
[2] | 156 | |
---|
[544] | 157 | #================================== |
---|
| 158 | # Restarts : Gerneral rule or local for each component ? |
---|
| 159 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts |
---|
[2] | 160 | |
---|
[544] | 161 | echo |
---|
| 162 | IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts" |
---|
[2] | 163 | |
---|
[544] | 164 | for option in ${config_Restarts[*]} ; do |
---|
| 165 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option} |
---|
| 166 | eval auxprint=\${config_Restarts_${option}} |
---|
| 167 | IGCM_debug_Print 3 "${option} : ${auxprint}" |
---|
| 168 | done |
---|
[2] | 169 | |
---|
[544] | 170 | #================================================================# |
---|
| 171 | # Test and Prepare directories # |
---|
| 172 | #================================================================# |
---|
[2] | 173 | |
---|
[544] | 174 | # ==> 4 kinds of input files : |
---|
| 175 | # 1) R_INIT : Initial State Files (Etat0, carteveg) |
---|
| 176 | # 2) R_BC : Boundary Conditions (Forcages, lai) |
---|
| 177 | # 3) Parameters files (allready define through ${SUBMIT_DIR}) |
---|
| 178 | # 4) Restarts files (allready define in IGCM_config_Initialize) |
---|
[2] | 179 | |
---|
[544] | 180 | # Here we offer the possibility to redefine R_INIT, R_BC |
---|
| 181 | # and PeriodNb through config.card |
---|
| 182 | R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT} |
---|
| 183 | IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb" |
---|
| 184 | IGCM_debug_Print 3 "R_INIT=${R_INIT}" |
---|
| 185 | R_BC=${config_UserChoices_R_BC:=${R_IN}/BC} |
---|
| 186 | IGCM_debug_Print 3 "R_BC=${R_BC}" |
---|
| 187 | PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}} |
---|
| 188 | IGCM_debug_Print 3 "Loop in main Job with ${PeriodNb} period(s)" |
---|
[2] | 189 | |
---|
[544] | 190 | # Test Archive input/output. |
---|
| 191 | IGCM_sys_TestDirArchive ${ARCHIVE} |
---|
| 192 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
| 193 | IGCM_sys_TestDirArchive ${R_IN} |
---|
| 194 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" |
---|
[2] | 195 | |
---|
[544] | 196 | #==================================================== |
---|
| 197 | #R_SAVE : Job output directory |
---|
| 198 | if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then |
---|
| 199 | FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' ) |
---|
| 200 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
[587] | 201 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
[544] | 202 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 203 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName} |
---|
| 204 | else |
---|
| 205 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
[587] | 206 | R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
[544] | 207 | R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 208 | R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 209 | fi |
---|
[2] | 210 | |
---|
[619] | 211 | if ( ${FirstInitialize} ) ; then |
---|
[544] | 212 | IGCM_sys_MkdirArchive ${R_SAVE} |
---|
| 213 | IGCM_sys_Mkdir ${R_BUFR} |
---|
| 214 | else |
---|
| 215 | IGCM_sys_TestDirArchive ${R_SAVE} |
---|
| 216 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}" |
---|
[2] | 217 | |
---|
[544] | 218 | IGCM_sys_TestDir ${R_BUFR} |
---|
| 219 | [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}" |
---|
[545] | 220 | |
---|
[544] | 221 | #Test state of run in run.card |
---|
| 222 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
[619] | 223 | |
---|
[544] | 224 | if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
[619] | 225 | echo |
---|
[544] | 226 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 227 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 228 | IGCM_debug_Exit |
---|
| 229 | IGCM_debug_Verif_Exit |
---|
[2] | 230 | fi |
---|
[544] | 231 | fi |
---|
[2] | 232 | |
---|
[544] | 233 | #==================================================== |
---|
| 234 | # Define REBUILD_DIR : where we store files needing rebuild process |
---|
| 235 | if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then |
---|
| 236 | REBUILD_DIR=${R_SAVE}/TMP |
---|
| 237 | IGCM_sys_MkdirArchive ${REBUILD_DIR} |
---|
| 238 | else |
---|
| 239 | REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 240 | IGCM_sys_MkdirWork ${REBUILD_DIR} |
---|
| 241 | fi |
---|
[146] | 242 | |
---|
[544] | 243 | #==================================================== |
---|
[619] | 244 | # Experience type : DEB(ug), DEV(elopment), RUN |
---|
[544] | 245 | if [ X${JobType} != XRUN ] ; then |
---|
| 246 | echo |
---|
| 247 | echo "====================================================" |
---|
| 248 | echo "libIGCM JOB is NOT in RUN type mode." |
---|
| 249 | echo "!! OUTPUT files will NOT be PROTECTED !!" |
---|
| 250 | echo "Be carefull : you can ERASE the result of this job !" |
---|
[128] | 251 | |
---|
[544] | 252 | case ${JobType} in |
---|
| 253 | DEB) |
---|
| 254 | echo "DEBUG mode : activation of 'set -vx' mode." |
---|
| 255 | echo "DEBUG mode : no protection for output files." |
---|
| 256 | echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 257 | ;; |
---|
| 258 | DEV) |
---|
| 259 | echo "DEVelopment mode : no protection for output files." |
---|
| 260 | echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency." |
---|
| 261 | ;; |
---|
| 262 | esac |
---|
[166] | 263 | |
---|
[544] | 264 | if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then |
---|
| 265 | if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then |
---|
[619] | 266 | echo "------------" |
---|
| 267 | echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency" |
---|
| 268 | echo " to PeriodLength : ${config_UserChoices_PeriodLength}" |
---|
| 269 | echo "------------" |
---|
| 270 | config_Post_RebuildFrequency=${config_UserChoices_PeriodLength} |
---|
[544] | 271 | fi |
---|
[128] | 272 | fi |
---|
[544] | 273 | echo "====================================================" |
---|
| 274 | echo |
---|
| 275 | fi |
---|
[128] | 276 | |
---|
[544] | 277 | #==================================================== |
---|
| 278 | #R_OUT_KSH : Storage place for job output |
---|
| 279 | #R_OUT_EXE : Storage place for binary used during simulation |
---|
| 280 | R_OUT_KSH=${R_SAVE}/Out |
---|
| 281 | R_OUT_EXE=${R_SAVE}/Exe |
---|
[166] | 282 | |
---|
[544] | 283 | #==================================================== |
---|
| 284 | #R_BUF_KSH : Buffer place for job output |
---|
| 285 | #R_BUF_EXE : Buffer place for binary used during simulation |
---|
| 286 | R_BUF_KSH=${R_BUFR}/Out |
---|
| 287 | R_BUF_EXE=${R_BUFR}/Exe |
---|
| 288 | |
---|
| 289 | IGCM_debug_PopStack "IGCM_config_Initialize" |
---|
[2] | 290 | } |
---|
| 291 | |
---|
| 292 | #=================================== |
---|
[118] | 293 | function IGCM_config_Analyse_PeriodLength |
---|
| 294 | { |
---|
[544] | 295 | IGCM_debug_PushStack "IGCM_config_Analyse_PeriodLength" |
---|
[118] | 296 | |
---|
[544] | 297 | typeset i |
---|
[124] | 298 | |
---|
[544] | 299 | # Determine number of day(s) in PeriodLength : |
---|
| 300 | case ${config_UserChoices_PeriodLength} in |
---|
| 301 | *Y|*y) |
---|
[619] | 302 | PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) |
---|
[544] | 303 | IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}" |
---|
| 304 | PeriodLengthInDays=0 |
---|
| 305 | i=0 |
---|
[619] | 306 | until [ $i -ge $PeriodLengthInYears ] ; do |
---|
| 307 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) |
---|
| 308 | (( i=i+1 )) |
---|
| 309 | done |
---|
[544] | 310 | ;; |
---|
| 311 | *M|*m) |
---|
[619] | 312 | PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) |
---|
[544] | 313 | IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}" |
---|
| 314 | PeriodLengthInDays=0 |
---|
| 315 | i=0 |
---|
[619] | 316 | until [ $i -ge $PeriodLengthInMonths ] ; do |
---|
| 317 | if [ $(( month + i )) -lt 13 ] ; then |
---|
| 318 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) |
---|
| 319 | else |
---|
| 320 | (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) |
---|
| 321 | fi |
---|
| 322 | (( i=i+1 )) |
---|
| 323 | done |
---|
[544] | 324 | ;; |
---|
[619] | 325 | *D|*d) |
---|
[544] | 326 | PeriodLengthInMonths=0 |
---|
| 327 | PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' );; |
---|
[619] | 328 | *) |
---|
[544] | 329 | IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." |
---|
| 330 | IGCM_debug_Verif_Exit ;; |
---|
| 331 | esac |
---|
[118] | 332 | |
---|
[544] | 333 | IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength" |
---|
[380] | 334 | } |
---|
[118] | 335 | |
---|
[380] | 336 | #=================================== |
---|
| 337 | function IGCM_config_Check |
---|
| 338 | { |
---|
[544] | 339 | IGCM_debug_PushStack "IGCM_config_Check" |
---|
[380] | 340 | |
---|
[544] | 341 | # If one of the following modulo is not zero : |
---|
| 342 | # we will issue an error then explain and exit in |
---|
| 343 | # AA_job IGCM_debug_Verif_Exit call before binary submission |
---|
[380] | 344 | |
---|
[544] | 345 | echo |
---|
| 346 | IGCM_debug_Print 1 "IGCM_config_Check" |
---|
| 347 | echo |
---|
| 348 | |
---|
| 349 | typeset i |
---|
| 350 | |
---|
[554] | 351 | # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency |
---|
[545] | 352 | if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then |
---|
[544] | 353 | AsynchronousRebuild=true |
---|
| 354 | IGCM_debug_Print 1 "Asynchronous rebuild has been activated." |
---|
[380] | 355 | echo |
---|
[544] | 356 | # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
| 357 | IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength" |
---|
| 358 | IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength |
---|
[554] | 359 | IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency" |
---|
| 360 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency |
---|
[544] | 361 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency" |
---|
| 362 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency |
---|
| 363 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency" |
---|
| 364 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency |
---|
| 365 | else |
---|
| 366 | AsynchronousRebuild=false |
---|
| 367 | IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" |
---|
| 368 | IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" |
---|
[380] | 369 | echo |
---|
[554] | 370 | #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero |
---|
[544] | 371 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength" |
---|
| 372 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength |
---|
| 373 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength" |
---|
| 374 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength |
---|
| 375 | fi |
---|
[380] | 376 | |
---|
[619] | 377 | # Check PackFrequency against other key frequencies |
---|
[554] | 378 | # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero |
---|
| 379 | if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then |
---|
| 380 | Pack=true |
---|
| 381 | # |
---|
| 382 | IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength" |
---|
| 383 | IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength |
---|
| 384 | IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency" |
---|
| 385 | IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency |
---|
| 386 | IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency" |
---|
| 387 | IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency |
---|
| 388 | else |
---|
| 389 | Pack=false |
---|
| 390 | fi |
---|
| 391 | |
---|
[544] | 392 | #modulo (TimeSeriesFrequency and all Chunck2D) must be zero |
---|
| 393 | NbJob=${#CHUNCK2D_SIZE[@]} |
---|
| 394 | i=0 |
---|
| 395 | until [ $i -ge $NbJob ]; do |
---|
| 396 | value=${CHUNCK2D_SIZE[${i}]} |
---|
| 397 | IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency" |
---|
| 398 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
[619] | 399 | case ${value} in |
---|
| 400 | *Y|*y) ;; |
---|
| 401 | *) IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card" |
---|
[544] | 402 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 403 | esac |
---|
| 404 | (( i=i+1 )) |
---|
| 405 | done |
---|
[387] | 406 | |
---|
[544] | 407 | #modulo (TimeSeriesFrequency and all Chunck3D) must be zero |
---|
| 408 | NbJob=${#CHUNCK3D_SIZE[@]} |
---|
| 409 | i=0 |
---|
| 410 | until [ $i -ge $NbJob ]; do |
---|
| 411 | value=${CHUNCK3D_SIZE[${i}]} |
---|
| 412 | IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency" |
---|
| 413 | IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency |
---|
[619] | 414 | case ${value} in |
---|
| 415 | *Y|*y) ;; |
---|
| 416 | *) IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card" |
---|
[544] | 417 | IGCM_debug_Exit "This will stop the job" ;; |
---|
| 418 | esac |
---|
| 419 | (( i=i+1 )) |
---|
| 420 | done |
---|
[380] | 421 | |
---|
[651] | 422 | #check to be sure there is enough space on temporary filesystems to run |
---|
| 423 | IGCM_debug_Print 1 "Check if there is enough space on temporary filesystem" |
---|
| 424 | IGCM_sys_check_quota |
---|
| 425 | |
---|
[544] | 426 | IGCM_debug_PopStack "IGCM_config_Check" |
---|
[118] | 427 | } |
---|
| 428 | |
---|
| 429 | #=================================== |
---|
[2] | 430 | function IGCM_config_PeriodStart |
---|
| 431 | { |
---|
[544] | 432 | IGCM_debug_PushStack "IGCM_config_PeriodStart" |
---|
[2] | 433 | |
---|
[544] | 434 | echo |
---|
| 435 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" |
---|
| 436 | echo |
---|
[2] | 437 | |
---|
[544] | 438 | if ( ${FirstInitialize} ) ; then |
---|
| 439 | #================================================# |
---|
| 440 | # Initialize date/period information # |
---|
| 441 | #================================================# |
---|
[2] | 442 | |
---|
[544] | 443 | IGCM_date_GetYearMonthDay $DateBegin year month day |
---|
| 444 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 445 | |
---|
[544] | 446 | eval PeriodDateBegin=${DateBegin} > /dev/null 2>&1 |
---|
| 447 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
| 448 | eval CumulPeriod=1 > /dev/null 2>&1 |
---|
[2] | 449 | |
---|
[544] | 450 | #=================================================# |
---|
| 451 | # Write updated run.card # |
---|
| 452 | #=================================================# |
---|
[2] | 453 | |
---|
[544] | 454 | #Correct run.card Configuration for this period |
---|
| 455 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 456 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 457 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
| 458 | if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then |
---|
| 459 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR} |
---|
| 460 | fi |
---|
[427] | 461 | |
---|
[544] | 462 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
[619] | 463 | |
---|
[544] | 464 | else |
---|
| 465 | #================================================# |
---|
| 466 | # The file run.card allready exist # |
---|
| 467 | #================================================# |
---|
[2] | 468 | |
---|
[544] | 469 | #Test state of run in run.card |
---|
| 470 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState |
---|
| 471 | if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then |
---|
[619] | 472 | echo |
---|
[544] | 473 | IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!" |
---|
| 474 | IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this" |
---|
| 475 | echo |
---|
| 476 | IGCM_debug_Exit |
---|
| 477 | IGCM_debug_Verif_Exit |
---|
| 478 | fi |
---|
[2] | 479 | |
---|
[544] | 480 | #===================================# |
---|
[619] | 481 | # Read updated run.card # |
---|
[544] | 482 | #===================================# |
---|
[2] | 483 | |
---|
[544] | 484 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix |
---|
| 485 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin |
---|
| 486 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd |
---|
| 487 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod |
---|
[2] | 488 | |
---|
[544] | 489 | PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) |
---|
| 490 | PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) |
---|
| 491 | eval CumulPeriod="${run_Configuration_CumulPeriod}" > /dev/null 2>&1 |
---|
[2] | 492 | |
---|
[544] | 493 | LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" ) |
---|
[471] | 494 | |
---|
[544] | 495 | typeset LastDate |
---|
| 496 | set +A LastDate -- $( echo ${LastPeriodDateEnd} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1 \2 \3/" ) |
---|
| 497 | LastYearDateEnd=${LastDate[0]} |
---|
| 498 | LastMonthDateEnd=${LastDate[1]} |
---|
| 499 | LastDayDateEnd=${LastDate[2]} |
---|
[471] | 500 | |
---|
[544] | 501 | if [ ${Period} = 1 ]; then |
---|
| 502 | # save last Job output |
---|
| 503 | typeset LastPeriod iLastPeriod Last_Script_Output_Name |
---|
| 504 | (( LastPeriod=CumulPeriod-PeriodNb )) |
---|
| 505 | iLastPeriod=$( printf "%06d" ${LastPeriod} ) |
---|
| 506 | Last_Script_Output_Name="${Script_Output_Prefix}_${config_UserChoices_JobName}.${iLastPeriod}" |
---|
| 507 | Last_run_card="run.card.${iLastPeriod}" |
---|
| 508 | #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name} |
---|
| 509 | #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1 |
---|
| 510 | IGCM_debug_Print 2 "Try to save previous ksh job output" |
---|
| 511 | IGCM_sys_Cd ${SUBMIT_DIR}/ |
---|
[634] | 512 | if [ X${Pack} = Xtrue ] ; then |
---|
| 513 | IGCM_sys_PutBuffer_Out ${Last_Script_Output_Name} ${R_BUF_KSH}/${Last_Script_Output_Name}.$$ rw |
---|
| 514 | else |
---|
| 515 | IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name}.$$ rw |
---|
| 516 | fi |
---|
[471] | 517 | |
---|
[544] | 518 | IGCM_card_CheckConflict run.card |
---|
[634] | 519 | if [ X${Pack} = Xtrue ] ; then |
---|
| 520 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/${Last_run_card}.$$ rw |
---|
| 521 | else |
---|
| 522 | IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/${Last_run_card}.$$ rw |
---|
| 523 | fi |
---|
[544] | 524 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 525 | else |
---|
| 526 | unset FileToBeDeleted |
---|
| 527 | fi |
---|
[2] | 528 | |
---|
[544] | 529 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 530 | IGCM_config_Analyse_PeriodLength |
---|
[2] | 531 | |
---|
[544] | 532 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running" |
---|
[2] | 533 | |
---|
[619] | 534 | fi |
---|
[544] | 535 | OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd} |
---|
[522] | 536 | |
---|
[544] | 537 | # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
| 538 | # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y) |
---|
| 539 | year_m1=$(( year - 1 )) |
---|
[619] | 540 | year_p1=$(( year + 1 )) |
---|
[544] | 541 | # Compute month_m1 (month minus 1M) |
---|
| 542 | # Compute yyyymm_m1 (yyyymm minus 1M) |
---|
| 543 | month_m1=$(( month - 1 )) |
---|
| 544 | if [ ${month_m1} = 0 ]; then |
---|
| 545 | month_m1=12 |
---|
| 546 | yyyymm_m1=${year_m1}12 |
---|
| 547 | elif [ ${month_m1} -le 9 ]; then |
---|
| 548 | month_m1=0${month_m1} |
---|
| 549 | yyyymm_m1=${year}${month_m1} |
---|
| 550 | else |
---|
| 551 | yyyymm_m1=${year}${month_m1} |
---|
| 552 | fi |
---|
| 553 | # Compute month_p1 (month plus 1M) |
---|
| 554 | # Compute yyyymm_p1 (yyyymm plus 1M) |
---|
| 555 | month_p1=$(( month + 1 )) |
---|
| 556 | if [ ${month_p1} = 13 ]; then |
---|
| 557 | month_p1=01 |
---|
| 558 | yyyymm_p1=${year_p1}01 |
---|
| 559 | elif [ ${month_p1} -le 9 ]; then |
---|
| 560 | month_p1=0${month_p1} |
---|
| 561 | yyyymm_p1=${year}${month_p1} |
---|
| 562 | else |
---|
| 563 | yyyymm_p1=${year}${month_p1} |
---|
| 564 | fi |
---|
| 565 | #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} " |
---|
| 566 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} " |
---|
| 567 | #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} " |
---|
[522] | 568 | |
---|
[544] | 569 | # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh |
---|
[522] | 570 | |
---|
[544] | 571 | #===================================================================# |
---|
| 572 | # Prepare variables available for ${COMP}.card and ${COMP}.driver # |
---|
[619] | 573 | # But available to any son functions # |
---|
[544] | 574 | #===================================================================# |
---|
[2] | 575 | |
---|
[544] | 576 | # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !) |
---|
| 577 | (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 )) |
---|
[2] | 578 | |
---|
[544] | 579 | # Debug Print : |
---|
| 580 | IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution" |
---|
| 581 | IGCM_debug_Print 1 "Year of simulation : ${year}" |
---|
| 582 | IGCM_debug_Print 1 "Month of simulation : ${month}" |
---|
| 583 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
| 584 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 585 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 586 | IGCM_debug_Print 1 "SimulationLengthInDays : ${SimulationLengthInDays}" |
---|
| 587 | IGCM_debug_Print 1 "ExperienceLengthInDays : ${ExperienceLengthInDays}" |
---|
[2] | 588 | |
---|
[544] | 589 | #================================================================# |
---|
| 590 | # Prepare variables available for comp_finalyze # |
---|
| 591 | #================================================================# |
---|
[2] | 592 | |
---|
[544] | 593 | # Period for save files |
---|
| 594 | eval DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd} > /dev/null 2>&1 |
---|
[2] | 595 | |
---|
[544] | 596 | # Prefix for save files of this period |
---|
| 597 | eval PREFIX=${config_UserChoices_JobName}_${DatesPeriod} > /dev/null 2>&1 |
---|
[2] | 598 | |
---|
[544] | 599 | # List of files that will be deleted in RUN_DIR after run |
---|
| 600 | [ -f stack ] && FileToBeDeleted[0]="stack" |
---|
[2] | 601 | |
---|
[544] | 602 | # Test if the same run as already been saved : |
---|
| 603 | if [ X${JobType} = XRUN ] ; then |
---|
| 604 | if [ ${DRYRUN} -le 0 ] ; then |
---|
| 605 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
[619] | 606 | IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job." |
---|
| 607 | IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files" |
---|
| 608 | IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or " |
---|
| 609 | IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory." |
---|
| 610 | IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists." |
---|
| 611 | IGCM_debug_Verif_Exit |
---|
[544] | 612 | fi |
---|
[2] | 613 | fi |
---|
[544] | 614 | else |
---|
| 615 | if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then |
---|
| 616 | IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode." |
---|
| 617 | fi |
---|
| 618 | fi |
---|
[128] | 619 | |
---|
[616] | 620 | typeset ExeNameIn ExeNameFirst CompNameFirst |
---|
| 621 | typeset comp i |
---|
| 622 | typeset tempvar tempvarMPI tempvarNOD NbElts j NbExec |
---|
| 623 | |
---|
| 624 | (( PROCESSUS_NUMBER = 0 )) |
---|
| 625 | (( i=0 )) |
---|
| 626 | (( NbExec=0 )) |
---|
| 627 | |
---|
| 628 | OK_PARA_MPI=false |
---|
| 629 | OK_PARA_OMP=false |
---|
| 630 | OK_PARA_NOD=false |
---|
| 631 | OK_PARA_MPMD=false |
---|
| 632 | |
---|
| 633 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 634 | |
---|
| 635 | IGCM_debug_Print 1 ${comp} |
---|
| 636 | |
---|
| 637 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 638 | |
---|
[619] | 639 | # NO order in config.card for parallelized values ! |
---|
[616] | 640 | # just use suffix : MPI , OMP and NOD (for number of NODes.) |
---|
| 641 | |
---|
| 642 | # NOD is the number of NODes allocated |
---|
| 643 | eval ${comp}_PROC_NOD=0 |
---|
| 644 | |
---|
| 645 | # MPI is the number of MPI processus per nodes |
---|
| 646 | eval ${comp}_PROC_MPI=0 |
---|
| 647 | |
---|
| 648 | # OMP is the number of OpenMP threads per MPI processus |
---|
| 649 | eval ${comp}_PROC_OMP=0 |
---|
[619] | 650 | |
---|
[616] | 651 | # Only if we really have an executable for the component : |
---|
[661] | 652 | ### if [ X${ExeNameIn} != X\"\" ] ; then |
---|
| 653 | if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; then |
---|
[616] | 654 | |
---|
| 655 | # Keep the first executable found and the first CompName |
---|
| 656 | ExeNameFirst=${ExeNameIn} |
---|
| 657 | CompNameFirst=${comp} |
---|
| 658 | |
---|
| 659 | # Are we a second executable? |
---|
| 660 | (( NbExec = NbExec + 1 )) |
---|
| 661 | |
---|
| 662 | # set 1 MPI task, 1 OpenMP thread and 1 node as default |
---|
| 663 | eval ${comp}_PROC_MPI=1 |
---|
| 664 | eval ${comp}_PROC_OMP=1 |
---|
| 665 | eval ${comp}_PROC_NOD=1 |
---|
| 666 | |
---|
| 667 | eval NbElts=\${#config_Executable_${comp}[@]} |
---|
| 668 | |
---|
| 669 | if [ ${NbElts} -ge 2 ] ; then |
---|
| 670 | (( j = 2 )) |
---|
| 671 | |
---|
[619] | 672 | while [ $j -lt ${NbElts} ] ; do |
---|
[616] | 673 | eval tempvar=\${config_Executable_${comp}[${j}]} |
---|
| 674 | |
---|
| 675 | if [ X${tempvar} = X ] ; then |
---|
[619] | 676 | echo "Error reading MPI/OMP parameters !!!" |
---|
| 677 | echo "Check your config.card." |
---|
[616] | 678 | exit 1 |
---|
| 679 | fi |
---|
| 680 | |
---|
| 681 | eval IGCM_debug_Print 2 ${tempvar} |
---|
| 682 | |
---|
| 683 | case ${tempvar} in |
---|
[619] | 684 | *[mM][pP][iI]*) |
---|
[616] | 685 | # Read MPI parameter for composante |
---|
[619] | 686 | eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" ) |
---|
| 687 | OK_PARA_MPI=true;; |
---|
| 688 | *[oO][mM][pP]*) |
---|
[616] | 689 | # Read OMP parameter for composante |
---|
[619] | 690 | eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" ) |
---|
| 691 | OK_PARA_OMP=true;; |
---|
| 692 | *[nN][oO][dD]*) |
---|
[616] | 693 | # Read NOD (NumBer of Nodes) parameter for composante |
---|
[619] | 694 | eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" ) |
---|
| 695 | OK_PARA_NOD=true |
---|
| 696 | OK_PARA_MPI=true;; |
---|
[616] | 697 | esac |
---|
| 698 | |
---|
| 699 | (( j = j + 1 )) |
---|
| 700 | done |
---|
| 701 | |
---|
| 702 | fi |
---|
| 703 | |
---|
| 704 | eval tempvarMPI=\${${comp}_PROC_MPI} |
---|
| 705 | eval tempvarNOD=\${${comp}_PROC_NOD} |
---|
| 706 | eval tempvarOMP=\${${comp}_PROC_OMP} |
---|
| 707 | |
---|
| 708 | (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP )) |
---|
| 709 | |
---|
| 710 | fi |
---|
| 711 | |
---|
| 712 | (( i=i+1 )) |
---|
| 713 | done |
---|
| 714 | |
---|
| 715 | # set MPMD mode if more than 2 executable names. |
---|
| 716 | [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true |
---|
| 717 | |
---|
| 718 | # Verification of BATCH_NUM_PROC_TOT total number of processors set in job header. |
---|
| 719 | if [ X${BATCH_NUM_PROC_TOT} != X ] ; then |
---|
| 720 | # BATCH_NUM_PROC_TOT is set |
---|
| 721 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 722 | IGCM_debug_Print 1 "MPI/OMP/NOD found into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " |
---|
| 723 | else |
---|
| 724 | # with previous method. |
---|
| 725 | if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then |
---|
| 726 | # with more than 1 proc |
---|
| 727 | if ( ${OK_PARA_MPMD} ) ; then |
---|
| 728 | # with MPMD ie CPL/oasis method |
---|
| 729 | echo "We will use default number of MPI tasks for this machine : " |
---|
| 730 | echo "${DEFAULT_NUM_PROC_OCE} for OCE; " |
---|
| 731 | echo "${DEFAULT_NUM_PROC_CPL} for CPL; " |
---|
| 732 | echo "${DEFAULT_NUM_PROC_ATM} for ATM; " |
---|
| 733 | echo "${DEFAULT_NUM_PROC_TOTAL} for the total number of processors; " |
---|
| 734 | OK_PARA_MPI=true |
---|
| 735 | CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL} |
---|
| 736 | OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE} |
---|
| 737 | ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM} |
---|
| 738 | PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL} |
---|
| 739 | else |
---|
| 740 | # with have only one executable |
---|
| 741 | echo "We will use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${config_Executable_Name} " |
---|
| 742 | OK_PARA_MPI=true |
---|
| 743 | eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT} |
---|
| 744 | PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT} |
---|
| 745 | fi |
---|
[619] | 746 | else |
---|
[616] | 747 | PROCESSUS_NUMBER=1 |
---|
| 748 | fi |
---|
| 749 | fi |
---|
| 750 | # Verification with PBS parameter |
---|
| 751 | if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then |
---|
| 752 | echo "Warning with parallelization parameters !" |
---|
| 753 | echo "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} " |
---|
| 754 | echo "is the total number of _processors_ reserved." |
---|
| 755 | echo "It is not equal to the sum of _processus_ = ${PROCESSUS_NUMBER}." |
---|
| 756 | echo "We stop now." |
---|
| 757 | exit 1 |
---|
| 758 | fi |
---|
[638] | 759 | NUM_PROC_CPL=${CPL_PROC_MPI} # for backward compatibility |
---|
| 760 | NUM_PROC_OCE=${OCE_PROC_MPI} # for backward compatibility |
---|
| 761 | NUM_PROC_ATM=${ATM_PROC_MPI} # for backward compatibility |
---|
[616] | 762 | else # BATCH_NUM_PROC_TOT="" |
---|
| 763 | if ( ${OK_PARA_MPI} ) ; then |
---|
| 764 | echo "You have not given a value of ${BATCH_NUM_PROC_TOT} processors," |
---|
| 765 | echo "but you have filled the parallel parameter in config->Executable->list." |
---|
| 766 | echo "Please add BATCH_NUM_PROC_TOT variable in job header." |
---|
| 767 | echo "We stop now." |
---|
| 768 | exit 1 |
---|
| 769 | else |
---|
| 770 | # sequential case ! |
---|
| 771 | if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then |
---|
| 772 | (( PROCESSUS_NUMBER = 1 )) |
---|
| 773 | echo "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)." |
---|
| 774 | echo "We set it to 1." |
---|
| 775 | fi |
---|
| 776 | fi |
---|
| 777 | fi |
---|
| 778 | |
---|
| 779 | IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}" |
---|
| 780 | |
---|
| 781 | IGCM_sys_build_execution_scripts |
---|
| 782 | |
---|
[544] | 783 | ExecutionFail=false |
---|
[473] | 784 | |
---|
[544] | 785 | IGCM_debug_PopStack "IGCM_config_PeriodStart" |
---|
[2] | 786 | } |
---|
| 787 | |
---|
| 788 | #=================================== |
---|
[523] | 789 | function IGCM_config_SaveSourceModifications |
---|
| 790 | { |
---|
[544] | 791 | IGCM_debug_PushStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 792 | |
---|
[544] | 793 | typeset ExeOutDateMax listVarEnv |
---|
| 794 | ExeOutDateMax=$1 |
---|
[523] | 795 | |
---|
[544] | 796 | listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR" |
---|
| 797 | IGCM_sys_RshMaster "\ |
---|
[545] | 798 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \ |
---|
[544] | 799 | export ExeOutDateMax=${ExeOutDateMax};\ |
---|
[545] | 800 | export R_OUT_EXE=${R_OUT_EXE};\ |
---|
| 801 | export PREFIX=${PREFIX};\ |
---|
| 802 | export SUBMIT_DIR=${SUBMIT_DIR};\ |
---|
| 803 | export listVarEnv=${listVarEnv};\ |
---|
| 804 | Script_Output=out_SaveSourceModifications;\ |
---|
| 805 | IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}" |
---|
[523] | 806 | |
---|
[544] | 807 | IGCM_debug_PopStack "IGCM_config_SaveSourceModifications" |
---|
[523] | 808 | } |
---|
| 809 | |
---|
| 810 | #=================================== |
---|
[2] | 811 | function IGCM_config_PeriodEnd |
---|
| 812 | { |
---|
[544] | 813 | IGCM_debug_PushStack "IGCM_config_PeriodEnd" |
---|
[2] | 814 | |
---|
[544] | 815 | echo |
---|
| 816 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd" |
---|
| 817 | echo |
---|
[2] | 818 | |
---|
[544] | 819 | #==================================# |
---|
| 820 | # Save Job output # |
---|
| 821 | #==================================# |
---|
[634] | 822 | if [ X${Pack} = Xtrue ] ; then |
---|
| 823 | IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output} |
---|
| 824 | else |
---|
| 825 | IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output} |
---|
| 826 | fi |
---|
[544] | 827 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}" |
---|
[471] | 828 | |
---|
[619] | 829 | IGCM_card_CheckConflict run.card |
---|
[634] | 830 | if [ X${Pack} = Xtrue ] ; then |
---|
| 831 | IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw |
---|
| 832 | else |
---|
| 833 | IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw |
---|
| 834 | fi |
---|
[2] | 835 | |
---|
[622] | 836 | if [ ${DRYRUN} -le 1 ] ; then |
---|
[457] | 837 | |
---|
[622] | 838 | IGCM_debug_Print 1 "Check components binary : size and creation date" |
---|
[2] | 839 | |
---|
[622] | 840 | typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize |
---|
| 841 | typeset comp i |
---|
| 842 | typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax |
---|
[2] | 843 | |
---|
[622] | 844 | #==================================# |
---|
| 845 | # Get last Exe Size # |
---|
| 846 | #==================================# |
---|
[2] | 847 | |
---|
[622] | 848 | (( i=0 )) |
---|
| 849 | if ( ${FirstInitialize} ) ; then |
---|
| 850 | run_Log_LastExeSize="" |
---|
| 851 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 852 | run_Log_LastExeSize[$i]=0 |
---|
| 853 | (( i=i+1 )) |
---|
| 854 | done |
---|
| 855 | else |
---|
| 856 | IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize |
---|
| 857 | fi |
---|
| 858 | #==================================# |
---|
| 859 | # And Build ExeDate # |
---|
| 860 | #==================================# |
---|
[2] | 861 | |
---|
[622] | 862 | # 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 |
---|
| 863 | # 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") |
---|
| 864 | # 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 |
---|
| 865 | ExeDate="" |
---|
| 866 | NextExeSize="( " |
---|
| 867 | (( i=0 )) |
---|
| 868 | UpdateExe=false |
---|
| 869 | (( ExeSecDateMax = 0 )) |
---|
| 870 | for comp in ${config_ListOfComponents[*]} ; do |
---|
[2] | 871 | |
---|
[622] | 872 | IGCM_debug_Print 3 ${comp} |
---|
[2] | 873 | |
---|
[622] | 874 | eval ExeNameIn=\${config_Executable_${comp}[0]} |
---|
| 875 | eval ExeNameOut=\${config_Executable_${comp}[1]} |
---|
| 876 | # Only if we really have an executable for the component : |
---|
| 877 | if [ X${ExeNameIn} = X\"\" ] ; then |
---|
| 878 | # If there is no exe file for this component |
---|
| 879 | (( ExeSize=0 )) |
---|
[619] | 880 | else |
---|
[622] | 881 | eval LS_bin=${R_EXE}/${ExeNameIn} |
---|
| 882 | IGCM_sys_FileSize ${LS_bin} ExeSize |
---|
| 883 | |
---|
| 884 | set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} ) |
---|
| 885 | if [ X${ExeDate} = X ] ; then |
---|
| 886 | # First component exe date |
---|
| 887 | ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 888 | else |
---|
| 889 | ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]} |
---|
| 890 | fi |
---|
| 891 | ExeDate=${ExeDate}_${LS_comp[7]} |
---|
[619] | 892 | fi |
---|
[2] | 893 | |
---|
[622] | 894 | if [ ${i} -eq 0 ] ; then |
---|
| 895 | # First component |
---|
| 896 | NextExeSize="( "${ExeSize} |
---|
[619] | 897 | else |
---|
[622] | 898 | NextExeSize=${NextExeSize}", "${ExeSize} |
---|
[619] | 899 | fi |
---|
[622] | 900 | eval LastCompExeSize=${run_Log_LastExeSize[$i]} |
---|
| 901 | (( i=i+1 )) |
---|
[523] | 902 | |
---|
[622] | 903 | if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then |
---|
| 904 | if ( ${FirstInitialize} ) ; then |
---|
| 905 | IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 906 | else |
---|
| 907 | IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !" |
---|
| 908 | IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !" |
---|
| 909 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut} |
---|
| 910 | fi |
---|
| 911 | eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw |
---|
| 912 | UpdateExe=true |
---|
| 913 | |
---|
| 914 | IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate |
---|
| 915 | if [ $ExeSecDateMax -lt $ExeSecDate ] ; then |
---|
| 916 | ExeSecDateMax=$ExeSecDate |
---|
| 917 | fi |
---|
[619] | 918 | fi |
---|
[622] | 919 | done |
---|
[2] | 920 | |
---|
[622] | 921 | # SD : switch off for now |
---|
| 922 | #if ( ${UpdateExe} ) ; then |
---|
| 923 | # echo "Launch SaveSourceModifications." |
---|
| 924 | # IGCM_config_SaveSourceModifications ${ExeSecDateMax} |
---|
| 925 | #fi |
---|
[523] | 926 | |
---|
[622] | 927 | NextExeSize=${NextExeSize}" )" |
---|
| 928 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}" |
---|
[457] | 929 | |
---|
[622] | 930 | if [ ${DRYRUN} -le 1 ] ; then |
---|
| 931 | tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt |
---|
| 932 | ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt ) |
---|
| 933 | RET=$? |
---|
| 934 | if [ $RET -eq 0 ] ; then |
---|
| 935 | # ExeCpuLog variable contents 5 fields |
---|
| 936 | echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" | \ |
---|
| 937 | gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \ |
---|
[544] | 938 | $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card |
---|
[622] | 939 | fi |
---|
| 940 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}_tail.txt" |
---|
[619] | 941 | fi |
---|
[622] | 942 | |
---|
[619] | 943 | fi |
---|
[2] | 944 | |
---|
[622] | 945 | # All was right ? no ? then we stop. |
---|
[619] | 946 | IGCM_debug_Verif_Exit |
---|
[2] | 947 | |
---|
[622] | 948 | # If all was OK, we can delete all files not necessary for next Job |
---|
[619] | 949 | echo |
---|
| 950 | IGCM_debug_Print 1 "Files that will be deleted before next period-run : " |
---|
[2] | 951 | |
---|
[619] | 952 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 953 | for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done |
---|
| 954 | else |
---|
| 955 | echo ${FileToBeDeleted[@]} |
---|
| 956 | fi |
---|
[2] | 957 | |
---|
[622] | 958 | #=================================================# |
---|
| 959 | # Modification of libIGCM behaviour # |
---|
| 960 | #=================================================# |
---|
[119] | 961 | |
---|
[622] | 962 | # To use this function, one must copy libIGCM.card from ${libIGCM} directory |
---|
| 963 | # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card, |
---|
| 964 | # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. |
---|
[619] | 965 | if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then |
---|
| 966 | echo |
---|
| 967 | echo "########################################################################" |
---|
| 968 | echo "!!! Modification of libIGCM behaviour !!!" |
---|
| 969 | echo |
---|
[119] | 970 | |
---|
[619] | 971 | IGCM_debug_Print 1 "DefineArrayFromOption : libIGCM_UserChanges in libIGCM.card" |
---|
| 972 | IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges |
---|
| 973 | IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]} |
---|
[119] | 974 | |
---|
[622] | 975 | # Special treatments for libIGCM internals |
---|
[619] | 976 | for option in ${libIGCM_UserChanges[*]} ; do |
---|
| 977 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option} |
---|
[119] | 978 | |
---|
[619] | 979 | echo "We will change : ${option}." |
---|
| 980 | eval echo "Previous value : " \${${option}} |
---|
| 981 | eval echo "Change to : " \${libIGCM_UserChanges_${option}} |
---|
[119] | 982 | |
---|
[619] | 983 | eval ${option}=\${libIGCM_UserChanges_${option}} |
---|
[119] | 984 | |
---|
[619] | 985 | case ${option} in |
---|
| 986 | config_UserChoices_DateEnd) |
---|
| 987 | IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd |
---|
| 988 | DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} ) |
---|
| 989 | |
---|
[622] | 990 | # Period Length In Days between DateBegin and DateEnd |
---|
[619] | 991 | (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} ) + 1 )) |
---|
| 992 | if [ ${ExperienceLengthInDays} -lt 0 ] ; then |
---|
| 993 | IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that." |
---|
| 994 | IGCM_debug_Exit "IGCM_PeriodEnd" " Wrong Dates." |
---|
| 995 | IGCM_debug_Verif_Exit |
---|
| 996 | fi |
---|
| 997 | ;; |
---|
| 998 | config_UserChoices_PeriodLength) |
---|
| 999 | IGCM_debug_Print 1 "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}" |
---|
| 1000 | ;; |
---|
| 1001 | PeriodNb) |
---|
| 1002 | IGCM_debug_Print 1 "Loop in main Job with ${PeriodNb} period(s)" |
---|
| 1003 | ;; |
---|
| 1004 | config_Post_RebuildFrequency) |
---|
| 1005 | IGCM_debug_Print 1 "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure" |
---|
| 1006 | IGCM_post_Configure |
---|
| 1007 | ;; |
---|
| 1008 | config_Post_TimeSeriesFrequency) |
---|
[653] | 1009 | IGCM_debug_Print 1 "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Configure" |
---|
[619] | 1010 | IGCM_post_Configure |
---|
| 1011 | ;; |
---|
| 1012 | config_Post_SeasonalFrequency) |
---|
[653] | 1013 | IGCM_debug_Print 1 "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Configure" |
---|
[619] | 1014 | IGCM_post_Configure |
---|
| 1015 | ;; |
---|
| 1016 | esac |
---|
| 1017 | done |
---|
[119] | 1018 | |
---|
[619] | 1019 | echo |
---|
| 1020 | echo "########################################################################" |
---|
| 1021 | echo |
---|
[544] | 1022 | fi |
---|
[119] | 1023 | |
---|
[544] | 1024 | #=================================================# |
---|
| 1025 | # Determine next computed period # |
---|
| 1026 | #=================================================# |
---|
[2] | 1027 | |
---|
[544] | 1028 | PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 ) |
---|
| 1029 | IGCM_date_GetYearMonthDay $PeriodDateBegin year month day |
---|
| 1030 | year_m1=$(( year - 1 )) |
---|
| 1031 | year_p1=$(( year + 1 )) |
---|
| 1032 | IGCM_config_Analyse_PeriodLength |
---|
| 1033 | PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) ) |
---|
[2] | 1034 | |
---|
[544] | 1035 | # Debug Print : |
---|
| 1036 | echo |
---|
| 1037 | IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution" |
---|
| 1038 | IGCM_debug_Print 1 "PeriodDateBegin : ${PeriodDateBegin}" |
---|
| 1039 | IGCM_debug_Print 1 "PeriodDateEnd : ${PeriodDateEnd}" |
---|
| 1040 | IGCM_debug_Print 1 "PeriodLengthInDays : ${PeriodLengthInDays}" |
---|
[2] | 1041 | |
---|
[544] | 1042 | PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} ) |
---|
| 1043 | PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} ) |
---|
[2] | 1044 | |
---|
[544] | 1045 | (( CumulPeriod = CumulPeriod + 1 )) |
---|
[2] | 1046 | |
---|
[544] | 1047 | # Debug Print : |
---|
| 1048 | echo |
---|
| 1049 | IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}" |
---|
| 1050 | IGCM_debug_Print 3 "PeriodDateEnd Human : ${PeriodDateEnd}" |
---|
| 1051 | IGCM_debug_Print 3 "CumulPeriod : ${CumulPeriod}" |
---|
[2] | 1052 | |
---|
[544] | 1053 | #=================================================# |
---|
[619] | 1054 | # Write updated run.card # |
---|
[544] | 1055 | #=================================================# |
---|
[2] | 1056 | |
---|
[544] | 1057 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix} |
---|
| 1058 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin} |
---|
| 1059 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd} |
---|
| 1060 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod} |
---|
[2] | 1061 | |
---|
[544] | 1062 | if ( ${FirstInitialize} ) ; then |
---|
| 1063 | # It's no more the first time |
---|
| 1064 | FirstInitialize=false |
---|
| 1065 | fi |
---|
[446] | 1066 | |
---|
[544] | 1067 | IGCM_debug_PopStack "IGCM_config_PeriodEnd" |
---|
[2] | 1068 | } |
---|
| 1069 | |
---|
| 1070 | #=================================== |
---|
| 1071 | function IGCM_config_Finalize |
---|
| 1072 | { |
---|
[544] | 1073 | IGCM_debug_PushStack "IGCM_config_Finalize" |
---|
[2] | 1074 | |
---|
[544] | 1075 | echo |
---|
| 1076 | IGCM_debug_Print 1 "IGCM_config_Finalize" |
---|
| 1077 | echo |
---|
[2] | 1078 | |
---|
[544] | 1079 | if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then |
---|
| 1080 | #==========================# |
---|
| 1081 | # End of entire simulation # |
---|
| 1082 | #==========================# |
---|
[2] | 1083 | |
---|
[544] | 1084 | # Mail notification |
---|
| 1085 | IGCM_sys_SendMail |
---|
[2] | 1086 | |
---|
[544] | 1087 | # |
---|
| 1088 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed" |
---|
| 1089 | IGCM_debug_Print 1 "Normal End of computation." |
---|
| 1090 | if ( $DEBUG_debug ) ; then |
---|
| 1091 | echo |
---|
| 1092 | IGCM_debug_Print 1 "Your files on ${R_SAVE} :" |
---|
| 1093 | IGCM_sys_Tree ${R_SAVE} |
---|
[2] | 1094 | |
---|
[544] | 1095 | IGCM_debug_Print 1 "Your files on ${R_BUFR} :" |
---|
| 1096 | IGCM_sys_Tree ${R_BUFR} |
---|
| 1097 | fi |
---|
| 1098 | else |
---|
| 1099 | #=================# |
---|
| 1100 | # Submit next job # |
---|
| 1101 | #=================# |
---|
[2] | 1102 | |
---|
[544] | 1103 | IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" |
---|
[2] | 1104 | |
---|
[544] | 1105 | # Name of next Ksh Script output : |
---|
| 1106 | eval Script_Output="${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )" |
---|
[2] | 1107 | |
---|
[544] | 1108 | IGCM_debug_Print 1 "Submit next job" |
---|
| 1109 | # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR |
---|
| 1110 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 1111 | # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName} |
---|
| 1112 | ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l ) |
---|
| 1113 | [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) ) |
---|
| 1114 | # Submit next job and come back |
---|
| 1115 | IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} |
---|
| 1116 | IGCM_sys_Cd - |
---|
| 1117 | fi |
---|
[154] | 1118 | |
---|
[544] | 1119 | # Supress Non Deleted Boundary files |
---|
| 1120 | if [ ${DRYRUN} -le 2 ] ; then |
---|
| 1121 | IGCM_comp_DelFixeBoundaryFiles |
---|
| 1122 | ls -la |
---|
| 1123 | fi |
---|
[619] | 1124 | |
---|
[544] | 1125 | # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName} |
---|
| 1126 | # Only for production run (No clean up in DEV or DEB mode) |
---|
| 1127 | # and command sent from .. directory. |
---|
| 1128 | IGCM_sys_Cd .. |
---|
| 1129 | [ X${JobType} = XRUN ] && IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 1130 | |
---|
| 1131 | IGCM_debug_PopStack "IGCM_config_Finalize" |
---|
[2] | 1132 | } |
---|
| 1133 | |
---|
| 1134 | #=================================== |
---|