Hi, I am new at programming (very hard), anyway I am supposed to load data from an existing file (10 records) the records contain name, height, weight, into 3 arrays (I successfully did it); then sort the data first by name, then by height (I am trying to use bubble sort, and a subroutine) I haven't successfully done that; after the data is sorted, I am to implement a binary search to find all the records that are above a certain height.
My code is as follows...
CODE
PROGRAM SEARCHBIO
INTEGER HEIGHT, WEIGHT, I, STATUS
CHARACTER *15, NAME
DIMENSION NAME(10), HEIGHT(10), WEIGHT(10)
*TO READ RECORDS FROM FILE
OPEN (UNIT = 10, FILE = 'biometric.dat', STATUS = 'OLD')
I = 1
READ (UNIT = 10, IOSTAT = STATUS, FMT = 100) NAME(I), HEIGHT(I), WEIGHT(I)
100 FORMAT (A16, 3X, I5, 3X, I5)
DO WHILE (STATUS .GE. O .AND. I .LE. 10)
READ (UNIT = 10, IOSTAT = STATUS, FMT = 100) NAME(I), HEIGHT(I), WEIGHT(I)
I = I + 1
END DO
* TO SORT THE RECORDS READ FROM FILE
LOOP = 1
COUNT = 0
DO WHILE (LOOP .LE. 10-COUNT)
IF (NAME(LOOP) .GT. NAME(LOOP+1)) THEN
* HERE I TRIED TO USE SUBROUTINE SWAP
CALL SWAP (NAME(LOOP), NAME(LOOP+1))
PRINT *, NAME(LOOP)
LOOP = LOOP + 1
COUNT = COUNT + 1
END IF
END DO
END
SUBROUTINE SWAP (A,B)
CHARACTER A, B, TMP
TMP = A
A = B
B = TMP
END
I get only 1 record and it is not sorted.
What's wrong? any help is deeeeeply appreciated.
Juan