C file EIGEN2.FOR
C ----------------------------------------------------------------------!-------
Contains VINTERP, GETRAYS, GETRAY1
C ----------------------------------------------------------------------!-------
C 14 Aug 2009 - Added W(459) as a phase to subtract from interpolated phases
C 14 Aug 2009 - Changed W(453) from rcvr range to rcvr central earth angle
C 13 Aug 2009 - Added phase, absorption, and Doppler shift to LOGFIL
C  4 May 2009 - replaced REAL*8 with DOUBLE PRECISION
C 13 Mar 2008 - Corrected length in common block /PCONST/
C 24 Apr 2007 - Enlarge common block /RAYDAT/
C 24 Apr 2007 - Read in everything from raysets
C 24 Apr 2007 - Correct decimal point format on xmtr latitude and longitude
C 24 Mar 2006 - Moved SWAP2, BINARY, FUD to S7
C 24 Mar 2006 - Moved KURVE, PLOTINI, PLTTLT, CPLOT, YTRIM, F, CLIP, KODE to S8
C 24 Mar 2006 - Changed COMMON block /RAYDEV/
C 13 September 2005 - Added NHOPIN(10000) to RAYDAT common block
C 13 September 2005 - Fixed "fudge factor" bug, temp1 calculated correctly
C 25 August 2005 - Changed read statements to include lower-case variables
C 25 August 2005 - Added lower-case variables to RAYDAT common block
C 23 August 2005 - Changed number of arguments in CALL GRACE
C ----------------------------------------------------------------------!-------
C		     Subroutine VINTERP
C
C ----------------------------------------------------------------------!-------
 
      SUBROUTINE VINTERP(NDEV,EL,RNGES,GTIM
     1 ,ptim,abs,dop,NPTS,NHOP,NPR,omega)                      ! 13-14 Aug 2009
C ----------------------------------------------------------------------!-------
C Interpolation routine 
C ----------------------------------------------------------------------!-------
 
	implicit double precision (a-h,o-z)
 
      DOUBLE PRECISION NPOS,EL(NPTS),RNGES(NPTS),GTIM(NPTS)
     1 ,ptim(npts),abs(npts),Dop(npts)                            ! 13 Aug 2009
     2 ,Dptim(333),omega(npts)                                    ! 14 Aug 2009

C     COMMON DECK "CONST" INSERTED HERE
      COMMON/PCONST/CREF,RGAS,GAMMA
     1 ,MO2,MN2,MO,MN,MH2O,MO3                        ! 9 Mar 2007 ! 13 Mar 2008
      DOUBLE PRECISION MO2,MN2,MO,MN,MH2O,MO3                      ! 13 Mar 2008
      COMMON/MCONST/PI,PIT2,PID2,DEGS,RAD,ALN10

C     COMMON DECK "CRAYCOM" INSERTED HERE
      COMMON/RAYCOM/NRAYS,MXRYS,MXHOP,MXXHOP,NRSLIM,ICODE
      COMMON/RAYCOM/NHOPS(333),MNHOPS(333)
