      PROGRAM DPSERTR
      ALLOCATABLE::Q(:,:),na(:),xi(:,:),nxi(:,:),NB(:),ND(:),P(:,:)
      ALLOCATABLE:: NROW(:),NCOL(:)
      COMMON/PARAM/NOPT,N,k,mtc
      logical mtc
      CHARACTER*80 FNAME,GNAME,INFORM
      ires=1
5010  WRITE(*,*) ' MAIN MENU '
      WRITE(*,*) '    1 UNWEIGHTED GRADIENT WITHIN ROWS AND COLUMNS '
      write(*,*) '      number of strict consistencies minus '
      write(*,*) '      inconsistencies ABOVE the main diagonal'
      WRITE(*,*) '    2 WEIGHTED GRADIENT WITHIN ROWS AND COLUMNS '
      write(*,*) '      weighted by positive or negative differences'
      WRITE(*,*) '    3 UNWEIGHTED GRADIENT WITHIN ROWS AND COLUMNS'
      WRITE(*,*) '      NUMBER OF INCONSISTENCIES TO BE MINIMIZED'
      WRITE(*,*) '    4 WEIGHTED GRADIENT WITHIN ROWS AND COLUMNS'
      WRITE(*,*) '      WEIGHTED INCONSISTENCIES TO BE MINIMIZED'
      WRITE(*,*) '    5 GORDON SEQUENCE COMPARISON MEASURE TO BE'
      WRITE(*,*) '      MINIMIZED--  ROW AND COLUMN ORDER CONSTRAINTS'
      WRITE(*,*) ' CHOICE? '
      READ(*,1) NOPT
      WRITE(*,552)
      IF(NOPT.EQ.5) NRES=2
      IF(NOPT.EQ.5) GO TO 3000
      WRITE(*,*) '1 FOR WITHIN ROW COMPARISONS ONLY, 2 FOR WITHIN COLUM
     &N COMPARISONS ONLY, 3 FOR BOTH COMPARISONS-- THESE CHOICES ARE
     &FOR THE SQUARE DERIVED MATRIX'
      READ(*,*) NCOMP
1     FORMAT(BN,I6)
      WRITE(*,*) '1 FOR WITHIN ROW COMPARISONS ONLY, 2 FOR WITHIN COLUM
     &N COMPARISONS ONLY, 3 FOR BOTH COMPARISONS-- THESE CHOICES ARE
     &FOR THE ORIGINAL RECTANGULAR MATRIX'
      READ(*,*) MCOMP
3000  WRITE(*,*) ' NUMBER OF ROWS IN THE INPUT MATRIX '
      READ(*,1) NR
      WRITE(*,552)
      WRITE(*,*) ' NUMBER OF COLUMNS IN THE INPUT MATRIX'
      READ(*,1) NC
      N=NR+NC
      IF(NOPT.EQ.5) GO TO 3001
      WRITE(*,*) 'ORDER RESTRICTIONS?'
      WRITE(*,*) '1 COLUMN ORDER RESTRICTIONS ONLY'
      WRITE(*,*) '2 ROW AND COLUMN ORDER RESTRICTIONS'
      READ(*,*) NRES
3001  WRITE(*,*) 'COLUMN ORDER RESTRICTION'
      WRITE(*,*) '1 IDENTITY ORDER'
      WRITE(*,*) '2 TO BE READ IN'
      READ(*,*) NCOLRES
      IF(NRES.EQ.2) WRITE(*,*) 'ROW ORDER RESTRICTION'
      IF(NRES.EQ.2) WRITE(*,*) '1 IDENTITY ORDER'
      IF(NRES.EQ.2) WRITE(*,*) '2 TO BE READ IN'
      IF(NRES.EQ.2) READ(*,*) NROWRES
      IF (NRES.EQ.1) ALLOCATE (Q(N,N),NA(N),NB(N),ND(N),P(NR,NC),
     &NROW(N),NCOL(N),XI(0:2**NR,0:NC),NXI(0:2**NR,0:NC),STAT=IERR)
      IF (NRES.EQ.2) ALLOCATE (Q(N,N),NA(N),NB(N),ND(N),P(NR,NC),
     &NROW(N),NCOL(N),XI(0:NR,0:NC),NXI(0:NR,0:NC),STAT=IERR)
      IF(IERR.NE.0) WRITE(*,*) 'ARRAY ALLOCATION ERROR'
      IF(IERR.NE.0) STOP
      IF(IERR.EQ.0) WRITE(*,*) 'ARRAY ALLOCATION SUCCESSFUL'
      WRITE(*,*) ' FILE NAME FOR THE INPUT MATRIX '
      READ(*,'(A)') FNAME
      WRITE(*,552)
      WRITE(*,*) ' FILE NAME FOR THE OUTPUT '
      READ(*,'(A)') GNAME
      WRITE(*,552)
      WRITE(*,550)
      WRITE(*,*) FNAME
      WRITE(*,*) GNAME
