[Fortran] 纯文本查看 复制代码
program main
implicit none
real(kind=8) :: a,b,c,e0,e1,e2,t1,t2,t3,x,r1,r2,de,p
integer :: i
OPEN(31,FILE='Ea.CIR80',STATUS='unknown')
OPEN(32,FILE='Eb.CIR80',STATUS='unknown')
OPEN(33,FILE='Gc.CIR80',STATUS='unknown')
t1 = 300.d0
t2 = 310.d0
t3 = 320.d0
e0 = 10000
call random_seed ()
!$OMP PARALLEL SECTIONS
!$OMP SECTION
do i = 1,10000
call random_number (x)
r1 = dble(x)
r2 = dble(x) * 2
e1 = t1 * e0
e2 = e1 * r2
de = e2 - e1
if(de.le.0) then
p = 1.d0
else
p = dexp(-de)
end if
if(p.le.r1) then
e2 = e1
else
e1 = e2
write(*,*) i
write(31,*) i,e2
end if
end do
close(31)
!$OMP SECTION
do i = 1,10000
call random_number (x)
r1 = dble(x)
r2 = dble(x) * 2
e1 = t2 * e0
e2 = e1 * r2
de = e2 - e1
if(de.le.0) then
p = 1.d0
else
p = dexp(-de)
end if
if(p.le.r1) then
e2 = e1
else
e1 = e2
write(*,*) ' ',i
write(32,*) i,e2
end if
end do
close(32)
!$OMP SECTION
do i = 1,10000
call random_number (x)
r1 = dble(x)
r2 = dble(x) * 2
e1 = t3 * e0
e2 = e1 * r2
de = e2 - e1
if(de.le.0) then
p = 1.d0
else
p = dexp(-de)
end if
if(p.le.r1) then
e2 = e1
else
e1 = e2
write(*,*) ' ',i
write(33,*) i,e2
end if
end do
close(33)
!$OMP END PARALLEL SECTIONS
end program main
[Fortran] 纯文本查看 复制代码
logical b
b=.false.
do i=1,10000
if(mod(i,50)==0) then
b=.not.b
if(b) then
交换t1,t2
else
交换t2,t3
end if
end if
end do