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