Sun MPI 4.0 User's Guide: With CRE

mprun Options versus Shell Syntax

The default I/O behavior of mprun (merged standard error and standard output) is equivalent to

% mprun -I "0rp,1wp,2w=@1" a.out

The -D option provides separate standard output and standard error streams; it is equivalent to:

% mprun -I "0rp,1wp,2w" a.out

You can use the -o option to force each line of output to be prepended with the rank of the process writing it. This is equivalent to

% mprun -I "0rp,1wt,2w=@1" a.out

If you redirect output to a shared file, you must use standard shell redirection rather than the equivalent -I formulation (-I "lwt=outfile"). The same restriction also applies to the linebuffer formulation (-I "lwt=outfile").

For example, the following command line concatenates the outputs of the individual processes of a job and writes them to outfile.dat:

% mprun -np 4 myprogram > outfile.dat

The following command line concatenates the outputs of the individual processes and appends them to the previous content of the output file:

% mprun -np 4 myprogram >> outfile.dat

The following table describes three mprun command-line options that provide the same control over standard I/O as some -I constructs, but are much simpler to express. Their -I equivalents are also shown.

Table 3-5 mprun Shortcut Summary

Command 

Description 

mprun -i 

Standard input to mprun is sent only to rank 0, and not to all other ranks. Equivalent to

mprun -I "0rpb,1wp,2w=@1" a.out

mprun -B 

Standard output and standard error are written to the file out.job.rank. Equivalent to mprun -I "0r=/dev/null,1w=out.&J.&R,2w=@1" a.out

mprun -o 

Use line buffering on standard output, prefixing each line with the rank of the process that wrote it. Equivalent to mprun -I "0rp,1wt,2w=@1" a.out


Note -

Specifying -o (forcing processes to prepend rank on output lines), or the equivalent -I syntax (such as -I1wt) will not work if redirection is also specified with -I (such as with -I1w=outfile). Use the standard shell redirection operator instead.


These shortcuts are not exact substitutions. The CRE uses ptys correctly, whether the -I option is present or absent. Also, the CRE merges standard error with standard output when it is appropriate. If either stderr or stdout is redirected (but not both), ptys are not used and stderr and stdout are separated. If both stderr and stdout are redirected, ptys are still not used, but stderr and stdout are combined.