       PROGRAM MRC
C======================================================================
C
C      MAIN PROGRAM TO READ THE MOLONGLO REFERENCE CATALOGUE
C
C      L. E. CRAM, University of Sydney: 1990 JUNE 20
C
C      VERSN number 1.00
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER*1 MFLAG
C
C -- SOME CONSTANTS
C
       VERSN  = 1.00
       PI     = 3.141592654
       TWOPI  = 2.0*PI
       RTOMIN = 180.0*60.0/PI
       RTORAD = PI/12.0
       DTORAD = PI/180.0
C
C -- OPEN THE DATA FILE
C
       OPEN (UNIT=7,FILE='mrcj2000',STATUS='OLD',ERR=800)
       REWIND (7)
C
C -- OPERATE MENU AND DECIDE ON ACTION
C
       MFLAG = 'M'
100    CONTINUE
       IF (MFLAG.EQ.'M') THEN
         CALL MENU (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'I') THEN
         CALL INDEX (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'D') THEN
         CALL DESIG (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'P') THEN
         CALL POSN (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'R') THEN
         CALL REGION (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'C') THEN
         CALL CITE (MFLAG)
         GOTO 100
       ELSE IF (MFLAG.EQ.'M') THEN
         GOTO 100
       ELSE IF (MFLAG.EQ.'Q') THEN
         STOP
       ELSE
         MFLAG='M'
         GOTO 100
       END IF
800    STOP ' ERROR OPENING UNIT 7 (mrcj2000)'
       END
       SUBROUTINE MENU (MFLAG)
C======================================================================
C      PRESENTS MENU ON SCREEN AND INVITES SELECTION
C
C      INPUT:     NONE
C
C      OUTPUT:    MFLAG    CHARACTER*1       ALPHANUMERIC FLAG
C
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER*1 MFLAG
C
       WRITE (*,
     & '('' ======================================================='')')
       WRITE (*,
     & '('' =            MOLONGLO REFERENCE CATALOG               ='')')
       WRITE (*,
     & '('' =                       MENU                          ='')')
       WRITE (*,
     & '('' =                                                     ='')')
       WRITE (*,
     & '('' = (I)ndex       : Locate by index number              ='')')
       WRITE (*,
     & '('' = (D)esignation : Locate by IAU designation           ='')')
       WRITE (*,
     & '('' = (P)osition    : NEAREST source to position          ='')')
       WRITE (*,
     & '('' = (R)egion      : Sources in given region             ='')')
       WRITE (*,
     & '('' = (M)enu        : Display this menu                   ='')')
       WRITE (*,
     & '('' = (C)itation    : List papers cited here              ='')')
       WRITE (*,
     & '('' = (Q)uit                                              ='')')
       WRITE (*,
     & '('' = [Type indicated letter then "Enter" to select item] ='')')
       WRITE (*,
     & '('' =                                                     ='')')
       WRITE (*,
     & '('' = "The Molonglo Reference Catalogue of Radio Sources" ='')')
       WRITE (*,
     & '('' =  Large,M.I., Mills,B.Y., Little,A.G., Crawford,D.F. ='')')
       WRITE (*,
     & '('' =                                & Sutton,J.M.        ='')')
       WRITE (*,
     & '('' =  Mon. Not. R. astr. Soc. (1981) vol. 194, p693-704  ='')')
       WRITE (*,
     & '('' =      & Microfiches MN 194/1                         ='')')
       WRITE (*,
     & '('' =                                                     ='')')
       WRITE (*,
     & '('' = Note: It takes about 90 sec to read the entire MRC  ='')')
       WRITE (*,
     & '('' =       from a hard disk drive on an AT compatible.   ='')')
       WRITE (*,
     & '('' = VERSION '',F4.2, '' =================================='',
     &   ''======'')') VERSN
       CALL GETFLG (MFLAG)
       RETURN
       END
       SUBROUTINE GETFLG (MFLAG)
C=======================================================================
C      PROMPT USER AND GET FLAG
C
C      INPUT:     NONE
C
C      OUTPUT:    MFLAG    CHARACTER*1       ALPHANUMERIC FLAG
C
C=======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER*1 MFLAG
C      
       WRITE (*,900)
