[Fortran] 纯文本查看 复制代码
program main
implicit real*8 (a-z)
include 'omp_lib.h'
integer i
integer,parameter :: s=320000
open(1,file='./epf.dat')
call cpu_time(t1)
call omp_set_num_threads(4)
!$OMP PARALLEL DO PRIVATE(epf,nobs)
do i=1,s
epf=2.0*i
nobs=epf**2
write(1,*) nobs,epf
end do
!$OMP END PARALLEL DO
call cpu_time(t2)
write(*,*) t2-t1
end
[Fortran] 纯文本查看 复制代码
program main
implicit none
include 'omp_lib.h'
integer i
integer,parameter :: s=3200000
integer :: t1 , t2
real :: epf , nobs
open(1,file='./epf.dat')
call system_clock(t1)
call omp_set_num_threads(4)
!$OMP PARALLEL DO PRIVATE(epf,nobs)
do i=1,s
epf=2.0*i
nobs=epf**2
end do
!$OMP END PARALLEL DO
call system_clock(t2)
write(*,*) t2-t1
end
[Fortran] 纯文本查看 复制代码
program main
use omp_lib
implicit none
integer :: i
call omp_set_num_threads(5)
!$omp parallel private(i)
i = omp_get_thread_num()
write(*,*) "Hello, Fortran Coder. from thread.",i
!$omp end parallel
write(*,*)
call omp_set_num_threads(3)
!$omp parallel private(i)
i = omp_get_thread_num()
write(*,*) "Hello, Fortran Coder. from thread.",i
!$omp end parallel
end program main