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