900    FORMAT (' PLEASE MAKE A MENU SELECTION:',/
     & ' (M)enu,(I)ndex,(D)esignation,(P)osition,(R)egion,',
     & '(C)itation,(Q)uit')
       READ  (*,'(1A)') MFLAG
C -- CONVERT TO UPPER CASE
       IF (ICHAR(MFLAG).GE.97) MFLAG=CHAR(ICHAR(MFLAG)-32)
       RETURN
       END 
       SUBROUTINE INDEX (MFLAG)
C======================================================================
C      LOCATE A SOURCE BY INDEX NUMBER
C
C      Output:     MFLAG      CHARACTER*1     RETURN MENU ITEM
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       INTEGER   KOUNT, NUMBER
       CHARACTER LINE*87, MFLAG*1
C
100    WRITE (*,900)
900    FORMAT (' Please enter the source number you want (1-12141)')
       READ  (*,*) NUMBER
       IF (NUMBER.LT.1 .OR. NUMBER.GT.12141) GOTO 100
C
       REWIND (7)
       WRITE (*,'('' Please wait.....'')')
       DO 10 KOUNT=1,NUMBER
         READ (7,'(A87)',ERR=999,END=200) LINE
10     CONTINUE
C
       CALL OUTSRC (NUMBER,LINE)
       CALL GETFLG (MFLAG)
       RETURN
C
200    CONTINUE
       WRITE (*,'('' End-of-file on Disk, Source not found'')')
       CALL GETFLG (MFLAG)
       RETURN
C
999    STOP ' Error reading MRC disk file in INDEX mode'
       END
       SUBROUTINE DESIG (MFLAG)
C======================================================================
C      LOCATE A SOURCE BY IAU DESIGNATION
C
C      Output:    MFLAG     CHARACTER*1     RETURN MENU SELECTION
C
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER LINE*87, IAU*8, MFLAG*1
       INTEGER KOUNT
C
100    WRITE (*,900)
900    FORMAT (' Please enter the IAU designation in the form ',
     &         'RRRRsDDD (e.g. 0028-505)')
       READ  (*,'(A8)',ERR=100) IAU
       IF (IAU(5:5).NE.'-'.AND.IAU(5:5).NE.'+') GOTO 100
C
       REWIND (7)
       WRITE (*,'('' Please wait.....'')')
       DO 10 KOUNT=1,12141
         READ (7,'(A87)',ERR=999,END=300) LINE
         IF (LINE(1:8).EQ.IAU) GOTO 200
10     CONTINUE
300    CONTINUE
C
       WRITE (*,910) IAU
910    FORMAT (' The source ',a8,' does not appear in the MRC')
       CALL GETFLG (MFLAG)
       RETURN
C
200    CONTINUE
       CALL OUTSRC (KOUNT, LINE)
       CALL GETFLG (MFLAG)
       RETURN
C
999    STOP 'Error reading MRC disk file in DESIGNATION mode'
       END
       SUBROUTINE POSN (MFLAG)
C======================================================================
C      LOCATES MRC SOURCE NEAREST TO SPECIFIED POSITION
C
C      Output:    MFLAG     CHARACTER*1     FLAG FOR NEXT MENU CHOICE
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER MFLAG*1, YN*1, LINE*87, LINEA*87, EPOCH*5
       CHARACTER SD
       INTEGER   RHH, RMM, DDD, DMM, DSS
       CHARACTER SD1*1
       INTEGER   RHH1, RMM1, RSS1, DDD1, DMM1, DSS1
       REAL      RSS
       INTEGER   NEARST, KOUNT
       REAL      COSDEC, DCR
       REAL      RA, DEC, R, D, DR, DIFF, DIFOLD
C
       WRITE (*,'(78(''=''))')
       WRITE (*,900)
900    FORMAT (' This option locates the MRC source NEAREST to your',/
     &         ' chosen RA, Dec in the selected coordinate system.'/)
       WRITE (*,940)
940    FORMAT (' + Note: The MRC avoids the Galactic plane! +',/)
       WRITE (*,910)
910    FORMAT (' Do you wish to use B1950 equinox? (Y/N)')
       READ (*,'(A)') YN
       EPOCH='J2000'
       IF (YN.EQ.'Y' .OR. YN.EQ.'y') THEN
         EPOCH='B1950'
       ELSE
         WRITE (*,'('' Equinox '',a5)') EPOCH
       END IF
