program fern real x,y,newx,newy,rand_num,ran2 integer maxit,i,iseed,i_switch,pgopen,i_symbol external ran2 if (pgopen('/xwin').le.0) stop call pgpap(5.0,1.0) call pgenv(-5.5,5.5,-0.5,10.5,1,-1) call pgsci(1) call pgscr(16,0.1,0.7,0.05) i_symbol = -1 100 write(*,*) 'What is the total number of iteration ?' read (*,*) maxit write(*,*) 'Give a random seed integer :' read (*,*) iseed call pgsci(2) DO 1000, II=1,MAXIT x = ran2(iseed) y = ran2(iseed) call pgbbuf c do i=1,maxit do i=1,20 rand_num = ran2(iseed) if (rand_num.lt.0.1) then newx = 0.14*x + 0.01*y - 0.08 newy = 0.00*x + 0.51*y - 1.31 x = newx y = newy else if (rand_num.lt.0.45)then newx = 0.43*x + 0.52*y + 1.49 newy = -0.45*x + 0.5*y - 0.75 x = newx y = newy else if (rand_num.lt.0.8) then newx = 0.45*x - 0.49*y - 1.62 newy = 0.47*x + 0.47*y - 0.74 x = newx y = newy else newx = 0.49*x + 0*y + 0.02 newy = 0*x + 0.51*y + 1.62 x = newx y = newy endif endif endif enddo call pgpt(1,x,y,i_symbol) call pgebuf 1000 CONTINUE 104 write(*,*) 'More points to draw ? (1=YES;0=NO)' read (*,*) i_switch if (i_switch.eq.0) goto 102 if (i_switch.eq.1) goto 100 goto 104 102 continue call pgclos end