C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MSFCWIND    GET SFC WIND
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 99-09-20
C
C ABSTRACT: GET SFC WIND SPEED, WIND DIR, U COMPONENT, OR V COMPONENT
C   FROM ONE FILE FOR ONE TIME.
C
C PROGRAM HISTORY LOG:
C   99-09-20  M. BARTH    ORIGINAL VERSION
C   00-03-22  M. BARTH    - RENAMED MXST_P TO MXSFC_P
C                         - BOTH SPD & DIR HAVE TO HAVE PASSED ANY
C                           QC THAT WAS APPLIED IN ORDER TO BE USED
C                           IN ANY CALCULATIONS NEEDED TO RETURN
C                           WHAT THE CALLER WANTS.
C   01-05-03  M. BARTH    CHANGED MRDNUM/MRDCHR TO MGTNUM/MGTCHR
C   02-04-30  M. BARTH    CHANGED MAX_QCCHK_P TO MAX_SFC_QCCHK_P
C   02-05-29  M. BARTH    RESTRUCTURED TEMPORARY MEMORY ARRAY USAGE
C   04-03-22  M. BARTH    ADDED COOP DATASET AND ITS HOURLY & DAILY
C                         WIND VARIABLES (AS WELL AS THE REGULAR
C                         ONES).
C   04-10-16  L. BENJAMIN ADDED NO SUCH VARIABLE CHECK FOR QCA CHECKS
C   06-09-01  L. BENJAMIN CHANGED COOP WIND VARIABLES
C
C USAGE:    CALL MSFCWIND (VCN,DSN,FNUM,OB,QCDESC,QCAPP,QCRES,STATUS)
C
C   INPUT ARGUMENT LIST:
C     VCN      - I       VARIABLE CODE NUMBER FOR FF, DD, U, V, OR
C                        HOURLY/DAILY VERSIONS OF THOSE
C     DSN      - I       DATASET CODE NUMBER
C     FNUM     - I       FILE NUMBER (INDEX IN COMMON) OF NETCDF FILE
C
C   OUTPUT ARGUMENT LIST:
C     OB       - RA      OBSERVATIONS IN M/K/S UNITS
C     QCDESC   - CA      QC DATA DESCRIPTORS
C     QCAPP    - RA      QC APPLIED WORD (SHOWS CHECKS APPLIED)
C     QCRES    - RA      QC RESULTS WORD (GOOD/BAD FOR EACH CHECK)
C     STATUS   - I       SUCCESS_P OR ERROR CODE
C
C   INPUT FILES:
C     NETCDF FILE OPENED USING DATA STRUCTURES FOR FNUM IN STRCCOM
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MGTCHR, MGTNUM, M_GETUV, M_MKDESC, M_ROTFAC
C
C REMARKS:
C   - FF & DD ARE STORED IN THE FILES.  IF THE CALLER REQUESTS ONE OF
C     THOSE, IT'S READ IN AND THAT'S ALL.
C   - IF U OR V IS REQUESTED, FF & DD ARE READ IN AND CONVERTED TO U/V.
C   - IF U OR V IS REQUESTED, THE QC RESULTS FROM FF & DD ARE
C     COMBINED.
C   - THIS ROUTINE IS ASSUMED TO BE CALLED BY A HIGHER-LEVEL MADIS
C     ROUTINE, SO NO ERROR CHECKING IS DONE ON THE INPUT VARIABLES.
C   - SEE madistmp.f FOR AN EXPLANATION OF HOW TEMPORARY STORAGE
C     IS HANDLED (ALL ARRAYS NAMED *TMP*).
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MSFCWIND (VCN,DSN,FNUM,OB,QCDESC,QCAPP,QCRES,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      INTEGER VCN,DSN,FNUM,STATUS
      REAL OB(*),QCAPP(*),QCRES(*)
      CHARACTER*1 QCDESC(*)

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      REAL OBTMP(MXSFC_P,2),COMPTMP(MXSFC_P,2),SINDL,COSDL,UTEMP,VTEMP
      REAL WIND(2),LONTMP(MXSFC_P)
      INTEGER I,J,VAL,VNUM,LEN1REC,FFVCN,DDVCN
      REAL QCATMP(MXSFC_P,2),QCRTMP(MXSFC_P,2)
      INTEGER QCA(2),QCR(2),QCARET,QCRRET
      CHARACTER*1 QCDTMP(MXSFC_P,2)
      LOGICAL QCMISS(2)
C     ------------------------------------------------------------------
C     TEMPORARY STORAGE DEFINITIONS
C     ------------------------------------------------------------------
      EQUIVALENCE(OBTMP,TMP_L2_N1)
      EQUIVALENCE(QCATMP,TMP_L2_N2)
      EQUIVALENCE(QCRTMP,TMP_L2_N3)
      EQUIVALENCE(QCDTMP,TMP_L2_C1)
      EQUIVALENCE(COMPTMP,TMP_L2_N1(MXSFC_P*2+1))
      EQUIVALENCE(LONTMP,TMP_L2_N2(MXSFC_P*2+1))

C     ------------------------------------------------------------------
C     TO CLERICALLY SIMPLIFY LIFE, BECAUSE THERE ARE 3 FLAVORS OF
C     COOP WINDS, PUT THE DESIRED FF/DD VCNS INTO LOCAL VARIABLES.
C     ------------------------------------------------------------------
      FFVCN = SFCFF_VN_P
      DDVCN = SFCDD_VN_P

      IF(DSN.EQ.COOP_DS_P)THEN

         IF(VCN.EQ.FF1H_VN_P.OR.VCN.EQ.DD1H_VN_P.OR.
     1      VCN.EQ.U1H_VN_P.OR.VCN.EQ.V1H_VN_P)THEN

            FFVCN = FF1H_VN_P
            DDVCN = DD1H_VN_P

         ELSE IF(VCN.EQ.FF24H_VN_P.OR.VCN.EQ.DD24H_VN_P.OR.
     1           VCN.EQ.U24H_VN_P.OR.VCN.EQ.V24H_VN_P)THEN

            FFVCN = FF24H_VN_P
            DDVCN = DD24H_VN_P
            
         ELSE IF(VCN.EQ.FFMAX1H_VN_P.OR.VCN.EQ.DDMAX1H_VN_P)THEN

            FFVCN = FFMAX1H_VN_P
            DDVCN = DDMAX1H_VN_P
            
         ELSE IF(VCN.EQ.FFGUST_VN_P.OR.VCN.EQ.DDGUST_VN_P)THEN

            FFVCN = FFGUST_VN_P
            DDVCN = DDGUST_VN_P
            
         ENDIF

      ENDIF

C     ------------------------------------------------------------------
C     IF THE REQUESTED VARIABLE IS THE ONE STORED IN THE DATASET, READ
C     IT'S QC STRUCTURES DIRECTLY.  THEN, IF IT DOESN'T HAVE TO BE
C     ROTATED FOR THE USER'S GRID PROJECTION, READ THE VARIABLE AND
C     WE'RE DONE.
C     ------------------------------------------------------------------
      IF(VCN.EQ.SFCFF_VN_P.OR.VCN.EQ.SFCDD_VN_P.OR.
     1   VCN.EQ.FF1H_VN_P.OR.VCN.EQ.DD1H_VN_P.OR.
     2   VCN.EQ.FF24H_VN_P.OR.VCN.EQ.DD24H_VN_P.OR.
     3   VCN.EQ.FFGUST_VN_P.OR.VCN.EQ.DDGUST_VN_P.OR.
     4   VCN.EQ.FFMAX1H_VN_P.OR.VCN.EQ.DDMAX1H_VN_P)THEN


C     ASSUME QC OK, SET FOR DIFFERNET CONDITIONS
         QCSTATUS = EQCOK_P

         IF(VQC(VCN,DSN).EQ.'Q')THEN


            CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'QCA',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCAPP,STATUS)

            IF(STATUS.EQ.VAR_NOTINDB_P)THEN
               QCSTATUS = EQCFAILED_P
               STATUS = SUCCESS_P
               DO I = 1, SFC_NRECS(FNUM)
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'
               ENDDO
            ELSE IF(STATUS.NE.SUCCESS_P)THEN
               RETURN
            ELSE
               CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'QCR',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCRES,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN

               CALL MGTCHR(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'DD',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),QCDESC,LEN1REC,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
            ENDIF
         ELSE

            QCSTATUS = EQCFAILED_P
            DO 1 I = 1, SFC_NRECS(FNUM)
               QCAPP(I) = 0
               QCRES(I) = 0
               QCDESC(I) = 'Z'
 1          CONTINUE

         ENDIF

         IF(DMTYPE.NE.0.AND.DMTYPE.NE.1)THEN

            CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN)),SFC_NCID(FNUM),
     1                  SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),MISS_P,OB,
     2                  STATUS)


            IF((VCN.EQ.FFMAX1H_VN_P.OR.VCN.EQ.DDMAX1H_VN_P .OR.
     1           VCN.EQ.FFGUST_VN_P.OR.VCN.EQ.DDGUST_VN_P)  .AND.
     2           (DSN.EQ.COOP_DS_P))THEN

