Update home authored by van Vliet's avatar van Vliet
...@@ -282,6 +282,7 @@ module purge ...@@ -282,6 +282,7 @@ module purge
``` ```
## Compiling programs ## Compiling programs
We are going to compile a very simple MPI (message passing interface) program, which is quite common on a cluster.
- vi hello.c - vi hello.c
``` ```
...@@ -308,8 +309,32 @@ int main (int argc, char *argv[]) ...@@ -308,8 +309,32 @@ int main (int argc, char *argv[])
} }
``` ```
If you are going to compile this program without the correct loaded module(s), you would see something like this:
```
$ module li
No modules loaded
$ gcc hello1.c -o hello1
hello1.c:2:10: fatal error: mpi.h: No such file or directory
#include <mpi.h>
^~~~~~~
compilation terminated.
```
So we need to load the correct module:
```
$ module add pmi/openpmix/4.0.0/gcc-8.2.1
```
- mpicc hello.c -o hello - mpicc hello.c -o hello
Handy reference:
| Language | C | C++ | Fortran77 | Fortran90 | Fortran95 |
| --- | --- | --- | --- | --- | --- |
| Command | mpicc | mpiCC | mpif77 | mpif90 | mpif95 |
- ./hello - ./hello
``` ```
... ...
......