C
       WRITE (*,905) EPOCH 
905    FORMAT(' Enter RA (',A5,') of your chosen point')
       CALL READRA (RHH1,RMM1,RSS1,RA)
       WRITE (*,906) EPOCH 
906    FORMAT(' Enter Dec (',A5,') of your chosen point')
       CALL READDE (SD1,DDD1,DMM1,DSS1,DEC)
       COSDEC=COS(DEC)
C
       DIFOLD=10000.0
       NEARST=1
       REWIND (7)
       WRITE (*,'('' Please wait.....'')')
       DO 10 KOUNT=1,12141
         READ (7,'(A87)',ERR=999,END=200) LINE
         IF (EPOCH(1:1).EQ.'B') THEN
           READ (LINE(10:21),'(2I3,F5.1)')       RHH,RMM,RSS
           READ (LINE(22:30),'(1A,I2,2I3)')   SD,DDD,DMM,DSS
         ELSE
           READ (LINE(31:41),'(2I3,F5.1)')       RHH,RMM,RSS
           READ (LINE(43:51),'(1A,I2,2I3)')   SD,DDD,DMM,DSS
         END IF
C
         R=RTORAD*(RHH+(RMM+RSS/60.0)/60.0)
         DR=R-RA
         IF (DR.GT. PI) DR=DR-TWOPI
         IF (DR.LT.-PI) DR=DR+TWOPI
         DCR=DR*COSDEC
C
         D=DTORAD*((ABS(DDD)+(DMM+DSS/60.0)/60.0))
         IF (SD.EQ.'-') D=-D
C
C -- CALCULATE SEPARATION AND TEST DISTANCE
C
         CALL SEPARN (RA, DEC, R, D, DIFF)
         IF (DIFF.LT.DIFOLD) THEN
           NEARST=KOUNT
           LINEA =LINE
           DIFOLD=DIFF
         END IF
         
10     CONTINUE
200    CONTINUE
C
       WRITE (*,'(78(''=''))')
       WRITE (*,920) RHH1,RMM1,RSS1,SD1,DDD1,DMM1,DSS1,EPOCH
920    FORMAT (' The MRC source NEAREST to RA='
     &    ,3I3.2,' Dec=',1A,I2.2,2I3.2,' (',A5,') is listed below.')
       WRITE (*,930) DIFOLD*RTOMIN
930    FORMAT (' The source lies ',f7.2,
     &  ' arcmin from the given point.')
       CALL OUTSRC  (NEARST, LINEA)
       CALL GETFLG (MFLAG)
       RETURN
999    STOP ' Error reading MRC disk file in POSITION mode'
       END
       SUBROUTINE REGION (MFLAG)
C======================================================================
C      LOCATES MRC SOURCE IN SPECIFIED REGION
C
C      Output:    MFLAG     CHARACTER*1     FLAG FOR NEXT MENU CHOICE
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER MFLAG*1, EPOCH*5, LINE*87, INSIDE(32)*87
       CHARACTER YN*1, ER*1, SD1*1, SD2*1, SD*1
       INTEGER   DD1,DM1,DS1,DD2,DM2,DS2
       INTEGER   RH1,RM1,RS1,RH2,RM2,RS2
       INTEGER   RHH,RMM,DDD,DMM,DSS
       REAL      RSS
       INTEGER   POINT(32), I, KOUNT
       REAL      RA,R,R1,R2,DEC,D,D1,D2,DIST,RADIUS,SEP(32)
C
       WRITE (*,'(78(''=''))')
       WRITE (*,900)
900    FORMAT (
     & ' This option lists all sources (limit 32) in a given area.',/
     & ' The area is defined by either RA/Dec bounds or by radius.'/)
       WRITE (*,901)
901    FORMAT (' You may specify either:',/
     & '     (i) The RA & Dec of the (E)dges of a "box" (E)',/
     & ' or (ii) The central RA & Dec and the (R)adius  (R)'/)
       WRITE (*,902)
902    FORMAT (' + Note: The MRC source density is about 1/sq.deg. +'/
     &         ' + Note: The MRC avoids the Galactic plane! +'/)
