Clicky

Fortran Wiki
OpenMP (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #3 to #4: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

OpenMP is an interface for developing parallel applications on shared memory systems.

Examples

Parallel Do Loops

Parallel do loops are as simple as adding an OMP directive before and after the loop, as in the following example.

program omp_par_do
 implicit none
 integer, parameter :: n = 100
 real, dimension(n) :: dat, result
 integer :: i
 !$OMP PARALLEL DO
 do i = 1, n
 result(i) = my_function(dat(i))
 end do
 !$OMP END PARALLEL DO
contains
 function my_function(d) result(y)
 real, intent(in) :: d
 real :: y
 ! do something complex with data to calculate y
 end function my_function
end program omp_par_do

You must enable OpenMP during compilation. See the documentation for your compiler for details. With GFortran, this is accomplished with the -fopenmp flag as follows:

% gfortran -fopenmp -o omp_par_do omp_par_do.f90
Revised on July 16, 2017 14:19:49 by changed Link? (81.204.244.159) (1305 characters / 0.0 pages)
Edit | Back in time (3 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: 2009, Parallelization

AltStyle によって変換されたページ (->オリジナル) /