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