Program examples#
If you have not done so already copy our examples to your home directory by running the following command:
cp -r /apps/gent/tutorials/Intro-HPC/examples ~/
~
(tilde) refers to your home directory, the directory you arrive by default when you login.
Go to our examples:
cd ~/examples/Program-examples
Here, we just have put together a number of examples for your convenience. We did an effort to put comments inside the source files, so the source code files are (should be) self-explanatory.
-
01_Python
-
02_C_C++
-
03_Matlab
-
04_MPI_C
-
05a_OMP_C
-
05b_OMP_FORTRAN
-
06_NWChem
-
07_Wien2k
-
08_Gaussian
-
09_Fortran
-
10_PQS
The above 2 OMP directories contain the following examples:
C Files | Fortran Files | Description |
---|---|---|
omp_hello.c | omp_hello.f | Hello world |
omp_workshare1.c | omp_workshare1.f | Loop work-sharing |
omp_workshare2.c | omp_workshare2.f | Sections work-sharing |
omp_reduction.c | omp_reduction.f | Combined parallel loop reduction |
omp_orphan.c | omp_orphan.f | Orphaned parallel loop reduction |
omp_mm.c | omp_mm.f | Matrix multiply |
omp_getEnvInfo.c | omp_getEnvInfo.f | Get and print environment information |
omp_bug1.c omp_bug1fix.c omp_bug2.c omp_bug3.c omp_bug4.c omp_bug4fix omp_bug5.c omp_bug5fix.c omp_bug6.c |
omp_bug1.f omp_bug1fix.f omp_bug2.f omp_bug3.f omp_bug4.f omp_bug4fix omp_bug5.f omp_bug5fix.f omp_bug6.f |
Programs with bugs and their solution |
Compile by any of the following commands:
C: | icc -openmp omp_hello.c -o hello\newline pgcc -mp omp_hello.c -o hello\newline gcc -fopenmp omp_hello.c -o hello |
---|---|
Fortran: | ifort -openmp omp_hello.f -o hello\newline pgf90 -mp omp_hello.f -o hello\newline gfortran -fopenmp omp_hello.f -o hello |
Be invited to explore the examples.