      SUBROUTINE FLINE(DLAT,DLONG,DATE,HT,LQ,XCO,LXCO,IX,IHEM)
C FLINE CALCULATES FIELD LINES TO BE PLOTTED ON CONTOURS. ACTUAL
C PLOTTING IS DONE IN CONT.
      COMMON /FLIN/ FLINES(2,3,180),NLINES
      DIMENSION XCOS(3,30),XCO(50),XCO1(30)
      SAVE
      DATA INIT /0/,N/1/
C IF N IS NEGATIVE, WE HAVE PREVIOUSLY HAD A REQUEST FOR FIELD LINES
C TO BE CALCULATED AT ALL IONOGRAMS.
      IF(N.LT.0) GO TO 30
C IF N=0, WE HAVE PREVIOUSLY REQUESTED NO FIELD LINES.
      IF(N.EQ.0) RETURN
      IF(INIT.GT.0) GO TO 10
C NOW WE INITIALIZE THIS ROUTINE.
      NLINES=0
      INIT=1
      IX1=IX+1
      FACT=1.
C WE NOW READ IN THE FIELD LINE REQUEST, N<0 ALL IONOGRAMS,
C     N=0 NO IONOGRAMS, OTHERWISE N SPECIFIED IONOGRAMS.
      READ(4,1100) N
 1100 FORMAT(I2)
      IF(N.EQ.0) RETURN
      IF(N.LT.0) GO TO 30
      GO TO(100,110,120,100),IX1
 1000 FORMAT(13(3F2.0,2X))
  120 FACT=1/60.
C NOW WE READ IN THE X-COEFFICIENTS OF SELECTED IONOGRAMS, THEN
C WE HAVE TESTS BASED ON THE SPECIFIED (BY IX, SEE READ4) KIND OF
C X-COEFFICIENT WE ARE DEALING WITH.
  110 READ(4,1000) ((XCOS(J,I),J=1,3),I=1,N)
      DO 5 I=1,N
      XCO1(I)=XCOS(1,I)*3600+XCOS(2,I)*60+XCOS(3,I)
    5 XCO1(I)=XCO1(I)*FACT
      GO TO 10
  100 READ(4,2000) (XCO1(I),I=1,N)
 2000 FORMAT(13F6.2)
      WRITE(6,2010)
 2010 FORMAT(1X,'FIELD LINE LATITUDES:')
      WRITE(6,2015) (XCO1(I),I=1,N)
 2015 FORMAT(1X,13(F6.2,2X))
C NOW WE CHECK TO SEE IF THIS IONOGRAM IS A SPECIFIED ONE.
   10 DO 20 I=1,N
      IF(ABS(XCO1(I)-XCO(LXCO)).LT..015) GO TO 30
   20 CONTINUE
      RETURN
C IF THIS IS A SPECIFIED IONOGRAM, OR IF ALL WERE REQUESTED, CALCULATE
C THE FIELD LINES.
   30 NLINES=NLINES+1
      FLINES(1,1,NLINES)=DLAT
      FLINES(1,2,NLINES)=DLONG
      FLINES(1,3,NLINES)=HT
      HT6=HT/6
C NOW WE CALCULATE THE FIELD LINE IN SIX PIECES.
      DO 40 I=1,6
      N1=NLINES+I-1
      CALL TRACE(FLINES(1,1,N1),FLINES(1,2,N1),FLINES(1,3,N1),FLINES(2,1
     X ,N1),FLINES(2,2,N1),FLINES(2,3,N1),HT6,DATE,IHEM)
C NOW STORE THE CALCULATED VALUES, AND INCREMENT THE COUNTER.
      DO 40 J=1,3
   40 FLINES(1,J,N1+1)=FLINES(2,J,N1)
      NLINES=NLINES+5
      RETURN
      END
