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