1 | #!/bin/bash -e |
---|
2 | # |
---|
3 | # 2014/01/06 gabriel |
---|
4 | |
---|
5 | function oar_fixldpath () { |
---|
6 | if [ -n "${LD_LIBRARY_PATH:+x}" ] |
---|
7 | then |
---|
8 | for ldpath in $(for lib in $(/sbin/ldconfig -p | awk 'BEGIN { FS = "=> " } ; {print $2}'); do dirname ${lib}; done | sort -u) |
---|
9 | do |
---|
10 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ldpath}" |
---|
11 | done |
---|
12 | fi |
---|
13 | } |
---|
14 | declare -fx oar_fixldpath |
---|
15 | |
---|
16 | exists_np='' |
---|
17 | exists_mf='' |
---|
18 | exists_vb='' |
---|
19 | |
---|
20 | for opt in $* |
---|
21 | do |
---|
22 | [ "${opt}" == "-np" ] && exists_np='y' |
---|
23 | [ "${opt}" == "-machinefile" ] && exists_mf='y' |
---|
24 | [ "${opt}" == "--machinefile" ] && exists_mf='y' |
---|
25 | [ "${opt}" == "-hostfile" ] && exists_mf='y' |
---|
26 | [ "${opt}" == "--hostfile" ] && exists_mf='y' |
---|
27 | [ "${opt}" == "--host" ] && exists_mf='y' |
---|
28 | [ "${opt}" == "-host" ] && exists_mf='y' |
---|
29 | [ "${opt}" == "-H" ] && exists_mf='y' |
---|
30 | [ "${opt}" == "--verbose" ] && exists_vb='y' |
---|
31 | [ "${opt}" == "-v" ] && exists_vb='y' |
---|
32 | [ "${opt}" == "--" ] && break |
---|
33 | done |
---|
34 | |
---|
35 | [ -n "${VERBOSE:+x}" ] && exists_vb='y' |
---|
36 | |
---|
37 | mpi_option='' |
---|
38 | |
---|
39 | # NODEFILE to use. By default specialized one |
---|
40 | nodefile="${OAR_NODE_FILE}" |
---|
41 | [ -n "${OAR_MSG_NODEFILE:+x}" -a -e "${OAR_MSG_NODEFILE}" ] && nodefile="${OAR_MSG_NODEFILE}" |
---|
42 | if [ -z ${exists_mf} ] |
---|
43 | then |
---|
44 | [ -e "${nodefile}" ] && mpi_option="-machinefile ${nodefile} ${mpi_option}" |
---|
45 | fi |
---|
46 | |
---|
47 | # Number of MPI parallel run. By default MAX. |
---|
48 | nbcpus='' |
---|
49 | [ -e "${nodefile}" ] && nbcpus=$(cat ${nodefile} | wc -l) |
---|
50 | [ -n "${OAR_NP:+x}" ] && nbcpus=${OAR_NP} |
---|
51 | if [ -z ${exists_np} ] |
---|
52 | then |
---|
53 | [ -z ${nbcpus} ] || mpi_option="-np ${nbcpus} ${mpi_option}" |
---|
54 | fi |
---|
55 | |
---|
56 | # VARIABLE to define in other MPI parallel run |
---|
57 | for varenv in $(env \ |
---|
58 | | grep "^[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" \ |
---|
59 | | egrep -v "^USER=|^TERM=|^OAR|^SGE_|^LS_COLORS=\ |
---|
60 | |^ENV=|^BASH_ENV=|^BASH_FUNC_|^HOSTNAME=|^LOGNAME=|^MAIL=\ |
---|
61 | |^MANPATH=|^PWD=\ |
---|
62 | |^OMPI_MCA_orte_rsh_agent=|^OMPI_MCA_plm_rsh_agent=\ |
---|
63 | |^SHELL=|^SSH_|^SUDO_COMMAND=|^HOME=|^DISPLAY=\ |
---|
64 | |^SHLVL=" \ |
---|
65 | | cut -f 1 -d '=' \ |
---|
66 | | sort ) |
---|
67 | do |
---|
68 | mpi_option="${mpi_option} -x ${varenv}" |
---|
69 | done |
---|
70 | |
---|
71 | # Special case of LD_LIBRARY_PATH and system path |
---|
72 | oar_fixldpath |
---|
73 | |
---|
74 | [ ! -z ${exists_vb} ] && echo mpirun ${mpi_option} $* |
---|
75 | exec mpirun ${mpi_option} $* |
---|