当前位置: 首页 > 工具软件 > MPICH2 > 使用案例 >

mpich2配置与测试_Ubuntu20安装MPICH2

岳谦
2023-12-01

本文参考http://duanple.blog.163.com/blog/static/709717672010329581914/

0.下载MPICH2

最开始作者安装最新版MPICH,即mpich3.0,但始终有问题,也不知如何解决,最终还是选择安装mpich2-1.2.1。

1. 安装前的系统准备

确保你的系统中已经安装了gcc和g++编译器, 以及g77或者gfortran编译器。你的系统中还需要安装Python 2.2 以上版本。

zuoan@WHU:~$ gcc --version

gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1

Copyright (C) 2013 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

zuoan@WHU:~$ g++ --version

g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1

Copyright (C) 2013 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

zuoan@WHU:~$ gfortran --version

GNU Fortran (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1

Copyright (C) 2013 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.

You may redistribute copies of GNU Fortran

under the terms of the GNU General Public License.

For more information about these matters, see the file named COPYING

zuoan@WHU:~$ python --version

Python 2.7.5+

另一个需要确认的就是,您当前的用户不是root用户。MPICH2的官方文档上面不推荐使用root用户进行安装。

2. 安装步骤

标准的 configure, make, make install 步骤,非常简单!

$ tar xzf mpich2-1.2.1.tar.gz

$ cd mpich2-1.2.1/

$ ./configure --prefix=/home/zuoan/soft/mpich2

(...省略)

$ make

(... 省略)

$ make install

(... 省略)

安装结束!

3. 设置环境变量

添加下面这行到/etc/profile文件的最后,然后重新起动系统使环境变量永久生效。

export PATH=/home/zzm/bin/mpich2/bin:$PATH

可以测试下看看环境变量是否已经设置好:

zuoan@WHU:~$ which mpd

/home/zuoan/soft/mpich2/bin/mpd

zuoan@WHU:~$ which mpirun

/home/zuoan/soft/mpich2/bin/mpirun

zuoan@WHU:~$ which mpiexec

/home/zuoan/soft/mpich2/bin/mpiexec

4. 添加mpd配置文件

在当前用户的home目录下面新建立一个名为".mpd.conf"的配置文件

One way to safely create this file is to do the following:

cd $HOME

touch .mpd.conf

chmod 600 .mpd.conf

and then use an editor to insert a line like

MPD_SECRETWORD=mr45-j9z

into the file.  (Of course use some other secret word than mr45-j9z.)

我的操作如下:

zuoan@WHU:~/program/examples$ cd $home

zuoan@WHU:~$ touch .mpd.conf

zuoan@WHU:~$ chmod 600 .mpd.conf

zuoan@WHU:~$ gedit .mpd.conf

5. 开始单机测试

如果你能得到和下面的类似的结果而且没有出现任何错误的话,说明你的MPICH2已经安装成功。

zuoan@WHU:~$ mpdallexit

zuoan@WHU:~$ mpd &

[2] 3008

[1]   完成                  mpd  (工作目录:~/program/examples)

(当前工作目录:~)

zuoan@WHU:~$ mpdtrace

WHU

6.运行程序

zuoan@WHU:~/program/examples$ mpirun -np 2 ./cpi

Process 0 of 2 is on WHU

Process 1 of 2 is on WHU

pi is approximately 3.1415926544231318, Error is 0.0000000008333387

wall clock time = 0.000170

阅读(1176) | 评论(0) | 转发(0) |

0

上一篇:没有了

 类似资料: