I am using a unix workstation with C shell. There were two compilers of mpif90, one compiled with ifort and one with gfortran, installed on the system. The default mpi compiler was the one compiled with gfortran.

Now, I want to change the default compiler to the ifort compiled one. It was stored in the folder "/usr/local/mvapich2-icc/bin". So I added the following to the ~/.cshrc file:

setenv mpif90 /usr/local/mvapich2-icc/bin/mpif90

and run "source ~/.cshrc" on the terminal. However, this seems not to have any effect. When I type "which mpif90", the path shown was still the gfortran compiled one.

How shall I set the environment properly so that the default compiler called was the ifort compiled one?

Any help would be appreciated. Thanks.


The easiest way to do this is to just adjust the $PATH:

set path = (/usr/local/mvapich2-icc/bin $path)

However, this means that all executables in /usr/local/mvapich2-icc/bin/ will be found before the ones in your default path, which you might not want (I can't be sure).

Now, if you're compiling software with a Makefile, you'll probably be better off just defining the variables there to use the appropriate MPI compiler.

  • Thanks for the suggestion. Finally I have added the link in the Makefile and everything goes smoothly. :) – user45857 Jan 29 '15 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.