Ubuntu16.04 installation and configuration mpich2

1. System environment: ubuntu16.04.2
2. Preparations

In order to avoid errors during installation, first update apt-get, install the three compilers gcc/g++ and gfortran

sudo apt-get update
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install gfortran

3. Download and install MPICH2

  1. Download address: http://www.mpich.org/downloads/
  2. unzip files:tar zxvf mpich-3.2.tar.gz
  3. Go to the unzipped folder:cd mpich-3.2
  4. Set the installation directory: ./configure -prefix=/home/username/mpich
    Note: The installation path is filled in after the prefix. If it is the home folder, don’t forget to add your own user name. There is no auto-completion here. one time
  5. Compile:make
  6. Installation: make install(Compilation and installation can also be combined into one step, make && make install)
  7. Configure the environment: Here is a supplement to the knowledge of configuring environment variables: http://blog.csdn.net/baidu_34045013/article/details/78237825
    For convenience, we set environment variables for all users of this machine (for other needs, please refer to the above link) , open /etc/environment
    sudo gedit /etc/environment
    and add your own path to the end of PATH, be careful not to forget the colon ":", the added PATH is as follows
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin :/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/username/mpich/bin"
    save and exit, enter in the terminal source /etc/environment
    and then enter $PATH to find that it has been updated, the environment variable configuration success
  8. Test: terminal input
    which mpicc
    which mpiexec
    If these two executable paths are displayed, the installation is successful

Fourth, run the test program

  1. Enter the examples folder in the mpich source file directory, first compile the cpi.c file, and generate the cpi executable file (if cpi already exists in the directory, this step can be omitted)
    mpicc cpi.c -o cpi

  2. execute cpi
    mpiexec ./cpi

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325953004&siteId=291194637