Newsgroups: comp.parallel.pvm
Path: ukc!uknet!EU.net!howland.reston.ans.net!darwin.sura.net!ms!sunny
From: sunny@cs.wm.edu (J. Sunny Egbo)
Subject: Re: redirection of stdout of slaves with PVM
Message-ID: <1994Mar16.210830.5888@cs.wm.edu>
Keywords: PVM stdout
Sender: news@cs.wm.edu (News System)
Nntp-Posting-Host: ri.cs.wm.edu
Organization: The College of William and Mary
References: <2m55i9$3ug@cismsun.univ-lyon1.fr>
Date: Wed, 16 Mar 1994 21:08:30 GMT
Lines: 60

In article <2m55i9$3ug@cismsun.univ-lyon1.fr> buffat@europe.mecaflu.ec-lyon.fr (Buffat Marc) writes:
>	Hi,
>Has anybody experience with the redirection of sdtout for slaves
>running PVM. By default standard output and error are written
>in the file /tmp/pvmd.xxx. How can I redirected the sdtout to
>the master stdout . I have try to use pvm_setopt with the
>parameter PvmOutputTid, but without success.
>Thanks in advance for any suggestion,
>	Marc
>------------------------------------------------------------------------
>Marc BUFFAT                                 ++++++++++++++++++++++++
>Lab. Mecanique des fluides LMFA             |     CNRS URA 263     |
>ECL, 36 av. Guy de Collongue                |     ECL Lyon         |
>Ecully 69131, FRANCE                        |     UCB Lyon I       |
>tel: (33) 72/18/61/61                       ++++++++++++++++++++++++
>fax: (33) 78/64/71/45                      
>email: buffat@mecaflu.ec-lyon.fr

Assuming that you will pvm_spawn several tasks, you need to do the
following three steps.

1. Define the task that should receive the output message and the
message id to be used.  For example if the current task is the one to
receive the output, do the following:

  pvm_setopt(PvmOutputTid, My_tid);
  pvm_setopt(PvmOutputCode, STDOUT_MSG);

where My_tid is the current task's id.

2. Spawn the sub-tasks on the target hosts.

3. Filter the output messages at some point in your code.  For
example, to filter message while waiting for child tasks to quit, do
the following:

    while (i<numNodes) {
    rbuf = pvm_recv(-1, -1);
    istat = pvm_bufinfo(rbuf, &msize, &mtype, &msndr);
    if (mtype == STDOUT_MSG) {
      pvm_upkint(&ftid, 1, 1);
      pvm_upkint(&msize, 1, 1);
      if (msize > 0) {
        longstr = (char *)malloc(sizeof(char)*(msize+1));
        pvm_upkbyte(longstr, msize, 1);
        longstr[msize] = '\0';
        fprintf(stdout,"%-80s\n", longstr);
        fflush(stdout);
        free(longstr);
      }
    }
    else if (mtype == IAM_QUITING)
      i++;
  }

I hope this helps.

-Sunny Egbo
 sunny@cs.wm.edu


