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