================================
MPI
================================


Introduction
===================

**MPI** (Message Passing Interface) is a library, containing many
subroutines and functions, that can be used by
Fortran and C/C++. MPI is designed for `distributed memory`__ machines. 


This section gives a quick introduction to MPI with Fortran example
codes. For more information refer to `mpi-forum.org`__. 

The Fortran codes for the examples in this section can be found in the course repository in directory "MPI".

__ http://math.unm.edu/~motamed/Teaching/Fall20/HPSC/parallel.html#parallel-computer-memory-architectures
__ http://mpi-forum.org/



Basic MPI subroutines and functions
===============================================

We will use the following MPI subroutines and functions:

* MPI_INIT

* MPI_FINALIZE

* MPI_COMM_SIZE

* MPI_COMM_RANK

* MPI_BARRIER

* MPI_REDUCE

* MPI_SEND

* MPI_RECV

* MPI_SENDRECV

* MPI_WTIME



Example 1: Hellow World!
===========================================

.. literalinclude:: ../hpsc2020/MPI/Example1/MPI_1.f90
   :language: fortran
   :linenos:



Example 2: Wave equation in 1D 
===========================================

.. literalinclude:: ../hpsc2020/MPI/Wave1D/Laptop/wave1D_mpi.f90
   :language: fortran
   :linenos: