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