C     IF COOP AND FFMAX1H_VN_P/DDMAX1H_VN_P OR FFGUST_VN_P/DDGUST_VN_P, 
C     CHECK FOR OLD VERSION.  5 MIN GUST AND HOURLY GUST SHARE THE SAME 
C     VARIABLE, JUST DIFFER SOFTWARE VERSION.  VERIFY GUST ARE HOURLY 
C     GUST.

               CALL MGTNUM(
     1              VNAME(PLATTYP_VN_P,DSN)(1:VLEN(PLATTYP_VN_P,DSN)),
     2              SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     3              MISS_P,OBTMP(1,1),STATUS)
               IF(STATUS.EQ.VAR_NOTINDB_P .OR. STATUS.NE.SUCCESS_P)THEN
                  DO I = 1, SFC_NRECS(FNUM)
                     OB(I) = MISS_P
                     QCAPP(I) = 0
                     QCRES(I) = 0
                     QCDESC(I) = 'Z'
                  ENDDO
C     NON-HOURLY GUST (VCN.EQ.FFMAX1H_VN_P.OR.VCN.EQ.DDMAX1H_VN_P)
               ELSE IF(VCN.EQ.FFGUST_VN_P.OR.VCN.EQ.DDGUST_VN_P)THEN
                  DO I = 1, SFC_NRECS(FNUM)
                     IF (OBTMP(I,1).EQ.100.OR.OBTMP(I,1).EQ.200.OR.
     2                    (OBTMP(I,1).GE.1 .AND. OBTMP(I,1).LT.2))THEN
                        OB(I) = MISS_P
                        QCAPP(I) = 0
                        QCRES(I) = 0
                        QCDESC(I) = 'Z'
                     ELSE
