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