C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MNPNHT      GET NPN LEVEL HEIGHTS (M MSL)
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 00-03-31
C
C ABSTRACT: GET NPN LEVEL HEIGHTS FOR DESIRED PROFILE TYPE.
C
C PROGRAM HISTORY LOG:
C   00-03-31  M. BARTH    ORIGINAL VERSION
C   01-07-10  M. BARTH    - CHANGES FOR AWIPS DATABASE
C                         - ADDED VCN ARG FOR HT/P OPTION
C                         - FILL IN NLEVELS ARRAY
C   08-08-15  L. BENJAMIN ADDED MISS_P AS MISSING DATA ARGUMENT FOR
C                         M_ZTOPSA.
C
C USAGE:    CALL MNPNHT (VCN,SPT,NRECS,NLEVELS,OB,QCDESC,QCAPP,QCRES)
C
C   INPUT ARGUMENT LIST:
C     VCN      - I       VARIABLE CODE NUMBER
C     SPT      - I       PROFILE TYPE CODE NUMBER
C     NRECS    - I       NUMBER OF RECORDS (STATIONS)
C
C   OUTPUT ARGUMENT LIST:
C     NLEVELS  - IA      NUMBER OF LEVELS
C     OB       - RA      HEIGHTS (M MSL) OR PRESSURES (PA) FOR ALL
C                        STATIONS/LEVELS
C     QCDESC   - CA      QC DATA DESCRIPTORS -- SET TO NO QC
C     QCAPP    - RA      QC APPLIED WORD     -- SET TO NO QC
C     QCRES    - RA      QC RESULTS WORD     -- SET TO NO QC
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    M_ZTOPSA
C
C REMARKS:
C   THIS IS HARD-WIRED FOR THE NPN WIND PROFILER CONFIGURATION AS
C   OF MARCH 2000.  ALTHOUGH THE CONFIGURATION HAS REMAINED THE
C   SAME FOR THE LAST 12 YEARS, YOU NEVER KNOW...
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MNPNHT (VCN,SPT,NRECS,NLEVELS,OB,QCDESC,QCAPP,QCRES)

C     ------------------------------------------------------------------
C     INCLUDES AND COMMONS
C     ------------------------------------------------------------------
      INCLUDE 'IMPLICIT'
      INCLUDE 'MADISCON'
      INCLUDE 'MADISCOM'

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      INTEGER VCN,SPT,NRECS
      REAL OB(*)
      INTEGER NLEVELS(*),QCAPP(*),QCRES(*)
      CHARACTER*1 QCDESC(*)

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      INTEGER I,J,NLEVS,NOUT,FIRST_LEV
      REAL M_ZTOPSA

C     ------------------------------------------------------------------
C     DETERMINE STARTING POINT, NUMBER OF LEVELS, BASED ON PROFILE TYPE
C     AND DATABASE.
C     ------------------------------------------------------------------
      IF(SPT.EQ.-1)THEN

         IF(CDBTYPE.EQ.FSL_DB_P)THEN
            NLEVS = 64
         ELSE IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
            NLEVS = 43
         ENDIF
         FIRST_LEV = 500

      ELSE IF(SPT.EQ.-2)THEN

         NLEVS = 36
         FIRST_LEV = 500

      ELSE

         IF(CDBTYPE.EQ.FSL_DB_P)THEN
            NLEVS = 36
         ELSE IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
            NLEVS = 15
         ENDIF
         FIRST_LEV = 7500

      ENDIF

C     ------------------------------------------------------------------
C     FILL IN THE NUMBER OF LEVELS AND THE HEIGHTS.
C     ------------------------------------------------------------------
      DO 1 I = 1, NRECS

         NLEVELS(I) = NLEVS

         NOUT = (I - 1) * NLEVS

         DO 2 J = 1, NLEVS

            IF(.NOT.(CDBTYPE.EQ.AWIPS_DB_P.AND.SPT.EQ.-3.AND.J.GT.8)
     1         .AND..NOT.(CDBTYPE.EQ.AWIPS_DB_P.AND.SPT.EQ.-1.AND.
     2                   J.GT.36))THEN

               OB(NOUT+J) = NPN_ELEV(I) + FIRST_LEV + (J-1) * 250

            ELSE IF(SPT.EQ.-1)THEN

               OB(NOUT+J) = NPN_ELEV(I) + 10250 + (J-37) * 1000

            ELSE

               OB(NOUT+J) = NPN_ELEV(I) + 10250 + (J-9) * 1000

            ENDIF

            QCAPP(NOUT+J) = 0
            QCRES(NOUT+J) = 0
            QCDESC(NOUT+J) = 'Z'

 2       CONTINUE

 1    CONTINUE

C     ------------------------------------------------------------------
C     IF WE'RE HERE TO GET PRESSURE, USE THE U.S. STANDARD ATMOSPHERE
C     CALCULATION, AND CONVERT FROM MB TO PASCALS.
C     ------------------------------------------------------------------
      IF(VCN.EQ.NPNP_VN_P)THEN

         DO 3 I = 1, NRECS * NLEVS

            OB(I) = M_ZTOPSA(OB(I),MISS_P) * 100.

 3       CONTINUE

      ENDIF

      RETURN
      END
C**---------------------------------------------------------------------
C**REQUIRED STANDARD FSL DISCLAIMER (NOVEMBER 2000)
C**---------------------------------------------------------------------
C**  OPEN SOURCE LICENSE/DISCLAIMER,  FORECAST SYSTEMS LABORATORY
C**  NOAA/OAR/FSL, 325 BROADWAY BOULDER, CO 80305
C**
C**  THIS SOFTWARE IS DISTRIBUTED UNDER THE OPEN SOURCE DEFINITION, 
C**  WHICH MAY BE FOUND AT http://www.opensource.org/osd.html.
C**
C**  IN PARTICULAR, REDISTRIBUTION AND USE IN SOURCE AND BINARY FORMS,
C**  WITH OR WITHOUT MODIFICATION, ARE PERMITTED PROVIDED THAT THE 
C**  FOLLOWING CONDITIONS ARE MET:
C**
C**  - REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THIS NOTICE, THIS LIST
C**    OF CONDITIONS AND THE FOLLOWING DISCLAIMER.
C**
C**  - REDISTRIBUTIONS IN BINARY FORM MUST PROVIDE ACCESS TO THIS 
C**    NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER, AND
C**    THE UNDERLYING SOURCE CODE.
C**
C**  - ALL MODIFICATIONS TO THIS SOFTWARE MUST BE CLEARLY DOCUMENTED, 
C**    AND ARE SOLELY THE RESPONSIBILITY OF THE AGENT MAKING THE 
C**    MODIFICATIONS.
C**
C**  - IF SIGNIFICANT MODIFICATIONS OR ENHANCEMENTS ARE MADE TO THIS
C**    SOFTWARE, THE FSL SOFTWARE POLICY MANAGER 
C**    (softwaremgr.fsl@noaa.gov) BE NOTIFIED.
C**
C**  THIS SOFTWARE AND ITS DOCUMENTATION ARE IN THE PUBLIC DOMAIN AND 
C**  ARE FURNISHED "AS IS."  THE AUTHORS, THE UNITED STATES GOVERNMENT,
C**  ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES, AND AGENTS MAKE NO 
C**  WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS OF THE SOFTWARE
C**  AND DOCUMENTATION FOR ANY PURPOSE.  THEY ASSUME NO RESPONSIBILITY 
C**  (1) FOR THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO 
C**  PROVIDE TECHNICAL SUPPORT TO USERS.
C**---------------------------------------------------------------------
