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