Ubuntu下Fortran多线程编程指南
一 环境准备与编译
二 OpenMP快速上手
program omp_hello
use omp_lib
implicit none
integer :: i, n
n = 8
call omp_set_num_threads(4)
!$omp parallel private(i) shared(n)
i = omp_get_thread_num()
print '("Hello from thread ", i0, " of ", i0)', i, omp_get_num_threads()
!$omp end parallel
!$omp parallel do schedule(static,1) reduction(+:n)
do i = 1, 100
n = n + i
end do
!$omp end parallel do
print '("Reduction sum = ", i0)', n
end program omp_hello
三 线程控制与性能调优
四 常见问题与排查
五 进阶并行模型