Newsgroups: comp.parallel.pvm
From: mapdjb@bath.ac.uk (D J Batey)
Subject: Re: Spawning with arguments
Organization: School of Mathematical Sciences, University of Bath, UK
Date: Fri, 1 Mar 1996 09:30:04 GMT
Message-ID: <DnL123.JFM.B.mary@bath.ac.uk>

In the referenced article, bassett@ecn.purdue.edu (Matthew H. Bassett) writes:
>I am trying to spawn executables which take a number of command line arguments. 
>According to the ref manual I can pass these areguments in the argv parameter of
>pvm_spawn.  But in the spawned jobs, these arguments are overwritten...for
>example for executable "run":
>
>main(argc, argv) {
>
> pvm_spawn("run", argv, NULL, NULL, 1, NULL);
>
> for (i = 0; i < argc; i++) {
>  cout << argv[i] << " ";	
> }
> cout << endl;
>
>}
>
>if I say run 1 2 3, the first copy prints "run 1 2 3" but the second copy only
>print "run" and that is all.
>
>Any ideas of what is going on?

Not entirely, but for a start the argv you pass to pvm_spawn must be
subtly different to the one passed to main, in two ways:

1) it should start at argv[1]
2) it should be null terminated

I would guess that 2) is a good place to start, whereupon the effects
of 1) will become apparent.

The implications of 2) are that unfortunately you will have to
allocate a new array (or realloc the old one) to make space for the
extra null element. 

Duncan.





