下载 mpich2-1.4.1p1.tar.gz
首先引入ifort环境变量。
export FC=ifort
export F90=ifort
(若要使用icc作为C编译器,则export CC=icc,否则不需设置,默认使用gcc)
提示如下错误:
configure: error: F90 and F90FLAGS are replaced by FC and FCFLAGS respectively in this configure, please unset F90/F90FLAGS and set FC/FCFLAGS instead and rerun configure again.
[root@glnode05 mpich2-1.4.1p1]# unset F90
[root@glnode05 mpich2-1.4.1p1]# export FCFLAGS=ifort;
[root@glnode05 mpich2-1.4.1p1]# export FC=ifort;
[root@glnode05 mpich2-1.4.1p1]# export F77=ifort;
[root@glnode05 mpich2-1.4.1p1]# ./configure --prefix=/opt/mpich2/mpich2 && make && make install
./configure --help 查看帮助
编译完毕,mpich2安装在 /opt/mpich2/mpich2/目录下,查看目录下的bin目录,发现只有mpif77,不过mpif77等同于mpi ifort,使用它同样可以编译 fortran 90 或者 95 程序。
测试:
/opt/mpich2/mpich2/bin/mpif77 rand2.f90
----------------------------------
! rand2.f90
! 使用gfortran不能编译通过,使用ifort可以编译通过
program my_random
CALL SEED(RND$TIMESEED)
CALL RANDOM(rand)
print *, rand
end program my_random
-----------------------------------