550   FORMAT(' INPUT AND OUTPUT FILES ARE ')
      WRITE(*,*) ' PROVIDE FORMAT FOR THE INPUT MATRIX '
      READ(*,'(A)') INFORM
      WRITE(*,552)
      WRITE(*,551)
      WRITE(*,*) INFORM
551   FORMAT(' INPUT FORMAT IS ')
      OPEN(1,FILE=FNAME)
      OPEN(2,FILE=GNAME,STATUS='NEW')
      WRITE(2,7799) NOPT
7799  FORMAT(' OPTIMIZATION MENU OPTION ',I4)
      WRITE(2,552)
      IF(NOPT.EQ.5) GO TO 3002
      IF(NCOMP.EQ.1) WRITE(2,*)
     &'WITHIN ROW COMPARISONS ONLY FOR THE DERIVED SQUARE MATRIX'
      IF(NCOMP.EQ.2) WRITE(2,*)
     &'WITHIN COLUMN COMPARISONS ONLY FOR THE DERIVED SQUARE MATRIX'
      IF(NCOMP.EQ.3) WRITE(2,*)
     &'BOTH WITHIN ROW AND COLUMN COMPARISONS USED FOR THE DERIVED
     & SQUARE MATRIX'
      WRITE(2,552)
      IF(MCOMP.EQ.1) WRITE(2,*)
     &'WITHIN ROW COMPARISONS ONLY FOR THE ORIGINAL MATRIX'
      IF(MCOMP.EQ.2) WRITE(2,*)
     &'WITHIN COLUMN COMPARISONS ONLY FOR THE ORIGINAL MATRIX'
      IF(MCOMP.EQ.3) WRITE(2,*)
     &'BOTH WITHIN ROW AND COLUMN COMPARISONS USED FOR THE ORIGINAL
     & MATRIX'
      WRITE(2,552)
3002  WRITE(2,*) 'INPUT MATRIX '
      DO 1002 I=1,N
      DO 1002 J=1,N
1002  Q(I,J)=0.0
      DO 1006 I=1,NR
      READ(1,INFORM) (Q(I,J+NR),J=1,NC)
      WRITE(2,552)
      WRITE(2,6000) (Q(I,J+NR),J=1,NC)
1006  CONTINUE
6000  FORMAT(2X,6F13.3)
      DO 1004 I=1,N
      NROW(I)=0
      NCOL(I)=0
      DO 1004 J=I+1,N
1004  Q(J,I)=Q(I,J)
      DO 505 I=1,NR
      DO 505 J=1,NC
505   P(I,J)=Q(I,NR+J)
      WRITE(2,552)
      DO 4000 I=1,NR
4000  NROW(I)=I
      DO 4001 J=1,NC
4001  NCOL(J)=J
      IF(NCOLRES.EQ.2) WRITE(*,*) 'INPUT COLUMN ORDER IN INTEGER FORM
     & SEPARATED BY BLANKS'
      IF(NCOLRES.EQ.2) READ(*,*) (NCOL(I),I=1,NC)
      IF((NRES.EQ.2).AND.(NROWRES.EQ.2)) WRITE(*,*) 'INPUT ROW ORDER
     & IN INTEGER FORM SEPARATED BY BLANKS'
      IF((NRES.EQ.2).AND.(NROWRES.EQ.2)) READ(*,*) (NROW(I),I=1,NR)
      WRITE(2,*) 'COLUMN ORDER IMPOSED'
      WRITE(2,4003) (NCOL(I),I=1,NC)
      WRITE(2,552)
