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