C     COMMON DECK "WWE" INSERTED HERE
      PARAMETER (NWARSZ=1000)
	character id*80
      common /ident/ id
      COMMON/WW/dum(10),MAXW,W(NWARSZ)
      DOUBLE PRECISION NRSLMI
      EQUIVALENCE (W(80),APOG) ,(W(401),PTYP) ,(W(403),ELMIN)
     1   ,(W(404),ELMAX) ,(W(405),ELVINC) ,(W(406),RGINC)
     2   ,(W(407),HOPLME) ,(W(408),NRSLME)
     3   ,(W(409),GAPLO), (W(410),GAPHI), (W(411),SYMRED)
     4   ,(W(428),GRPMIN) ,(W(429),GRPMAX) ,(W(430),GRPVINC)
     5   ,(W(432),HOPLMG) ,(W(433),NRSLMG)
     6   ,(W(434),RFSPEED) ,(W(435),TMFT) ,(W(436),RMAX)
     7   ,(W(453),rcCEA) ,(W(454),SLPCUT)                         ! 14 Aug 2009
     8   ,(W(456),HOPLMI) ,(W(457),NRSLMI) ,(W(458),ESET)
     9   ,(W(459),PHASE0)                                         ! 14 Aug 2009
      DOUBLE PRECISION MAXSTP,MAXERR,INTYP,LLAT,LLON
      EQUIVALENCE (EARTHR,W(1)),(RAY,W(2)),(XMTRH,W(3)),(TLAT,W(4)),
     1 (TLON,W(5)),(OW,W(6)),(FBEG,W(7)),(FEND,W(8)),(FSTEP,W(9)),
     2 (AZ1,W(10)),(AZBEG,W(11)),(AZEND,W(12)),(AZSTEP,W(13)),
     3 (BETA,W(14)),(ELBEG,W(15)),(ELEND,W(16)),(ELSTEP,W(17)),
     8   (RUNSUP,W(18)),(RCVRH,W(20)),
     4 (ONLY,W(21)),(HOP,W(22)),(MAXSTP,W(23)),(PLAT,W(24)),(PLON,W(25))
     5,(HMAX,W(26)),(RAYFNC,W(29)),(EXTINC,W(33)),
     6 (HMIN,W(27)),(RGMAX,W(28)),
     8 (INTYP,W(41)),(MAXERR,W(42)),(ERATIO,W(43)),
     6 (STEP1,W(44)),(STPMAX,W(45)),(STPMIN,W(46)),(FACTR,W(47)),
     7 (SKIP,W(71)),(RAYSET,W(72)),(PRTSRP,W(74)),(HITLET,W(75))
     9 ,(BINRAY,W(76)),(PAGLN,W(77)),(PLT,W(81)),(PFACTR,W(82)),
     1 (LLAT,W(83)),(LLON,W(84)),(RLAT,W(85)),(RLON,W(86))
     2,(TIC,W(87)),(HB,W(88)),(HT,W(89)),(TICV,W(96))
C
C     COMMON DECK "CEFILES" INSERTED HERE
      COMMON/EFILES/INFILE,IOTFIL,LOGFIL,NCNTRL,NRYSFL
C
      external binary
C
      DATA KOUNT/0/
C
      rcrng=rcCEA*EARTHR                                          ! 14 Aug 2009
      KOUNT=KOUNT+1
      IF(KOUNT.EQ.1) WRITE(LOGFIL,35)
C35    FORMAT('  ENTRY HOP-NO RAY-NO  EST EL      ELEV(LOW/HIGH)   '
C     1   ,'   RANGES(LOW/HIGH)     SLOPE  GROUP TIMES')
35    FORMAT('  ENTRY HOP-NO RAY-NO    ELEVATION     RANGE   GROUP'
     1   ,'      PHI,SEC  DPHI,DEG ABSORP, dB Doppler,Hz')     ! 13-14 Aug 2009
C
      OPOS=BINARY(RNGES(1)-RCRNG)
      DO 100 I=2,NPTS
         NPOS=BINARY(RNGES(I)-RCRNG)
         IF(OPOS*NPOS.EQ.1.0) GO TO 100
         OPOS=NPOS
         IM1=I-1
         Dptim(IM1)=(ptim(IM1)-phase0)*omega(IM1)*degs            ! 14 Aug 2009
         Dptim(I)=(ptim(I)-phase0)*omega(I)*degs                  ! 14 Aug 2009
         IF(RNGES(I).GT.RMAX .OR. RNGES(IM1).GT.RMAX) GO TO 100
         IF(RNGES(I).EQ.RNGES(IM1)) GO TO 100
         SLOPE=(EL(I)-EL(IM1))/(RNGES(I)-RNGES(IM1))
C
C     USE RANGE SENSITIVITY AS CUTOFF ON RAYS
         ELF=EL(IM1)+SLOPE*(RCRNG-RNGES(IM1))
30       IF(DABS(SLOPE).LE.SLPCUT) GO TO 60
C
crb   There are several lines added here by Ron Brent to write
crb   information to the file HARPO.IN.
ccccc NOTE:  The lines added by Ron Brent have now been commented out,
ccccc        since NDEV is now passed into this routine as 43.  Thus,
ccccc        RB's correct modifications are no longer needed. jah.

         IF(NPR.NE.0) WRITE(NDEV,40) '  0'
         IF(NPR.NE.0) WRITE(NDEV,40) ID
         NPR=NPR+1
         WRITE(NDEV,45) sngl(ELF)
40    FORMAT(10A8)
45    FORMAT(' 15',T4,F8.3,T18,'1',T25,'ELEVATION ANGLE')
      FCTR=1.0
      IF(RNGES(I).NE.RNGES(IM1))
     1   FCTR=(RCRNG-RNGES(IM1))/(RNGES(I)-RNGES(IM1))