4003  FORMAT(20I3)
      WRITE(2,552)
      IF(NRES.EQ.1) WRITE(2,*) 'NO ROW ORDER IMPOSED'
      IF(NRES.EQ.2) WRITE(2,*) 'ROW ORDER IMPOSED'
      IF(NRES.EQ.2) WRITE(2,4003) (NROW(I),I=1,NR)
6500  WRITE(*,*) ' PROGRAM RUNNING '
      WRITE(*,552)
      Z=-1.0e+20
      IF(NOPT.LE.2) Z=Z
      IF(NOPT.GT.2) Z=-Z
      NZ=0
      IF(NRES.EQ.1) GO TO 4004
      DO 4020 I=0,NR
      DO 4020 J=0,NC
      XI(I,J) = Z
4020  NXI(I,J)=NZ
      XI(0,0) = 0.0
      XI(0,1) = 0.0
      IF(NOPT.EQ.5) XI(0,1)=2.0*Q(NROW(1),NCOL(1)+NR)
      NXI(0,1) = NCOL(1)+NR
      XI(1,0) = 0.0
      IF(NOPT.EQ.5) XI(1,0)=2.0*Q(NROW(1),NCOL(1)+NR)
      NXI(1,0) = NROW(1)
      K=0
      INDEX=0
      GO TO 4030
4031  K=K+1
      WRITE(*,3012) K
      INDEX=K
      IF(K.EQ.(NR+1)) GO TO 5
      DO 4021 I=1,K
4021  NA(I)=NROW(I)
      GO TO 4030
4004  DO 4005 I=0,2**NR
      DO 4005 J=0,NC
      XI(I,J)=Z
4005  NXI(I,J) = NZ
      XI(0,0) = 0.0
      XI(0,1)=0.0
      NXI(0,1) = NCOL(1)+NR
      DO 4006 I=1,NR
      INDEX=2**(I-1)
      XI(INDEX,0) = 0.0
      NXI(INDEX,0) = I
4006  CONTINUE
      K=0
      INDEX=0
      GO TO 4030
4     K=K+1
      WRITE(*,3012) K
3012  FORMAT(' PROCESSING ROW SUBSETS OF SIZE ',I4)
      IF(K.EQ.(NR+1)) GO TO 5
      MTC=.FALSE.
6     go to 30
30    IF(MTC) GO TO 40
      M2=0
      nH=K
      GO TO 50
40    IF(M2.LT.(NR-nH)) nH=0
      nH=nH+1
      M2=ND(K+1-nH)
50    DO 51 J=1,nH
51    ND(K+J-nH)=M2+J
      MTC=ND(1).NE.(NR-K+1)
      go to 6050
6050  INDEX=0
      DO 10 I=1,K
      NA(I)=ND(I)
10    INDEX=INDEX+2**(ND(I)-1)
4030  DO 4010 KCOL=0,NC
      IF((K.EQ.0).AND.(KCOL.EQ.0)) GO TO 4010
      IF(KCOL.EQ.0) KTOT = K
      IF(KCOL.EQ.0) GO TO 4011
      KTOT=KCOL+K
      DO 4012 I=1,KCOL
4012  NA(I+K)=NCOL(I)+NR
4011  JJ=1
      DO 7 I=1,N
      DO 8 J=1,KTOT
      IF(NA(J).EQ.I) GO TO 7
8     CONTINUE
      NB(JJ)=I
      JJ=JJ+1
7     CONTINUE
      NK=N-KTOT
      IF(NK.EQ.0) EXIT
20    DO 9 JJ=1,NK
      J1=NB(JJ)
      IF(((NRES.EQ.2).AND.(J1.LE.NR)).AND.(J1.NE.NROW(K+1))) GO TO 9
      IF((J1.GT.NR).AND.(J1.NE.(NCOL(KCOL+1)+NR))) GO TO 9
      SUM=0.0
      GO TO (13,5005,13,5005,3005) NOPT
3005  IF((J1.GT.NR).AND.((K.LT.NR).AND.(K.GT.0))) SUM=
     &Q(NROW(K),J1)+Q(NROW(K+1),J1)
      IF((J1.GT.NR).AND.((K.LT.NR).AND.(K.EQ.0)))SUM=
     &2.0*Q(NROW(1),J1)
      IF((J1.GT.NR).AND.(K.EQ.NR)) SUM=2.0*Q(NROW(K),J1)
      IF((J1.LE.NR).AND.((KCOL.LT.NC).AND.(KCOL.GT.0))) SUM=
     &Q(J1,NCOL(KCOL)+NR)+Q(J1,NCOL(KCOL+1)+NR)
      IF((J1.LE.NR).AND.((KCOL.LT.NC).AND.(KCOL.EQ.0))) SUM=
     &2.0*Q(J1,NCOL(1)+NR)
      IF((J1.LE.NR).AND.(KCOL.EQ.NC)) SUM=2.0*Q(J1,NCOL(KCOL)+NR)
      GO TO 14
