gbaso
gbaso

Reputation: 145

Install fftw-2.1.5 with mpi in local

I'm trying to install fftw-2.1.5 libraries on a IBM cluster with linux, with the --enable-mpi flag, but I have since failed to do so. I need fftw version 2.1.5 because GADGET2 code requires that version, with mpi support.

First, I installed mpich-3.0.4 with:

cd ~/mpich-3.0.4
./configure --prefix=$HOME --enable-shared
make
make install

Then I edited my .bashrc file, adding:

export LD_LIBRARY_PATH="$HOME/lib"
PATH=$PATH:$HOME/bin

Then I tried to install ffw:

./configure --prefix=$HOME/test --enable-mpi LDFLAGS=-L$HOME/lib CPPFLAGS=-I$HOME/include

but I got an error message:

checking for mpicc... mpicc
checking for MPI_Init... no
checking for MPI_Init in -lmpi... no
checking for MPI_Init in -lmpich... no
configure: error: couldn't find mpi library for --enable-mpi

All of my mpi test programs works, and I was able to install everything on my laptop in /usr/local. I tried to search the problem, but I only found that I need to enable LDFLAGS and CCPFLAGS, which I already did.

Anyone knows how to fix this?

EDIT: Following francis' suggestion, I used CFLAGS instead of CPPFLAGS, and I got through the ./compile part. But I receive another error during make:

/opt/ibmcmp/vac/11.1/bin/.orig/xlc: 1501-208 (S) command option D is missing a subargument

It seems a problem related with the ibm compiler (xlc).

EDIT2: Solved by passing mpicc as the right compiler to ./configure, with the CC flag.

For the records, the correct command is:

 ./configure --prefix=$HOME --enable-mpi --enable-type-prefix --enable-float LDFLAGS=-L$HOME/lib CFLAGS=-I$HOME/include CC=mpicc

(type-prefix and float are extra options required by GADGET2)

Upvotes: 4

Views: 5506

Answers (1)

masterdesky
masterdesky

Reputation: 63

Preamble

It's a very old thread, but I'm currently working with the very same environment and the solution presented above on itself didn't solve my problem. However my tiny addendum to it - which eventually solved my problem - may be still relevant and useful for others too in the future. (Also, I'm fairly new to GNU/Linux, so my answer could be trivial to others. I'm sorry about that beforehand.)

After a week of failing to install FFTW 2.1.5 and 3.3.9 with a locally installed MPI (OpenMPI 3.1.3 in my case), while constantly looking back at this thread (and many others), the working solution I "discovered" was completely counterintuitive (at least to me, again).

The (necessary but not sufficient) steps in the original post

The solution and meticulous details in the original post and edit are necessary but they need just a small remark to be sufficient. That's why I'm writing this answer in the first place. You have to run the configuration of both FFTW2 and FFTW3 as stated in EDIT2 in the original answer.

For FFTW2 the command is

./configure --prefix=/path/to/install \
            --enable-mpi \
            --enable-type-prefix \
            --enable-float \
            LDFLAGS=-L/path/to/mpi/lib CFLAGS=-I/path/to/mpi/include \
            CC=mpicc

while for FFTW3 it's

./configure --prefix=/path/to/install \
            --enable-mpi \
            --enable-float \
            LDFLAGS=-L/path/to/mpi/lib CFLAGS=-I/path/to/mpi/include \
            CC=mpicc

(There is no --enable-type-prefix flag for FFTW3, the prefix is written at the beginning of each FFTW3 header automatically in every case)

NOTE: Specifying explicitly the compiler as CC=mpicc was redundant in my case for both FFTW2 and FFTW3, but can be necessary for others.

The treachery of Linux $PATH

In the original discussion, others mention correctly, that in order to use locally installed headers and binaries, you have to add them to $LD_LIBRARY_PATH and $PATH respectively. The same goes for MPI too, of course. However. As for myself, the Linux novice, who found it out the hard way, that information wasn't enough on itself. Unsuspectingly - and unaware of my upcoming one week journey to Linux hell for beginners -, I updated my $PATH and $LD_LIBRARY_PATH variables as

PATH=$PATH:/path/to/mpi/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpi/lib

export $PATH
export $LD_LIBRARY_PATH

At the end of the session these variables cease to exist, so you have to use them in this session, or make them "permanent", by adding these lines to your ~/.bashrc (or the corresponding ~/...rc file of the shell you're using). I've done all of the above, and... FFTW still won't detect MPI libraries...

The sufficient addendum

You see, the commands above are completely valid and that's one of the ways how you generally add a path to any of these variables. We've all done it many times. I'm not familiar with the inner nature of FFTW, but as it tuns out, if you place the path/to/mpi/... at the end of $PATH or $LD_LIBRARY_PATH, it simply won't find them. I don't know why, I don't even know, whether it's a common and trivial behaviour, so don't ask me about this particular anomaly. So if you still experience the same issue after you've done all of the above, just simply add MPI at the beginning of your path and dynamic library path as follows:

PATH=/path/to/mpi/bin:$PATH
LD_LIBRARY_PATH=/path/to/mpi/lib:$LD_LIBRARY_PATH

export $PATH
export $LD_LIBRARY_PATH

Yes. After a week of constant trial and errors to set up an environment for GADGET2 and GADGET4 and other softwares, this small change was the solution.

Upvotes: 1

Related Questions