C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MGETVCN     GET VCN FROM VARIABLE CODE NAME
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 00-07-26
C
C ABSTRACT: TRANSLATE USER'S VARIABLE CODE NAME INTO THE VARIABLE
C   CODE NUMBER ("VCN") USED INTERNALLY.
C
C PROGRAM HISTORY LOG:
C   01-07-26  M. BARTH    ORIGINAL VERSION
C   03-09-24  M. BARTH    - ADDED SATWND DATASETS
C                         - CHANGED DSET NAMES FROM 9 TO 20 CHARACTERS
C   04-03-24  M. BARTH    CHANGED THE "REMARKS" COMMENT ON SORTING
C   04-10-01  L. BENJAMIN - ADDED SATSND DATASETS
C   05-10-27  L. BENJAMIN - ADDED SATRAD DATASETS
C   05-11-18  L. BENJAMIN - ADDED SNOW DATASETS
C   08-07-12  L. BENJAMIN - ADDED WISDOM DATASETS
C
C USAGE:    CALL MGETVCN (VCODE,VCN,VCT,STATUS)
C
C   INPUT ARGUMENT LIST:
C     VCODE    - C       USER'S VARIABLE CODE NAME  
C
C   OUTPUT ARGUMENT LIST:
C     VCN      - I       INTERNAL VARIABLE CODE NUMBER
C     VCT      - C       VARIABLE CODE TYPE ('N' - NUMBER, 'C' - CHAR)
C     STATUS   - I       SUCCESS_P OR INV_VCN_P
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MERROR, M_CBSRCH
C
C REMARKS:
C   NOTE THAT WHEN YOU'RE DEVELOPING A NEW DATASET, IF YOU GET AN ERROR
C   FROM MGETVCN THAT SAYS YOU'VE GOT AN INVALID VARIABLE WHEN YOU KNOW
C   IT'S VALID, THE PROBLEM IS MOST LIKELY THAT THE *VCN.TXT FILE
C   HASN'T BEEN ALPHABETICALLY SORTED -- THIS IS REQUIRED.  ALSO,
C   ***** AND THIS IS IMPORTANT *****, BECAUSE OF OS ODDITIES, YOU NEED
C   TO MAKE SURE THAT THE SORT IS DONE:
C
C   SORT -K 1,1 XXXVCN.TXT > WHATEVER
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MGETVCN(VCODE,VCN,VCT,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      CHARACTER*(*) VCODE,VCT
      INTEGER VCN,STATUS

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      INTEGER I
      CHARACTER*7 NAME
      CHARACTER*20 DSET
      LOGICAL MATCH

C     *****************************************************************
C     ******************* BEGIN OF MGETVCN ****************************
C     *****************************************************************

C     ------------------------------------------------------------------
C     ASSUME FAILURE.  MAKE SURE THAT THE VCODE ISN'T TOO LONG, THEN
C     CALL THE BINARY SEARCH ROUTINE TO FIND A MATCH.
C     ------------------------------------------------------------------
      STATUS = INV_VCN_P
      I = LEN(VCODE)

      IF(I.LE.7)THEN

         NAME = '       '
         NAME(1:I) = VCODE
         CALL M_CBSRCH(VCNAME(1,CDTYPE),NAME,NVCODE(CDTYPE),I,MATCH)
         IF(MATCH)THEN
            VCN = VCVCN(I,CDTYPE)
            VCT = VTYPE(I,CDTYPE)
            STATUS = SUCCESS_P

         ENDIF


      ENDIF

      IF(STATUS.EQ.INV_VCN_P)THEN

         IF(CDTYPE.EQ.SFC_DS_P)THEN

            DSET = 'SFC'
         
         ELSE IF(CDTYPE.LE.MAX_UAPTDSET_P)THEN

            DSET = UAPTDSET_NAME(CDTYPE)

         ELSE IF(CDTYPE.EQ.HYD_DS_P)THEN

            DSET = 'HYDRO'

         ELSE IF(CDTYPE.EQ.SATW_DS_P)THEN

            DSET = 'SATWND'

         ELSE IF(CDTYPE.EQ.SATS_DS_P)THEN

            DSET = 'SATSND'

         ELSE IF(CDTYPE.EQ.SATR_DS_P)THEN

            DSET = 'SATRAD'

         ELSE IF(CDTYPE.EQ.SNOW_DS_P)THEN

            DSET = 'SNOW'

         ELSE IF(CDTYPE.EQ.WISDOM_DS_P)THEN

            DSET = 'WISDOM'

         ENDIF

         CALL MERROR('MGETVCN: INVALID VARIABLE CODE -- '//DSET//
     1               ' -- '//NAME)

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