CMAX: [Version 1.0 (6/22/93)]
CMAX: ----------------------------------------------------
CMAX: Transformation of REFHGT from refhgt.f
CMAX: ----------------------------------------------------
c.....................................................................c
C                                                                     !
C Program Name :  REFHGT                     Date: May 31, 1991       !
C Programmer   :  M. Seablom                                          !
C Analysis Version 1.1                                                !
C                                                                     !
C Program REFHGT adds a space in the DATA array for reference level   !
C height observations for satellite data.                             !
C                                                                     !
c.....................................................................c
C                                                                     !
C N A S A  /  G M S B   O p t i m u m   I n t e r p o l a t i o n     !
C                                                                     !
c.....................................................................c
      SUBROUTINE refhgt(data,nobs,ikx,ilat,ilon,ipzw,ityp,iz,iwu,iwv,
     &    itim,ref_pressure,maxobservpoints)
      INTEGER ikx, ilat, ilon, ipzw, nobs, MaxObservPoints, counter
      REAL data(:), ref_pressure(*)
      CHARACTER * 60 message
!hpf$ distribute data(block)
!hpf$ distribute ref_pressure(block)
C Extract reference pressures. Check for profile existence by scan-
C ning the 400 millibar level.
      counter = 0
      DO 7000 i = 1 , nobs
        IF ((data(ipzw + i - 1) .EQ. 400.) .AND. (data(ikx + i - 1) 
     &        .GT. 30.) .AND. (data(ikx + i - 1) .LE. 86.)) THEN
          counter = counter + 1
          IF (nobs + counter .GT. maxobservpoints) THEN
            message = ' REFHGT: MaxObservPoints exceeded while ' // 
     &' adding reference observations '
            CALL flash(5,message,1)
          ENDIF
          data(ikx + nobs + counter - 1) = data(ikx + i - 1)
          data(ilat + nobs + counter - 1) = data(ilat + i - 1)
          data(ilon + nobs + counter - 1) = data(ilon + i - 1)
          data(ipzw + nobs + counter - 1) = ref_pressure(i)
          data(iz + nobs + counter - 1) = 0.
          data(iwu + nobs + counter - 1) = 1.E15
          data(iwv + nobs + counter - 1) = 1.E15
          data(itim + nobs + counter - 1) = data(itim + i - 1)
          ref_pressure(nobs + counter) = ref_pressure(i)
        ENDIF
 7000 CONTINUE
      nobs = nobs + counter
      WRITE( 6,'(/," REFHGT: ",i7," reference height observations",     
     & " constructed.",/)' ) counter
      END
