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