100    WRITE (*,903)
903    FORMAT (' Search with (E)dges or (R)adius?')
       READ (*,'(A)') ER
C -- UPPER CASE
       IF (ICHAR(ER).GE.97) ER=CHAR(ICHAR(ER)-32)
       IF (ER.NE.'E' .AND. ER.NE.'R') GOTO 100
C
       WRITE (*,910)
910    FORMAT (' Do you wish to use B1950 equinox? (Y/N)')
       READ (*,'(A)') YN
       EPOCH='J2000'
       IF (YN.EQ.'Y' .OR. YN.EQ.'y') THEN
         EPOCH='B1950'
       ELSE
         WRITE (*,'('' Equinox '',a5)') EPOCH
       END IF
C
C -- TWO KINDS OF CHOICE
C
       IF (ER.EQ.'E') THEN
C
C -- SEARCH BY EDGES
C
110      CONTINUE
         WRITE (*,920)
920      FORMAT(' Enter earlier RA limit first')
         CALL READRA (RH1, RM1, RS1, R1)
         WRITE (*,921)
921      FORMAT(' Enter later RA limit second')
         CALL READRA (RH2, RM2, RS2, R2)
C
120      WRITE (*,930)
930      FORMAT(' Enter more northerly Dec limit first')
         CALL READDE (SD1, DD1, DM1, DS1, D1)
         WRITE (*,931)
931      FORMAT(' Enter more southerly Dec limit second') 
         CALL READDE (SD2, DD2, DM2, DS2, D2)
         IF (D1.LT.D2) THEN
           WRITE (*,'('' Please enter northern Dec first'')')
           GOTO 120
         END IF
         DIST = 0.0
C
       ELSE
C
C -- SEARCH BY RADIUS
C
130      WRITE (*,940) EPOCH
940      FORMAT(' Enter RA (',A5,') of the centre of the',
     &          ' search region')
         CALL READRA (RH1, RM1, RS1, RA)
         WRITE (*,941) EPOCH
941      FORMAT(' Enter Dec (',A5,') of the centre of the',
     &          ' search region')
         CALL READDE (SD1, DD1, DM1, DS1, DEC)
140      WRITE (*,950)
950      FORMAT (' Enter the radius of the search region in',
     &           ' decimal arcmin (e.g. 120.0)')
         READ (*,*) RADIUS
         IF (RADIUS .LE. 0.0) GOTO 140
         IF (RADIUS .GT. 600.0) THEN
           WRITE (*,'('' Try a smaller radius! '')')
           GOTO 140
         END IF
C
C -- CONVERT TO RADIANS
C
         RADIUS = RADIUS / RTOMIN
         D1=DEC+RADIUS
         D2=DEC-RADIUS
       END IF
C
C -- READ FILE
C
       KOUNT=0
       REWIND (7)
       WRITE (*,'('' Please wait.....'')')
       DO 10 I=1,12141
         READ (7,'(A87)',ERR=999,END=200) LINE
C15     CONTINUE
         IF (EPOCH(1:1).EQ.'B') THEN
           READ (LINE(10:20),'(2I3,F5.1)') RHH,RMM,RSS
           READ (LINE(22:30),'(1A,I2,2I3)') SD,DDD,DMM,DSS
         ELSE
           READ (LINE(31:41),'(2I3,F5.1)') RHH,RMM,RSS
           READ (LINE(43:51),'(1A,I2,2I3)') SD,DDD,DMM,DSS
         END IF
C
         R=RTORAD*(RHH+(RMM+RSS/60.0)/60.0)
         D=DTORAD*(ABS(DDD)+(DMM+DSS/60.0)/60.0)
         IF (SD.EQ.'-') D=-D
C
C -- TWO DIFFERENT STRATEGIES HERE FOR "BOX" OR "CIRCLE"
C
         IF (ER .EQ. 'E') THEN
           IF (D.GT.D1 .OR. D.LT.D2) GOTO 10
C
C -- SPECIFIED REGION BY EDGES:
C -- TRICKY PART HERE TO TAKE ACCOUNT OF 0h RA.
C -- IF (R2>R1) THEN ARC DOES NOT CROSS 0h,
C -- IF (R2<R1) THEN ARC DOES CROSS 0h
C
           IF (R2.GT.R1) THEN
             IF (R.LT.R1) GOTO 10
             IF (R.GT.R2) GOTO 200
           ELSE
             IF (R.LT.R1 .AND. R.GT.R2) GOTO 10
           END IF
         ELSE
