PROGRAM D8R6 C Driver for routine SORT3 PARAMETER(NLEN=64) DIMENSION A(NLEN),IB(NLEN),IC(NLEN),WKSP(NLEN),INDX(NLEN) CHARACTER MSG1*33,MSG2*31 CHARACTER MSG*64,AMSG(64)*1,BMSG(64)*1,CMSG(64)*1 EQUIVALENCE(MSG,AMSG(1)),(MSG1,AMSG(1)),(MSG2,AMSG(34)) DATA MSG1/'I''d rather have a bottle in front'/ DATA MSG2/' of me than a frontal lobotomy.'/ WRITE(*,*) 'Original message:' WRITE(*,'(1X,64A1,/)') (AMSG(J),J=1,64) C Read array of random numbers OPEN(5,FILE='TARRAY.DAT',STATUS='OLD') READ(5,*) (A(I),I=1,NLEN) CLOSE(5) C Create array IB and array IC DO 11 I=1,NLEN IB(I)=I IC(I)=NLEN+1-I 11 CONTINUE C Sort array A while mixing IB and IC CALL SORT3(NLEN,A,IB,IC,WKSP,INDX) C Scramble message according to array IB DO 12 I=1,NLEN J=IB(I) BMSG(I)=AMSG(J) 12 CONTINUE WRITE(*,*) 'Scrambled message:' WRITE(*,'(1X,64A1,/)') (BMSG(J),J=1,64) C Unscramble according to array C DO 13 I=1,NLEN J=IC(I) CMSG(J)=BMSG(I) 13 CONTINUE WRITE(*,*) 'Mirrored message:' WRITE(*,'(1X,64A1,/)') (CMSG(J),J=1,64) END