CMAX: [Version 1.0 (6/22/93)]
CMAX: ----------------------------------------------------
CMAX: Transformation of OFFLVL from offlvl.f
CMAX: ----------------------------------------------------
      SUBROUTINE offlvl(data,nobs)
      
      INTEGER MaxObservPoints
      PARAMETER (MaxObservPoints = 150000)
c  This subroutine corrects the type flag in the data array for
c  inclusion of off-level (significant) data.
c
c     Maximal observation points
c
c
c
      REAL data (MaxObservPoints * 10), kx, pres, mandp18 (18)
      CHARACTER * 8 dataname, obsname
      LOGICAL qobs, offlev, found, onestage
      COMMON / dataptrs / ikx, ilat, ilon, iprs, ityp, idel, ifcer
      COMMON / gridxx / im, jnp, mlev
      COMMON / scan / maxobs, rscan, onestage, MaxData
      COMMON / pmh / pmand (14)
      COMMON / obs / maxdex, nfgge, lun, hh (13, 13, 20), 
     &vcoroe (18, 18, 4), obserr (200, 4, 19), ww (13, 13, 20),
     &qobs (200, 5), offlev (200)
      common / obschar / dataname (5), obsname(200)
!hpf$ distribute data(block)
!hpf$ distribute hh(block,block,block)
!hpf$ distribute mandp18(block)
!hpf$ distribute obserr(block,block,block)
!hpf$ distribute offlev(block)
!hpf$ distribute pmand(block)
!hpf$ distribute qobs(block,block)
!hpf$ distribute vcoroe(block,block,block)
!hpf$ distribute ww(block,block,block)
c  Scan for observations on mandatory levels.
      REAL  PRES100(maxobservpoints*10)
!hpf$ distribute pres100(block)
      DO i = 1 , nobs
        found = .FALSE.
        kx = data(ikx + i - 1)
        pres100(iprs + i - 1) = data(iprs + i - 1)
        DO j = 1 , mlev
          IF (abs(pres100(iprs + i - 1) - pmand(j)) .LT. .001) THEN
            found = .TRUE.
          ENDIF
        ENDDO
        IF (.NOT.(found .OR. offlev(int(kx)))) THEN
          data(ityp + i - 1) = 0.
        ENDIF
      ENDDO
c  If the observation is not on a mandatory level, check "offlev" for
c  permission to use it.
      RETURN
      END
