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