Someone on the FreeDOS Facebook group has been experimenting with
FORTRAN77 programming using Open Watcom FORTRAN77 on FreeDOS. It gave
me a weird motivation to write some FORTRAN code of my own.

I used to write a lot of data analysis programs in FORTRAN when I was
a physics undergrad in the early 1990s, but not much since then.

I also thought I'd make it "DOS" by experimenting with the Open Watcom
FORTRAN77 graphics library. If anyone wants to try some FORTRAN
programming, here's a sample program that generates the Mandelbrot Set
in VGA graphics:

>C MANDELBROT'S SET, IN GRAPHICS MODE
>      INCLUDE 'GRAPHAPI.FI'
>      INCLUDE 'GRAPH.FI'
>
>      PARAMETER(STEP=.005)
>      REAL DIST
>      REAL R,I
>      COMPLEX Z,C
>      INTEGER X,Y
>      INTEGER COUNT
>
>      CALL _SETVIDEOMODE(_VRES16COLOR)
>
>C THIS IS A SIMPLE INTERATION OF Z=Z**2 + C
>C WHERE BOTH Z AND C ARE COMPLEX VALUES
>
>C ITERATE AND VARY THE C, START WITH Z=0,0
>C THE INTERESTING VALUES ARE FROM C.REAL=-2.0 TO 1.0
>C AND C.IMAG=1 TO -1
>
>C CONTINUE THE ITERATIONS AS LONG AS Z IS WITHIN A LIMIT (LIKE 2).
>      Y=0
>      DO 100 I=1.0,-1.0,-STEP
>      Y=Y+1
>
>      X=0
>      DO 100 R=-2.0,1.0,STEP
>      X=X+1
>
>      C=CMPLX(R,I)
>      Z=CMPLX(0.0,0.0)
>      COUNT=0
>
>10    Z=Z**2+C
>
>C USE THE THEOREM A**2 + B**2 = C**2
>C SO IF C**2 IS LESS THAN 4, WE KNOW C IS LESS THAN 2
>C (SEE ABOVE COMMENTS ABOUT THE LIMIT AS 2)
>      DIST=REAL(Z)**2 + IMAG(Z)**2
>      COUNT=COUNT+1
>      IF ((DIST.LT.4.0).AND.(COUNT.LT.100)) GOTO 10
>
>C DISPLAY THE VALUE AS A PIXEL ON THE SCREEN
>C SET THE PIXEL COLOR TO INDICATE HOW QUICKLY IT GREW,
>C OR BLACK IF IT REMAINED CONTAINED
>      CALL _SETCOLOR(1 + COUNT/10)
>      IF (COUNT.EQ.100) CALL _SETCOLOR(_BLACK)
>      CALL _SETPIXEL(X,Y)
>100   CONTINUE
>
>      PAUSE
>      CALL _SETVIDEOMODE(_DEFAULTMODE)
>
>      PRINT 900, X,Y
>900   FORMAT(I3,1HX,I3)
>      END

The PAUSE statement at the end silently waits for you to press Enter.
Then it resets to text mode and prints the final values of X and Y.

This actually has an "off by one" error, because I forgot graphics
start in x,y=0,0 (this starts in x,y=1,1). But it's okay because it
generates a 600x400 image, so it's well within the 640x480 resolution.

Remove the ">" at the start of each line, so you preserve the columns.

This probably should set a lower limit than 100, but it was a good
value to test with. It just means you get a large blue field, with
color only around the edges of the black field of the Mandelbrot Set.


_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to