在官网下载所需要的安装版本
开始安装
解压
sudo tar -xvf mpich-4.1.tar.gz
sudo mv mpich-4.1 mpich4
更新软件源
sudo apt-get update
安装C、C++、gfortran
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install gfortran
解锁文件夹
sudo chown -R zteng mpich4
开始编译
sudo ./configure --disable-fortran --with-device=ch4:ofi --prefix=/安装路径/mpich4/mpich-install 2>&1 | tee c.txt
sudo apt install autoconf
#autoconf工具帮助我们自动地生成符合自由软件惯例的Makefile
autoconf
#clocal.m4:17: warning: this file was generated for autoconf 2.69.
#You have another version of autoconf. It may work, but is not guaranteed to.
#If you have problems, you may need to regenerate the build system entirely.
#To do so, use the procedure documented by the package, typically 'autoreconf'.
#configure.ac:617: warning: The macro `AC_PROG_CC_C99' is obsolete.
#configure.ac:617: You should run autoupdate.
#./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
#configure.ac:617: the top level
sudo apt install make
#安装make是因为后面需要用到make命令编译自己的程序
#正在读取软件包列表... 完成
sudo make -j 30 #此处make我调用30核数,快的很了
#/bin/sh ./config.status --recheck
...
sudo make install
设置环境变量
sudo vim /etc/profile
export MPI_ROOT=/home/zteng/mpich4/mpich-install #填写自己的路径
export PATH=$MPI_ROOT/bin:$PATH
export MANPATH=$MPI_ROOT/man:$MANPATH
sudo source /etc/profile
sudo: source:找不到命令
sudo -s #不知道为啥找不到命令,于是我进入root用户
root@zteng-Tower:/home/zteng/mpich4# source /etc/profile #可用
root@zteng-Tower:/home/zteng/mpich4# which mpicc #查看位置
root@zteng-Tower:/home/zteng/mpich4# mpichversion #查看版本
root@zteng-Tower:/home/zteng/mpich4# mpirun -n 10 ./examples/cpi #跑个例子,可以
说明
有时候没有权限就直接进root上跑吧
sudo -s