60    CONTINUE
C      WRITE(LOGFIL,50)
C     1  KOUNT,NHOP,I,sngl(ELF),sngl(EL(IM1)),sngl(EL(I))
C     2  ,sngl(RNGES(IM1)),sngl(RNGES(I)),sngl(SLOPE)
C     3  ,sngl(GTIM(IM1)),sngl(GTIM(I))
C     4  ,sngl(GTIM(IM1)+FCTR*(GTIM(I)-GTIM(IM1)))
50    FORMAT(3I6,3F11.5,2F11.4,F8.4,3F11.5)
      WRITE(LOGFIL,501)
     1  KOUNT,NHOP,I-1,sngl(EL(IM1)),sngl(RNGES(IM1)),sngl(GTIM(IM1))
     2 ,sngl(PTIM(IM1))
     3 ,sngl(dPTIM(IM1))                                          ! 14 Aug 2009
     4 ,sngl(ABS(IM1)),sngl(DOP(IM1))                             ! 13 Aug 2009
      WRITE(LOGFIL,502)
     1  KOUNT,NHOP
     2 ,sngl(i-1.d0+fctr)
     3  ,sngl(ELF)
     4  ,SNGL(rcrng)
     5  ,sngl(GTIM(IM1)+FCTR*(GTIM(I)-GTIM(IM1)))
     6  ,sngl(PTIM(IM1)+FCTR*(PTIM(I)-PTIM(IM1)))
     7  ,sngl(dPTIM(IM1)+FCTR*(dPTIM(I)-dPTIM(IM1)))              ! 14 Aug 2009
     8  ,sngl(ABS(IM1)+FCTR*(ABS(I)-ABS(IM1)))
     9  ,sngl(DOP(IM1)+FCTR*(DOP(I)-DOP(IM1)))                    ! 13 Aug 2009
      WRITE(LOGFIL,501)
     1  KOUNT,NHOP,I,sngl(EL(I)),sngl(RNGES(I)),sngl(GTIM(I))
     2 ,sngl(PTIM(I))
     3 ,sngl(dPTIM(I))                                            ! 14 Aug 2009
     4 ,sngl(ABS(I)),sngl(DOP(I))                                 ! 13 Aug 2009
501   FORMAT(3I6,5X,F11.5,F11.4,2F11.5,F8.3,2F11.5)                           ! 13 Aug 2009
502   FORMAT(2I6,F11.4,F11.5,F11.4,2F11.5,F8.3,2F11.5)                        ! 13 Aug 2009



100   CONTINUE
C
C ----------------------------------------------------------------------!-------
      END SUBROUTINE VINTERP
C ----------------------------------------------------------------------!-------
 
C ----------------------------------------------------------------------!-------
C			Function GETRAYS
C
C ----------------------------------------------------------------------!-------
 
      FUNCTION GETRAYS(NDEV,NRUN)
C ----------------------------------------------------------------------!-------
 
      implicit double precision (a-h,o-z)
 
C+
C+P   (GETRAYS) READ NRUN'TH RAYSET FROM FILE UNIT NDEV.
C+    IF LAST READ WENT PAST NRUN, DO RE-WIND
C+
C
      DATA LRUN/1000/
      IF(NRUN.LE.LRUN) THEN
          REWIND NDEV
          LRUN=1
      ENDIF
      LR=LRUN
      LRUN=NRUN+1
      DO 100 I=LR,NRUN
        GETRAYS=GETRAY1(NDEV)
        IF(GETRAYS.NE.0.0) RETURN
100     CONTINUE
        RETURN
C ----------------------------------------------------------------------!-------
        END FUNCTION GETRAYS
C ----------------------------------------------------------------------!-------
C8888888888888
C ----------------------------------------------------------------------!-------
C			Function GETRAY1
C
C ----------------------------------------------------------------------!-------
      FUNCTION GETRAY1(NDEV)
C ----------------------------------------------------------------------!-------
C
      implicit double precision (a-h,o-z)
C
C+
C+P   (GETRAY1) READ SINGLE RAYSET FROM FILE UNIT NDEV.
C+    ASSUME FILE IS POSITIONED AT OR BEFORE TRANSMIT RAY.
C+    READ WILL TERMINATE AT END-OF-RAYSET OR FILE EOF
C+
C
      CHARACTER FID*3
      LOGICAL NEWREAD
c      CHARACTER LINE*80,C,CEOF,TYPE,rcvr,TRANS,STATE,MINDIS
      CHARACTER LINE*90,C,CEOF,TYPE,rcvr,TRANS,STATE,MINDIS        ! 24 Apr 2007
      DOUBLE PRECISION xmtrlat,xmtrlong,AZIMUTH,ELEVA,recvht,dazimuth
     1 ,RANGE
