      SUBROUTINE DISKRQ (A,NOA,LIM,SAMTIM,HELJD,NORUN,TITLE,
     *                   NOAOLD,NRNOLD,ITPHAS)     
C     
C     THIS SUBROUTINE INPUTS ARRAYS FROM DISK   
C     ***** INPUT DATA *****  
C     1 CARD IN FREE FORMAT WITH THE CONSECUTIVE VARIABLES: 
C       FNAME  = THE NAME OF THE DISK FILE CONTAINING THE DATA    
C       IA     = THE ARRAY ELEMENT OF A TO CONTAIN THE FIRST DATA PT    
C                (IF 0 THEN : IF NORUN=1 THEN IA=1 ELSE IA=LIM(2,NORUN-1)+1   
C       NOA    = NUMBER OF POINTS TO BE READ (IF 0 THEN THE NUMBER
C                ON THE FIRST RECORD OF THE DATA FILE WHICH SHOULD
C                BE THE NUMBER OF POINTS IN THE FILE IS USED).    
C       ICODE  = 0 IF USUAL DATA I.E. INPUT FORMAT IS (10I7)
C                1 IF NOT - A SECOND CARD MUST BE SUPPLIED WHICH  
C                HAS THE DATA TYPE (I - INTEGER , R - REAL) IN COL
C                1 , THE NUMBER OF POINTS PER RECORD IN COL 2-3 AND     
C                THE INPUT FORMAT FROM COLUMN 4.
C     2 CARD WITH I OR R IN COL 1 , THE NUMBER OF POINTS PER RECORD     
C       IN COLUMNS 2 AND 3 AND THE FORMAT FROM COL 4 ( INCLUDING  
C       PARENTHESES) WITH WHICH THE DATA IS READ IN. IF I IN COL1 
C       THEN DATA IS ASSUMED INTEGER. IF R IN COL1 THEN ASSUMED REAL.   
C     3 THE DATA FILE MUST HAVE ITS FIRST RECORD IN THE FORMAT    
C       OF THE OUTPUT FROM THE SINGLECHAN REDUCTION PROGRAM SO THAT     
C       THE HELIOCENTRIC JULIAN DATE OF THE START OF THE RUN AND  
C       THE SAMPLING INTERVAL (HJD1,DELTUA) ARE READ CORRECTLY    
C     
      DIMENSION A(1), IDATA(80), XDATA(80)
      DIMENSION SAMTIM(1),LIM(2,1)  
      EXTERNAL TRMLEN
      INTEGER TRMLEN
      CHARACTER*1 IFORMA*78,I1,I2,ITYPE,FNAME*25,TITLE*80       
      CHARACTER HEAD*36,FNAME1*25,FNAMEN*25 
      DOUBLE PRECISION HELJD(1),HJD1     
      FNAME1=' '  
      LOG=11
      I1='I'
      I2='R'
      PRINT 1     
    1 FORMAT(/12X,'RUN  NO OF  START    END   SMPL        H.J.D.  NO IN'
     *      ,'  TITLE'/ 
     *      12X,'       PTS     PT     PT   TIME                 FILE') 
      PRINT 3     
    2 READ *,FNAME,IA,NOA,ICODE     
      IF(FNAME1.EQ.' ')FNAME1=FNAME 
      IF(FNAME.NE.' ')FNAMEN=FNAME  
      IF(FNAME.EQ.' '.AND.IA.EQ.0.AND.NOA.EQ.0.AND.ICODE.EQ.0)THEN
        NOA=LIM(2,NORUN)
        PRINT 3   
    3   FORMAT(12X,93('-'))   
        PRINT *,' '     
        CLOSE(11) 
        IF(NORUN.GT.1)THEN    
C     
C         MAKE UP A TITLE CONSISTING OF THE FIRST FILE NAME 
C         READ IN '-' LAST FILE NAME READ IN E.G. S3773-S3787     
C     
          TITLE=' '
          IPT=1   
          ICH=0   
          DO 4 J=1,TRMLEN(FNAME1)+1 
            ICH=ICH+1   
            IF(J.LE.TRMLEN(FNAME1))THEN   
              TITLE(ICH:ICH)=FNAME1(J:J)  
            ELSE  
              TITLE(ICH:ICH)='-'    
            END IF
    4     CONTINUE
          DO 5 J=1,TRMLEN(FNAMEN)   
            ICH=ICH+1   
            TITLE(ICH:ICH)=FNAMEN(J:J)    
    5     CONTINUE
        END IF    
        RETURN    
      END IF
      CLOSE(11)   
      OPEN(11,FILE=FNAME,STATUS='OLD')     
C     
C     CHECK WHETHER A NON-STANDARD READ FORMAT IS NECESSARY 
C     
C     
      IF(ICODE.EQ.0)THEN
        ITYPE='I' 
        NCARD=10  
        IFORMA='(10I7)'    
      END IF
      IF(ICODE.NE.0)READ 13,ITYPE,NCARD,IFORMA
   13 FORMAT(A1,I2,A78) 
C     
C     READ THE DATA FILE HEADER RECORD    
C     
      IF(IFORMA(1:6).NE.'(2X,10')     
     *READ(LOG,15)HEAD,IHJD,HJD,DELTUA,NINFIL,IFACT   
   15 FORMAT(A36,I10,F8.7,6X,F8.1,2X,2I5) 
      IF(IFORMA(1:6).EQ.'(2X,10')THEN 
        READ(LOG,16)HEAD,IDELT
   16   FORMAT(A36,5X,I6)     
        DELTUA=FLOAT(IDELT)/1000.0  
        IHJD=0    
        HJD=0.0   
        IFACT=1   
        NINFIL=0  
      END IF
C     
C     CHECK IA , THE NO OF PTS TO BE READ AND NORUN   
C     
      NORUN=NORUN+1     
      IF(IA.EQ.1)THEN
        NORUN=1
        NRNOLD=0
        NOAOLD=0
        ITPHAS=0
      END IF
      IF(NORUN.EQ.1)IA=1
      IF(IA.EQ.0.AND.NORUN.GT.1)IA=LIM(2,NORUN-1)+1   
      IF(NOA.EQ.0.AND.NINFIL.GT.0)NOA=NINFIL    
      IF(NOA.EQ.0.AND.NINFIL.EQ.0)THEN    
        PRINT *,'NUMBER OF PINTS TO BE READ FROM THIS FILE IS 0'  
        PRINT *,'BOTH ON YOUR DATA CARD AND IN THE FILE - HELP'   
        STOP
      END IF
      HJD1=IHJD   
      HJD1=HJD1+HJD     
C     
C     PRINT THE INFORMATION GLEANED SO FAR
C     
      PRINT 25,NORUN,NOA,IA,IA+NOA-1,DELTUA,HJD1,NINFIL,    
     *         HEAD
   25 FORMAT(12X,I3,3I7,F7.1,F14.7,I7,2X,A36)   
      K=0   
   30 J=K+1 
      K=K+NCARD   
      IF(K.GT.NOA)K=NOA 
      IF(ITYPE.EQ.I1)THEN     
        READ(LOG,IFORMA)(IDATA(I),I=1,NCARD)    
      ELSE  
        READ(LOG,IFORMA)(XDATA(I),I=1,NCARD)    
      END IF
      L=0   
      DO 60 I=J,K 
        L=L+1     
        IF(ITYPE.EQ.I1)THEN   
          A(IA-1+I)=IDATA(L)  
        ELSE
          A(IA-1+I)=XDATA(L)  
        END IF    
   60 CONTINUE    
      IF(K.LT.NOA)GO TO 30    
C     
C     FINISH OFF THE READING  
C     
      IF(LOG.NE.7.AND.LOG.NE.8)REWIND LOG 
      NOA=NOA+NOAOLD    
      NOAOLD=NOA  
      IF(IA.EQ.1)TITLE=HEAD
      SAMTIM(NORUN)=DELTUA    
      LIM(1,NORUN)=IA   
      LIM(2,NORUN)=NOA  
      HELJD(NORUN)=HJD1 
      GO TO 2     
      END   
