1. 依赖
gcc 、gfortran
sudo agt-get install gfortran
报错: Could not connect to archive.ubuntu.com:80
解决方法:换镜像源
ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
ubuntu镜像_ubuntu下载地址_ubuntu安装教程-阿里巴巴开源镜像站
2. 安装
两小时入门MPI与并行计算(二):MPI的安装与配置 - 知乎
3. 运行
.bashrc 文件配置:
export PATH=/usr/local/mpich-4.0.2/bin:$PATH
export C_INCLUDE_PATH=/usr/local/mpich-4.0.2/include/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH:CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/usr/local/mpich-4.0.2/lib:$LD_LIBRARY_PATH
编译:
g++ main.cpp -O3 -o ./main -pthread -lyaml-cpp -L/usr/local/mpich-4.0.2/lib/ -lmpich
运行:
mpirun -np 2 ./main