C     !25 August 2005 - added lower-case variables
C     COMMON DECK "CONST" INSERTED HERE
      COMMON/PCONST/CREF,RGAS,GAMMA
     1 ,MO2,MN2,MO,MN,MH2O,MO3                        ! 9 Mar 2007 ! 13 Mar 2008
      DOUBLE PRECISION MO2,MN2,MO,MN,MH2O,MO3                      ! 13 Mar 2008
      COMMON/MCONST/PI,PIT2,PID2,DEGS,RAD,ALN10
C     COMMON DECK "WWE" INSERTED HERE
      PARAMETER (NWARSZ=1000)
c        character id*80                                   ! 30 Mar 2006
      COMMON/WW/dum(10),MAXW,W(NWARSZ)
      DOUBLE PRECISION NRSLMI
      EQUIVALENCE (W(80),APOG) ,(W(401),PTYP) ,(W(403),ELMIN)
     1   ,(W(404),ELMAX) ,(W(405),ELVINC) ,(W(406),RGINC)
     2   ,(W(407),HOPLME) ,(W(408),NRSLME)
     3   ,(W(409),GAPLO), (W(410),GAPHI), (W(411),SYMRED)
     4   ,(W(428),GRPMIN) ,(W(429),GRPMAX) ,(W(430),GRPVINC)
     5   ,(W(432),HOPLMG) ,(W(433),NRSLMG)
     6   ,(W(434),RFSPEED) ,(W(435),TMFT) ,(W(436),RMAX)
     7   ,(W(453),rcCEA) ,(W(454),SLPCUT)
     8   ,(W(456),HOPLMI) ,(W(457),NRSLMI) ,(W(458),ESET)
     9   ,(W(459),PHASE0)                                         ! 14 Aug 2009
C     COMMON DECK "CRAYCOM" INSERTED HERE
      COMMON/RAYCOM/NRAYS,MXRYS,MXHOP,MXXHOP,NRSLIM,ICODE
      COMMON/RAYCOM/NHOPS(333),MNHOPS(333)

C     COMMON DECK "CRAYDAT" INSERTED HERE
      integer hopmax                                               ! 24 Apr 2007
      DOUBLE PRECISION logdensT, logdensR                          ! 24 Apr 2007
      character*1 Tevent, event                                    ! 24 Apr 2007
      COMMON/RAYDAT/ nwndabs(333), xmtrht(333),                    ! 24 Apr 2007
     1 xmtrlat(333), xmtrlong(333), rcvrht(333), omega(333),       !  3 May 2007
     2 AZIMUTH(333), ELEVA(333), polarTR(333), polarTI(333),       ! 24 Apr 2007
     3 hopmax(333), logdensT(333),                                 ! 24 Apr 2007
     4 recvht(10000), RANGE(10000), dazimuth(10000),               ! 24 Apr 2007
     5 rcvrAZ(10000), rcvrEL(10000),                               ! 24 Apr 2007
     6 GRPTIM(10000), phase(10000), absorb(10000),                 ! 24 Apr 2007
     7 Doppler(10000), polarRR(10000), polarRI(10000),             ! 24 Apr 2007
     8 nhopin(10000), logdensR(10000), NELMTS                      ! 24 Apr 2007
      
      COMMON/RAYDAT2/ FID, event(10000)                            ! 24 Apr 2007

C     !25 August 2005 - added lower-case variables to RAYDAT common block

C     COMMON DECK "CEFILES" INSERTED HERE
c      COMMON/EFILES/INFILE,IOTFIL,LOGFIL,NCNTRL,NRYSFL
C
C
      DATA TYPE,rcvr,MINDIS,TRANS,CEOF/2*'R','M','T',' '/
      DATA NEWREAD/.TRUE./
      DATA UNDEF,BELEVA/2*1.E25/
      DATA MAXHOP/0/
C
      GEOF=0.0
      NRSETS=0
      NRAYS=0
      MX=0
      BAZIMUT=UNDEF
C+
C+    RESET 'STATE' FLAG USED TO INITIATE NEW RAY SERIES
C+
      STATE=CEOF
C  CONVERT ANGLES TO DEGREES
      ELMIND=DEGS*ELMIN
      ELMAXD=DEGS*ELMAX
C     temp1 = fud(elmind)                              ! 13 September 2005
      temp1 = elmind*0.999                             ! 13 September 2005
