Someone on the FreeDOS Facebook group is exploring F77 programming
using Open Watcom FORTRAN, and they recently asked about sorting.

I don't know FORTRAN very well (at least, not anymore) but I know
there isn't a "sort" routine provided in the standard FORTRAN 77
library. I looked through the Open Watcom FORTRAN documentation and I
don't see a "sort" routine there either.

But maybe I missed it. Does anyone here write FORTRAN programs in Open
Watcom FORTRAN?

__

Of course, a bubble sort isn't hard to write, and isn't a bad choice
if your list is fairly short. I shared that with him. Here's a sample
FORTRAN 77 program that creates a list of ten random numbers (from 1
to 100) and sorts it with a bubble sort:

>      INTEGER NUM(10)
>      INTEGER SEED
>      INTEGER I, J, K
>      PRINT*,'ENTER RANDOM SEED'
>      READ*,SEED
>* FILL RANDOM DATA
>      PRINT*,'RANDOM DATA:'
>      DO 10 I=1,10,1
>      NUM(I) = INT(100*URAND(SEED) + 1)
>10    PRINT'(2I3)',I,NUM(I)
>* BUBBLE SORT THE LIST
>      PRINT*,'SORTING..'
>      DO 100 I=10,2,-1
>        DO 100 J=1,I-1,1
>        IF (NUM(J).GT.NUM(I)) THEN
>          K=NUM(J)
>          NUM(J)=NUM(I)
>          NUM(I)=K
>        ENDIF
>100   CONTINUE
>* PRINT THE RESULTS
>      DO 110 I=1,10,1
>110   PRINT'(2I3)',I,NUM(I)
>      END


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

Reply via email to