      SUBROUTINE FIND_STATIONS(LOND, LONU, LATD, LATU, ! INPUT
     1                         INVAR, ILG1,ILAT,
     2                         NSTATIONS, LON_STAT, LAT_STAT,
     3                         STN_LOC ) ! OUTPUT

        IMPLICIT NONE

!
! LOCATE THE POSITION OF THE STATIONS ON THE GAUSSIAN GRID
! THIS SUBROUTINE CAN BE CALLED IN DIFFERENT WAYS
! IF THE POINTS ARE NOT MOVING WITH TIME (FIXED OBSERVING STATIONS)
! CALL ONCE AT THE BEGINNING OF THE RUN BUT IF THE POINTS ARE MOVING
! (SATELLITE GROUND TRACK OR MAYBE A SHIP) CALL AS FREQUENTLY AS NEEDED
!

!
! PARAMETERS
!
      INTEGER, PARAMETER :: NG = 205120 ! NUMBER OF GRID POINTS IN A T213 GRID

!
! INPUT DATA
!

      INTEGER, INTENT(IN) ::
     1 INVAR, ! FLAG IF THE POINTS ARE NOT CHANGING (GROUND SITES) INVAR=0 OR
              ! THEY ARE MOVING (SATELLITE PATH) INVAR=1
     2 NSTATIONS, ! NUMBER OF STATIONS
     3 ILG1,
     4 ILAT

      REAL, INTENT(IN) ::
     1 LATD(NG), ! LOWER LATITUDE IN DEGREES
     2 LATU(NG)  ! UPPER LATITUDE IN DEGREES

      REAL, INTENT(IN) ::
     1 LOND(NG), ! LOWER LONGITUDE IN DEGREES
     2 LONU(NG)  ! UPPER LONGITUDE IN DEGREES

      REAL, INTENT(IN) ::
     2 LON_STAT(NSTATIONS), ! STATION LONGITUDES (DEGREES)
     3 LAT_STAT(NSTATIONS)  ! STATION LATITUDES (DEGREES)

!
! OUTPUT DATA
!

      INTEGER, INTENT(OUT) ::
     1 STN_LOC(NSTATIONS) ! INDEX OF STATION, BASED ON LIST

!
! LOCAL DATA
!

      INTEGER ::
     1 ISTAT,
     2 IJ,
     3 MAXX

      REAL ::
     1 LOND_MAX,
     2 LONU_MIN

! COMMON BLOCK DATA

      REAL :: PTOIT,MOIST
      INTEGER :: LONSL,NLAT,ILEV,LEVS,LRLMT,ICOORD,LAY

      COMMON /SIZES/  LONSL,NLAT,ILEV,LEVS,LRLMT,ICOORD,LAY,PTOIT,MOIST

      MAXX = ILG1*NLAT

! Find the maximum and minimum points
      LOND_MAX = MAXVAL(LOND(1:MAXX))
      LONU_MIN = MINVAL(LONU(1:MAXX))

!
! Try to find the stations in the section of the earth on the local processor
      DO ISTAT = 1, NSTATIONS
         DO IJ = 1, MAXX
            IF (LAT_STAT(ISTAT) .LE. LATU(IJ) .AND.
     1           LAT_STAT(ISTAT) .GT. LATD(IJ)) THEN
! Works for most points
               IF (LON_STAT(ISTAT) .GE. LOND(IJ) .AND.
     1              LON_STAT(ISTAT) .LT. LONU(IJ)) THEN
                  STN_LOC(ISTAT) = IJ
               END IF
! Special cases for a longitude straddling zero longitude
               IF (LON_STAT(ISTAT) .LE. LOND_MAX .AND.
     1             LON_STAT(ISTAT) .LT. LONU_MIN) THEN
                  STN_LOC(ISTAT) = IJ
               END IF
               IF (LON_STAT(ISTAT) .GE. LOND_MAX) THEN
                  STN_LOC(ISTAT) = IJ
               END IF
            END IF
         END DO! IJ
      END DO ! ISTAT

      RETURN
      END SUBROUTINE FIND_STATIONS
