! ---------------------------------------------- ! Example program ! ! Complex arithmetics, applied to Mandelbrot set ! Complex plane box corners (x0,y0) to (x1,y1) ! ---------------------------------------------- program mandel implicit none integer, parameter:: dp=kind(1.d0),ix=10000 real(dp),parameter:: d=1.d-2,x0=-1.5d0,x1=0.5d0,y0=-1.d0,y1=1.d0 integer:: i complex(dp):: cx,c real(dp):: x,y x = x0 do y = y0 do c = cmplx(x,y,dp) cx = c do i = 1, ix cx = cx**2+c if(abs(cx)>2) exit end do write(12,'(2f8.3,i10)') c,i y = y + d if(y>y1) exit end do write(12,*) x = x + d write(*,'(f0.1," percent done")') (x-x0)/(x1-x0)*100.d0 if(x>x1) exit end do end program mandel