Basic HTML version of Foils prepared 17 Sept 1996

Foil 69 Example of PURE Function from Chuck Koelbel

From New CPS615HPF and Fortran90 Discussion Sept 17 96 Basic Simulation Track for Computational Science CPS615 -- Fall Semester 96. by Geoffrey C. Fox, Tom Haupt


1 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)
2 END FORALL
3 This can call the PURE function mandelbrot which is essentially a generalized intrinsic
4 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. .AND. k < itol )
    • xtmp = xtmp*xtmp - x
    • k = k + 1
    • END DO
    • mandelbrot = k
5 END FUNCTION mandelbrot

in Table To:


© on Tue Oct 7 1997