C
C -- SPECIFIED REGION BY RADIUS
C
           CALL SEPARN (R, D, RA, DEC, DIST)
           IF (DIST.GT.RADIUS) GOTO 10
         END IF
C 
C -- PROCESS A POINT INSIDE THE SEARCH AREA
C
         KOUNT         = KOUNT+1
         INSIDE(KOUNT) = LINE
         POINT (KOUNT) = I
         SEP  (KOUNT)  = DIST*RTOMIN
C
         IF (KOUNT.GT.31) THEN
           WRITE (*,'('' ** Buffer full: search stopped! **'')')
           GOTO 200
         END IF
10     CONTINUE
200    CONTINUE
C        
C -- OUTPUT DATA ON SOURCES FOUND
C
       WRITE (*,'(78(''=''))')
       IF (ER.EQ.'E') THEN
         WRITE (*,970) KOUNT,RH1,RM1,RS1,RH2,RM2,RS2,
     &                 SD1,DD1,DM1,DS1,SD2,DD2,DM2,DS2,EPOCH
970      FORMAT(' Found ',I2,' sources in "box" bounded by',/
     &          ' RA=',3I3.2,';',3I3.2,
     &     ' Dec=',1A,I2.2,2I3.2,';',1A,I2.2,2I3.2,' (',A5,')',/)
       ELSE
         WRITE (*,980) KOUNT,RADIUS*RTOMIN,
     &                 RH1,RM1,RS1,SD1,DD1,DM1,DS1,EPOCH
980      FORMAT (' Found ',I2,' sources in "circle" of radius ',
     &           F6.2,' arcmin centred on',/
     &           ' RA=',3I3.2,' Dec=',1A,I2.2,2I3.2,' (',A5,')')
       END IF
C
C -- PRINT SOURCES ONE AT A TIME
C
       DO 20 I=1,KOUNT
C
         WRITE (*,'(78(''=''))')
         IF (ER .EQ. 'E') THEN
           WRITE (*,'('' Source number '',I2)') I
         ELSE
           WRITE (*,990) I,SEP(I),RH1,RM1,RS1,SD1,DD1,DM1,DS1,EPOCH
990        FORMAT (' Source number ',I2,' is ',F6.2,
     &   ' arcmin from RA=',3I3.2,' Dec=',1A,I2.2,2I3.2,' (',A5,')')
         END IF
C
         CALL OUTSRC (POINT(I),INSIDE(I))
         IF (I.LT.KOUNT) THEN
           WRITE (*,'('' Enter CR to examine next source'')')
           READ (*,*)
         END IF
20     CONTINUE
C
       CALL GETFLG (MFLAG)
       RETURN
999    STOP ' Error reading MRC disk file in REGION mode'
       END
       SUBROUTINE OUTSRC (INDEX,LINE)
C======================================================================
C      PRINTS ONE LINE OF MRC WITH FULL HEADER DESCRIPTION
C
C      INPUT:     INDEX    INTEGER            ENTRY NUMBER IN MRC
C                 LINE     CHARACTER*87       LINE IN ASCII
C
C      OUTPUT:    NONE
C
C======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       INTEGER      INDEX, K
       CHARACTER    LINE*87, FLAG*3
C
       WRITE (*,'(78(''=''))')
C
C -- NUMBER AND DESIGNATION
C
       WRITE (*,900) INDEX, LINE(1:10)
900    FORMAT (' SOURCE NUMBER ',I5,' IN MRC: DESIGNATION MRC ',A10)
C
C -- COORDINATES
C
       WRITE (*,920) LINE(11:20),LINE(52:55),LINE(22:30),LINE(56:58)
920    FORMAT (' RA(B1950):',A10,' +/- ',A4,'(sec) ;',
     &         ' Dec(B1950):',A9,' +/-',A3,'(arcsec)')
       WRITE (*,930) LINE(32:41),LINE(52:55),LINE(43:51),LINE(56:58)
930    FORMAT (' RA(J2000):',A10,' +/- ',A4,'(sec) ;',
     &         ' Dec(J2000):',A9,' +/-',A3,'(arcsec)')
       WRITE (*,940) LINE(77:81),LINE(83:87)
