Subject: MPI_INIT

From: [email-masked] (Jon Flower)
Date: Mon, 8 Mar 93 12:44:15 PST

To throw in my two cents worth.....

The business with argc and argv (and, of course environ) has been
a thorn in the side of Express for many years. We've adopted a
standard two-faced approach in which C programmers get their
"main" routine renamed (silently) to exp_main which we then call
from our own main. In this case argc and argv get dealt with by
Express and passed to the main routine. This approach has the 
disease mentioned by Rik, that two or more different software
suppliers may want to pull the same trick causing confusion.

In fortran we went the way of MPI_INIT with no arguments. This
seems to work but has the difficulty that things beyond the
ken of the message passing system can be affected by it.

For example, the Express program

	program foo
	write(6,*) 'I have started'
	call kxinit		-- i.e., MPI_INIT
	write(6,*) 'Done with kxinit'
	stop
	end

is actually wrong because the I/O system needs to know parameters
that don't get set till the call to kxinit. We could, of course,
enforce the rule in MPI that only MPI routines are affected by the
MPI_INIT call and that, therefore, you can put anything you like
before the call to MPI_INIT as long as its name doesn't start
with MPI_!!!!! I dont think this is going to work in the long run
since it actively discourages library vendors from building their
codes with MPI routines!!!

Also, in Rik's example, I think the code has to look sort of
like

	main(argc, argv)
	int argc;
	char **argv;
	{
		MPI_INIT(&argc, &argv);
		FOO_INIT(&argc, &argv);
			/* etc... */

if we want to allow for the chance that it's actually MPI_INIT that
passes down the arguments....... this is pretty ugly......

My personal vote would be for making the user rename their top
level entry point:

	MPI_main(int argc, char **argv, char **environ)   in C
and     MPI_MAIN in fortran

Perhaps some compiler level support for potentially changing the
name of the entry point so that third party software vendors could
build their own "front-ends" that puts their own code first?? I appreciate
that this is definitately NOT current practice and has all sorts of
diseases of its own with different software suppliers providing layer
upon layer of "fake" compiler front-ends.

Another option that I would probably support would be bagging
argc/argv altogether at the MPI level. In this case a function call
with no arguments that had to be the first thing you did would be
OK -- if you do it wrong you probably get a core dump! Express' attempts
to deal with argc and argv date back to the days when hardware vendors
didn't provide these things and we wanted to ourselves. Now all the 
systems I know of start up C programs apropriately and the
need for Express (or some other system) to get in behind them is not
so crucial...?.... A slight counter-example to my own argument, 
however, is that some systems give you mangled argc/argv and 
particularly environ. This can lead to bizarre results. (Systems
which permit a remote host capability sometimes give you the 
environment that you would have had on the local host rather than
the one you actually have on the remote host.)
	
	Jon