[103] | 1 | #!/bin/bash -e |
---|
| 2 | # |
---|
| 3 | # 2014/01/06 gabriel |
---|
| 4 | |
---|
| 5 | exists_np='' |
---|
| 6 | exists_mf='' |
---|
| 7 | exists_vb='' |
---|
| 8 | |
---|
| 9 | for opt in $* |
---|
| 10 | do |
---|
| 11 | [ "${opt}" == "-np" ] && exists_np='y' |
---|
| 12 | [ "${opt}" == "-machinefile" ] && exists_mf='y' |
---|
| 13 | [ "${opt}" == "--machinefile" ] && exists_mf='y' |
---|
| 14 | [ "${opt}" == "-hostfile" ] && exists_mf='y' |
---|
| 15 | [ "${opt}" == "--hostfile" ] && exists_mf='y' |
---|
| 16 | [ "${opt}" == "--host" ] && exists_mf='y' |
---|
| 17 | [ "${opt}" == "-host" ] && exists_mf='y' |
---|
| 18 | [ "${opt}" == "-H" ] && exists_mf='y' |
---|
| 19 | [ "${opt}" == "--verbose" ] && exists_vb='y' |
---|
| 20 | [ "${opt}" == "-v" ] && exists_vb='y' |
---|
| 21 | [ "${opt}" == "--" ] && break |
---|
| 22 | done |
---|
| 23 | |
---|
| 24 | [ -n "${VERBOSE:+x}" ] && exists_vb='y' |
---|
| 25 | |
---|
| 26 | mpi_option='' |
---|
| 27 | |
---|
| 28 | # NODEFILE to use. By default specialized one |
---|
| 29 | nodefile="${OAR_NODE_FILE}" |
---|
| 30 | [ -n "${OAR_MSG_NODEFILE:+x}" -a -e "${OAR_MSG_NODEFILE}" ] && nodefile="${OAR_MSG_NODEFILE}" |
---|
| 31 | if [ -z ${exists_mf} ] |
---|
| 32 | then |
---|
| 33 | [ -e "${nodefile}" ] && mpi_option="-machinefile ${nodefile} ${mpi_option}" |
---|
| 34 | fi |
---|
| 35 | |
---|
| 36 | # Number of MPI parallel run. By default MAX. |
---|
| 37 | nbcpus='' |
---|
| 38 | [ -e "${nodefile}" ] && nbcpus=$(cat ${nodefile} | wc -l) |
---|
| 39 | [ -n "${OAR_NP:+x}" ] && nbcpus=${OAR_NP} |
---|
| 40 | if [ -z ${exists_np} ] |
---|
| 41 | then |
---|
| 42 | [ -z ${nbcpus} ] || mpi_option="-np ${nbcpus} ${mpi_option}" |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | # Change login remote shell |
---|
[112] | 46 | if [ "${OMPI_MCA_orte_rsh_agent}" == "oarsh" ] |
---|
| 47 | then |
---|
| 48 | OMPI_MCA_orte_rsh_agent="oar-envsh" |
---|
| 49 | fi |
---|
[103] | 50 | if [ "${OMPI_MCA_plm_rsh_agent}" == "oarsh" ] |
---|
| 51 | then |
---|
| 52 | OMPI_MCA_plm_rsh_agent="oar-envsh" |
---|
| 53 | fi |
---|
| 54 | |
---|
| 55 | [ ! -z ${exists_vb} ] && echo mpirun ${mpi_option} $* |
---|
| 56 | exec mpirun ${mpi_option} $* |
---|