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