Fortrna program with arguments

David Luet luet at phoenix.Princeton.EDU
Fri Nov 15 16:27:15 EST 2002


Thanks Pete for your answer, however I could not make it to work with what you
told me. I found a quick fix though.
Pete Wyckoff wrote:

> The random string of characters is PBS trying to talk to its demuxer
> with some weak security by ensuring that they both have the same
> "cookie".  The patch provided in mpiexec/patch/pbs-2.3.12-mpiexec.diff
> gets rid of this and adds the ability to forward stdin/stdout/stderr
> from the application processes back to mpiexec.  But things should work
> at least even without the PBS patch.  You still should apply it and
> restart the pbs moms if you can.

I did install the PBS patch but maybe it didn't work. I'll try again.

>
> The huge number of extra arguments are what is necessary to get an
> MPICH/P4 application to start itself in parallel.  If you call
> MPI_Init(&argc, &argv) early in your program, these arguments are
> stripped out so that the application does not see them after that call.
> The same thing happens with mpirun.

But "MPI_Init(&argc, &argv)" is a C command from what I understand the
equivalent in Fortran is "call MPI_init(ierr)" and that's what I used in the
code I submitted.


> Note that the above is _not_ true with old mpich versions.
> How old is your mpich?

I use mpich-1.2.4

So here is how I fixed the problem. Instead of calling MPI_init in my main
Fortran program I do it in a C function that I call in the Fortran code. Here is
my C function:

#include <mpi.h>
#include <stdio.h>
#include <string.h>

int    xargc;
char **xargv;
extern int    __argc_save;
extern char **__argv_save;

void zarg_() {          /* call zarg() from fortran */
  int i;

  MPI_Init(&(__argc_save), &(__argv_save));

  xargc = __argc_save;
  xargv = __argv_save;
}

xargc and **xargv are the Fortran equivalent of argc and **argv in C.
It works but it's not elegant. So if somebody has a better solution I would
still like to know it.
Thanks for your help.
David


--
David Luet
MAE Department
Princeton University








More information about the mpiexec mailing list