48. 用于Mandelbrot 集合的纯函数 |
! The caller (显式接口没有示出)
FORALL ( i=1:n, j=1:m)
k(i,j) = mandelbrot( CMPLX((i-1)*1.0/(n-1), (j-1)*1.0/(m-1)), 1000)
END FORALL
!The callee
PURE INTEGER FUNCTION mandelbrot(x,itol)
COMPLEX, INTENT(IN) :: X
INTEGER, INTENT(IN) :: itol
COMPLEX xtmp
INTEGER k
k = 0
xtmp = -x
DO WHILE (ABS(xtmp)<2.0 .AND. k<itol)
xtmp = xtmp*xtmp - x
k = k + 1
END DO
mandelbrot = k
END FUNCTION mandelbrot
Copyright: NPACT |