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