Mandelbrot Set

by qbguy (no login)

PROGRAM MANDEL
IMPLICIT NONE
INTEGER, PARAMETER :: N=999, RESOLUTION=999
INTEGER, DIMENSION(N,N) :: COLOUR
REAL, DIMENSION(N,N) :: CR, CI, ZR, ZI, ZRS, ZIS
INTEGER I, J
DO I=1,N
CR(I,:)=(I*3.0/N) - 2.0
CI(:,I)=(I*3.0/N) - 1.5
END DO
ZR=CR; ZI=CI; ZRS=ZR*ZR; ZIS=ZI*ZI
DO I=0, RESOLUTION
WHERE (ZRS + ZIS <= 4.0)
ZRS = ZR * ZR
ZIS = ZI * ZI
ZI = 2.0 * ZR * ZI + CI
ZR = ZRS - ZIS + CR
COLOUR = I
END WHERE
END DO
OPEN(UNIT=10, FILE='mandel.pgm')
WRITE(10, FMT='(''P2'',/,i3,2x,i3,/,i3)') N, N, RESOLUTION
WRITE(10,*) colour
CLOSE(UNIT=10)
END PROGRAM MANDEL

It outputs in pgm format:
http://netpbm.sourceforge.net/doc/pgm.html
http://en.wikipedia.org/wiki/Netpbm_format
http://netpbm.sourceforge.net/

pgm is natively supported by ubuntu's image viewer, and by the GNU Image Manipulation Program (gimp).

For windows, try installing the GiMP or look at http://gnuwin32.sourceforge.net/packages/netpbm.htm


Posted on Nov 24, 2008, 1:48 PM

Respond to this message   

Return to Index