Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29386 Discussions

Compiling MPICH2 with Intel Fortran Compilar V.11

nileshjrane
Beginner
2,521 Views

Hello folks,

I am a newbie to Linux. I want to debug a parallel fortran code using idb V-11 on UBUNTU 9.10. I have installed idb successfully and it works fine for simple (non-parallel codes). But i couldn't compile parallel code using ifort command.I get following error:

>>nilesh_3d_2.f(20): error #5102: Cannot open include file 'mpif.h'
>>Include 'mpif.h'

I tried giving library path of my installed mpich2 folder(mpif.h file) using "-I" option but it does not work. it still gives errors like this:

>>undefined reference to `mpi_init_'

I searched here and i gotta know that probably i need to compile the mpich2 package with ifort 1st so that it will be compatible with ifort. If it is so, can some one please tell me very simple step-by-step approach to do this, or if there is some other solution to this problem then to do that???

Thanks in advance..

0 Kudos
8 Replies
rreis
New Contributor I
2,521 Views

The mpich2 you have in your sytem was compiled against the gcc suit (gcc, g++ and gfortran). You have to go to the mipch website, download the sources, unpack them and compile against the intel compilers suite.

So, if you have the intel compilers in your system (icc for C, ifort for fortran, icpc for C++), you can compile the mpich2 with them. It will probably has a ./configure, make, make install type of instalation. Meaning...

./configure will prepare the right environment for the compilation. if you do

./configure -help you will get a list of variable you can set. probably you will want

./configure -prefix=/somedir_to_put_mpich2 CC=icc CXX=icpc FC=ifort F77=ifort

but it's better to check. then you have to do make and then make install.

please notice that you will be having two mpich2 installations in your system and you have to be carefull with that (or you uninstall the one you got from the package system or set appropriate PATH so the system finds the ifort mpich first)

hope this will help you.

0 Kudos
nileshjrane
Beginner
2,521 Views
Quoting rreis

The mpich2 you have in your sytem was compiled against the gcc suit (gcc, g++ and gfortran). You have to go to the mipch website, download the sources, unpack them and compile against the intel compilers suite.

So, if you have the intel compilers in your system (icc for C, ifort for fortran, icpc for C++), you can compile the mpich2 with them. It will probably has a ./configure, make, make install type of instalation. Meaning...

./configure will prepare the right environment for the compilation. if you do

./configure -help you will get a list of variable you can set. probably you will want

./configure -prefix=/somedir_to_put_mpich2 CC=icc CXX=icpc FC=ifort F77=ifort

but it's better to check. then you have to do make and then make install.

please notice that you will be having two mpich2 installations in your system and you have to be carefull with that (or you uninstall the one you got from the package system or set appropriate PATH so the system finds the ifort mpich first)

hope this will help you.

Hi rreis,

Thank you very much, thats exactly what i wanted. now just one more doubt. The README of mpich2 says i need to run two more commands after configure:

>>make 2>&1 | tee m.txt

>>make install 2>&1 | tee mi.txt

Do i have to put any flag here like i put in configure?? And after doing all this, now ifort will compile my code correctly right?? or should i use mpif90 instead of ifort??? or ifort with -I option will do???

0 Kudos
nileshjrane
Beginner
2,521 Views

And yes i do have 2 installations now, but i have to set path for mpd, mpirun etc commands using "export PATH" command right?? Then, when i complete 2nd installation and run "export PATH", these commands automatically will be linked with new installations if i am not wrong. And then how to switch to older install directory?? I mean is there any way that i write this env. variable in bashrc file and can switch between the two directories at will???

Thanks....[:)]

0 Kudos
rreis
New Contributor I
2,521 Views

no, no more flags...notice however in the ./configure you can give the compilers optimization flags. in the setup in the last post it will compile but without any optimizations (you will have a non-optimized library). you can give the optimization flags like

./configure (BUNCH OF OPTIONS) CFLAGS="-O3 -someting - something2"

for instance...

You should always compile mpi programs with the mpi scripts like

mpif90, mpif77, mpicc, ...

what these do is invoke the proper compiler and also set the proper enviromnent variables and link with the proper mpi libraries. I think you should take some time and read more about the way things get to work in the mpi world...

I see now your first problem also arose from using ifort directly, instead of mpif90 (anyway it is not advisable to mix mpi libraries compiled with diferent compilers)

0 Kudos
rreis
New Contributor I
2,521 Views
Quoting nileshjrane

And yes i do have 2 installations now, but i have to set path for mpd, mpirun etc commands using "export PATH" command right?? Then, when i complete 2nd installation and run "export PATH", these commands automatically will be linked with new installations if i am not wrong. And then how to switch to older install directory?? I mean is there any way that i write this env. variable in bashrc file and can switch between the two directories at will???

Thanks....[:)]

you can put...

alias ifortenv="export PATH=/path_to_ifort_mpich2:$PATH"

everytime you do ifortenv in your path you will get the right thing. if not you stay with the old one...

0 Kudos
nileshjrane
Beginner
2,521 Views
Quoting rreis

no, no more flags...notice however in the ./configure you can give the compilers optimization flags. in the setup in the last post it will compile but without any optimizations (you will have a non-optimized library). you can give the optimization flags like

./configure (BUNCH OF OPTIONS) CFLAGS="-O3 -someting - something2"

for instance...

You should always compile mpi programs with the mpi scripts like

mpif90, mpif77, mpicc, ...

what these do is invoke the proper compiler and also set the proper enviromnent variables and link with the proper mpi libraries. I think you should take some time and read more about the way things get to work in the mpi world...

I see now your first problem also arose from using ifort directly, instead of mpif90 (anyway it is not advisable to mix mpi libraries compiled with diferent compilers)

I did use mpif90 initially, but i thought it would be better to compile the code with ifort if i have to debug it with idb. I have faced compatibility issues earlier for using different compilers to compile two linked codes. so i wanted to use ifort only this time. Anyway, i went through the log file for "configure" command now and i noticed that it does recognise ifort command automatically (without any F90 flag), ofcoarse along with gcc and gfortran.

And i have started reading MPI programming, but i am not aware of actual software issues, as our sys admin takes care of all such issues..but he doesnt know about idb, so i had to look for it myself.

0 Kudos
rreis
New Contributor I
2,521 Views
sorry, I presumed too much. Anyway I advise you to have a mpich2 version compiled exclusively with the intel suite (icc, icpc and ifort). Good luck!
0 Kudos
nileshjrane
Beginner
2,521 Views
Quoting rreis
sorry, I presumed too much. Anyway I advise you to have a mpich2 version compiled exclusively with the intel suite (icc, icpc and ifort). Good luck!

I did setup everything now...Thank you very much for your help...
0 Kudos
Reply