940    FORMAT (' Galactic coordinates: l=',a5,' b=',a5)
C
C -- FLUX DENSITY
C
       WRITE (*,950) LINE(59:65),LINE(66:70)
950    FORMAT (' FLUX DENSITY AT 408 MHz:',A7,' +/- ',A5,' Jy')
C
C -- MORPHOLOGY FLAGS
C
       IF (LINE(71:73).EQ.'   ') THEN
         WRITE (*,960)
960    FORMAT (' Source unresolved: < 1 arcmin (EW) & < 2 sec (z)',
     &         ' arcmin (NS)')
       ELSE
        DO 10 K=71,73
         FLAG=LINE(K:K)
         IF (FLAG.EQ.'A') THEN
           WRITE (*,'('' A-flag: Small scale structure present'')')
         END IF
         IF (FLAG.EQ.'E') THEN
           WRITE (*,'('' E-flag: Extended source (> 10 arcmin)'')')
         END IF
         IF (FLAG.EQ.'C') THEN
           WRITE (*,'('' C-flag: Complex extended source'')')
         END IF
         IF (FLAG.EQ.'M') THEN
           WRITE (*,'('' M-flag: Multiple sources (within 8 arcmin)'')')
         END IF
         IF (FLAG.EQ.'N') THEN
           WRITE (*,'('' N-flag: Weak neighbouring sources'')')
         END IF
10      CONTINUE
       END IF
C
C -- CROSS-REFERENCE FLAG
C
       IF (LINE(74:76).EQ.'   ') THEN
         WRITE (*,'('' No cross-references to this source'')')
       ELSE
         IF (LINE(74:74).EQ.'J') THEN
           WRITE (*,'('' Source imaged at 843 MHz by Jones (1989)'')')
         END IF
         DO 20 K=75,76
           FLAG=LINE(K:K)
           IF (FLAG.EQ.'P') THEN
             WRITE (*,
     &         '('' Source lies within 2 arcmin of a Parkes source'')')
           END IF
           IF (FLAG.EQ.'S') THEN
             WRITE (*,'('' Source in Schilizzi & McAdam (1975)'')')
           END IF
           IF (FLAG.EQ.'M') THEN
             WRITE (*,'('' Source in Clarke et al. (1976)'')')
           END IF
           IF (FLAG.EQ.'C') THEN
             WRITE (*,'('' Source in Cameron (1971)'')')
           END IF
           IF (FLAG.EQ.'R') THEN
             WRITE (*,'('' Source in Robertson (1973)'')')
           END IF
20       CONTINUE
       END IF
C  
       WRITE (*,'(78(''=''))')
       RETURN
       END
       SUBROUTINE CITE (MFLAG)
C=======================================================================
C      Lists citations from the MRC reference list
C
C      Output   MFLAG      CHARACTER*1      NEXT SELECTION FLAG
C
C=======================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER MFLAG*1
C
       WRITE (*,800)
800    FORMAT ('======================================================')
       WRITE (*,810)
810    FORMAT (' Papers cited by MRC flags')
       WRITE (*,800)
       WRITE (*,820)
820    FORMAT (' 1. Bolton, J.G., Wright, A.E. & Savage, A. (1979)',/
     & '    Aust. J. Phys. Ap. Suppl. Vol 46, 1. (Parkes catalogue)',/
     &         ' 2. Cameron, M.J. (1971)',/
     & '    Mon. Not. R. astr. Soc. Vol 152, 439.',/
     &         ' 3. Clarke, J.N., Little, A.G. & Mills, B.Y. (1976)',/
     & '    Aust. J. Phys. Ap. Suppl. Vol 40, 1.',/
     &         ' 4. Jones, P.A. (1989) PhD Thesis, Uni. of Sydney',/
     & '    (also Jones , P.A. & McAdam, W.B. (1990) in preparation)')
       WRITE (*,830)
