Given a machine named foo which will be the server, and two machines named bar and baz which will be the clients. The user wishes to run 8 copies of a.out on bar (with ranks 0-7 in MPI_COMM_WORLD) and 4 copies of b.out on baz (with ranks 8-11 in MPI_COMM_WORLD).
On foo: impirun -server 2 (typed by user)
128.162.19.8:5678 (output from impirun)
On bar: impirun -client 0 128.162.19.8:5678 -np 8 a.out
On baz: impirun -client 1 128.162.19.8:5678 -np 4 b.out
#!/bin/csh
setenv hostport `impirun -server 2 | head -1`
rsh bar impirun -client 0 $hostport -np 8 a.out &
rsh baz impirun -client 1 $hostport -np 4 b.out &
wait
On some systems, the above script may only work if impirun is restricted to writing only a single line of text, since subsequent lines could potentially cause a SIGPIPE on impirun after the head process terminates.
A slightly different approach might be to incorporate support for a configuration file directly into the impirun command line:
% impirun -server 2 -file appfile
where appfile contains:
bar -client 0 $hostport -np 8 a.out
baz -client 1 $hostport -np 4 b.out
(End of rationale.)