From: Maciej Golebiewski <s30125@hotbot.com>
Newsgroups: comp.parallel.mpi
Subject: SOLUTION TO: MPICH 1.1.2 on Linux with PGI
Date: Tue, 11 May 1999 14:32:46 +0200
Organization: Organization? Me???
Message-Id: <3738236E.C721573E@hotbot.com>
References: <7gqleg$dc6$1@news-int.gatech.edu>
    <373152C0.4292522D@hotbot.com> <7gs2ho$gpt$1@news-int.gatech.edu>
    <3732966E.8FE69727@hotbot.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Xref: ukc comp.parallel.mpi:5070


Hello everyone,

I finally solved problems with compiling MPICH 1.1.2 on Linux with PGI
compilers. Even if Thorsten decided to move to LAM, I post my solution
because I think it might be interesting for others to see it as well.

Due to some tests performed by configure AND how pgf90 works, it is
illegal to specify pgf90 as a FORTRAN 77 compiler (-fc=pgf90) to
configure.

The correct invocation looks like that:

./configure -device=your_preferred_one -cc=pgcc -fc=pgf77 -f90=pgf90 \
-cflags="-Muchar -B"

But before you can run ./configure, first you have to patch it, because
PGI C compiler is very picky about some type convertions:

diff ~/mpich_def/configure ~/mpich_patch/configure
6049a6043
> union semun arg;
6056c6050,6051
< semctl(semset_id,0,IPC_RMID,0); }
---
> arg.val = 0;
> semctl(semset_id,0,IPC_RMID,arg); }

Now you can run the above shown ./configure command.
After ./configure completes you should check out its output for
some indication of errors (eg. messages like "Could not build executable
program:") If everything seems OK, you have to patch 3 more files.
This is because they are generated automatically by configure and
have appended a line saying:
# Generated ....
And PGI preprocessor doesn't like that. Those 3 file are:
include/mpif.h
romio/include/mpio.h
romio/include/mpiof.h

Here's the patch (it converts the offending line to an acceptable
comment
form):

diff ~/mpich_def/include/mpif.h ~/mpich_patch/include/mpif.h
198c198
< # Generated automatically from mpiof.h.in by configure.
---
> !     # Generated automatically from mpiof.h.in by configure.

diff ~/mpich_def/romio/include/mpiof.h
~/mpich_patch/romio/include/mpiof.h
1c1
< # Generated automatically from mpiof.h.in by configure.
---
> !     # Generated automatically from mpiof.h.in by configure.

diff ~/mpich_def/romio/include/mpio.h ~/mpich_patch/romio/include/mpio.h
1c1
< # Generated automatically from mpio.h.in by configure.
---
> /* # Generated automatically from mpio.h.in by configure. */

Now you are ready to run make. After it finishes, check out its output
for errors, but everything should be OK.

And the last thing to patch: I have been unable to use the "USE MPI"
directive with pgf90: it complains about wrong format.  It might be
my fault, as I'm clueless when it comes to FORTRAN. Anyway, I managed
to compile and run a trivial F90 MPI program by commenting out the 1st
and the last line (Module MPI and End Module MPI) in include/mpif.f90
and then using include instead of use in my program:

# cat my_examples/hello.f90
        PROGRAM hello
        IMPLICIT NONE
        INCLUDE 'mpif.f90'
        INTEGER ierr, myid, numprocs

        call MPI_INIT( ierr )
        call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
        call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
        print *, "Process ", myid, " of ", numprocs, " is alive"
        call MPI_FINALIZE(ierr)
        stop
        end

# build/LINUX/ch_lfshmem/bin/mpif90 -o hello my_examples/hello.f90
Linking:
# hello -np 8
 Process            1 of            8 is alive
 Process            2 of            8 is alive
 Process            3 of            8 is alive
 Process            4 of            8 is alive
 Process            5 of            8 is alive
 Process            6 of            8 is alive
 Process            0 of            8 is alive
 Process            7 of            8 is alive
FORTRAN STOP
# FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
#

That's it. I hope that this post will be helpful to the next person
trying to get MPICH running with PGI on a Linux system.

Maciej Golebiewski

Maciej Golebiewski wrote:
> 
> Thorsten W. Hertel wrote:
> > I swear :) it doesn't work, I just installed the mpi again with
> > #
> > configure -device=ch_lfshmem -noc++ -fc=/usr/local/pgi/linux86/bin/pgf90 -f9
> > 0=
> > /usr/local/pgi/linux86/bin/pgf90
> > and I still get a bunch of error messages :-(

