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