0

I have an MPI program (Fortran, MPICH) which I need to shell out from to a script which, in turn, starts its own MPI program (using mpirun). Thus far, I've wrapped the shell out (system) command in an if(system_num .eq. root_system_num) thing so only one MPI process runs the script. However, this causes a series of HYDU_create_process errors.

I considered using MPI_Comm_spawn but there are warnings like "MPI does not say what happens if the program you start is a shell script and that shell script starts a program that calls MPI_INIT", so this seems less than ideal, as well.

Some points:

  • The program called in shell script does not need to interact with the calling program at all. The calling program just needs to wait until that process is done.
  • There is not an easy way to turn the shell script into a separate executable (lots of environment variable setting, and so on).
  • Ideally, this should work for both MPICH and Open MPI.

Is there a way to do this?

Wesley Bland
  • 8,816
  • 3
  • 44
  • 59
Eli Lansey
  • 1,130
  • 2
  • 15
  • 28

1 Answers1

1

For MPICH, you might be best served by using MPI_Comm_spawn, unfortunately. Your only other option is to figure out all of the implementation-dependent, version-dependent environment variables which need to be unset in your shell script before invoking the nested MPI program. Some example variables (for MPICH) would include PMI_RANK and PMI_PORT:

% mpiexec -n 1 env | egrep '^PMI|^HYD'
HYDI_CONTROL_FD=8
PMI_RANK=0
PMI_FD=7
PMI_SIZE=1

Obviously, different variables will need to be twiddled for Open MPI or different versions of MPICH2/MPICH.

Dave Goodell
  • 2,143
  • 16
  • 18
  • Yeah, I'm leaning towards MPI_Comm_spawn. But now I need to parse all sorts of files to extract what environment variables should be before the code itself parses the files. Files designed to be read by Fortran, now I've gotta rig a shellscript to do it. – Eli Lansey Apr 11 '13 at 13:43