The following examples show how to use the OpenMP* features. See more examples in the OpenMP Fortran version 2.0 specifications.
This example shows a simple parallel loop where each iteration contains a different number of instructions. To get good load balancing, dynamic scheduling is used. The end do has a nowait because there is an implicit barrier at the end of the parallel region.
Example 1 |
---|
subroutine do_1 (a,b,n) |
This example shows two parallel regions fused to reduce fork/join overhead. The first end do has a nowait because all the data used in the second loop is different than all the data used in the first loop.
Example 2 |
---|
subroutine do_2 (a,b,c,d,m,n) |
This example demonstrates the use of the SECTIONS directive. The logic is identical to the preceding DO example, but uses SECTIONS instead of DO. Here the speedup is limited to 2 because there are only two units of work whereas in DO: Two Difference Operators above there are n-1 + m-1 units of work.
Example 3 |
---|
subroutine sections_1 (a,b,c,d,m,n) |
This example demonstrates how to use a SINGLE construct to update an element of the shared array a. The optional nowait after the first loop is omitted because it is necessary to wait at the end of the loop before proceeding into the SINGLE construct.
Example 4 |
---|
subroutine sp_1a (a,b,n) |