Take a look at these scripts, they don't do anything fancy, they just
prepare the machinefile and the rsh wrapper for mpich. Openmpi does
the right thing by itself by looking at SGE's environment variables.