-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.f90
66 lines (65 loc) · 1.7 KB
/
main.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
program main
implicit none
double precision :: xmin,xmax,ymin,ymax,dx,dy,t1,t2,xc,yc,xd,ts
double precision, allocatable :: x(:),y(:),result(:,:)
integer :: i,j,k,l,xn,yn,maxiter
xmin = -2.25
xmax = 0.75
xn = 450
ymin = -1.25
ymax = 1.25
yn = 375
maxiter = 200
allocate(x(xn))
allocate(y(yn))
allocate(result(xn,yn))
dx = (xmax-xmin)/(xn-1)
do i=1,xn
x(i) = xmin+dx*(i-1)
end do
dy = (ymax-ymin)/(yn-1)
do j=1,yn
y(j) = ymin+dy*(j-1)
end do
result=0
ts=0
do l = 1,1000
call CPU_TIME(t1)
do i=1,xn
do j=1,yn
xc = x(i)
yc = y(j)
do k= 1,maxiter
xd = xc
xc = xc*xc - yc*yc + x(i)
yc = 2*xd*yc + y(j)
if (xc*xc + yc*yc > 4) then
result(i,j) = k
exit
end if
if (k .eq. maxiter) then
result(i,j) = maxiter
end if
enddo
end do
end do
call CPU_TIME(t2)
ts = ts + t2-t1
enddo
print *, "time : ", (ts/1000)*1000
open(1,file="result.csv", action="write")
do i=1,xn
do j=1,yn
if (j.ne.yn) then
write(1,'(F10.5)', advance="no") result(i,j)
write(1,'(A)',advance="no") ","
else
write(1,'(F10.5)') result(i,j)
endif
end do
end do
close(1)
deallocate(x)
deallocate(y)
deallocate(result)
end program main