830    FORMAT (' 5. Large, M.I., Mills, B.Y., Little, A.G.,',
     &         ' Crawford, D.F. & Sutton, J.M.',/
     & '    (1981) Mon. Not. R. astr. Soc. Vol 194, 693.',/ 
     & '    Microfiches MN 194/1. (The Molonglo Reference Catalogue)',/
     &         ' 6. Robertson, J.G. (1973)',/
     & '    Aust. J. Phys. Vol 26, 403.',/
     &         ' 7. Schilizzi, R.T. & McAdam, W.B. (1975)',/
     & '    Mem. R. astr. Soc. Vol 79, 1.')
       WRITE (*,800)
C
       CALL GETFLG (MFLAG)
       RETURN
       END       
       SUBROUTINE READRA (RH, RM, RS, RA)
C==========================================================================
C      TEST FOR ERRORS IN ENTERING RA
C
C      INPUTS:      RH    INTEGER   RA (HOURS)
C                   RM    INTEGER   RA (MINS OF TIME)
C                   RS    INTEGER   RA (SECS OF TIME)
C 
C      OUTPUTS:     RA    REAL      RA (RADIANS)
C==========================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       INTEGER RH, RM, RS, IERR
       REAL    RA
C
       IERR=0
100    WRITE (*,'('' (The format for RA must be hh mm ss)'')')
       READ  (*,'(I2,2I3)') RH, RM, RS
       IF (RS.LT.0 .OR. RS.GE.60) GOTO 100
       IF (RM.LT.0 .OR. RM.GE.60) GOTO 100
       IF (RH.LT.0 .OR. RH.GE.24) GOTO 100
       RA=RH+(RM+RS/60.0)/60.0
       RA=RA*RTORAD
       RETURN
       END
       SUBROUTINE READDE (SD, DD, DM, DS, DEC)
C==========================================================================
C      TEST FOR ERRORS IN ENTERING DEC
C
C      INPUTS:      SD    CHARACTER SIGN OF DEC
C                   DD    INTEGER   DEC (HOURS)
C                   DM    INTEGER   DEC (MINS OF ARC)
C                   DS    INTEGER   DEC (SECS OF ARC)
C 
C      OUTPUTS:     DEC   REAL      DEC (RADIANS)
C==========================================================================
       REAL PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       COMMON /CONST/ PI, TWOPI, RTOMIN, RTORAD, DTORAD, VERSN
       CHARACTER SD*1
       INTEGER   DD, DM, DS, IERR
       REAL      DEC
C
       IERR=0
100    WRITE (*,'('' (The format for Dec must be (+/-)dd mm ss)'')')
       READ  (*,'(1A,I2,2I3)') SD, DD, DM, DS
       IF (SD.NE.'-' .AND. SD.NE.'+') GOTO 100
       IF (DS.LT.0.0 .OR. DS.GE.60.0) GOTO 100
       IF (DM.LT.0.0 .OR. DM.GE.60.0) GOTO 100
C
       DEC=ABS(DD)+(DM+DS/60.0)/60.0
       IF (SD.EQ.'-') DEC=-DEC
       IF (DEC.GE.90 .OR. DEC.LE.-90)  GOTO 100
C
       IF (DEC.GT.18.5) THEN
         WRITE (*,'(/,'' + Note:'',
     &         '' the MRC is incomplete north of +18.5 deg. +'',/)')
       ELSE IF (DEC.LT.-85.0) THEN
         WRITE (*,'(/,'' + Note:'',
     &         '' the MRC is incomplete south of -85 deg. +'',/)')
       END IF
C
       DEC=DEC*DTORAD
       RETURN
       END
       SUBROUTINE SEPARN (R1,D1,R2,D2,DIST)
C========================================================================
C      CALCULATES SEPARATION OF TWO POINS OF SPECIFIED RA/DEC
C
C      INPUT      R1      REAL      RA OF 1ST POINT
C                 R2      REAL      RA OF 2ND POINT
C                 D1      REAL      DEC OF 1ST POINT
C                 D2      REAL      DEC OF 2ND POINT
C                 
C      OUTPUT     DIST    REAL      SEPARATION OF POINTS
C
C      NOTE: ALL ANGLES IN RADIANS
C
C========================================================================
       REAL R1, D1, R2, D2, DIST, TEMP
C
       TEMP=SIN((D1-D2)/2.0)** 2
       TEMP=TEMP+COS(D1)*COS(D2)*(SIN((R1-R2)/2.0)**2)
       DIST=2.0*ASIN(SQRT(TEMP))
C
       RETURN
       END