C     temp2 = fud(elmaxd)                              ! 13 September 2005
      temp2 = elmaxd*1.001                             ! 13 September 2005
C
C+
C+    LOOP THRU ALL INPUT LINES
C+
      DO 500 NLINE=1,100000
C+
C+    ATTEMPT TO FIND NEXT TRANSMIT RAY
C+
C
C.....READ A LINE FROM FILE, EXIT ON EOF
      DO 10 I=1,300
c      print *, 'before read'
           if(newread) READ(NDEV,'(A)',IOSTAT=ios) LINE
c      print *, 'after read', line
           if (ios.lt.0) then
                geof = 1.0
                go to 900
           endif
C+
           newread = .true.
C+
C+    USING CHARACTER CODE IN 80TH COLUMN LOCATE NEXT TRANSMIT SERIES
C+    C can be 'T', 'R', 'M'.  The usual situation is:  a single line
C     with 'T' in 80th column followed by numerous (NHOP, i believe) lines
C     with 'R' in 80th column.  If 'M' is in the 80th column, this indicates
C     that the line is skipped and there will be a gap in the plot.
C
          C=LINE(80:80)
C+
C+    IF TRANSMIT RAY NOT SEEN, IGNORE OTHER LINES OF INPUT
C+
          IF(STATE.eq.TRANS.and.c.eq.ceof) goto 900
c
          IF(C .NE. TRANS) GO TO 15
          INC=1
          IF(NRAYS.gt.0) then
CCCCC        
      print*,'nrays #2 = ',nrays
              NHOPS(NRAYS)=NHOP+NMIND
              MNHOPS(NRAYS)=MINHOP
              MINHOP=0
              IF(NHOP.LE.0) then
                   nhops(nrays) = 9999
ccccc              INC=0
              endif
              IF(NRAYS.ge.MXRYS) stop' NUMBER OF RAYS EXCEEDS LIMIT'
          endif
          NRAYS=NRAYS+INC
C
C  RESET ALL THE COUNTERS FOR RAYSETS
          NMIND=0
          NHOP=0
          MINHOP=0
C+
C+I   READ AZIMUTH AND ELEVATION OF NEW RAY
C+
C         READ(LINE,2222) FID,AZIMUTH(NRAYS),ELEVA(NRAYS)
C          READ(LINE,2222) FID,xmtrlat(NRAYS),xmtrlong(NRAYS),
C     1    AZIMUTH(NRAYS),ELEVA(NRAYS)         ! 25 August 2005
c      print *, 'before read ', line
          READ(LINE,2222) FID, nwndabs(NRAYS), xmtrht(NRAYS), 
     1    xmtrlat(NRAYS), xmtrlong(NRAYS), rcvrht(NRAYS), omega(NRAYS),!3mAY2007
     2    AZIMUTH(NRAYS), ELEVA(NRAYS), polarTR(NRAYS), polarTI(NRAYS), 
     3    hopmax(NRAYS), Tevent, logdensT(NRAYS)                   ! 24 Apr 2007
c      print *, 'after read ', Tevent
          IF(BAZIMUT.NE.UNDEF.AND.BAZIMUT.NE.AZIMUTH(NRAYS)) then
               print*,'bazimut undef'
               GO TO 480
          endif
          IF(BELEVA.EQ.ELEVA(NRAYS)) then
              print*,'beleva=eleva(nrays)'
              gO TO 490
          endif
          BELEVA=ELEVA(NRAYS)
          BAZIMUT=AZIMUTH(NRAYS)
C
c
          IF(BELEVA.LT.temp1.OR.BELEVA.GT.temp2) then
              PRINT*,'BELEVA = ',BELEVA
              PRINT*,'TEMP1 = ',TEMP1
              PRINT*,'TEMP2 = ',TEMP2
              print*,'failed temp tst'
              GO TO 490
          endif
C
          IF(STATE.EQ.TRANS) then
              GO TO 500
          endif
C
15        IF(STATE.NE.TRANS) GO TO 155
          IF(C .EQ. rcvr) then
               GO TO 100
          endif
          IF(C .eq. MINDIS) then
               nmind = nmind + 1
          endif
 
C  SET MINIMUM SETS FLAG
 
          GO TO 10
C
155       IF(C.eq.TRANS) then
             STATE=TRANS
             IF(MX.NE.0) then
                 print*,'mx .ne.0,going to 500'
                 GO TO 500
             endif
             READ(LINE,3333) MX
             PRINT 4444,MXXHOP,MX
             MXHOP=MIN0(MX,MXXHOP)
          endif
 