C     OK
                     ENDIF
                  ENDDO
               ELSE
C     HOURLY GUST
                  DO I = 1, SFC_NRECS(FNUM)
                     IF (OBTMP(I,1).EQ.100.OR.OBTMP(I,1).EQ.200.OR.
     2                    (OBTMP(I,1).GE.1 .AND. OBTMP(I,1).LT.2))THEN
C     OK
                     ELSE
                        OB(I) = MISS_P
                        QCAPP(I) = 0
                        QCRES(I) = 0
                        QCDESC(I) = 'Z'
                     ENDIF
                  ENDDO
               ENDIF
            ENDIF


            RETURN

         ENDIF

      ENDIF

C     ------------------------------------------------------------------
C     READ IN THE QC FLAGS FROM FF, DD SO WE CAN USE THEM IN DECIDING
C     WHETHER OR NOT EACH WIND HAS BEEN FOUND BAD.  IF SO, WE WON'T
C     DO ANY CONVERSIONS FOR IT AND WILL RETURN MISSING DATA.
C     ------------------------------------------------------------------
      QCMISS(1) = .FALSE.
      IF(VQC(FFVCN,DSN).EQ.'Q')THEN

         CALL MGTNUM(VNAME(FFVCN,DSN)(1:VLEN(FFVCN,DSN))//
     1               'QCA',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),MISS_P,QCATMP(1,1),STATUS)
         IF(STATUS.EQ.VAR_NOTINDB_P)THEN
            QCMISS(1) = .TRUE.
            QCSTATUS = EQCFAILED_P
            STATUS = SUCCESS_P
            DO I = 1, SFC_NRECS(FNUM)
               QCATMP(I,1) = 0
               QCRTMP(I,1) = 0
               QCDTMP(I,1) = 'Z'
            ENDDO
         ELSE IF(STATUS.NE.SUCCESS_P)THEN
            RETURN
         ELSE
            CALL MGTNUM(VNAME(FFVCN,DSN)(1:VLEN(FFVCN,DSN))//
     1               'QCR',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),MISS_P,QCRTMP(1,1),STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN
            CALL MGTCHR(VNAME(FFVCN,DSN)(1:VLEN(FFVCN,DSN))//
     1               'DD',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),QCDTMP(1,1),LEN1REC,STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN
         ENDIF
      ELSE
         QCMISS(1) = .TRUE.
         QCSTATUS = EQCFAILED_P
         DO 11 I = 1, SFC_NRECS(FNUM)
            QCATMP(I,1) = 0
            QCRTMP(I,1) = 0
            QCDTMP(I,1) = 'Z'
 11      CONTINUE

      ENDIF

      QCMISS(2) = .FALSE.
      IF(VQC(DDVCN,DSN).EQ.'Q')THEN

         CALL MGTNUM(VNAME(DDVCN,DSN)(1:VLEN(DDVCN,DSN))//
     1               'QCA',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),MISS_P,QCATMP(1,2),STATUS)
         IF(STATUS.EQ.VAR_NOTINDB_P)THEN
            QCMISS(2) = .TRUE.
            QCSTATUS = EQCFAILED_P
            STATUS = SUCCESS_P
            DO I = 1, SFC_NRECS(FNUM)
               QCATMP(I,2) = 0
               QCRTMP(I,2) = 0
               QCDTMP(I,2) = 'Z'
            ENDDO
         ELSE IF(STATUS.NE.SUCCESS_P)THEN
            RETURN
         ELSE
            CALL MGTNUM(VNAME(DDVCN,DSN)(1:VLEN(DDVCN,DSN))//
     1               'QCR',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),MISS_P,QCRTMP(1,2),STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN
            CALL MGTCHR(VNAME(DDVCN,DSN)(1:VLEN(DDVCN,DSN))//
     1               'DD',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),QCDTMP(1,2),LEN1REC,STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN
         ENDIF
      ELSE
         QCMISS(2) = .TRUE.
         QCSTATUS = EQCFAILED_P
         DO 21 I = 1, SFC_NRECS(FNUM)
            QCATMP(I,2) = 0
            QCRTMP(I,2) = 0
            QCDTMP(I,2) = 'Z'
 21      CONTINUE

      ENDIF

