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