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