C     ------------------------------------------------------------------
C     READ FF & DD.  CONVERT TO U/V.
C     ------------------------------------------------------------------
      CALL MGTNUM(VNAME(FFVCN,DSN)(1:VLEN(FFVCN,DSN)),
     1            SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2            MISS_P,OBTMP(1,1),STATUS)
      IF(STATUS.NE.SUCCESS_P)RETURN

      CALL MGTNUM(VNAME(DDVCN,DSN)(1:VLEN(DDVCN,DSN)),
     1            SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2            MISS_P,OBTMP(1,2),STATUS)
      IF(STATUS.NE.SUCCESS_P)RETURN

      DO 13 I = 1, SFC_NRECS(FNUM)
         CALL M_GETUV(OBTMP(I,2),OBTMP(I,1),MISS_P,COMPTMP(I,1),
     1                COMPTMP(I,2))
 13   CONTINUE

C     ------------------------------------------------------------------
C     IF NEEDED, ROTATE THE WIND COMPONENTS FOR THE USER'S PROJECTION.
C     NOTE THAT THIS REQUIRES GETTING THE LONGITUDE (WHICH, ALONG WITH
C     THE WINDS, ARE READ IN A FEW EXTRA TIMES IN ORDER TO KEEP THE
C     WIND LOGIC LOOK THE SAME AS ANYTHING ELSE AT THE CALLER'S LEVEL.
C     IF NEEDED TO SPEED THINGS UP, THESE DATA COULD BE KEPT IN COMMON,
C     BUT THAT WOULD TAKE UP MEMORY...)
C     ------------------------------------------------------------------
      IF(DMTYPE.EQ.0.OR.DMTYPE.EQ.1)THEN

         CALL MGTNUM(VNAME(LON_VN_P,DSN)(1:VLEN(LON_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2               MISS_P,LONTMP,STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

         DO 14 I = 1, SFC_NRECS(FNUM)

            IF(COMPTMP(I,1).NE.MISS_P.AND.COMPTMP(I,2).NE.MISS_P)THEN

               CALL M_ROTFAC(LONTMP(I),LON_XX_U,ROTCON_U,SINDL,COSDL)
               UTEMP = COMPTMP(I,1)
               VTEMP = COMPTMP(I,2)
               COMPTMP(I,1) = COSDL * UTEMP + SINDL * VTEMP
               COMPTMP(I,2) = -SINDL * UTEMP + COSDL * VTEMP

            ENDIF

 14      CONTINUE

      ENDIF

C     ------------------------------------------------------------------
C     IF FF OR DD IS WHAT THE USER WANTS, WE ALREADY HAVE THE QC.  NOW
C     CONVERT BACK TO FF/DD AND RETURN THE CHOSEN VARIABLE TO THE USER,
C     AND RETURN TO CALLER.
C     ------------------------------------------------------------------
      IF(VCN.EQ.FFVCN.OR.VCN.EQ.DDVCN)THEN

         IF(VCN.EQ.DDVCN)THEN
            VNUM = 1
         ELSE
            VNUM = 2
         ENDIF

         IF(QCMISS(1) .OR. QCMISS(2))THEN
            QCSTATUS = EQCFAILED_P
         ELSE
            QCSTATUS = EQCOK_P
         ENDIF

         DO 15 I = 1, SFC_NRECS(FNUM)

            IF(COMPTMP(I,1).EQ.MISS_P.OR.COMPTMP(I,2).EQ.MISS_P.OR.
     1         QCDTMP(I,1).EQ.'B'.OR.QCDTMP(I,1).EQ.'X'.OR.
     2         QCDTMP(I,1).EQ.'Q'.OR.QCDTMP(I,2).EQ.'B'.OR.
     3         QCDTMP(I,2).EQ.'X'.OR.QCDTMP(I,2).EQ.'Q')THEN

               OB(I) = MISS_P
               QCAPP(I) = 0
               QCRES(I) = 0
               QCDESC(I) = 'Z'

            ELSE

               CALL M_DDFF(COMPTMP(I,1),COMPTMP(I,2),MISS_P,WIND(1),
     1                     WIND(2))
               OB(I) = WIND(VNUM)
               IF(QCMISS(1) .OR. QCMISS(2))THEN
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'
               ENDIF
            ENDIF

 15      CONTINUE

         RETURN

      ENDIF

C     ------------------------------------------------------------------
C     COMBINE THE QC FOR FF & DD INTO ONE FLAG.  WHILE WE'RE AT IT,
C     STUFF IN THE DESIRED COMPONENT (THAT'S NOW BEEN ROTATED, IF
C     NEEDED) INTO THE CALLER'S OB ARRAY.  (YES, THAT'S CORRECT, WE
C     DON'T PROVIDE U/V FORMS OF THE DD/FF1HMAX COOP VARIABLES.)
C     ------------------------------------------------------------------


      IF(VCN.EQ.SFCU_VN_P.OR.VCN.EQ.U1H_VN_P.OR.VCN.EQ.U24H_VN_P)THEN
         VNUM = 1
      ELSE
         VNUM = 2
      ENDIF

      DO 31 I = 1, SFC_NRECS(FNUM)

         IF(COMPTMP(I,1).EQ.MISS_P.OR.COMPTMP(I,2).EQ.MISS_P.OR.
     1      QCDTMP(I,1).EQ.'B'.OR.QCDTMP(I,1).EQ.'X'.OR.
     2      QCDTMP(I,1).EQ.'Q'.OR.QCDTMP(I,2).EQ.'B'.OR.
     3      QCDTMP(I,2).EQ.'X'.OR.QCDTMP(I,2).EQ.'Q')THEN

            QCAPP(I) = 0
            QCRES(I) = 0
            QCDESC(I) = 'Z'
            OB(I) = MISS_P

         ELSE

            QCAPP(I) = 0
            QCRES(I) = 0

            OB(I) = COMPTMP(I,VNUM)

C     ------------------------------------------------------------------
C     IF QC MISSING, SET MISSING, ELSE PROCESS AS ASSIGNED
C     ------------------------------------------------------------------
            IF(QCSTATUS .EQ. EQCFAILED_P)THEN
               QCAPP(I) = 0
               QCRES(I) = 0
               QCDESC(I) = 'Z'
            ELSE



C     ------------------------------------------------------------------
C     PUT THE QC APPLIED/RESULTS WORDS INTO INTEGER FORMAT (THEIR
C     TRUE NATURE) SO WE CAN EXAMINE THE BITS, AND COMBINE THEM.
C     ------------------------------------------------------------------
               QCA(1) = QCATMP(I,1)
               QCA(2) = QCATMP(I,2)
               QCR(1) = QCRTMP(I,1)
               QCR(2) = QCRTMP(I,2)
               QCARET = 0
               QCRRET = 0

               DO 32 J = 1, MAX_SFC_QCCHK_P

                  CALL M_CHCKQC(QCA(1),J,VAL,STATUS)
                  IF(VAL.EQ.1)CALL M_SETQC(QCARET,J,QCARET,STATUS)
                  CALL M_CHCKQC(QCA(2),J,VAL,STATUS)
                  IF(VAL.EQ.1)CALL M_SETQC(QCARET,J,QCARET,STATUS)
                  CALL M_CHCKQC(QCR(1),J,VAL,STATUS)
                  IF(VAL.EQ.1)CALL M_SETQC(QCRRET,J,QCRRET,STATUS)
                  CALL M_CHCKQC(QCR(2),J,VAL,STATUS)
                  IF(VAL.EQ.1)CALL M_SETQC(QCRRET,J,QCRRET,STATUS)
                  
 32            CONTINUE

C     ------------------------------------------------------------------
C     IF EITHER THE SPEED OR DIR DESCRIPTOR SHOWS SUBJECTIVE QC, USE
C     THAT VALUE.  OTHERWISE, TRANSLATE THE NEW QCAPP/QCRES INTO THE
C     DESCRIPTOR TO BE RETURNED.
C     ------------------------------------------------------------------
               IF(QCDTMP(I,1).EQ.'G'.OR.QCDTMP(I,1).EQ.'B')THEN

                  QCDESC(I) = QCDTMP(I,1)

               ELSE IF(QCDTMP(I,2).EQ.'G'.OR.QCDTMP(I,2).EQ.'B')THEN

                  QCDESC(I) = QCDTMP(I,2)

               ELSE

                  CALL M_MKDESC(QCARET,QCRRET,QCDESC(I))

               ENDIF

               QCAPP(I) = QCARET
               QCRES(I) = QCRRET
            ENDIF
         ENDIF

 31   CONTINUE

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