Newsgroups: comp.parallel.pvm
Path: ukc!uknet!EU.net!howland.reston.ans.net!europa.eng.gtefsd.com!ulowell!xn.ll.mit.edu!usenet
From: rickl@rambo (Rick Lloyd x4841 )
Subject: Re: How to start pvm inside a program?
Message-ID: <1994Mar9.220812.3626@xn.ll.mit.edu>
Sender: usenet@xn.ll.mit.edu
Organization: MIT Lincoln Laboratory
References: <1994Feb24.232333.290@dagoba.escape.de> <2ll3ek$hmo@quabbin.crl.dec.com> <WSPMB12K@math.fu-berlin.de>
Date: Wed, 9 Mar 94 22:08:12 GMT
Lines: 55

In article <WSPMB12K@math.fu-berlin.de> wolff@inf.fu-berlin.de (Thomas Wolff) writes:
>hsu@crl.dec.com (William Hsu) writes:
>
>: int
>: check_and_start_pvm ()
>: {
>:    int  mytid;
>
>:    if ( (mytid = pvm_mytid ()) > 0 ) return mytid;
>
>:    /* PVM not running, start it and return */
>:    printf ( "starting PVM, please be patient." );
>:    system ("pvmd3 &");
>:    sleep (2);    /* need to wait a little since deamon in background */
>:    mytid = pvm_mytid ();
>:    if ( master_tid < 0 ) master_tid = mytid;
>:    return mytid;
>: }
>: You have to wait a little, though, since system returns right away, otherwise
>: the pvm_mytid call fails.
>So what about:
>        mytid = pvm_mytid ();
>        if (mytid == PvmSysErr) {
>                system ("pvm < /dev/null");
>                mytid = pvm_mytid ();
>        }
>        return mytid;
>


here's how I do it...

 /* start master pvmd */
 switch (ret_val = pvm_start_pvmd(0, (char **) NULL, 1))
    {
  case PvmDupHost:
    fprintf(stderr,
	    "pvmd already running.\n");
    break;
  case (PvmSysErr):
    fprintf(stderr,
	    "pvmd system error\n");
    pvm_halt();
    exit(1);
    break;
    }

 /* connect to pvm */
 if ((my_tid = pvm_mytid()) < 0)
    {
    pvm_halt();
    exit(1);
    }

Rick Lloyd

