test04, test05, test06 and test07’s documentation

test04, test05, test06 and test07 are compiled by Makefile and they can be run using run.sh. All four programs calculate the number “pi” in a rather silly way: the programs are merely examples of different types of parallelism.

Program

Overall Strategy

Main Program

Called Function

test04

serial

serial

serial

test05

MPI only

MPI

serial

test06

OpenMP only

serial

OpenMP

test07

MPI+OpenMP

MPI

OpenMP

All four programs use mod_safe/sub_allocate_array(); the two programs that use MPI also use mod_safe_mpi/sub_allreduce_array(). As all four programs use random numbers the output is not repeatable. The correct output for the first program should be something like:

How does real pi compare to calculated pi? real = 3.141592654; calc = 3.156000000

Whereas the correct output for the second program should be something like:

For MPI task 0 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.132000000 For MPI task 1 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.164000000 For MPI task 2 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.100000000 For MPI task 3 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.148000000 Overall, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.136000000

Whereas the correct output for the third program should be something like:

How does real pi compare to calculated pi? real = 3.141592654; calc = 3.153000000

Whereas the correct output for the fourth program should be something like:

For MPI task 0 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.141000000 For MPI task 1 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.147000000 For MPI task 3 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.108000000 For MPI task 2 of 4, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.129000000 Overall, how does real pi compare to calculated pi? real = 3.141592654; calc = 3.131250000

Of course, the ordering of the lines from the programs that use MPI cannot be relied upon.

program  test04

Import standard modules …

Use :

iso_fortran_env, mod_safe (const_pi()), mod_test04

Call to:

calc_pi()

Description

Import standard modules …

Needed modules

  • iso_fortran_env

Variables

  • mod_test04/nsamples [integer,parameter=1000]

Subroutines and functions

function  mod_test04/calc_pi()

Import standard modules …

Return:

ans [real ]

Use :

iso_fortran_env, mod_safe (sub_allocate_array())

program  mod_test04/test05

Import standard modules …

Use :

iso_fortran_env, mpi, mod_safe (const_pi(), func_mean(), sub_allocate_array()), mod_safe_mpi (sub_allreduce_array()), mod_test05

Call to:

calc_pi()

Description

Import standard modules …

Needed modules

  • iso_fortran_env

Variables

  • mod_test05/nsamples [integer,parameter=1000]

Subroutines and functions

function  mod_test05/calc_pi()

Import standard modules …

Return:

ans [real ]

Use :

iso_fortran_env, mod_safe (sub_allocate_array())

program  mod_test05/test06

Import standard modules …

Use :

iso_fortran_env, mod_safe (const_pi()), mod_test06

Call to:

calc_pi()

Description

Import standard modules …

Needed modules

  • iso_fortran_env

Variables

  • mod_test06/nsamples [integer,parameter=1000]

Subroutines and functions

function  mod_test06/calc_pi()

Import standard modules …

Return:

ans [real ]

Use :

iso_fortran_env, omp_lib, mod_safe (sub_allocate_array())

program  mod_test06/test07

Import standard modules …

Use :

iso_fortran_env, mpi, mod_safe (const_pi(), func_mean(), sub_allocate_array()), mod_safe_mpi (sub_allreduce_array()), mod_test07

Call to:

calc_pi()

Description

Import standard modules …

Quick access

Variables:

nsamples

Routines:

calc_pi()

Needed modules

  • iso_fortran_env

Variables

  • mod_test07/nsamples [integer,parameter=1000]

Subroutines and functions

function  mod_test07/calc_pi()

Import standard modules …

Return:

ans [real ]

Use :

iso_fortran_env, omp_lib, mod_safe (sub_allocate_array())

Called from:

test04, test05, test06, test07