13    IF(NCOMP.EQ.2) GO TO 8000
      DO 15 I=1,KTOT
      I1=NA(I)
      DO 16 J=1,NK
      J2=NB(J)
      IF(J2.EQ.J1) GO TO 16
      IF((I1.LE.NR).AND.((J1.LE.NR).OR.(J2.LE.NR))) GO TO 16
      IF((I1.GT.NR).AND.((J1.GT.NR).OR.(J2.GT.NR))) GO TO 16
      IF((MCOMP.EQ.1).AND.(I1.GT.NR)) GO TO 16
      IF((MCOMP.EQ.2).AND.(I1.LE.NR)) GO TO 16
      IF((NOPT.EQ.1).AND.(Q(I1,J1).LT.Q(I1,J2))) SUM=SUM+1.0
      if(q(i1,j1).gt.q(i1,j2)) sum=sum-1.0
16    CONTINUE
15    CONTINUE
8000  IF(NCOMP.EQ.1) GO TO 14
      DO 17 J=1,NK
      J2=NB(J)
      IF(J2.EQ.J1) GO TO 17
      DO 18 I=1,KTOT
      I1=NA(I)
      IF((J2.LE.NR).AND.((J1.LE.NR).OR.(I1.LE.NR))) GO TO 18
      IF((J2.GT.NR).AND.((J1.GT.NR).OR.(I1.GT.NR))) GO TO 18
      IF((MCOMP.EQ.1).AND.(J2.GT.NR)) GO TO 18
      IF((MCOMP.EQ.2).AND.(J2.LE.NR)) GO TO 18
      IF((NOPT.EQ.1).AND.(Q(J1,J2).LT.Q(I1,J2))) SUM=SUM+1.0
      if(q(j1,j2).gt.q(i1,j2)) sum=sum-1.0
18    CONTINUE
17    CONTINUE
      GO TO 14
5005  IF(NCOMP.EQ.2) GO TO 8001
      DO 715 I=1,KTOT
      I1=NA(I)
      DO 716 J=1,NK
      J2=NB(J)
      IF(J2.EQ.J1) GO TO 716
      IF((I1.LE.NR).AND.((J1.LE.NR).OR.(J2.LE.NR))) GO TO 716
      IF((I1.GT.NR).AND.((J1.GT.NR).OR.(J2.GT.NR))) GO TO 716
      IF((MCOMP.EQ.1).AND.(I1.GT.NR)) GO TO 716
      IF((MCOMP.EQ.2).AND.(I1.LE.NR)) GO TO 716
      IF(NOPT.EQ.2) SUM=SUM+q(i1,j2)-q(i1,j1)
      IF((NOPT.EQ.4).AND.((Q(I1,J2)-Q(I1,J1)).LT.0.0))
     &SUM=SUM+Q(I1,J2)-Q(I1,J1)
716    CONTINUE
715    CONTINUE
8001  IF(NCOMP.EQ.1) GO TO 14
      DO 717 J=1,NK
      J2=NB(J)
      IF(J2.EQ.J1) GO TO 717
      DO 718 I=1,KTOT
      I1=NA(I)
      IF((J2.LE.NR).AND.((J1.LE.NR).OR.(I1.LE.NR))) GO TO 718
      IF((J2.GT.NR).AND.((J1.GT.NR).OR.(I1.GT.NR))) GO TO 718
      IF((MCOMP.EQ.1).AND.(J2.GT.NR)) GO TO 718
      IF((MCOMP.EQ.2).AND.(J2.LE.NR)) GO TO 718
      IF(NOPT.EQ.2) SUM=SUM+Q(I1,J2)-Q(J1,J2)
      IF((NOPT.EQ.4).AND.((Q(I1,J2)-Q(J1,J2)).LT.0.0))
     &SUM=SUM+Q(I1,J2)-Q(J1,J2)
