C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MSETQC      SET QC FILTERING CHOICE
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 99-09-28
C
C ABSTRACT: SET QC FILTERING CHOICE, BASED ON DATA DESCRIPTOR VALUES.
C   SEE REMARKS SECTION FOR DISCUSSION OF THE FILTERING.
C
C PROGRAM HISTORY LOG:
C   99-09-28  M. BARTH    ORIGINAL VERSION
C   00-03-23  M. BARTH    - CHANGES TO ALLOW FOR UPPER-AIR-POINT DATA
C                         - ADDED IQCTYPE 99
C
C USAGE:    CALL MSETQC (IQCTYPE,STATUS)
C
C   INPUT ARGUMENT LIST:
C     IQCTYPE  - I       QC FILTERING TYPE:
C
C                        0 - NO QC FILTERING (DEFAULT)
C                        1 - "COARSE":   PASSED AT LEAST STAGE 1
C                        2 - "SCREENED": PASSED AT LEAST STAGE 2
C                        3 - "VERIFIED": PASSED AT LEAST STAGE 3
C                       99 - HIGHEST QC POSSIBLE FOR VARIABLE/DATASET
C
C   OUTPUT ARGUMENT LIST:
C     STATUS   - I       0 - SUCCESS, OR ERROR CODE
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MERROR
C
C REMARKS:
C   - WITHOUT CALLING THIS ROUTINE, BY DEFAULT ALL OBS WILL BE
C     RETURNED, ALONG WITH THEIR QC STRUCTURES, AND THE CALLER CAN
C     SORT OUT WHAT HE OR SHE WANTS BY HIM OR HERSELF.
C   - ONLY VALUES PASSING QC WILL BE RETURNED.  IN OTHER WORDS,
C     IF THE USER SELECTS COARSE QC FILTERING, AND WE HAVE AN OB
C     THAT PASSED THE STAGE 1 CHECKS BUT FAILED A HIGHER-ORDER
C     CHECK, THE OB WILL BE FILTERED.
C   - SUBJECTIVE QC OVERRIDES THE QC CHECKS.  THEREFORE, IF QC
C     FILTERING IS TURNED ON, SUBJECTIVE GOOD WILL ALWAYS BE
C     RETURNED AND SUBJECTIVE BAD WILL ALWAYS BE FILTERED.
C   - THE FQCINC FUNCTION CAN BE USED TO INQUIRE ABOUT THE HIGHEST
C     LEVEL OF QC POSSIBLY AVAILABLE FOR A GIVEN VARIABLE, AND THE
C     VALUE RETURNED BY THAT FUNCTION CAN BE USED AS INPUT TO THIS
C     ROUTINE.  ALTERNATIVELY, THE USER CAN SPECIFY THE HIGHEST LEVEL
C     POSSIBLE BE USED FOR EACH VARIABLE/DATASET BY SETTING IQCTYPE
C     TO 99.
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MSETQC (IQCTYPE,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      INTEGER IQCTYPE,STATUS

C     ------------------------------------------------------------------
C     IF NO SUBSYSTEM HAS BEEN INITIALIZED, RETURN WITH ERROR.
C     ------------------------------------------------------------------
      IF(MADIS_INIT.NE.INIT_P)THEN
         STATUS = SUB_NOTINIT_P
         CALL MERROR('MSETQC: NO MADIS SUBSYSTEM INITIALIZED')
         RETURN
      ENDIF

C     ------------------------------------------------------------------
C     KNOCK OUT THE CURRENT QC FILTERING SELECTION.  VALIDATE INPUT,
C     AND FILL THE SELECTION IN THE COMMON IF INPUT'S VALID.
C     ------------------------------------------------------------------
      QCTYPE = 0
      IF(IQCTYPE.LT.0.OR.(IQCTYPE.GT.MAX_QC_STAGE_P.AND.
     1   IQCTYPE.NE.99))THEN

         STATUS = INV_QCT_P
         CALL MERROR('MSETQC: INVALID QC TYPE')

      ELSE

         QCTYPE = IQCTYPE
         STATUS = SUCCESS_P

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