CMAX: [Version 1.0 (6/22/93)]
CMAX: ----------------------------------------------------
CMAX: Transformation of GETMIX from getmix.f
CMAX: ----------------------------------------------------
      SUBROUTINE getmix_v1(ilev,xkx,os,ln,xlat,os100,ln100,xlon,os101,
     &    ln101,xpr,os102,ln102,xmix,os103,ln103,xrh,os104,ln104,bq,
     &    os105,ln105,nobs,nlobs,pmand,mlev,mmix,sigdat)
C  THIS SUBROUTINE CHOOSES OBS OF RH/MIX AT A CERTAIN LEVEL, ILEV,
C  AND STORES THEM INTO COMMON /LEVEL/ TO BE CHECKED BY ROUTINE CHKMIX
cmax: Changed argument XKX to passed with index
      INTEGER os
      INTEGER ln
cmax: Changed argument XLAT to passed with index
      INTEGER os100
      INTEGER ln100
cmax: Changed argument XLON to passed with index
      INTEGER os101
      INTEGER ln101
cmax: Changed argument XPR to passed with index
      INTEGER os102
      INTEGER ln102
cmax: Changed argument XMIX to passed with index
      INTEGER os103
      INTEGER ln103
cmax: Changed argument XRH to passed with index
      INTEGER os104
      INTEGER ln104
cmax: Changed argument BQ to passed with index
      INTEGER os105
      INTEGER ln105
      INTEGER bq(1-os105+1:ln105+1-os105)
      INTEGER I
      INTEGER II
      INTEGER ILEV
      INTEGER NLOBS
      INTEGER NOBS
      REAL pmand (mlev)
      DIMENSION xkx(1-os+1:ln+1-os)
      DIMENSION xlat(1-os100+1:ln100+1-os100)
      DIMENSION xlon(1-os101+1:ln101+1-os101)
      DIMENSION xmix(1-os103+1:ln103+1-os103)
      DIMENSION xpr(1-os102+1:ln102+1-os102)
      DIMENSION xrh(1-os104+1:ln104+1-os104)
C  MAXIMUM BAD/GOOD LIST SIZE, BATCH SIZE, NUMBER OF NEIGHBORING POINTS
      COMMON / BUDDY / MAXLEV, MAXLIST, MAXBATCH, MAXINDX, BUDDIST, BUDL
     &AT
      LOGICAL sigdat
C  DATA AT A PRESSURE LEVEL .
      COMMON / LEVEL / INDX (20000), KX (20000), LAT (20000), LON (20000
     &), PR (20000), RH (20000), MIX (20000), DIFF (20000), QDATA (20000
     &)
      REAL INDX, KX, LAT, LON, MIX
      INTEGER QDATA
      CHARACTER * 60 message
!hpf$ distribute bq(block)
!hpf$ distribute diff(block)
!hpf$ distribute indx(block)
!hpf$ distribute kx(block)
!hpf$ distribute lat(block)
!hpf$ distribute lon(block)
!hpf$ distribute mix(block)
!hpf$ distribute pmand(block)
!hpf$ distribute pr(block)
!hpf$ distribute qdata(block)
!hpf$ distribute rh(block)
!hpf$ distribute xkx(block)
!hpf$ distribute xlat(block)
!hpf$ distribute xlon(block)
!hpf$ distribute xmix(block)
!hpf$ distribute xpr(block)
!hpf$ distribute xrh(block)
      message(1:60) = ' '
      lev1 = mlev - mmix + 1
C  LOOP OVER REPORTS
      nlobs = 0
      DO 7000 i = 1 , nobs
C  CHECK PRESSURE LEVEL (SIGNIFICANT LEVEL DATA BEING USED)
        IF (sigdat) THEN
          IF (ilev .NE. iplev(xpr(i))) THEN
            GOTO 500
          ENDIF
C  RULE OUT DATA ABOVE HIGHEST HUMIDITY ANALYSIS LEVEL
          IF (ilev .EQ. lev1 .AND. xpr(i) .LT. pmand(lev1)) THEN
            GOTO 500
          ENDIF
C  CHECK PRESSURE LEVEL (SIGNIFICANT LEVEL DATA NOT BEING USED)
        ELSE
          IF (abs(xpr(i) - pmand(ilev)) .GT. 0.001) THEN
            GOTO 500
          ENDIF
        ENDIF
C  DATA IS AT AN ACCEPTABLE PRESSURE LEVEL
        nlobs = nlobs + 1
        IF (nlobs .GT. maxlev) THEN
          message = ' GETMIX: MAXLEV exceeded. '
          CALL flash(5,message,1)
        ENDIF
        indx(nlobs) = i
        qdata(nlobs) = bq(i)
  500   CONTINUE
 7000 CONTINUE
C GATHER DATA USING INDX-ARRAY.
      IF (nlobs .NE. 0) THEN
        DO ii = 1 , nlobs
          i = indx(ii) + 0.5
          kx(ii) = xkx(i)
          lat(ii) = xlat(i)
          lon(ii) = xlon(i)
          pr(ii) = xpr(i)
          rh(ii) = xrh(i)
          mix(ii) = xmix(i)
        ENDDO
      ENDIF
      RETURN
      END
CMAX: ----------------------------------------------------
