C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MSETHYDROPVDR SET HYDRO PROVIDER TO ENABLED/DISABLED
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 01-07-24
C
C ABSTRACT: ENABLE OR DISABLE ONE MADIS DATA PROVIDER.
C
C PROGRAM HISTORY LOG:
C   01-07-24  M. BARTH    ORIGINAL VERSION
C   03-05-27  M. BARTH    CHANGES RESULTING FROM REMOVAL OF THE SUBSRCIN
C                         FILE FOR THIS DATASET:  WHEN A PROVIDER ISN'T
C                         FOUND, DON'T RETURN AN ERROR.  INSTEAD, KEEP A
C                         LIST OF PROVIDERS THAT AREN'T FOUND FOR USE 
C                         LATER ON WHEN THEY ARE FOUND IN THE INPUT 
C                         DATA.
C   09/27/05  L. BENJAMIN REDUCED COMMENT SIZE.  NO CODE CHANGE.
C
C USAGE:    CALL MSETHYDROPVDR (PROVDR,FLAG,STATUS)
C
C   INPUT ARGUMENT LIST:
C     PROVDR   - C       PROVIDER NAME (.LE. 10 CHARACTERS)
C     FLAG     - L       .TRUE. - ENABLE, .FALSE. - DISABLE
C
C   OUTPUT ARGUMENT LIST:
C     STATUS   - I       0 - SUCCESS, OR ERROR CODE
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MERROR
C
C REMARKS:
C   - IN ADDITION TO THE PROVIDER NAMES THE CALLER CAN USE 'ALL-HYDRO' 
C   - THE MADISCOM PROVIDER ARRAYS (NPVD, PVDNAME, ETC.) HAVE SFC
C     PROVIDERS IN ROW 1, HYDRO PROVIDERS IN ROW 2.
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MSETHYDROPVDR(PROVDR,FLAG,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      CHARACTER*(*) PROVDR
      INTEGER STATUS
      LOGICAL FLAG

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      CHARACTER*10 PROVDR_L
      INTEGER N,I

      N = LEN(PROVDR)
      PROVDR_L = PROVDR(1:N)
      DO 1 I = 10, N+1, -1
         PROVDR_L(I:I) = ' '
 1    CONTINUE

      IF(HYDRO_INIT.NE.INIT_P)THEN
         STATUS = SELSUB_NOTINIT_P
         CALL MERROR('MSETHYDROPVDR: SELECTED SUBSYSTEM NOT '//
     1               'INITIALIZED - HYDRO')
         GO TO 900
      ENDIF

      STATUS = SUCCESS_P

      IF(PROVDR_L.EQ.'ALL-HYDRO ')THEN

C     ------------------------------------------------------------------
C     USE FLAG FOR ALL PROVIDERS ALREADY IDENTIFIED, AND USE IT FOR ANY 
C     NEW PROVIDERS THAT HAVE ALREADY BEEN SPECIFIED VIA AN EARLIER CALL
C     TO THIS ROUTINE, BUT THAT HAVEN'T YET SHOWN UP AND GOTTEN
C     ENABLED/DISABLED.
C     ------------------------------------------------------------------
         DO 2 I = 1, MAX_HYDRODSET_P
            HYDRODSET_ENBL(I) = FLAG
 2       CONTINUE

         DO 3 I = 1, NPVD(2)
            PROVDR_ENBL(I,2) = FLAG
 3       CONTINUE

         ALL_ENBL(2) = FLAG

         DO I = 1, NNEWPVD(2)
            NEW_ENBL(I,2) = FLAG
         ENDDO

      ELSE

C     ------------------------------------------------------------------
C     WE CURRENTLY ONLY HAVE ONE HYDRO DATASET.  IF & WHEN WE HAVE MORE,
C     WE'LL NEED TO CHECK THE PROVDR_L AGAINST NON-LDAD-HYDRO ONES,
C     AND ACT ACCORDINGLY (AS IN THE SFC VERSION OF THIS ROUTINE).
C     ------------------------------------------------------------------
         HYDRODSET_ENBL(LHYDRO_DS_P) = FLAG

         DO 5 I = 1, NPVD(2)

            IF(PVDNAME(I,2).EQ.PROVDR_L)THEN

               PROVDR_ENBL(I,2) = FLAG

               GO TO 100

            ENDIF

 5       CONTINUE

C     ------------------------------------------------------------------
C     IF WE HAVEN'T HIT MAX_SUBSRC_P IN THE NEW PROVIDER LIST, ADD
C     AN ENTRY FOR THIS AS-YET-UNKNOWN PROVIDER.
C     ------------------------------------------------------------------
         IF(NNEWPVD(2).NE.MAX_SUBSRC_P)THEN
               
            NNEWPVD(2) = NNEWPVD(2) + 1
            NEWPVDNAME(NNEWPVD(2),2) = PROVDR_L
            NEW_ENBL(NNEWPVD(2),2) = FLAG

         ENDIF

      ENDIF

 100  IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     CLEAR THE LAST TIME READ FIELD SO NEW STATIONS WILL HAVE TO BE
C     LOADED.  
C     ------------------------------------------------------------------
         LAST_HYDRO_ATIME = '         '

      ENDIF

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