718    CONTINUE
717    CONTINUE
      GO TO 14
14    S=XI(INDEX,KCOL)
      IF(NOPT.GT.2) SUM = ABS(SUM)
      IF(NRES.EQ.2) INDEXT=INDEX+1
      IF(NRES.EQ.1) INDEXT=INDEX+2**(J1-1)
      TEMP=S+SUM
      IF(J1.LE.NR) CP=XI(INDEXT,KCOL)
      IF(J1.GT.NR) CP=XI(INDEX,KCOL+1)
      IF((NOPT.LE.2).AND.(TEMP.LT.CP)) GO TO 9
      IF((NOPT.GT.2).AND.(TEMP.GT.CP)) GO TO 9
      IF(J1.LE.NR) XI(INDEXT,KCOL)=TEMP
      IF(J1.LE.NR) NXI(INDEXT,KCOL) = J1
      IF(J1.GT.NR) XI(INDEX,KCOL+1) = TEMP
      IF(J1.GT.NR) NXI(INDEX,KCOL+1) =J1
9     CONTINUE
4010  CONTINUE
      IF(NRES.EQ.2) GO TO 4031
      IF((NRES.EQ.1).AND.(K.EQ.0)) GO TO 4
      IF(MTC) GO TO 6
      GO TO 4
5     IF(NRES.EQ.1) NSUM=(2**NR)-1
      IF(NRES.EQ.2) NSUM=NR
      SMAX=XI(NSUM,NC)
      NT=NXI(NSUM,NC)
      WRITE(2,552)
      WRITE(2,*) ' CUMULATIVE OBJECTIVE FUNCTION     PERMUTATION IN REVE
     &RSE ORDER '
      WRITE(2,1010) SMAX,NT
      NA(N)=NT
1010  FORMAT(9X,F13.3,13X,I12)
      NN=N-1
      INDEX=NSUM
      INDEXC=NC
      DO 12 I=1,NN
      IF(NT.GT.NR) INDEXC=INDEXC-1
      IF((NT.LE.NR).AND.(NRES.EQ.1)) INDEX=INDEX-(2**(NT-1))
      IF((NT.LE.NR).AND.(NRES.EQ.2)) INDEX=INDEX-1
      NT=NXI(INDEX,INDEXC)
      S=XI(INDEX,INDEXC)
      NA(N-I) = NT
12    WRITE(2,1010) S,NT
      GO TO (2000,5006,2000,5006,5006) NOPT
5006  WRITE(2,552)
      WRITE(2,5007) SMAX
      IF(NOPT.EQ.5) GO TO 7777
      XNCON=0.0
      XNDIF=0.0
      DO 8022 K=1,N
      DO 8022 J=1,K-1
      DO 8022 I=1,J-1
      IF(((K.EQ.J).OR.(K.EQ.I)).OR.(J.EQ.I)) GO TO 8022
      IF(((NA(I).LE.NR).AND.((NA(K).LE.NR).OR.(NA(J).LE.NR))).OR.
     &((NA(I).GT.NR).AND.((NA(K).GT.NR).OR.(NA(J).GT.NR)))) GO TO 9051
      IF(((MCOMP.EQ.1).AND.(NA(I).GT.NR)).OR.((MCOMP.EQ.2).AND.  
     &(NA(I).LE.NR))) GO TO 9051
      IF((NCOMP.NE.2).AND.(Q(NA(I),NA(J)).LT.Q(NA(I),NA(K))))
     &XNCON=XNCON+Q(NA(I),NA(K))-Q(NA(I),NA(J))
      IF((NCOMP.NE.2).AND.(Q(NA(I),NA(J)).GT.Q(NA(I),NA(K))))
     &XNDIF=XNDIF+Q(NA(I),NA(J))-Q(NA(I),NA(K))
9051  IF(((NA(K).LE.NR).AND.((NA(I).LE.NR).OR.(NA(J).LE.NR))).OR.  
     &((NA(K).GT.NR).AND.((NA(I).GT.NR).OR.(NA(J).GT.NR)))) GO TO 8022
      IF(((MCOMP.EQ.1).AND.(NA(K).GT.NR)).OR.((MCOMP.EQ.2).AND.  
     &(NA(K).LE.NR))) GO TO 8022
      IF((NCOMP.NE.1).AND.(Q(NA(J),NA(K)).LT.Q(NA(I),NA(K))))
     &XNCON=XNCON+Q(NA(I),NA(K))-Q(NA(J),NA(K))
      IF((NCOMP.NE.1).AND.(Q(NA(J),NA(K)).GT.Q(NA(I),NA(K))))
     &XNDIF=XNDIF+Q(NA(J),NA(K))-Q(NA(I),NA(K))
