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