      SUBROUTINE ROLDMOD
C Read pre-existing model file

      INCLUDE 'BINFIT.INC'
      INCLUDE 'MODEL.INC'

      IC = 0
      DO WHILE ( IC .LE. MXMOD )
          CALL CREADMDL(INMOD,ICTMP,MODLAMBDA,P3,P4,P5,P6,P7,P8,P9,
     1                  DMAGMAX,*55,0)
          NCOMP = MAX(IC,ICTMP)
D         WRITE(OUTC,'(A,I3)') ' ROLDMOD: NCOMP = ',NCOMP
          IC = ICTMP
          IF ( IC .LE. MXMOD ) THEN
              FOUND = .FALSE.
              DO IG = 1, NFILT
                  IF ( ABS(MODLAMBDA-LAMBDA0(IG)) .LT. 0.1 )
     1            THEN
                      FOUND = .TRUE.
                      WRITE(OUTC,'(1X,F5.1,A,I2)') LAMBDA0(IG),
     1                  ' nm wavelength is filter number ',IG
                      IF ( (IC.EQ.1) .AND. (IG.EQ.1) ) THEN
                          PARM(1,1,1) = P3        ! Separation
                          PARM(1,1,2) = P4        ! Position angle
                          PARM(1,1,3) = P5        ! Diam
                          PARM(1,1,7) = P6        ! Comp. flux(1)
                          PARM(1,1,8) = P7        ! Total flux(1)
D                         WRITE(OUTC,'(A,F10.4,A,F10.4)')
D    1                       ' FLUX = ',FLUX(1,1),';  FLUXTOT = ',
D    2                        FLUXTOT(1,1)
                      ELSE IF ( (IC.EQ.1) .AND. (IG.NE.1) ) THEN
                          PARM(1,IG,4) = P3       ! Diam(IG)/Diam(1)
                          PARM(1,IG,7) = P4       ! Comp. flux(IG)
                          PARM(1,IG,8) = P5       ! Total flux(IG)
                      ELSE IF ( (IC.NE.1) .AND. (IG.EQ.1) ) THEN
                          PARM(IC,1,1) = P3       ! Separation(IC)
                          PARM(IC,1,2) = P4       ! Position angle
                          PARM(IC,1,3) = P5       ! Diam
                          PARM(IC,1,5) = P6       ! Mag. difference
                          PARM(IC,1,7) = P7       ! Comp. flux(1)
                      ELSE IF ( (IC.NE.1) .AND. (IG.NE.1) ) THEN
                          PARM(IC,IG,4) = P3      ! Diam(IG)/Diam(1)
                          PARM(IC,IG,5) = P4      ! Mag. difference
                          PARM(IC,IG,6) = P5      ! Color
                          PARM(IC,IG,7) = P6      ! Comp. flux(IG)
                      END IF
                  END IF
                  IF(.NOT.FOUND .AND. IG.GE.NFILT .AND. MODLAMBDA.NE.0.)
     1                THEN
                      WRITE(OUTC,'(1X,F5.1,A)') MODLAMBDA,
     1                ' nm does not match wavelengths in data files'
                  END IF
              END DO
          ELSE
              WRITE(OUTC,'(1X,I4,A,I4,A)') ICTMP,
     1            ' components are too many; limit is',MXMOD,'.'
          END IF
      END DO
   55 CONTINUE                ! Come here on exit from CREADMDL
      NPARM = NCOMP*NFILT*8
D     WRITE(OUTC,'(A,I3)') ' In ROLDMOD: NPARM = ',NPARM
C Test whether PARM, PARM1D arrays are really equivalent
D     DO I=1,NCOMP
D         DO J=1,NFILT
D             DO K=1,8
D                 WRITE(OUTC,'(A,3(I1,A),G11.4)') 
D    1               ' PARM(',I,',',J,',',K,') = ',PARM(I,J,K)
D             END DO
D         END DO
D     END DO
D     DO I=1,MXPARM
D         WRITE(OUTC,'(A,I3,A,G11.4)') ' PARM1D(',I,') = ',PARM1D(I)
D     END DO

      RETURN
      END

