Closed epmikida closed 9 years ago
Original date: 2015-02-12 21:20:55
This problem does not occur with C/C++ AMPI programs, only Fortran.
The example program uses the Fortran2003 standard's command line parsing functions. Before the 2003 standard, Fortran did not have a standard way of accessing the command line, though gfortran provided its own intrinsic functions iargc() and getarg() which other compilers copied before the 2003 standard.
MPI implementations seem to differ on their support of Fortran command line arguments. MPICH1 required compiler intrinsics for it and MPICH2 and MPICH3 abandoned that requirement and guaranteed nothing.
Original date: 2015-02-18 22:33:48
I found two functions in ampif.C for handling command line arguments in Fortran AMPI programs: mpi_get_argc() and mpi_get_argv(). These have to be called in place of the usual Fortran command line parsing functions in order to handle command line arguments in Fortran AMPI programs.
These functions use the C/C++ idiom of command line parsing though: they include the program's name in argc and argv. Fortran does not include the program's name or anything before it in the argument list. I will add functions to AMPI that follow the Fortran conventions so that you can drop the replacements into a Fortran MPI program when running with AMPI.
Also, this should probably be added to the AMPI documentation somewhere, since no other MPI implementation does this. And more generally we might also want to add a Fortran AMPI example program to examples/ampi/.
Original issue: https://charm.cs.illinois.edu/redmine/issues/669
To recreate using the attached program:
./build AMPI net-linux-x86_64 gfortran gcc ampif90 cmd_line.f90 -o cmd_line ./charmrun ./cmd_line x y z
This should cause the following output: Arg count = 3 Arg 1: x Arg 2: y Arg 3: z
But instead nothing gets printed out.
If you comment out lines 4 and 25 and uncomment lines 3 and 26, you can recompile and run it as a regular MPI program:
mpif90 cmd_line.f90 -o cmd_line mpirun -n 1 ./cmd_line x y z
And it gives the expected output.
cmd_line.f90