C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MRAOBCHR    GET A RAOB CHARACTER NETCDF VARIABLE
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 01-05-03
C
C ABSTRACT: GET A RAOB CHARACTER VARIABLE FROM COMMON OR FROM AN OPEN
C   NETCDF FILE.
C
C PROGRAM HISTORY LOG:
C   01-05-03  M. BARTH    ORIGINAL VERSION
C   01-07-26  M. BARTH    CHANGED INV_VCN_P STATUS TO INV_INTV_P
C
C USAGE:    CALL MRAOBCHR (VNAME,NCID,RECDIM,STARTR,NRECS,VDATA,LEN1REC,
C                          STATUS)
C
C   INPUT ARGUMENT LIST:
C     VNAME    - C       NETCDF VARIABLE NAME
C     NCID     - I       ID OF THE OPEN NETCDF QC FILE
C     RECDIM   - I       DIMENSION ID OF THE FILE'S RECORD DIMENSION
C     STARTR   - I       STARTING RECORD TO READ
C     NRECS    - I       NUMBER OF RECORDS TO READ
C
C   OUTPUT ARGUMENT LIST:
C     VDATA    - CA      CHARACTER ARRAY WITH DATA FILLED IN
C     LEN1REC  - I       NUMBER OF CHARACTERS IN A SINGLE RECORD
C     STATUS   - I       SUCCESS_P OR ERROR CODE
C
C   INPUT FILES:
C     WHATEVER NETCDF FILE'S OPEN ON NCID.
C
C SUBPROGRAMS CALLED:
C     UNIQUE:  MERROR
C
C REMARKS:
C   ALL RAOB VARIABLES THAT HAVE A LEVEL DIMENSION HAVE ALREADY BEEN
C   READ INTO THE STRCCOM COMMON.  WE'LL PULL OUT THE DESIRED VARIABLE
C   FOR THE FILE CURRENTLY BEING PROCESSED FOR ALL RECORDS.
C
C   THE ONLY RAOB CHARACTER VARIABLES OBTAINED BY THIS ROUTINE ARE THE
C   QC DATA DESCRIPTORS.
C
C   THE VARIABLE NAMES SPECIFIED BY THE CALLER ARE FOUND IN RAOBTBL.TXT
C   AND ARE HARD-WIRED INSIDE THIS ROUTINE.
C
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MRAOBCHR(VNAME,NCID,RECDIM,STARTR,NRECS,VDATA,LEN1REC,
     1                    STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      CHARACTER*(*) VNAME
      INTEGER NCID,RECDIM,STARTR,NRECS,LEN1REC,STATUS
      CHARACTER*1 VDATA(*)

C     ------------------------------------------------------------------
C     LOCAL PARAMETERS:
C
C     - MAXVAR    NUMBER OF VARIABLES HANDLED BY THIS ROUTINE
C
C     ALSO NOTE THAT THE ORDER OF VARIABLES IN VNAMES MUST MATCH THE
C     ORDER OF PROCESSING IN MRAOBINT (E.G., P_RAOB_P=1, HT_RAOB_P=2,
C     ETC.)
C     ------------------------------------------------------------------
      INTEGER MAXVAR
      PARAMETER (MAXVAR = 6)

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      INTEGER IVAR,I,J,K,JLAST,VNC(MAXVAR)
      CHARACTER*13 VNAMES(MAXVAR)

C     ------------------------------------------------------------------
C     DATA STATEMENTS (KEEP AT BOTTOM OF DECLARATIONS)
C     ------------------------------------------------------------------
      DATA VNAMES/'pressureDD','heightDD','temperatureDD','dpdDD',
     1            'windDirDD','windSpeedDD'/
      DATA VNC/10,8,13,5,9,11/


C     ------------------------------------------------------------------
C     MAKE SURE THIS IS A VARIABLE HANDLED BY THIS ROUTINE.
C     ------------------------------------------------------------------
      DO 1 IVAR = 1, MAXVAR

         IF(VNAME(1:VNC(IVAR)).EQ.VNAMES(IVAR)(1:VNC(IVAR)))GO TO 2

 1    CONTINUE

      STATUS = INV_INTV_P
      CALL MERROR('MRAOBCHR: INTV - INVALID RAOB VARIABLE')
      GO TO 900

C     ------------------------------------------------------------------
C     NOTE THAT WE HAVE TO FILL IN BLANKS ABOVE THE LAST ACTUAL DATA
C     LEVEL.
C     ------------------------------------------------------------------
 2    JLAST = 0

      DO 20 I = STARTR, NRECS

         J = JLAST + 1

         DO 21 K = 1, RAOB_NLEVELS(I,RAOB_FNUM)

            VDATA(J) = RAOB_QCDD(K,I,IVAR,RAOB_FNUM)
            J = J + 1

 21      CONTINUE

         DO 22 K = RAOB_NLEVELS(I,RAOB_FNUM) + 1, MXRAOBLEV_P

            VDATA(J) = ' '
            J = J + 1

 22      CONTINUE

         JLAST = JLAST + MXRAOBLEV_P

 20   CONTINUE

      LEN1REC = 1
      STATUS = SUCCESS_P

 900  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**---------------------------------------------------------------------