8022  CONTINUE
      WRITE(2,552)
      SUM=XNCON+XNDIF
      DIF=XNCON-XNDIF
      WRITE(2,8003) XNCON,XNDIF,DIF,SUM,DIF/SUM
      GO TO 7777
5007  FORMAT(' INDEX OF GRADIENT COMPARISON IS', F9.3)
552   FORMAT(1H )
2000  CM=1.0
2005  SMAX=SMAX/CM
      WRITE(2,552)
      WRITE(2,5007) SMAX
      XNCON=0.0
      XNDIF=0.0
      DO 8002 K=1,N
      DO 8002 J=1,K-1
      DO 8002 I=1,J-1
      IF(((K.EQ.J).OR.(K.EQ.I)).OR.(J.EQ.I)) GO TO 8002
      IF(((NA(I).LE.NR).AND.((NA(K).LE.NR).OR.(NA(J).LE.NR))).OR.  
     &((NA(I).GT.NR).AND.((NA(K).GT.NR).OR.(NA(J).GT.NR)))) GO TO 9050
      IF(((MCOMP.EQ.1).AND.(NA(I).GT.NR)).OR.((MCOMP.EQ.2).AND.  
     &(NA(I).LE.NR))) GO TO 9050
      IF((NCOMP.NE.2).AND.(Q(NA(I),NA(J)).LT.Q(NA(I),NA(K))))
     &XNCON=XNCON+1.0
      IF((NCOMP.NE.2).AND.(Q(NA(I),NA(J)).GT.Q(NA(I),NA(K))))
     &XNDIF=XNDIF+1.0
9050  IF(((NA(K).LE.NR).AND.((NA(I).LE.NR).OR.(NA(J).LE.NR))).OR.  
     &((NA(K).GT.NR).AND.((NA(I).GT.NR).OR.(NA(J).GT.NR)))) GO TO 8002
      IF(((MCOMP.EQ.1).AND.(NA(K).GT.NR)).OR.((MCOMP.EQ.2).AND.
     &(NA(K).LE.NR))) GO TO 8002
      IF((NCOMP.NE.1).AND.(Q(NA(J),NA(K)).LT.Q(NA(I),NA(K))))
     &XNCON=XNCON+1.0
      IF((NCOMP.NE.1).AND.(Q(NA(J),NA(K)).GT.Q(NA(I),NA(K))))
     &XNDIF=XNDIF+1.0
8002  CONTINUE
      WRITE(2,552)
      SUM=XNCON+XNDIF
      DIF=XNCON-XNDIF
      WRITE(2,8003) XNCON,XNDIF,DIF,SUM,DIF/SUM
8003  FORMAT('CONSISTENCIES ',F10.3,' INCONSISTENCIES ',F10.3,
     &' DIFFERENCE',F10.3,' SUM',F10.3,' RATIO',F10.3)
      GO TO 7777
7777  WRITE(2,552)
      WRITE(2,*) ' REORDERED MATRIX '
      INR=1
      INC=1
      DO 9001 I=1,N
      IF(NA(I).LE.NR) NB(INR)=NA(I)
      IF(NA(I).LE.NR) INR=INR+1
      IF(NA(I).GT.NR) ND(INC)=NA(I)-NR
      IF(NA(I).GT.NR) INC=INC+1
9001  CONTINUE
      WRITE(2,552)
      WRITE(2,*) 'ROW PERMUTATION'
      WRITE(2,9010) (NB(I),I=1,NR)
9010  FORMAT(20I4)
      WRITE(2,552)
      WRITE(2,*) 'COLUMN PERMUTATION'
      WRITE(2,9010) (ND(I),I=1,NC)
      WRITE(2,552)
      DO 600 I=1,NR
      IP=NB(I)
      WRITE(2,552)
      WRITE(2,6000) (P(IP,ND(J)),J=1,NC)
600   CONTINUE
      STOP
      END