10    CONTINUE  ! i=1,300
C
      stop'QUESTIONABLE RAYSET FILE FORMAT'
100   IF(NHOP+NMIND.GE.MXXHOP) then
           print*,'nhop,nmind,mxxhop = ',nhop,nmind,mxxhop
           GO TO 490
      endif
 

      NHOP=NHOP+1
C      PRINT*,'NHOP = ',NHOP
      NN=NHOP+NMIND
      IF(NHOP.EQ.1) MINHOP=NN
      LNHOP=(NRAYS-1)*MXXHOP+NN
C+
C+    READ RANGE,DELAY AND HOP NUMBER FOR EACH RAY OF SERIES
C+
C     READ (LINE,5555) RANGE(LNHOP), GRPTIM(LNHOP), NHOPIN
C      READ (LINE,5555) recvht(LNHOP), RANGE(LNHOP), dazimuth(LNHOP),
C     1GRPTIM(LNHOP), NHOPIN(LNHOP)                             ! 25 August 2005
c      print *, 'before read ', line
      READ (LINE,5555) recvht(LNHOP), RANGE(LNHOP), dazimuth(LNHOP),
     1 rcvrAZ(LNHOP), rcvrEL(LNHOP), 
     2 GRPTIM(LNHOP), phase (LNHOP), absorb(LNHOP), Doppler(LNHOP), 
     3 polarRR(LNHOP), polarRI(LNHOP), NHOPIN(LNHOP), event(LNHOP), 
     4 logdensR(LNHOP)                                             ! 24 Apr 2007
c      print *, 'after read ', 
c     1 recvht(LNHOP), RANGE(LNHOP), dazimuth(LNHOP),
c     2 rcvrAZ(LNHOP), rcvrEL(LNHOP), 
c     3 GRPTIM(LNHOP), phase (LNHOP), absorb(LNHOP), Doppler(LNHOP), 
c     4 polarRR(LNHOP), polarRI(LNHOP), NHOPIN(LNHOP), event(LNHOP), 
c     5 logdensR(LNHOP) 
      if (inc.eq.0) then
           range(lnhop) = undef
      endif
 
C
C+
C+    COMPLAIN IF HOP NUMBER DOES NOT COMPARE WITH RUNNING VALUE
C+
      IF(NHOPIN(LNHOP).EQ.NN) GO TO 500
c        WRITE(LOGFIL,1200) NRAYS,NHOP,NHOPIN,NMIND
c1200  FORMAT(' FOR RAY NO',I3,',NHOP=',I10
c    1      ,' ,NHOPIN(LNHOP)=',I4,' ,NMIND=',I4,'..LOGIC ERROR1')
         STOP 'logic error, see code'
C
C     CHANGE OF AZIMUTH SO HOLD THIS SET
480   NEWREAD=.FALSE.
      NRAYS=NRAYS-1
      RETURN
C
C     ABORT THIS RAY
490   print*,'state = ceof'
      STATE=CEOF
500   CONTINUE
      PRINT *,' LINE LIMIT ON RAYSETS REACHED'
C
900   GETRAY1=GEOF
      IF(NRAYS.LE.0) then
           RETURN
      endif
      IF(NHOP.gt.0) then
           NHOPS(NRAYS)=NHOP+NMIND
           MNHOPS(NRAYS)=NMIND+1
           RETURN
      endif
      NRAYS=NRAYS-1
 
C2222      FORMAT(A,T44,2F10.5)                                 ! 25 August 2005
C2222       FORMAT(A,T14,2F6.2,T44,2F10.5)                      ! 25 August 2005
2222       FORMAT(A,I1,F9.4,2F6.3,2F9.4,2F10.5                     ! 24 Apr 2007
     1 ,T69,F5.2,F4.2,I2,A1,F10.5)                                 ! 24 Apr 2007
3333       FORMAT(T78,I2)
4444      FORMAT(' HOPLIM=',I3,' MXHOP=',I4)
C5555  FORMAT(T10,F9.4,T37,F10.5,T78,I2)                        ! 25 August 2005
C5555  FORMAT(F9.4,F9.4,F6.3,T37,F10.5,T78,I2)                  ! 25 August 2005
5555  FORMAT(2F9.4,3F6.3,2F10.5,2F6.3,F5.2,F4.2,I2,A1,F10.5)       ! 24 Apr 2007
      RETURN
C ----------------------------------------------------------------------!-------
      END FUNCTION GETRAY1
C ----------------------------------------------------------------------!-------
c88888888888
