source: trunk/oarutils/oar-envmpirun @ 215

Last change on this file since 215 was 112, checked in by g7moreau, 10 years ago
  • Update mpirun script
File size: 1.5 KB
Line 
1#!/bin/bash -e
2#
3# 2014/01/06 gabriel
4
5exists_np=''
6exists_mf=''
7exists_vb=''
8
9for opt in $*
10do
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
22done
23
24[ -n "${VERBOSE:+x}" ] && exists_vb='y'
25
26mpi_option=''
27
28# NODEFILE to use. By default specialized one
29nodefile="${OAR_NODE_FILE}"
30[ -n "${OAR_MSG_NODEFILE:+x}" -a -e "${OAR_MSG_NODEFILE}" ] && nodefile="${OAR_MSG_NODEFILE}"
31if [ -z ${exists_mf} ]
32then
33   [ -e "${nodefile}" ] && mpi_option="-machinefile ${nodefile} ${mpi_option}"
34fi
35
36# Number of MPI parallel run. By default MAX.
37nbcpus=''
38[ -e "${nodefile}" ]  && nbcpus=$(cat ${nodefile} | wc -l)
39[ -n "${OAR_NP:+x}" ] && nbcpus=${OAR_NP}
40if [ -z ${exists_np} ]
41then
42   [ -z ${nbcpus} ] || mpi_option="-np ${nbcpus} ${mpi_option}"
43fi
44
45# Change login remote shell
46if [ "${OMPI_MCA_orte_rsh_agent}" == "oarsh" ]
47then
48   OMPI_MCA_orte_rsh_agent="oar-envsh"
49fi
50if [ "${OMPI_MCA_plm_rsh_agent}" == "oarsh" ]
51then
52   OMPI_MCA_plm_rsh_agent="oar-envsh"
53fi
54
55[ ! -z ${exists_vb} ] && echo mpirun ${mpi_option} $*
56exec mpirun ${mpi_option} $*
Note: See TracBrowser for help on using the repository browser.