[1164] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Jacques Belier |
---|
| 5 | # Contact: |
---|
| 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
| 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | #--------------------------------------------------------------------- |
---|
| 14 | #- Installation of jobs according to environment |
---|
| 15 | #--------------------------------------------------------------------- |
---|
| 16 | function ins_job_Usage |
---|
| 17 | { |
---|
| 18 | print - " |
---|
| 19 | ins_job installs the jobs in the directories |
---|
| 20 | which contain a file config.card |
---|
| 21 | |
---|
| 22 | ins_job must be launched on the host |
---|
| 23 | on which the job will be submitted |
---|
| 24 | |
---|
| 25 | Usage : |
---|
[1274] | 26 | ${b_n} [-h] [-v] [-e] |
---|
| 27 | or on curie/TGCC : |
---|
[1303] | 28 | ${b_n} [-h] [-v] [-e] [-p project] [-c number of cores] |
---|
[1468] | 29 | or on irene/TGCC : |
---|
| 30 | ${b_n} [-h] [-v] [-e] [-p project] [-s post-project] [-q type_of_node] [-c number of cores] |
---|
[1305] | 31 | or on ada /IDRIS |
---|
| 32 | ${b_n} [-h] [-v] [-e] [-m MPI environment] |
---|
[1164] | 33 | Options : |
---|
[1274] | 34 | -h : help |
---|
| 35 | -v : verbose mode |
---|
| 36 | -e : turn on ensemble mode (hindcast/forecast or date restart) |
---|
[1401] | 37 | -f : ins_job is force to create jobs even if they already exist |
---|
[1274] | 38 | on curie only : |
---|
| 39 | -p project : add default project on curie |
---|
[1468] | 40 | -c number of cores : add default number of cores for postprocessing on curie : 1-16 |
---|
| 41 | on irene only : |
---|
| 42 | -p project : add default project on irene |
---|
| 43 | -s post-project : add default project use for post-processing on irene |
---|
| 44 | -q type_of_node : add default type of nodes for postprocessing on irene skylake/xlarge |
---|
| 45 | -c number of cores : add default number of cores for postprocessing on irene 1-112 |
---|
[1305] | 46 | on ada only : |
---|
| 47 | - m MPI environment : add default MPI environment (Intel MPI or IBM MPI) |
---|
[1164] | 48 | " |
---|
| 49 | } |
---|
| 50 | function ins_job_Warning |
---|
| 51 | { |
---|
| 52 | [[ ${x_v} = 'verbose' ]] && print - "\n############### WARNING ###############"; |
---|
| 53 | [[ ${x_v} = 'verbose' ]] && print - "File ${n_f} already exists\nin directory ${j}"; |
---|
| 54 | [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !"; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | function ins_job_Check_JobName |
---|
| 58 | { |
---|
| 59 | verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])} |
---|
| 60 | |
---|
| 61 | if [ ${#verif} -ne 0 ] ; then |
---|
| 62 | echo "################ ERROR ################" |
---|
| 63 | echo "${JobName} is invalid." |
---|
| 64 | echo "- JobName can only contain alphanumeric characters, \".\" and \"-\"" |
---|
| 65 | echo "- JobName must start with a letter" |
---|
| 66 | |
---|
| 67 | ((NbErr=NbErr+1)) |
---|
| 68 | |
---|
| 69 | Status=1 |
---|
| 70 | else |
---|
| 71 | Status=0 |
---|
| 72 | fi |
---|
| 73 | |
---|
| 74 | return ${Status} |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | #- |
---|
| 78 | # dirname and basename |
---|
| 79 | #- |
---|
| 80 | d_n=$(dirname ${0}); b_n=$(basename ${0}); |
---|
| 81 | #- |
---|
| 82 | # Retrieving and validation of the options |
---|
| 83 | #- |
---|
| 84 | x_v='silencious'; |
---|
| 85 | x_e=false; |
---|
[1401] | 86 | x_f=false; |
---|
[1164] | 87 | x_p=false; |
---|
[1468] | 88 | x_q=false; |
---|
| 89 | x_s=false; |
---|
[1274] | 90 | x_c=false; |
---|
[1305] | 91 | x_m=false; |
---|
[1468] | 92 | while getopts :hvefc:p:m:q:s: V ; do |
---|
[1164] | 93 | case $V in |
---|
| 94 | (h) ins_job_Usage; exit 0;; |
---|
| 95 | (v) x_v='verbose';; |
---|
| 96 | (e) x_e=true;; |
---|
[1401] | 97 | (f) x_f=true;; |
---|
[1164] | 98 | (p) x_p=true |
---|
| 99 | ProjectID=${OPTARG} ;; |
---|
[1468] | 100 | (s) x_s=true |
---|
| 101 | PostID=${OPTARG} ;; |
---|
| 102 | (q) x_q=true |
---|
| 103 | ProjectNode=${OPTARG} ;; |
---|
[1274] | 104 | (c) x_c=true |
---|
| 105 | ProjectCore=${OPTARG} ;; |
---|
[1305] | 106 | (m) x_m=true |
---|
| 107 | MPIEnvironment=${OPTARG} ;; |
---|
[1164] | 108 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
| 109 | exit 2;; |
---|
| 110 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
| 111 | exit 2;; |
---|
| 112 | esac |
---|
| 113 | done |
---|
| 114 | [ ${x_v} = 'silencious' ] && export DEBUG_sys=false |
---|
| 115 | shift $(($OPTIND-1)); |
---|
| 116 | #- |
---|
| 117 | # Define working files |
---|
| 118 | #- |
---|
| 119 | F_MOD=$(cd ${d_n}'/..';/bin/pwd;) |
---|
| 120 | # [[ ${F_MOD##*/} != 'modipsl' ]] && \ |
---|
| 121 | # { print - "directory 'modipsl' unreachable"; exit 3; } |
---|
| 122 | W_W=${d_n}'/../libIGCM' |
---|
| 123 | [[ ! -d ${W_W} ]] && { print - "${W_W} unreachable"; exit 3; } |
---|
| 124 | libIGCM=$(cd ${W_W};/bin/pwd;) |
---|
| 125 | F_JOB=${libIGCM}'/AA_job'; |
---|
| 126 | [[ ! -f ${F_JOB} ]] && { print - "${F_JOB} unreachable"; exit 3; } |
---|
| 127 | F_RCI=${libIGCM}'/run.card.init'; |
---|
| 128 | [[ ! -f ${F_RCI} ]] && { print - "${F_RCI} unreachable"; exit 3; } |
---|
| 129 | #- |
---|
| 130 | # Accessing to functions (without stack) |
---|
| 131 | #- |
---|
[1249] | 132 | # No verbosity (0, 1, 2, 3) |
---|
| 133 | Verbosity=0 |
---|
| 134 | # No de debug |
---|
[1164] | 135 | DEBUG_debug=false |
---|
[1249] | 136 | # Dont move libIGCM |
---|
[1164] | 137 | MirrorlibIGCM=false |
---|
[1249] | 138 | # Behave like computing job |
---|
[1164] | 139 | TaskType=computing |
---|
[1249] | 140 | # Source libIGCM |
---|
[1164] | 141 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 142 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 143 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 144 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
[1242] | 145 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[1164] | 146 | if [ $x_e = 'true' ] ; then |
---|
| 147 | . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh |
---|
| 148 | fi |
---|
| 149 | |
---|
[1172] | 150 | #- |
---|
| 151 | [[ ${x_v} = 'verbose' ]] && \ |
---|
| 152 | { |
---|
| 153 | print - ""; |
---|
| 154 | print - '--- Host : '${SYSTEM}; |
---|
| 155 | print - '--- modipsl : '${F_MOD}; |
---|
| 156 | print - '--- libIGCM : '${libIGCM}; |
---|
| 157 | print - '--- basic job : '${F_JOB}; |
---|
| 158 | print - '--- basic card : '${F_RCI}; |
---|
| 159 | } |
---|
| 160 | #- |
---|
| 161 | [[ ${x_v} = 'verbose' ]] && print - "\nInstallation of jobs for '${SYSTEM}'"; |
---|
| 162 | #- |
---|
| 163 | |
---|
[1164] | 164 | NbErr=0 |
---|
| 165 | |
---|
| 166 | #- |
---|
[1274] | 167 | # Define Project parameters to set up jobs header for Curie (TGCC) |
---|
[1303] | 168 | # on curie define ProjectID and ProjectCore : option or answer |
---|
| 169 | # on curie ProjectNode forced to standard since 16/3/2016 |
---|
[1164] | 170 | #- |
---|
[1274] | 171 | |
---|
| 172 | if [ X"${SYSTEM}" == "Xcurie" ] ; then |
---|
| 173 | if ( ! ${x_p} ) ; then |
---|
[1164] | 174 | ProjectID=$( ccc_myproject | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | head -n 1 ) |
---|
[1315] | 175 | ProjectID=${ProjectID:="devcmip6"} |
---|
[1164] | 176 | answer="" |
---|
[1468] | 177 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i curie | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u ) ) :" |
---|
[1164] | 178 | read answer |
---|
| 179 | |
---|
[1322] | 180 | if [ "X${answer}" != "X" ] ; then |
---|
| 181 | ProjectID=${answer} |
---|
| 182 | fi |
---|
| 183 | |
---|
[1371] | 184 | if [ "X${ProjectID}" = "Xgencmip6" ] ; then |
---|
[1315] | 185 | ProjectID=devcmip6 |
---|
| 186 | fi |
---|
[1274] | 187 | fi # if ( ! ${x_p} ) |
---|
| 188 | |
---|
[1303] | 189 | #- ProjectNode forced to standard since 16/3/2016 |
---|
| 190 | ProjectNode="standard" |
---|
[1274] | 191 | |
---|
[1303] | 192 | echo ProjectID is ${ProjectID} and ProjectNode for PostProcessing is ${ProjectNode} |
---|
[1274] | 193 | |
---|
[1303] | 194 | #- ProjectNode is known (standard since 16/3/2016) set ProjectCoreMax |
---|
| 195 | ProjectCoreMax="16" |
---|
[1274] | 196 | |
---|
| 197 | if ( ! ${x_c} ) ; then |
---|
[1303] | 198 | #- ProjectNode is known (standard since 16/3/2016), set ProjectCore to default or answer |
---|
| 199 | ProjectCore="4" |
---|
[1274] | 200 | answerOK=false |
---|
| 201 | |
---|
| 202 | while ( ! ${answerOK} ) ; do |
---|
| 203 | answer="" |
---|
| 204 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\"), possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" : " |
---|
| 205 | read answer |
---|
| 206 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
| 207 | done |
---|
| 208 | |
---|
| 209 | if [ "X${answer}" != "X" ] ; then |
---|
| 210 | ProjectCore=${answer} |
---|
| 211 | fi |
---|
[1303] | 212 | |
---|
[1274] | 213 | fi # if ( ! ${x_c} ) |
---|
[1303] | 214 | |
---|
[1274] | 215 | echo ProjectCore is ${ProjectCore} |
---|
[1303] | 216 | #- ProjectCore is set (option or answer) |
---|
[1316] | 217 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
[1274] | 218 | |
---|
[1437] | 219 | elif [ X"${SYSTEM}" == "Xirene" ] ; then |
---|
| 220 | if ( ! ${x_p} ) ; then |
---|
[1468] | 221 | ProjectID=$( ccc_myproject | grep -i irene |grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | head -n 1 ) |
---|
[1437] | 222 | ProjectID=${ProjectID:="gch0316"} |
---|
| 223 | answer="" |
---|
[1468] | 224 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u ) ) :" |
---|
[1437] | 225 | read answer |
---|
| 226 | |
---|
| 227 | if [ "X${answer}" != "X" ] ; then |
---|
| 228 | ProjectID=${answer} |
---|
| 229 | fi |
---|
| 230 | |
---|
| 231 | fi # if ( ! ${x_p} ) |
---|
| 232 | |
---|
| 233 | echo ProjectID is ${ProjectID} at Irene |
---|
| 234 | |
---|
[1465] | 235 | |
---|
[1468] | 236 | if ( ! ${x_q} ) ; then |
---|
| 237 | #- ProjectID is known (option or answer), set ProjectNode |
---|
| 238 | ProjectNode="skylake" |
---|
| 239 | answerOK=false |
---|
| 240 | |
---|
| 241 | while ( ! ${answerOK} ) ; do |
---|
| 242 | answer="" |
---|
| 243 | print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"skylake\" or \"xlarge\" : " |
---|
| 244 | read answer |
---|
| 245 | [ "X${answer}" == "X" ] || [ "X${answer}" == "Xskylake" ] || [ "X${answer}" == "Xxlarge" ] && answerOK=true |
---|
| 246 | done |
---|
| 247 | |
---|
| 248 | if [ "X${answer}" != "X" ] ; then |
---|
| 249 | ProjectNode=${answer} |
---|
| 250 | fi |
---|
| 251 | |
---|
| 252 | fi # if ( ! ${x_q} ) |
---|
| 253 | echo ProjectNode is ${ProjectNode} at Irene |
---|
[1465] | 254 | |
---|
[1468] | 255 | #- ProjectNode is known (option or answer) set ProjectCoreMax |
---|
| 256 | [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" |
---|
| 257 | #- ProjectCoreMax is 48 for standard and 112 for xlarge |
---|
| 258 | |
---|
[1465] | 259 | if ( ! ${x_c} ) ; then |
---|
[1468] | 260 | #- ProjectNode is known (option or answer), set ProjectCore default |
---|
| 261 | [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" |
---|
[1465] | 262 | answerOK=false |
---|
| 263 | |
---|
| 264 | while ( ! ${answerOK} ) ; do |
---|
| 265 | answer="" |
---|
[1468] | 266 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")" |
---|
| 267 | print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : " |
---|
[1465] | 268 | read answer |
---|
| 269 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
| 270 | done |
---|
| 271 | |
---|
| 272 | if [ "X${answer}" != "X" ] ; then |
---|
| 273 | ProjectCore=${answer} |
---|
| 274 | fi |
---|
| 275 | |
---|
| 276 | fi # if ( ! ${x_c} ) |
---|
| 277 | |
---|
| 278 | echo ProjectCore is ${ProjectCore} |
---|
| 279 | #- ProjectCore is set (option or answer) |
---|
| 280 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
| 281 | |
---|
[1468] | 282 | #- ProjetCore is known (option or answer) set PostID : project ID for post-processing |
---|
| 283 | |
---|
| 284 | if ( ! ${x_s} ) ; then |
---|
| 285 | PostID=$( ccc_myproject | grep -i irene | grep -i ${ProjectNode} | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | head -n 1 ) |
---|
| 286 | PostID=${PostID:="gch0316"} |
---|
| 287 | answer="" |
---|
| 288 | print - "Hit Enter or give project ID (default is ${PostID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i ${ProjectNode} | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u ) ) :" |
---|
| 289 | read answer |
---|
| 290 | |
---|
| 291 | if [ "X${answer}" != "X" ] ; then |
---|
| 292 | PostID=${answer} |
---|
| 293 | fi |
---|
| 294 | |
---|
| 295 | fi # if ( ! ${x_p} ) |
---|
| 296 | |
---|
| 297 | echo PostID is ${PostID} at Irene on ${ProjectNode} for post-processing |
---|
| 298 | |
---|
[1305] | 299 | elif [ X"${SYSTEM}" == "Xada" ] ; then |
---|
[1316] | 300 | if ( ! ${x_m} ) ; then |
---|
| 301 | MPIEnvironment=IBM |
---|
| 302 | # Intel MPI Environment. |
---|
| 303 | answerOK=false |
---|
| 304 | while ( ! ${answerOK} ) ; do |
---|
| 305 | answer="" |
---|
| 306 | print - "Hit Enter or give MPI Environement (default is ${MPIEnvironment}), possible MPI environments are IBM (MPI IBM) and Intel (MPI Intel) :" |
---|
| 307 | read answer |
---|
| 308 | [ "X${answer}" == "X" ] || [ "X${answer}" == "XIBM" ] || [ "X${answer}" == "XIntel" ] && answerOK=true |
---|
| 309 | done |
---|
[1305] | 310 | |
---|
[1316] | 311 | if [ "X${answer}" != "X" ] ; then |
---|
| 312 | MPIEnvironment=${answer} |
---|
| 313 | fi |
---|
| 314 | fi # if ( ! ${x_pm} ) |
---|
| 315 | echo MPIEnvironment is ${MPIEnvironment} |
---|
[1391] | 316 | elif [ X"${SYSTEM}" == "Xlxiv8" ] || [ X"${SYSTEM}" == "Xifort_CICLAD" ] ; then |
---|
| 317 | # obelix, ciclad, climserv |
---|
| 318 | echo "" |
---|
| 319 | echo "You need to check and maybe adapt headers in the main job especially the line: " |
---|
| 320 | echo " #PBS -l nodes=x:ppn=y " |
---|
| 321 | echo "where x is the number of nodes, y the number of cores per node and x*y is the total number of cores for the job. " |
---|
| 322 | echo "y must not be bigger than the maximum numer of cores per node on the machine (often 8 or 16)." |
---|
[1274] | 323 | fi # if [ X"${SYSTEM}" == "Xcurie" ] |
---|
[1164] | 324 | |
---|
| 325 | #- |
---|
| 326 | # Define the pattern string to substitute |
---|
| 327 | #- |
---|
[1172] | 328 | W_P='#-Q- '; W_W=${W_P}${SYSTEM}; |
---|
[1164] | 329 | #- |
---|
| 330 | # Extract list of 'config.card' files |
---|
| 331 | # and create jobs with AA_job |
---|
| 332 | #- |
---|
| 333 | F_CFG='config.card'; |
---|
| 334 | F_CFG_ENS='ensemble.card'; |
---|
| 335 | SUBMIT_DIR_ENS=$( pwd ) |
---|
[1271] | 336 | for i in $( pwd )/config.card |
---|
[1164] | 337 | do |
---|
[1271] | 338 | if [ ! -f $i ] ; then |
---|
| 339 | echo "" |
---|
| 340 | echo "################## WARNING ##################" |
---|
| 341 | echo "No config.card available in current directory" |
---|
| 342 | echo "" |
---|
| 343 | continue |
---|
| 344 | fi |
---|
| 345 | |
---|
| 346 | |
---|
[1164] | 347 | j=$(cd ${i%/*};/bin/pwd;) |
---|
| 348 | n_f=${F_RCI##*/}; |
---|
| 349 | |
---|
| 350 | if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then |
---|
| 351 | # Do not treat config.card if it is in sub-directory of EXPERIMENTS |
---|
| 352 | # Continue to next config.card |
---|
| 353 | continue |
---|
| 354 | else |
---|
| 355 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
| 356 | fi |
---|
| 357 | |
---|
| 358 | # Find out if new structure and set .resol filename |
---|
| 359 | if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then |
---|
| 360 | # New Structure |
---|
| 361 | [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure" |
---|
| 362 | new_struct=yes |
---|
| 363 | resolfile=$j/.resol |
---|
| 364 | else |
---|
| 365 | # Old Structure |
---|
| 366 | new_struct=no |
---|
| 367 | resolfile=$j/../.resol |
---|
| 368 | fi |
---|
| 369 | |
---|
| 370 | # Get all variables declared in section UserChoices in config.card |
---|
| 371 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices |
---|
| 372 | # Set default values |
---|
| 373 | config_UserChoices_ExpType="" |
---|
| 374 | RESOL_ATM_3D=this_is_a_test_string |
---|
| 375 | RESOL=this_is_another_test_string |
---|
| 376 | typeset option |
---|
| 377 | for option in ${config_UserChoices[*]} ; do |
---|
| 378 | IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option} |
---|
| 379 | done |
---|
| 380 | |
---|
| 381 | # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file |
---|
| 382 | if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then |
---|
| 383 | TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' ) |
---|
| 384 | echo TRUERESOL = $TRUERESOL |
---|
| 385 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" ) |
---|
| 386 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
| 387 | elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then |
---|
| 388 | TRUERESOL=$( head -1 $resolfile ) |
---|
| 389 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" ) |
---|
| 390 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
| 391 | else |
---|
| 392 | JobName=${config_UserChoices_JobName} |
---|
| 393 | fi |
---|
| 394 | |
---|
| 395 | # Check JobName validity : only alphanumerical characters, "-" and "." are authorized |
---|
| 396 | ins_job_Check_JobName |
---|
| 397 | RetCode=$? |
---|
| 398 | [[ $RetCode -gt 0 ]] && continue |
---|
| 399 | |
---|
| 400 | [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" |
---|
| 401 | |
---|
| 402 | # Add specific treatment for new type of directory structure |
---|
| 403 | if [ ${new_struct} == yes ] ; then |
---|
| 404 | |
---|
| 405 | if [ "X${config_UserChoices_ExpType}" = X ] ; then |
---|
| 406 | echo "\nERROR in ${j}/config.card" |
---|
| 407 | echo "ins_job stops here" |
---|
| 408 | echo "=> The variable ExpType must be added in config.card in section UserChoices" |
---|
[1238] | 409 | echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" |
---|
[1164] | 410 | exit 4 |
---|
| 411 | else |
---|
| 412 | [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" |
---|
| 413 | fi |
---|
| 414 | |
---|
| 415 | if [ -d ${j}/${JobName} ] ; then |
---|
[1359] | 416 | echo "Directory ${j}/${JobName} exists already. It will not be overwritten." |
---|
| 417 | echo "Remove the existing directory or change JobName before relaunching ins_job." |
---|
[1164] | 418 | continue |
---|
| 419 | fi |
---|
| 420 | echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" |
---|
| 421 | cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} |
---|
| 422 | cp -r ${j}/GENERAL/* ${j}/${JobName}/. |
---|
| 423 | cp -f ${j}/${F_CFG} ${j}/${JobName}/. |
---|
| 424 | if [ -f ${F_CFG_ENS} ] ; then |
---|
| 425 | cp -f ${j}/${F_CFG_ENS} ${j}/${JobName}/. |
---|
| 426 | SUBMIT_DIR_ENS=${j}/${JobName} |
---|
| 427 | fi |
---|
| 428 | rm -f ${j}/${F_CFG} |
---|
| 429 | rm -f ${j}/${F_CFG_ENS} |
---|
| 430 | rm -f ${j}/${F_CFG}.bak |
---|
| 431 | j=${j}/${JobName} |
---|
| 432 | [[ ${x_v} = 'verbose' ]] && echo new j=$j |
---|
| 433 | fi |
---|
| 434 | # end specific treatment for new type directory structure |
---|
| 435 | |
---|
| 436 | [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ |
---|
| 437 | { |
---|
| 438 | [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; |
---|
| 439 | \cp ${F_RCI} ${j}; |
---|
| 440 | } |
---|
[1242] | 441 | |
---|
[1238] | 442 | #================================== |
---|
[1242] | 443 | # Read ListOfComponents section: |
---|
| 444 | #echo |
---|
| 445 | #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
| 446 | |
---|
| 447 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} ListOfComponents |
---|
| 448 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 449 | IGCM_card_DefineArrayFromOption ${j}'/'${F_CFG} ListOfComponents ${comp} |
---|
| 450 | done |
---|
| 451 | #IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
| 452 | |
---|
| 453 | #================================== |
---|
[1238] | 454 | # Read Executable section: |
---|
[1242] | 455 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable |
---|
[1164] | 456 | |
---|
[1238] | 457 | # Define the execution context (MPMD, SPMD, MPI/OMP ...) |
---|
[1242] | 458 | IGCM_config_ConfigureExecution ${j}'/'${F_CFG} |
---|
[1238] | 459 | |
---|
| 460 | # coreNumber : TOTAL NUMBER OF CORES |
---|
| 461 | # mpiTasks : TOTAL NUMBER OF MPI TASKS |
---|
| 462 | # openMPthreads : NUMBER OF OpenMP THREADS |
---|
| 463 | |
---|
[1164] | 464 | # File name for Job |
---|
| 465 | n_f='Job_'${JobName}; |
---|
[1401] | 466 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
[1164] | 467 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
| 468 | sed -e "/^${W_W} */ s///" \ |
---|
| 469 | -e "/^${W_P}/d" \ |
---|
| 470 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
| 471 | -e "s/::Jobname::/${JobName}/" \ |
---|
| 472 | -e "s/::default_project::/${ProjectID}/" \ |
---|
| 473 | ${F_JOB} > ${j}'/'${n_f} |
---|
| 474 | chmod u+x ${j}'/'${n_f} |
---|
[1238] | 475 | |
---|
| 476 | # update Headers so that ressources description are accurate (MPMD/SPMD/...) |
---|
| 477 | IGCM_sys_updateHeaders ${j}'/'${n_f} |
---|
[1164] | 478 | done |
---|
[1238] | 479 | |
---|
[1164] | 480 | #- |
---|
| 481 | # Extract list of AA_* files in libIGCM |
---|
| 482 | # and create jobs (for all except AA_job) |
---|
| 483 | #- |
---|
| 484 | for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print) |
---|
| 485 | do |
---|
| 486 | i_f=${i##*/}; |
---|
| 487 | [[ ${i_f} = 'AA_job' ]] && { continue; } |
---|
| 488 | j=${i%/*}; n_f=${i_f#AA_}'.job'; |
---|
[1401] | 489 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
[1164] | 490 | [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" |
---|
| 491 | sed -e "/^${W_W} */ s///" \ |
---|
| 492 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
| 493 | -e "/^${W_P}/d" \ |
---|
| 494 | -e "s/::default_node::/${ProjectNode}/" \ |
---|
[1274] | 495 | -e "s/::default_core::/${ProjectCore}/" \ |
---|
[1164] | 496 | -e "s/::default_project::/${ProjectID}/" \ |
---|
[1468] | 497 | -e "s/::default_post_project::/${PostID}/" \ |
---|
[1164] | 498 | ${i} > ${j}'/'${n_f} |
---|
| 499 | chmod u+x ${j}'/'${n_f} |
---|
| 500 | done |
---|
| 501 | #- |
---|
| 502 | # set default_project in libIGCM_sys_curie.ksh too. |
---|
| 503 | #- |
---|
[1172] | 504 | if [ X"${SYSTEM}" == "Xcurie" ] ; then |
---|
[1164] | 505 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_curie.ksh |
---|
| 506 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
| 507 | fi |
---|
| 508 | #- |
---|
| 509 | # Limited to hindcast/forecast and date restart Ensemble for the time being |
---|
| 510 | if [ ${x_e} = 'true' ] ; then |
---|
| 511 | #.. Read input data from ensemble.card .. |
---|
| 512 | SUBMIT_DIR=${SUBMIT_DIR_ENS} |
---|
[1361] | 513 | RUN_DIR="${WORKDIR}/ENSEMBLE_TMP" |
---|
[1164] | 514 | # |
---|
| 515 | # Copy initial things around and define variables (hindcast/forecast case) |
---|
| 516 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 517 | IGCM_ensemble_Init |
---|
| 518 | |
---|
| 519 | if [[ ${ensemble_Ens_PARAMETRIC_active} = 'y' ]] ; then |
---|
| 520 | echo "WARNING: Parametric Ensemble is not implemented yet..." |
---|
| 521 | fi |
---|
| 522 | |
---|
| 523 | if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then |
---|
| 524 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 525 | IGCM_ensemble_DateInit |
---|
| 526 | # As it says |
---|
| 527 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 528 | IGCM_ensemble_DatePeriodicStarts |
---|
| 529 | # As it says |
---|
| 530 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 531 | IGCM_ensemble_DateNonPeriodicStarts |
---|
| 532 | # Clean |
---|
| 533 | IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 534 | fi |
---|
| 535 | |
---|
| 536 | if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then |
---|
| 537 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 538 | IGCM_ensemble_CastInit |
---|
| 539 | # As it says |
---|
| 540 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 541 | IGCM_ensemble_CastPeriodicStarts |
---|
| 542 | # As it says |
---|
| 543 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 544 | IGCM_ensemble_CastNonPeriodicStarts |
---|
| 545 | # As it says |
---|
| 546 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 547 | IGCM_ensemble_CastMemberList |
---|
| 548 | # Done |
---|
[1361] | 549 | #IGCM_sys_Cp ${RUN_DIR}/CreatedDir.txt ${SUBMIT_DIR} |
---|
[1164] | 550 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 551 | # Clean |
---|
| 552 | IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 553 | fi |
---|
| 554 | fi |
---|
| 555 | #- |
---|
| 556 | [[ ${x_v} = 'verbose' ]] && print - ""; |
---|
| 557 | #- |
---|
| 558 | # That's all folks |
---|
| 559 | #- |
---|
| 560 | |
---|
| 561 | if [ ${NbErr} -ne 0 ] ; then |
---|
| 562 | echo "################ ERROR ################" |
---|
| 563 | echo "${NbErr} invalid JobName(s) found, check the log" |
---|
| 564 | fi |
---|
| 565 | |
---|
| 566 | |
---|
| 567 | exit 0; |
---|