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