IBM Books

MPI Programming Guide

MP_STDOUT_MODE, mpc_stdout_mode

Purpose

Sets the mode for STDOUT.

Library

libmpi.a

C synopsis

#include <pm_util.h>
int mpc_stdout_mode(int mode);

FORTRAN synopsis

MP_STDOUT_MODE(INTEGER MODE)

Parameters

mode
is the mode to which STDOUT is to be set. The valid values are:

taskid
specifies single mode for STDOUT, where taskid is the task identifier of the new single task. This value must be between 0 and n-1, where n is the total of tasks in the current partition. The taskid requested does not have to be the issuing task.

-2
specifies ordered mode for STDOUT. The macro STDIO_ORDERED is supplied for use in C programs.

-3
specifies unordered mode for STDOUT. The macro STDIO_UNORDERED is supplied for use in C programs.

Description

This parallel utility subroutine requests that STDOUT be set to single, ordered, or unordered mode. In single mode, only one task output is displayed. In unordered mode, output is displayed in the order received at the home node. In ordered mode, each parallel task writes output data to its own buffer. When a flush request is made all the task buffers are flushed, in order of task ID, to STDOUT home node.

Notes

Return values

In C and C++ calls, the following applies:

0
indicates successful completion.

-1
indicates that an error occurred. A message describing the error will be issued.

Examples

C Example

The following program uses poe with the -labelio yes option and three tasks:

    #include <pm_util.h>
 
main()
{
 mpc_stdout_mode(STDIO_ORDERED);
 printf("These lines will appear in task order\n");
 /*
  * Call mpc_flush here to make sure that one task
  * doesn't change the mode before all tasks have
  * sent the previous printf string to the home node.
  */
 mpc_flush(1);
 mpc_stdout_mode(STDIO_UNORDERED);
 printf("These lines will appear in the order received by the home node\n");
 /*
  * Since synchronization is not used here, one task could actually
  * execute the next statement before one of the other tasks has
  * executed the previous statement, causing one of the unordered
  * lines not to print.
  */
 mpc_stdout_mode(1);
 printf("Only 1 copy of this line will appear from task 1\n");
}
 

Running the above C program produces the following output (task order of lines 4-6 may differ):

FORTRAN Example

CALL MP_STDOUT_MODE(-2)
WRITE(6, *) 'These lines will appear in task order'
CALL MP_FLUSH(1)
CALL MP_STDOUT_MODE(-3)
WRITE(6, *) 'These lines will appear in the order received by the home node'
CALL MP_STDOUT_MODE(1)
WRITE(6, *) 'Only 1 copy of this line will appear from task 1'
END

Running the above program produces the following output (the task order of lines 4 through 6 may differ):

Related information

Commands:

Subroutines:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]