[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] |
---|
[1468] | 27 | or on irene/TGCC : |
---|
[1471] | 28 | ${b_n} [-h] [-v] [-e] [-p project] [-q type_of_node] [-c number of cores] |
---|
[1305] | 29 | or on ada /IDRIS |
---|
| 30 | ${b_n} [-h] [-v] [-e] [-m MPI environment] |
---|
[1164] | 31 | Options : |
---|
[1274] | 32 | -h : help |
---|
| 33 | -v : verbose mode |
---|
| 34 | -e : turn on ensemble mode (hindcast/forecast or date restart) |
---|
[1401] | 35 | -f : ins_job is force to create jobs even if they already exist |
---|
[1468] | 36 | on irene only : |
---|
| 37 | -p project : add default project on irene |
---|
| 38 | -q type_of_node : add default type of nodes for postprocessing on irene skylake/xlarge |
---|
| 39 | -c number of cores : add default number of cores for postprocessing on irene 1-112 |
---|
[1305] | 40 | on ada only : |
---|
| 41 | - m MPI environment : add default MPI environment (Intel MPI or IBM MPI) |
---|
[1536] | 42 | -t wall time : change default wall time |
---|
[1164] | 43 | " |
---|
| 44 | } |
---|
| 45 | function ins_job_Warning |
---|
| 46 | { |
---|
| 47 | [[ ${x_v} = 'verbose' ]] && print - "\n############### WARNING ###############"; |
---|
| 48 | [[ ${x_v} = 'verbose' ]] && print - "File ${n_f} already exists\nin directory ${j}"; |
---|
| 49 | [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !"; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | function ins_job_Check_JobName |
---|
| 53 | { |
---|
| 54 | verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])} |
---|
| 55 | |
---|
| 56 | if [ ${#verif} -ne 0 ] ; then |
---|
| 57 | echo "################ ERROR ################" |
---|
| 58 | echo "${JobName} is invalid." |
---|
| 59 | echo "- JobName can only contain alphanumeric characters, \".\" and \"-\"" |
---|
| 60 | echo "- JobName must start with a letter" |
---|
| 61 | |
---|
| 62 | ((NbErr=NbErr+1)) |
---|
| 63 | |
---|
| 64 | Status=1 |
---|
| 65 | else |
---|
| 66 | Status=0 |
---|
| 67 | fi |
---|
| 68 | |
---|
| 69 | return ${Status} |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | #- |
---|
| 73 | # dirname and basename |
---|
| 74 | #- |
---|
| 75 | d_n=$(dirname ${0}); b_n=$(basename ${0}); |
---|
| 76 | #- |
---|
| 77 | # Retrieving and validation of the options |
---|
| 78 | #- |
---|
| 79 | x_v='silencious'; |
---|
| 80 | x_e=false; |
---|
[1401] | 81 | x_f=false; |
---|
[1164] | 82 | x_p=false; |
---|
[1468] | 83 | x_q=false; |
---|
[1274] | 84 | x_c=false; |
---|
[1305] | 85 | x_m=false; |
---|
[1536] | 86 | x_t=false; |
---|
| 87 | while getopts :hvefc:p:m:q:s:t: V ; do |
---|
[1164] | 88 | case $V in |
---|
| 89 | (h) ins_job_Usage; exit 0;; |
---|
| 90 | (v) x_v='verbose';; |
---|
| 91 | (e) x_e=true;; |
---|
[1401] | 92 | (f) x_f=true;; |
---|
[1164] | 93 | (p) x_p=true |
---|
| 94 | ProjectID=${OPTARG} ;; |
---|
[1468] | 95 | (q) x_q=true |
---|
| 96 | ProjectNode=${OPTARG} ;; |
---|
[1274] | 97 | (c) x_c=true |
---|
| 98 | ProjectCore=${OPTARG} ;; |
---|
[1305] | 99 | (m) x_m=true |
---|
| 100 | MPIEnvironment=${OPTARG} ;; |
---|
[1536] | 101 | (t) x_t=true |
---|
| 102 | WallTime=${OPTARG} ;; |
---|
[1164] | 103 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
| 104 | exit 2;; |
---|
| 105 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
| 106 | exit 2;; |
---|
| 107 | esac |
---|
| 108 | done |
---|
| 109 | [ ${x_v} = 'silencious' ] && export DEBUG_sys=false |
---|
| 110 | shift $(($OPTIND-1)); |
---|
| 111 | #- |
---|
| 112 | # Define working files |
---|
| 113 | #- |
---|
| 114 | F_MOD=$(cd ${d_n}'/..';/bin/pwd;) |
---|
| 115 | # [[ ${F_MOD##*/} != 'modipsl' ]] && \ |
---|
| 116 | # { print - "directory 'modipsl' unreachable"; exit 3; } |
---|
| 117 | W_W=${d_n}'/../libIGCM' |
---|
[1585] | 118 | #W_W=${d_n} # S.Senesi - not sure of the intent in line above, but that clashes with using a symbolic link for libIGCM in modipsl/, which is must useful for development |
---|
[1164] | 119 | [[ ! -d ${W_W} ]] && { print - "${W_W} unreachable"; exit 3; } |
---|
| 120 | libIGCM=$(cd ${W_W};/bin/pwd;) |
---|
| 121 | F_JOB=${libIGCM}'/AA_job'; |
---|
| 122 | [[ ! -f ${F_JOB} ]] && { print - "${F_JOB} unreachable"; exit 3; } |
---|
[1585] | 123 | F_JOB_DEBUG=${libIGCM}'/AA_job_debug'; |
---|
| 124 | [[ ! -f ${F_JOB_DEBUG} ]] && { print - "${F_JOB_DEBUG} unreachable"; exit 3; } |
---|
[1164] | 125 | F_RCI=${libIGCM}'/run.card.init'; |
---|
| 126 | [[ ! -f ${F_RCI} ]] && { print - "${F_RCI} unreachable"; exit 3; } |
---|
| 127 | #- |
---|
| 128 | # Accessing to functions (without stack) |
---|
| 129 | #- |
---|
[1249] | 130 | # No verbosity (0, 1, 2, 3) |
---|
| 131 | Verbosity=0 |
---|
| 132 | # No de debug |
---|
[1164] | 133 | DEBUG_debug=false |
---|
[1249] | 134 | # Dont move libIGCM |
---|
[1164] | 135 | MirrorlibIGCM=false |
---|
[1249] | 136 | # Behave like computing job |
---|
[1164] | 137 | TaskType=computing |
---|
[1249] | 138 | # Source libIGCM |
---|
[1164] | 139 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
| 140 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
| 141 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
| 142 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
[1242] | 143 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
[1164] | 144 | if [ $x_e = 'true' ] ; then |
---|
| 145 | . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh |
---|
| 146 | fi |
---|
| 147 | |
---|
[1172] | 148 | #- |
---|
| 149 | [[ ${x_v} = 'verbose' ]] && \ |
---|
| 150 | { |
---|
| 151 | print - ""; |
---|
| 152 | print - '--- Host : '${SYSTEM}; |
---|
| 153 | print - '--- modipsl : '${F_MOD}; |
---|
| 154 | print - '--- libIGCM : '${libIGCM}; |
---|
| 155 | print - '--- basic job : '${F_JOB}; |
---|
| 156 | print - '--- basic card : '${F_RCI}; |
---|
| 157 | } |
---|
| 158 | #- |
---|
| 159 | [[ ${x_v} = 'verbose' ]] && print - "\nInstallation of jobs for '${SYSTEM}'"; |
---|
| 160 | #- |
---|
| 161 | |
---|
[1164] | 162 | NbErr=0 |
---|
| 163 | |
---|
| 164 | #- |
---|
[1470] | 165 | # Define Project parameters to set up jobs header for Irene (TGCC) |
---|
| 166 | # on Irene define ProjectID and ProjectCore : option or answer |
---|
| 167 | # on Irene ProjectNode default projectnode set to xlarge since 17/10/2018 |
---|
[1164] | 168 | #- |
---|
[1274] | 169 | |
---|
[1164] | 170 | |
---|
[1470] | 171 | if [ X"${SYSTEM}" == "Xirene" ] ; then |
---|
[1322] | 172 | |
---|
[1470] | 173 | #- set ProjectID if required |
---|
[1437] | 174 | if ( ! ${x_p} ) ; then |
---|
[1471] | 175 | print - "Wait for the next question ..." |
---|
[1470] | 176 | #- default ProjectID |
---|
| 177 | ProjectID=$( ccc_myproject | grep -i irene |grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 ) |
---|
[1437] | 178 | answer="" |
---|
[1470] | 179 | 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 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) " |
---|
[1437] | 180 | read answer |
---|
| 181 | |
---|
| 182 | if [ "X${answer}" != "X" ] ; then |
---|
| 183 | ProjectID=${answer} |
---|
| 184 | fi |
---|
| 185 | |
---|
| 186 | fi # if ( ! ${x_p} ) |
---|
| 187 | |
---|
| 188 | echo ProjectID is ${ProjectID} at Irene |
---|
| 189 | |
---|
[1465] | 190 | |
---|
[1470] | 191 | # set ProjectNode if required |
---|
[1468] | 192 | if ( ! ${x_q} ) ; then |
---|
[1470] | 193 | #- default ProjectNode |
---|
| 194 | ProjectNode="xlarge" |
---|
[1471] | 195 | #- is xlarge possible for ${ProjectID} ? |
---|
[1533] | 196 | echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1 || ProjectNode="xlarge" |
---|
[1471] | 197 | |
---|
| 198 | if [ "X${ProjectNode}" == "Xxlarge" ] ; then |
---|
| 199 | answerOK=false |
---|
[1468] | 200 | |
---|
[1471] | 201 | while ( ! ${answerOK} ) ; do |
---|
| 202 | answer="" |
---|
| 203 | print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"skylake\" or \"xlarge\" : " |
---|
| 204 | read answer |
---|
| 205 | [ "X${answer}" == "X" ] || [ "X${answer}" == "Xskylake" ] || [ "X${answer}" == "Xxlarge" ] && answerOK=true |
---|
| 206 | done |
---|
[1468] | 207 | |
---|
[1471] | 208 | if [ "X${answer}" != "X" ] ; then |
---|
| 209 | ProjectNode=${answer} |
---|
| 210 | fi |
---|
| 211 | |
---|
| 212 | else |
---|
| 213 | print - "PostProcessing will be done on ${ProjectNode}" |
---|
| 214 | fi |
---|
[1468] | 215 | |
---|
| 216 | fi # if ( ! ${x_q} ) |
---|
[1470] | 217 | echo ProjectNode for post-processing is ${ProjectNode} at Irene |
---|
[1465] | 218 | |
---|
[1468] | 219 | #- ProjectNode is known (option or answer) set ProjectCoreMax |
---|
| 220 | [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" |
---|
| 221 | #- ProjectCoreMax is 48 for standard and 112 for xlarge |
---|
| 222 | |
---|
[1465] | 223 | if ( ! ${x_c} ) ; then |
---|
[1468] | 224 | #- ProjectNode is known (option or answer), set ProjectCore default |
---|
| 225 | [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" |
---|
[1470] | 226 | |
---|
| 227 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
| 228 | |
---|
[1465] | 229 | answerOK=false |
---|
| 230 | |
---|
| 231 | while ( ! ${answerOK} ) ; do |
---|
| 232 | answer="" |
---|
[1471] | 233 | print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : " |
---|
[1468] | 234 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")" |
---|
[1465] | 235 | read answer |
---|
| 236 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
| 237 | done |
---|
| 238 | |
---|
| 239 | if [ "X${answer}" != "X" ] ; then |
---|
| 240 | ProjectCore=${answer} |
---|
| 241 | fi |
---|
| 242 | |
---|
| 243 | fi # if ( ! ${x_c} ) |
---|
| 244 | |
---|
[1470] | 245 | echo ProjectCore for post-processing is ${ProjectCore} |
---|
[1465] | 246 | #- ProjectCore is set (option or answer) |
---|
| 247 | |
---|
[1536] | 248 | #- set WallTime if required |
---|
| 249 | if ( ! ${x_t} ) ; then |
---|
| 250 | #- default WallTime 1800 s |
---|
| 251 | WallTime=1800 |
---|
| 252 | answer="" |
---|
| 253 | print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) " |
---|
| 254 | read answer |
---|
| 255 | |
---|
| 256 | if [ "X${answer}" != "X" ] ; then |
---|
| 257 | WallTime=${answer} |
---|
| 258 | fi |
---|
| 259 | |
---|
| 260 | fi # if ( ! ${x_t} ) |
---|
| 261 | |
---|
[1547] | 262 | echo Wall time limit is ${WallTime} seconds |
---|
[1536] | 263 | |
---|
[1518] | 264 | elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then |
---|
| 265 | |
---|
| 266 | #- set ProjectID if required |
---|
| 267 | if ( ! ${x_p} ) ; then |
---|
| 268 | print - "Wait for the next question ..." |
---|
| 269 | #- default ProjectID |
---|
| 270 | ProjectID=$( ccc_myproject | grep -i irene |grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 ) |
---|
| 271 | answer="" |
---|
| 272 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) " |
---|
| 273 | read answer |
---|
| 274 | |
---|
| 275 | if [ "X${answer}" != "X" ] ; then |
---|
| 276 | ProjectID=${answer} |
---|
| 277 | fi |
---|
| 278 | |
---|
| 279 | fi # if ( ! ${x_p} ) |
---|
| 280 | |
---|
| 281 | echo ProjectID is ${ProjectID} at Irene-amd |
---|
| 282 | |
---|
| 283 | # set ProjectNode if required |
---|
| 284 | if ( ! ${x_q} ) ; then |
---|
| 285 | #- default ProjectNode |
---|
[1529] | 286 | ProjectNode="rome" |
---|
[1518] | 287 | #- is xlarge possible for ${ProjectID} ? |
---|
| 288 | echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1 || ProjectNode="rome" |
---|
| 289 | |
---|
| 290 | if [ "X${ProjectNode}" == "Xxlarge" ] ; then |
---|
| 291 | answerOK=false |
---|
| 292 | |
---|
| 293 | while ( ! ${answerOK} ) ; do |
---|
| 294 | answer="" |
---|
[1529] | 295 | print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"rome\" : " |
---|
[1518] | 296 | read answer |
---|
[1529] | 297 | [ "X${answer}" == "X" ] || [ "X${answer}" == "Xrome" ] && answerOK=true |
---|
[1518] | 298 | done |
---|
| 299 | |
---|
| 300 | if [ "X${answer}" != "X" ] ; then |
---|
| 301 | ProjectNode=${answer} |
---|
| 302 | fi |
---|
| 303 | |
---|
| 304 | else |
---|
| 305 | print - "PostProcessing will be done on ${ProjectNode}" |
---|
| 306 | fi |
---|
| 307 | |
---|
| 308 | fi # if ( ! ${x_q} ) |
---|
| 309 | echo ProjectNode for post-processing is ${ProjectNode} at Irene-amd |
---|
| 310 | |
---|
| 311 | #- ProjectNode is known (option or answer) set ProjectCoreMax |
---|
| 312 | [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" |
---|
| 313 | #- ProjectCoreMax is 48 for standard and 112 for xlarge |
---|
| 314 | |
---|
| 315 | if ( ! ${x_c} ) ; then |
---|
| 316 | #- ProjectNode is known (option or answer), set ProjectCore default |
---|
| 317 | [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" |
---|
| 318 | |
---|
| 319 | # let check minimum/maximum value 1/${ProjectCoreMax} |
---|
| 320 | |
---|
| 321 | answerOK=false |
---|
| 322 | |
---|
| 323 | while ( ! ${answerOK} ) ; do |
---|
| 324 | answer="" |
---|
| 325 | print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : " |
---|
| 326 | print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")" |
---|
| 327 | read answer |
---|
| 328 | [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true |
---|
| 329 | done |
---|
| 330 | |
---|
| 331 | if [ "X${answer}" != "X" ] ; then |
---|
| 332 | ProjectCore=${answer} |
---|
| 333 | fi |
---|
| 334 | |
---|
| 335 | fi # if ( ! ${x_c} ) |
---|
| 336 | |
---|
| 337 | echo ProjectCore for post-processing is ${ProjectCore} |
---|
| 338 | #- ProjectCore is set (option or answer) |
---|
| 339 | |
---|
[1536] | 340 | #- set WallTime if required |
---|
| 341 | if ( ! ${x_t} ) ; then |
---|
| 342 | #- default WallTime 1800 s |
---|
| 343 | WallTime=1800 |
---|
| 344 | answer="" |
---|
| 345 | print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) " |
---|
| 346 | read answer |
---|
| 347 | |
---|
| 348 | if [ "X${answer}" != "X" ] ; then |
---|
| 349 | WallTime=${answer} |
---|
| 350 | fi |
---|
| 351 | |
---|
| 352 | fi # if ( ! ${x_t} ) |
---|
| 353 | |
---|
[1547] | 354 | echo Wall time limit is ${WallTime} seconds |
---|
[1536] | 355 | |
---|
[1490] | 356 | elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then |
---|
| 357 | |
---|
| 358 | #- set ProjectID if required |
---|
| 359 | if ( ! ${x_p} ) ; then |
---|
| 360 | print - "Wait for the next question ..." |
---|
| 361 | #- default ProjectID |
---|
| 362 | ProjectID=$( echo $IDRPROJ ) |
---|
| 363 | answer="" |
---|
| 364 | print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are: $( groups ; echo ) " |
---|
| 365 | read answer |
---|
| 366 | |
---|
| 367 | if [ "X${answer}" != "X" ] ; then |
---|
| 368 | ProjectID=${answer} |
---|
| 369 | fi |
---|
| 370 | |
---|
| 371 | fi # if ( ! ${x_p} ) |
---|
| 372 | |
---|
| 373 | echo ProjectID is ${ProjectID} at Jean-Zay |
---|
| 374 | |
---|
[1536] | 375 | #- set WallTime if required |
---|
| 376 | if ( ! ${x_t} ) ; then |
---|
| 377 | #- default WallTime 30 minutes |
---|
| 378 | WallTime=30 |
---|
| 379 | answer="" |
---|
| 380 | print - "Hit Enter or give required wall time in minutes for computing job (default is \"${WallTime}\" minutes, maximum is 1200 minutes) " |
---|
| 381 | read answer |
---|
| 382 | |
---|
| 383 | if [ "X${answer}" != "X" ] ; then |
---|
| 384 | WallTime=${answer} |
---|
| 385 | fi |
---|
| 386 | |
---|
| 387 | fi # if ( ! ${x_t} ) |
---|
| 388 | |
---|
| 389 | echo Wall time limit is ${WallTime} minutes |
---|
| 390 | |
---|
[1305] | 391 | elif [ X"${SYSTEM}" == "Xada" ] ; then |
---|
[1316] | 392 | if ( ! ${x_m} ) ; then |
---|
| 393 | MPIEnvironment=IBM |
---|
| 394 | # Intel MPI Environment. |
---|
| 395 | answerOK=false |
---|
| 396 | while ( ! ${answerOK} ) ; do |
---|
| 397 | answer="" |
---|
| 398 | print - "Hit Enter or give MPI Environement (default is ${MPIEnvironment}), possible MPI environments are IBM (MPI IBM) and Intel (MPI Intel) :" |
---|
| 399 | read answer |
---|
| 400 | [ "X${answer}" == "X" ] || [ "X${answer}" == "XIBM" ] || [ "X${answer}" == "XIntel" ] && answerOK=true |
---|
| 401 | done |
---|
[1305] | 402 | |
---|
[1316] | 403 | if [ "X${answer}" != "X" ] ; then |
---|
| 404 | MPIEnvironment=${answer} |
---|
| 405 | fi |
---|
| 406 | fi # if ( ! ${x_pm} ) |
---|
| 407 | echo MPIEnvironment is ${MPIEnvironment} |
---|
[1470] | 408 | |
---|
[1585] | 409 | elif [ X"${SYSTEM}" == "Xobelix" ] || [ X"${SYSTEM}" == "Xifort_CICLAD" ] ; then |
---|
[1391] | 410 | # obelix, ciclad, climserv |
---|
| 411 | echo "" |
---|
| 412 | echo "You need to check and maybe adapt headers in the main job especially the line: " |
---|
| 413 | echo " #PBS -l nodes=x:ppn=y " |
---|
| 414 | 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. " |
---|
| 415 | echo "y must not be bigger than the maximum numer of cores per node on the machine (often 8 or 16)." |
---|
[1472] | 416 | fi # if [ X"${SYSTEM}" == "Xirene" ] |
---|
[1164] | 417 | |
---|
| 418 | #- |
---|
| 419 | # Define the pattern string to substitute |
---|
| 420 | #- |
---|
[1522] | 421 | W_P='#-Q- '; W_W=${W_P}${SYSTEM}' '; |
---|
[1164] | 422 | #- |
---|
| 423 | # Extract list of 'config.card' files |
---|
| 424 | # and create jobs with AA_job |
---|
| 425 | #- |
---|
| 426 | F_CFG='config.card'; |
---|
| 427 | F_CFG_ENS='ensemble.card'; |
---|
| 428 | SUBMIT_DIR_ENS=$( pwd ) |
---|
[1271] | 429 | for i in $( pwd )/config.card |
---|
[1164] | 430 | do |
---|
[1271] | 431 | if [ ! -f $i ] ; then |
---|
| 432 | echo "" |
---|
| 433 | echo "################## WARNING ##################" |
---|
| 434 | echo "No config.card available in current directory" |
---|
| 435 | echo "" |
---|
| 436 | continue |
---|
| 437 | fi |
---|
| 438 | |
---|
| 439 | |
---|
[1164] | 440 | j=$(cd ${i%/*};/bin/pwd;) |
---|
| 441 | n_f=${F_RCI##*/}; |
---|
| 442 | |
---|
| 443 | if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then |
---|
| 444 | # Do not treat config.card if it is in sub-directory of EXPERIMENTS |
---|
| 445 | # Continue to next config.card |
---|
| 446 | continue |
---|
| 447 | else |
---|
| 448 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
| 449 | fi |
---|
| 450 | |
---|
| 451 | # Find out if new structure and set .resol filename |
---|
| 452 | if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then |
---|
| 453 | # New Structure |
---|
| 454 | [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure" |
---|
| 455 | new_struct=yes |
---|
| 456 | resolfile=$j/.resol |
---|
| 457 | else |
---|
| 458 | # Old Structure |
---|
| 459 | new_struct=no |
---|
| 460 | resolfile=$j/../.resol |
---|
| 461 | fi |
---|
| 462 | |
---|
| 463 | # Get all variables declared in section UserChoices in config.card |
---|
| 464 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices |
---|
| 465 | # Set default values |
---|
| 466 | config_UserChoices_ExpType="" |
---|
| 467 | RESOL_ATM_3D=this_is_a_test_string |
---|
| 468 | RESOL=this_is_another_test_string |
---|
[1543] | 469 | ResolAtm=this_is_a_new_another_test |
---|
[1164] | 470 | typeset option |
---|
| 471 | for option in ${config_UserChoices[*]} ; do |
---|
| 472 | IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option} |
---|
| 473 | done |
---|
| 474 | |
---|
| 475 | # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file |
---|
| 476 | if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then |
---|
| 477 | TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' ) |
---|
| 478 | echo TRUERESOL = $TRUERESOL |
---|
| 479 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" ) |
---|
| 480 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
| 481 | elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then |
---|
| 482 | TRUERESOL=$( head -1 $resolfile ) |
---|
| 483 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" ) |
---|
| 484 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
[1543] | 485 | elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${ResolAtm} ) = X ] ; then |
---|
| 486 | TRUERESOL=${config_UserChoices_ResolAtm} |
---|
| 487 | JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${ResolAtm}/${TRUERESOL}/" ) |
---|
| 488 | IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} |
---|
[1164] | 489 | else |
---|
| 490 | JobName=${config_UserChoices_JobName} |
---|
| 491 | fi |
---|
| 492 | |
---|
| 493 | # Check JobName validity : only alphanumerical characters, "-" and "." are authorized |
---|
| 494 | ins_job_Check_JobName |
---|
| 495 | RetCode=$? |
---|
| 496 | [[ $RetCode -gt 0 ]] && continue |
---|
| 497 | |
---|
| 498 | [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" |
---|
| 499 | |
---|
| 500 | # Add specific treatment for new type of directory structure |
---|
| 501 | if [ ${new_struct} == yes ] ; then |
---|
| 502 | |
---|
| 503 | if [ "X${config_UserChoices_ExpType}" = X ] ; then |
---|
| 504 | echo "\nERROR in ${j}/config.card" |
---|
| 505 | echo "ins_job stops here" |
---|
| 506 | echo "=> The variable ExpType must be added in config.card in section UserChoices" |
---|
[1238] | 507 | echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" |
---|
[1164] | 508 | exit 4 |
---|
| 509 | else |
---|
| 510 | [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" |
---|
| 511 | fi |
---|
| 512 | |
---|
| 513 | if [ -d ${j}/${JobName} ] ; then |
---|
[1359] | 514 | echo "Directory ${j}/${JobName} exists already. It will not be overwritten." |
---|
| 515 | echo "Remove the existing directory or change JobName before relaunching ins_job." |
---|
[1489] | 516 | #continue |
---|
| 517 | exit |
---|
[1164] | 518 | fi |
---|
| 519 | echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" |
---|
| 520 | cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} |
---|
| 521 | cp -r ${j}/GENERAL/* ${j}/${JobName}/. |
---|
| 522 | cp -f ${j}/${F_CFG} ${j}/${JobName}/. |
---|
| 523 | if [ -f ${F_CFG_ENS} ] ; then |
---|
| 524 | cp -f ${j}/${F_CFG_ENS} ${j}/${JobName}/. |
---|
| 525 | SUBMIT_DIR_ENS=${j}/${JobName} |
---|
| 526 | fi |
---|
| 527 | rm -f ${j}/${F_CFG} |
---|
[1489] | 528 | # rm -f ${j}/${F_CFG_ENS} |
---|
[1164] | 529 | rm -f ${j}/${F_CFG}.bak |
---|
| 530 | j=${j}/${JobName} |
---|
| 531 | [[ ${x_v} = 'verbose' ]] && echo new j=$j |
---|
| 532 | fi |
---|
| 533 | # end specific treatment for new type directory structure |
---|
| 534 | |
---|
| 535 | [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ |
---|
| 536 | { |
---|
| 537 | [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; |
---|
| 538 | \cp ${F_RCI} ${j}; |
---|
| 539 | } |
---|
[1242] | 540 | |
---|
[1238] | 541 | #================================== |
---|
[1242] | 542 | # Read ListOfComponents section: |
---|
| 543 | #echo |
---|
| 544 | #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents" |
---|
| 545 | |
---|
| 546 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} ListOfComponents |
---|
| 547 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 548 | IGCM_card_DefineArrayFromOption ${j}'/'${F_CFG} ListOfComponents ${comp} |
---|
| 549 | done |
---|
| 550 | #IGCM_debug_Print 3 ${config_ListOfComponents[*]} |
---|
| 551 | |
---|
| 552 | #================================== |
---|
[1238] | 553 | # Read Executable section: |
---|
[1242] | 554 | IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable |
---|
[1164] | 555 | |
---|
[1238] | 556 | # Define the execution context (MPMD, SPMD, MPI/OMP ...) |
---|
[1242] | 557 | IGCM_config_ConfigureExecution ${j}'/'${F_CFG} |
---|
[1238] | 558 | |
---|
| 559 | # coreNumber : TOTAL NUMBER OF CORES |
---|
| 560 | # mpiTasks : TOTAL NUMBER OF MPI TASKS |
---|
| 561 | # openMPthreads : NUMBER OF OpenMP THREADS |
---|
| 562 | |
---|
[1585] | 563 | # File name for Job_debug |
---|
| 564 | n_f='Job_debug_'${JobName}; |
---|
| 565 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
| 566 | sed -e "/^${W_W} */ s///" \ |
---|
| 567 | -e "/^${W_P}/d" \ |
---|
| 568 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
| 569 | -e "s/::Jobname::/${JobName}/" \ |
---|
| 570 | -e "s/::default_project::/${ProjectID}/" \ |
---|
| 571 | -e "s/::WallTime::/${WallTime}/" \ |
---|
| 572 | ${F_JOB_DEBUG} > ${libIGCM}'/'${n_f} |
---|
| 573 | chmod u+x ${libIGCM}'/'${n_f} |
---|
| 574 | |
---|
| 575 | # update Headers so that ressources description are accurate (MPMD/SPMD/...) |
---|
| 576 | IGCM_sys_updateHeaders ${libIGCM}'/'${n_f} |
---|
| 577 | |
---|
[1164] | 578 | # File name for Job |
---|
| 579 | n_f='Job_'${JobName}; |
---|
[1401] | 580 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
[1164] | 581 | [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; |
---|
| 582 | sed -e "/^${W_W} */ s///" \ |
---|
| 583 | -e "/^${W_P}/d" \ |
---|
| 584 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
| 585 | -e "s/::Jobname::/${JobName}/" \ |
---|
| 586 | -e "s/::default_project::/${ProjectID}/" \ |
---|
[1536] | 587 | -e "s/::WallTime::/${WallTime}/" \ |
---|
[1164] | 588 | ${F_JOB} > ${j}'/'${n_f} |
---|
| 589 | chmod u+x ${j}'/'${n_f} |
---|
[1238] | 590 | |
---|
| 591 | # update Headers so that ressources description are accurate (MPMD/SPMD/...) |
---|
| 592 | IGCM_sys_updateHeaders ${j}'/'${n_f} |
---|
[1585] | 593 | |
---|
[1164] | 594 | done |
---|
[1238] | 595 | |
---|
[1164] | 596 | #- |
---|
| 597 | # Extract list of AA_* files in libIGCM |
---|
| 598 | # and create jobs (for all except AA_job) |
---|
| 599 | #- |
---|
| 600 | for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print) |
---|
| 601 | do |
---|
| 602 | i_f=${i##*/}; |
---|
| 603 | [[ ${i_f} = 'AA_job' ]] && { continue; } |
---|
[1585] | 604 | [[ ${i_f} = 'AA_job_debug' ]] && { continue; } |
---|
[1164] | 605 | j=${i%/*}; n_f=${i_f#AA_}'.job'; |
---|
[1401] | 606 | [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } |
---|
[1164] | 607 | [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" |
---|
| 608 | sed -e "/^${W_W} */ s///" \ |
---|
| 609 | -e "s%::modipsl::%${F_MOD}%" \ |
---|
| 610 | -e "/^${W_P}/d" \ |
---|
| 611 | -e "s/::default_node::/${ProjectNode}/" \ |
---|
[1274] | 612 | -e "s/::default_core::/${ProjectCore}/" \ |
---|
[1164] | 613 | -e "s/::default_project::/${ProjectID}/" \ |
---|
[1471] | 614 | -e "s/::default_post_project::/${ProjectID}/" \ |
---|
[1164] | 615 | ${i} > ${j}'/'${n_f} |
---|
| 616 | chmod u+x ${j}'/'${n_f} |
---|
| 617 | done |
---|
| 618 | #- |
---|
[1490] | 619 | # set default_project in libIGCM_sys_irene and libIGCM_sys_jeanzay. |
---|
[1164] | 620 | #- |
---|
[1472] | 621 | if [ X"${SYSTEM}" == "Xirene" ] ; then |
---|
[1473] | 622 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh |
---|
[1164] | 623 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
[1518] | 624 | elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then |
---|
| 625 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh |
---|
| 626 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
[1490] | 627 | elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then |
---|
| 628 | i=${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh |
---|
| 629 | sed -i -e "s/::default_project::/${ProjectID}/" ${i} |
---|
[1164] | 630 | fi |
---|
| 631 | #- |
---|
| 632 | # Limited to hindcast/forecast and date restart Ensemble for the time being |
---|
| 633 | if [ ${x_e} = 'true' ] ; then |
---|
[1489] | 634 | if [ ! -f ${F_CFG_ENS} ] ; then |
---|
| 635 | echo "" |
---|
| 636 | echo "################## WARNING ##################" |
---|
| 637 | echo "No ensemble.card available in current directory" |
---|
| 638 | echo "" |
---|
| 639 | exit |
---|
| 640 | # continue |
---|
| 641 | fi |
---|
| 642 | |
---|
[1164] | 643 | #.. Read input data from ensemble.card .. |
---|
| 644 | SUBMIT_DIR=${SUBMIT_DIR_ENS} |
---|
[1475] | 645 | RUN_DIR="${CCCWORKDIR}/ENSEMBLE_TMP" |
---|
[1164] | 646 | # |
---|
| 647 | # Copy initial things around and define variables (hindcast/forecast case) |
---|
| 648 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 649 | IGCM_ensemble_Init |
---|
| 650 | |
---|
| 651 | if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then |
---|
| 652 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 653 | IGCM_ensemble_DateInit |
---|
| 654 | # As it says |
---|
| 655 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 656 | IGCM_ensemble_DateNonPeriodicStarts |
---|
| 657 | fi |
---|
| 658 | |
---|
| 659 | if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then |
---|
| 660 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 661 | IGCM_ensemble_CastInit |
---|
| 662 | # As it says |
---|
| 663 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 664 | IGCM_ensemble_CastPeriodicStarts |
---|
| 665 | # As it says |
---|
[1489] | 666 | #IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 667 | #IGCM_ensemble_CastMemberList |
---|
[1164] | 668 | fi |
---|
[1489] | 669 | # Done |
---|
| 670 | IGCM_sys_Cd ${SUBMIT_DIR} |
---|
| 671 | # Clean |
---|
| 672 | IGCM_sys_Rm -rf ${RUN_DIR} |
---|
| 673 | |
---|
[1164] | 674 | fi |
---|
[1554] | 675 | # |
---|
| 676 | # Install a light copy of C-ESM-EP in SUBMIT_DIR/Cesmep and create a |
---|
| 677 | # C-ESM-EP launch script there. |
---|
| 678 | # |
---|
[1564] | 679 | [ ${new_struct?} == yes ] && prefix="$JobName/" |
---|
[1554] | 680 | IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep |
---|
| 681 | if [ ${config_Post_Cesmep} != FALSE ]; then |
---|
[1559] | 682 | IGCM_config_CommonConfiguration ${prefix}config.card |
---|
[1567] | 683 | if [ x"${config_Post_CesmepMail}" == x"TRUE" ] || [ x"${config_Post_CesmepMail}" == x"True" ] ; then |
---|
| 684 | # Compute mail adress - inspired by libIGCM_post.ksh - should be turned in a function |
---|
| 685 | if [ ! -z ${config_UserChoices_MailName} ] ; then |
---|
| 686 | MailAdress=${config_UserChoices_MailName} |
---|
| 687 | elif [ -f ~/.forward ] ; then |
---|
| 688 | MailAdress=$( cat ~/.forward ) |
---|
| 689 | else |
---|
| 690 | MailAdress=${USER} |
---|
| 691 | fi |
---|
[1559] | 692 | else |
---|
[1567] | 693 | MailAdress=None |
---|
[1559] | 694 | fi |
---|
| 695 | # |
---|
| 696 | components="," |
---|
| 697 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 698 | components=${components}${comp}, ; |
---|
| 699 | done |
---|
| 700 | if [ X"${SYSTEM}" == "Xirene" ] || [ X"${SYSTEM}" == "Xirene-amd" ] ; then |
---|
| 701 | IGCM_card_DefineVariableFromOption ${prefix}config.card UserChoices DateBegin |
---|
| 702 | ${config_Post_CesmepCode}/libIGCM_install.sh $(pwd)/${prefix} \ |
---|
[1554] | 703 | ${config_Post_CesmepComparison} $JobName ${R_SAVE} ${ProjectID} \ |
---|
[1559] | 704 | ${MailAdress} ${config_UserChoices_DateBegin//-/} \ |
---|
| 705 | ${config_Post_Cesmep} ${CesmepPeriod} ${config_Post_CesmepSlices} $components |
---|
[1554] | 706 | else |
---|
[1559] | 707 | echo -e "\nERROR Cannot (yet) handle CESMEP atlas on this computer system" |
---|
[1554] | 708 | echo "=> Variable Cesmep in config.card's section Post must be set to FALSE" |
---|
| 709 | exit 5 |
---|
| 710 | fi |
---|
| 711 | fi |
---|
[1164] | 712 | #- |
---|
| 713 | [[ ${x_v} = 'verbose' ]] && print - ""; |
---|
| 714 | #- |
---|
| 715 | # That's all folks |
---|
| 716 | #- |
---|
| 717 | |
---|
| 718 | if [ ${NbErr} -ne 0 ] ; then |
---|
| 719 | echo "################ ERROR ################" |
---|
| 720 | echo "${NbErr} invalid JobName(s) found, check the log" |
---|
| 721 | fi |
---|
| 722 | |
---|
| 723 | |
---|
| 724 | exit 0; |
---|