C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MINIT       INITIALIZE MADIS SUBSYSTEM
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 99-09-14
C
C ABSTRACT: INITIALIZE VARIOUS MADIS SUBSYSTEMS
C
C PROGRAM HISTORY LOG:
C   99-09-14  M. BARTH    ORIGINAL VERSION
C   99-11-19  M. BARTH    ADDED 'AWIPS' SUBSYSTEM
C   00-02-01  M. BARTH    ADDED 'EXTERNAL' SUBSYSTEM
C   00-03-22  M. BARTH    ADDED 'RAOB', 'NPN' & 'ACARS' SUBSYSTEMS
C   00-06-13  M. BARTH    ACTIVATED THE 'ACARS' SUBSYSTEM
C   01-04-27  M. BARTH    CHANGES FOR AWIPS-STYLE FILES/DIRECTORIES
C   01-06-29  M. BARTH    - REMOVED PSOS AND GSOS DATASETS
C                         - REMOVED AWIPS SUBSYSTEM
C                         - ADDED DBASE ARGUMENT AND PROCESSING
C                         - ADDED MTMRNG CALL
C                         - USE ENVIRONMENT VARIABLES TO DETERMINE
C                           DATA & STATIC FILE DIRECTORY PATHS
C                         - ADDED 'HYDRO' SUBSYSTEM
C                         - ADDED MRDVCODE STUFF
C   02-04-30  M. BARTH    ADDED 'MAP' SUBSYSTEM
C   03-05-27  M. BARTH    - REMOVED SUBSRCIN FILE ARGUMENT FROM
C                           MUAPTINIT AND MHYDROINIT.
C                         - ADDED DUMMY SATW DATASET (FOR WRF 3DVAR).
C                         - CHANGED WHERE AWIPS2_DB IS SET SO THAT
C                           MINIT CALLS FOR NON-SFC DATASETS DON'T
C                           AFFECT THE AWIPS2_DB CHOICE FOR SFC.
C   03-07-01  M. BARTH    ADDED 'RDMTR' SUBSYSTEM
C   03-09-24  M. BARTH    REPLACED DUMMY 'SATW' SUBSYSTEM WITH REAL
C                         'SATWND' SUBSYSTEM
C   03-10-03  M. BARTH    - ADDED THE ABILITY TO USE OPENDAP/DODS OR
C                           TO RUN THIS ON THE MADIS WEB SERVER (WHERE
C                           WE NEED TO GUNZIP THE DATA FILES BEFORE
C                           OPENING THEM)
C                         - ADDED ACARS TO AWIPS DATABASE SUPPORT
C   04-03-22  M. BARTH    ADDED 'COOP' AS A SFC DATASET.
C   04-06-16  M. BARTH    ADDED 'ACARSP' SUBSYSTEM
C   04-08-19  M. BARTH    ADDED MADIS_SERVER_ROOT ENVIRONMENT VARIABLE
C                         FOR USE IN DEFINING THE PATH TO BE USED FOR
C                         TEMPORARY UNZIPPED MADIS DATA FILES.  ALSO
C                         TOOK DATA_DIR OUT OF THE PATHS TO EACH
C                         DIRECTORY -- THIS IS SO THAT MMADISOPEN
C                         CAN CHOOSE THE APPROPRIATE ROOT.
C   04-09-24  L. BENJAMIN ADDED 'SATS' SUBSYSTEM
C   05-10-25  L. BENJAMIN ADDED 'SATR' SUBSYSTEM
C   05-11-18  L. BENJAMIN ADDED 'SNOW' SUBSYSTEM
C   06-08-02  L. BENJAMIN ADDED 'UrbaNet' AS A SFC DATASET
C   07-04-27  L. BENJAMIN CHANGED OPENDAP/DODS TAG FROM "HTTP://"
C                         AT THE BEGINING TO ANYWHERE IN THE LINE
C   08-06-13  L. BENJAMIN ADDED SETTING EXTRA MISSING VALUE CHECK FOR
C                         AWIPS AND ACARS CASES.
C   08-06-23  M. BARTH    ADDED HIGH FREQUENCY METAR AS A SFC DATASET.
C   09-07-23  L. BENJAMIN ADDED NEPP, HCN, AND CRN AS A SFC DATASETS.
C   11-01-04  L. BENJAMIN ADDED "HTTPS://" TO OPENDAP/DODS TAGS
C
C 
C USAGE:    CALL MINIT (SUB,DBASE,ERRFLG,STATUS)
C
C   INPUT ARGUMENT LIST:
C     SUB      - C       NAME OF SUBSYSTEM TO INITIALIZE:
C                        'SFC'      SURFACE
C                        'EXTERNAL' FOR USAGE OF MADISLIB
C                                   CALLS BY PROGRAMS
C                                   NOT READING MADIS DATA
C                        'RAOB'     RADIOSONDE
C                        'NPN'      NOAA PROFILER NETWORK
C                        'ACARS'    ACARS
C                        'ACARSP'   ACARS PROFILES
C                        'MAP'      MULTI-AGENCY PROFILERS
C                        'HYDRO'    HYDRO
C                        'SATWND'   SATELLITE WINDS
C                        'RDMTR'    RADIOMETER
C                        'SATSND'   SATELLITE SOUNDINGS
C                        'SATRAD'   SATELLITE RADIANCE
C                        'SNOW'     SNOW
C     DBASE    - C       NAME OF DATABASE TO USE:
C                        'FSL'      DATA OBTAINED FROM FSL
C                        'AWIPS'    DATA OBTAINED FROM AWIPS
C                        'AWIPS2'   DATA OBTAINED FROM AWIPS, BUT
C                                   USE UN-QC'ED MESONET FILES
C     ERRFLG   - L       TRUE  - OUTPUT ERROR MSGS TO STDOUT
C                        FALSE - DON'T OUTPUT ERROR MSGS
C
C   OUTPUT ARGUMENT LIST:
C     STATUS   - I       0 - SUCCESS, OR ERROR CODE
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MERROR, MSFCCLS, MSFCINIT, MTMRNG, MUAPTCLS, MUAPTINIT,
C                MSATWNDINIT, M_LSTCHR, MHYDROCLS, MHYDROINIT, MRDVCODE,
C                MSATWNDCLS, MSATSNDINIT, MSATSNDCLS, MSATRADINIT, 
C                MSATRADCLS, MSNOWINIT, MSNOWCLS
C     NETCDF:    NCPOPT
C
C REMARKS:
C   - OPENDAP/DODS ACCESS IS DONE BY DETECTING THAT THE MADIS_DATA
C     ENVIRONMENT VARIABLE IS A URL.  IN THAT CASE, DATA FILES ARE
C     OPENED WITH A ".gz" EXTENSION.
C   - MADIS WEB SERVER PROCESSING IS INDICATED BY THE PRESENCE OF THE
C     MADIS_SERVER ENVIRONMENT VARIABLE.  IF THAT VARIABLE EXISTS AND
C     IS SET TO "ACTIVE", THEN THE USER'S PID IS SAVED BY THIS ROUTINE
C     AND USED WHEN CREATING TEMPORARY FILES WITH GUNZIPPED DATA PRIOR
C     TO OPENING THE FILES IN THE MMADISOPEN ROUTINE.  THE TEMPORARY
C     FILES ARE PLACED INTO A MADIS DIRECTORY TREE WHOSE ROOT IS
C     POINTED TO BY THE MADIS_SERVER_ROOT ENVIRONMENT VARIABLE.
C   - NOTE THAT OPENDAP/DODS AND MADIS SERVER ACCESS ARE MUTUALLY
C     EXCLUSIVE.
C   - MISS_AWIPS_VAL2 AND MISS_ACARS_VAL2 ARE USED FOR SPECIAL
C     MISSING VALUES CHECKS.  USE THE DEFAULT MISSING VALUES UNLESS
C     THE DATASET HAS ALTERNATIVE ONES.

C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MINIT(SUB,DBASE,ERRFLG,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      CHARACTER*(*) SUB,DBASE
      LOGICAL       ERRFLG
      INTEGER       STATUS

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      INTEGER I,SLEN,ALEN,M_LSTCHR,GETPID,HIDX
      CHARACTER*255 STATIC_DIR,SERVER_ACTIVE
      CHARACTER*6 PID

C     ------------------------------------------------------------------
C     TRANSFER CALLER'S ERROR FLAG TO COMMON AND SET NON-FATAL,
C     NON-VERBOSE NETCDF ERROR HANDLING (WE'LL HANDLE THEM).
C     ------------------------------------------------------------------
      VERBOSE = ERRFLG
      CALL NCPOPT(0)

C     ------------------------------------------------------------------
C     SPECIAL MISSING CASE FOR AWIPS_DB_P DATA.  SOME DATA SETS HAVE 
C     MULTIPLE MISSING VALUES, THIS VARIABLE IS USED TO HANDLE THOSE 
C     CASES.  IT'S DEFAULT SETTING IS THE DEFAULT AWIPS MISSING VALUE.  
C     BELOW IN THE DS ASSIGNMENT THE SECOND MISSING VALUE IS SET IF 
C     NEEDED.
C     ------------------------------------------------------------------
      MISS_AWIPS_VAL2 = -99999.0

C     ------------------------------------------------------------------
C     SPECIAL MISSING CASE FOR ACARS DATA.  ACARS DATA HAS A SECOND
C     MISSING VALUES, THIS VARIABLE IS USED TO HANDLE THOSE 
C     CASES.  IT'S DEFAULT SETTING IS THE DEFAULT REAL MISSING VALUE.  
C     IN THE ACARS DS ASSIGNMENT TEH ACRARS SPECIAL CASE VALUE IS
C     ASSIGNED.
C     ------------------------------------------------------------------
      MISS_ACARS_VAL2 = 3.40282346E+38
C     ------------------------------------------------------------------
C     READ IN THE ENVIRONMENT VARIABLES USED TO SPECIFY THE PATHS TO
C     THE STATIC FILES AND DATA DIRECTORIES.  MAKE SURE THAT THESE
C     WON'T PRODUCE FILENAMES LONGER THAN 255 CHARACTERS.  
C
C     THEN DETERMINE IF ANY PART OF THE MADIS_DATA VARIABLE IS 
C     "HTTP://" OR "HTTPS://".  IN THAT CASE WE'RE BEING USED VIA 
C     OPENDAP/DODS, AND WE'LL NEED TO OPEN THE NETCDF FILES WITH A ".gz" 
C     ENVIRONMENT EXTENSION.  IF THAT'S NOT THE CASE, DETERMINE IF THE 
C     MADIS_SERVER VARIABLE EXISTS, AND IF SO, IS EQUAL TO "ACTIVE".  
C     THIS MEANS THAT WE'RE BEING RUN ON THE MADIS WEB SERVER AND WILL 
C     NEED TO GET THE USER'S PID FOR LATER USE BY MMADISOPEN IN CREATING 
C     TEMPORARY GUNZIPPED DATA FILES.  WE'LL ALSO NEED TO GET THE ROOT 
C     OF THE MADIS DIRECTORY TREE TO BE USED FOR THE TEMPORARY FILES 
C     FROM THE MADIS_SERVER_ROOT ENVIRONMENT VARIABLE.  
C     ------------------------------------------------------------------
      CALL GETENV('MADIS_STATIC',STATIC_DIR)
      SLEN = M_LSTCHR(STATIC_DIR,255)
      IF(SLEN.EQ.0)THEN
         STATUS = NO_SDIR_P
         CALL MERROR('MINIT: MADIS_STATIC ENVIRONMENT VARIABLE'//
     1               ' NOT DEFINED')
         RETURN
      ELSE IF(SLEN.GT.238)THEN
         STATUS = INV_SDIR_P
         CALL MERROR('MINIT: MADIS_STATIC DIRECTORY PATH TOO LONG')
         RETURN
      ENDIF

      CALL GETENV('MADIS_DATA',DATA_DIR)
      DLEN = M_LSTCHR(DATA_DIR,255)
      IF(DLEN.EQ.0)THEN
         STATUS = NO_DDIR_P
         CALL MERROR('MINIT: MADIS_DATA ENVIRONMENT VARIABLE'//
     1               ' NOT DEFINED')
         RETURN
      ELSE IF(DLEN.GT.227)THEN
         STATUS = INV_DDIR_P
         CALL MERROR('MINIT: MADIS_DATA DIRECTORY PATH TOO LONG')
         RETURN
      ENDIF
      HIDX = INDEX(DATA_DIR(1:DLEN),'http://')
      IF(HIDX.EQ.0)HIDX = INDEX(DATA_DIR(1:DLEN),'HTTP://')
      IF(HIDX.EQ.0)HIDX = INDEX(DATA_DIR(1:DLEN),'https://')
      IF(HIDX.EQ.0)HIDX = INDEX(DATA_DIR(1:DLEN),'HTTPS://')
      IF(HIDX.GT.0)THEN
         FEXT = '.gz        '
      ELSE
         FEXT = '           '
         CALL GETENV('MADIS_SERVER',SERVER_ACTIVE)
         ALEN = M_LSTCHR(SERVER_ACTIVE,255)
         IF(ALEN.GE.6)THEN
            IF(INDEX(SERVER_ACTIVE(1:ALEN),'ACTIVE').GT.0)THEN

               I = GETPID()
               IF(I.LE.99999)THEN
                  WRITE(PID,1000)I
 1000             FORMAT(I6)
               ELSE
                  WRITE(PID,1000)MOD(I,100000)
                  PID(1:1) = 'M'
               ENDIF
               DO I = 1, 6
                  IF(PID(I:I).EQ.' ')PID(I:I) = '0'
               ENDDO
               FEXT = '.tmp.'//PID

               CALL GETENV('MADIS_SERVER_ROOT',TMP_DIR)
               TLEN = M_LSTCHR(TMP_DIR,255)
               IF(TLEN.EQ.0)THEN
                  STATUS = NO_TDIR_P
                  CALL MERROR('MINIT: MADIS_SERVER_ROOT ENVIRONMENT '//
     1                        'VARIABLE NOT DEFINED')
                  RETURN
               ELSE IF(TLEN.GT.227)THEN
                  STATUS = INV_TDIR_P
                  CALL MERROR('MINIT: MADIS_SERVER_ROOT DIRECTORY'//
     1                        ' PATH TOO LONG')
                  RETURN
               ENDIF

            ENDIF
         ENDIF
      ENDIF

C     ------------------------------------------------------------------
C     INDICATE WHICH DATABASE IS BEING USED FOR THE DATASET BEING
C     INITIALIZED.  IF UNKNOWN, RETURN WITH ERROR.
C     ------------------------------------------------------------------
      IF(DBASE(1:3).EQ.'FSL')THEN

         CDBTYPE = FSL_DB_P

      ELSE IF(DBASE(1:6).EQ.'AWIPS2')THEN

         CDBTYPE = AWIPS_DB_P

      ELSE IF(DBASE(1:5).EQ.'AWIPS')THEN

         CDBTYPE = AWIPS_DB_P

      ELSE

         STATUS = INV_DB_P
         CALL MERROR('MINIT: INVALID DATABASE')
         RETURN

      ENDIF

C     ------------------------------------------------------------------
C     INITIALIZE THE SELECTED SUBSYSTEM (OR RETURN WITH INVALID SUBSYS
C     ERROR).
C     ------------------------------------------------------------------
      IF(SUB(1:3).EQ.'SFC')THEN

C     ------------------------------------------------------------------
C     IF THIS IS THE AWIPS SFC DATABASE, INDICATE WHETHER OR NOT THIS
C     IS THE AWIPS2 OPTION.
C     ------------------------------------------------------------------
         IF(DBASE(1:6).EQ.'AWIPS2')THEN
            AWIPS2_DB = .TRUE.
         ELSE
            AWIPS2_DB = .FALSE.
         ENDIF

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET SFCINIT DO MOST OF THE WORK, AND HAVE MRDVCODE
C     READ IN THE LIST OF VARIABLE CODE NAMES & NUMBERS FOR THIS TYPE.
C     ------------------------------------------------------------------
         IF(SFC_INIT.EQ.INIT_P)CALL MSFCCLS

         CALL MSFCINIT(STATIC_DIR(1:SLEN)//'/sfctbl.txt',
     2                 STATIC_DIR(1:SLEN)//'/stadic.txt',
     3                 STATIC_DIR(1:SLEN)//'/sfcsrcin.txt',
     4                 STATIC_DIR(1:SLEN)//'/topomini.txt',
     5                 STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(SFC_DS_P,STATIC_DIR(1:SLEN)//'/sfcvcn.txt',
     2                    STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            SFCDIR(1) = '/point/metar/netcdf/'
            SFCDIRLEN(1) = 20
            SFCDIR(2) = '/point/maritime/netcdf/'
            SFCDIRLEN(2) = 23
            SFCDIR(3) = '/point/sao/netcdf/'
            SFCDIRLEN(3) = 18
            SFCDIR(5) = '/LDAD/coop/netCDF/'
            SFCDIRLEN(5) = 18
            SFCDIR(6) = '/LDAD/urbanet/netCDF/'
            SFCDIRLEN(6) = 21
            SFCDIR(7) = '/LDAD/hfmetar/netCDF/'
            SFCDIRLEN(7) = 21
            SFCDIR(8) = '/LDAD/nepp/netCDF/'
            SFCDIRLEN(8) = 18
            SFCDIR(9) = '/LDAD/hcn/netCDF/'
            SFCDIRLEN(9) = 17
            SFCDIR(10) = '/LDAD/crn/netCDF/'
            SFCDIRLEN(10) = 17

            IF(DBASE(1:3).EQ.'FSL'.OR.DBASE(1:6).EQ.'AWIPS2')THEN

               SFCDIR(4) = '/LDAD/mesonet/netCDF/'
               SFCDIRLEN(4) = 21

            ELSE

               SFCDIR(4) = '/LDAD/mesonet/qc/'
               SFCDIRLEN(4) = 17

            ENDIF

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.
C
C     NOTE THESE SPECIAL CASES:
C
C     - THE AWIPS DATABASE SAO/COOP/URBANET/HFMETAR/NEPP/HCN/CRN 
C       DATASETS DON'T EXIST IN THE REAL AWIPS DATABASE, BUT A USER 
C       MAY GET THESE DATASETS FROM FSL TO AUGMENT HIS/HER AWIPS 
C       DATABASE.  THEREFORE WE'LL TURN OFF VERBOSE ERROR HANDLING 
C       AND TRY TO READ THEIR TEMPLATES.  IF ONE OF THEM ISN'T THERE, 
C       WE'LL DISABLE THAT DATASET.
C
C     - THE AWIPS DATABASE MESONET/QC DIRECTORY TEMPLATE IS WRONG
C       IN BUILDS 5.1.2 AND EARLIER.  THEREFORE WE'LL USE THE MESONET
C       TEMPLATE FOR THE FSL DATABASE (WHICH HAS THE SAME TIME INVENTORY
C       STRUCTURES & VALUES).
C     ------------------------------------------------------------------
            IF(DBASE(1:5).EQ.'AWIPS')THEN

               DO 100 I = 1, MAX_SFCDSET_P

                  IF(I.EQ.SAO_DS_P.OR.I.EQ.COOP_DS_P.OR.
     1               I.EQ.URBANET_DS_P.OR.
     2               I.EQ.HFMETAR_DS_P.OR.I.EQ.NEPP_DS_P.OR.
     3               I.EQ.HCN_DS_P.OR.I.EQ.CRN_DS_P
     4                 )VERBOSE = .FALSE.
                  IF(DBASE(1:5).EQ.'AWIPS'.AND..NOT.AWIPS2_DB)THEN
                     CALL MTMRNG(STATIC_DIR(1:SLEN)//
     1                           '/mesonet.template',SLEN+17,
     2                           SFCDSET_CUTOFF(I),SFCDSET_INCR(I),
     3                           STATUS)
                  ELSE
                     CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                           SFCDIR(I)(1:SFCDIRLEN(I))//'template',
     2                           DLEN+SFCDIRLEN(I)+8,SFCDSET_CUTOFF(I),
     3                           SFCDSET_INCR(I),STATUS)
                  ENDIF
                  IF(I.EQ.SAO_DS_P.OR.I.EQ.COOP_DS_P
     1                 .OR.I.EQ.URBANET_DS_P.OR.I.EQ.HFMETAR_DS_P
     2                 .OR.I.EQ.NEPP_DS_P.OR.I.EQ.HCN_DS_P.OR.
     3                 I.EQ.CRN_DS_P)THEN
                     VERBOSE = ERRFLG
                     IF(STATUS.NE.SUCCESS_P)THEN
                        IF(I.EQ.SAO_DS_P)THEN
                           SFCDSET_ENBL(SAO_DS_P) = .FALSE.
                           SAO_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.COOP_DS_P)THEN
                           SFCDSET_ENBL(COOP_DS_P) = .FALSE.
                           COOP_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.URBANET_DS_P)THEN
                           SFCDSET_ENBL(URBANET_DS_P) = .FALSE.
                           URBANET_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.HFMETAR_DS_P)THEN
                           SFCDSET_ENBL(HFMETAR_DS_P) = .FALSE.
                           HFMETAR_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.NEPP_DS_P)THEN
                           SFCDSET_ENBL(NEPP_DS_P) = .FALSE.
                           NEPP_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.HCN_DS_P)THEN
                           SFCDSET_ENBL(HCN_DS_P) = .FALSE.
                           HCN_DSET_AVAIL = .FALSE.
                        ELSE IF(I.EQ.CRN_DS_P)THEN
                           SFCDSET_ENBL(CRN_DS_P) = .FALSE.
                           CRN_DSET_AVAIL = .FALSE.
                        ENDIF
                     ELSE
                        IF(I.EQ.SAO_DS_P)THEN
                           SAO_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.COOP_DS_P)THEN
                           COOP_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.URBANET_DS_P)THEN
                           URBANET_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.HFMETAR_DS_P)THEN
                           HFMETAR_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.NEPP_DS_P)THEN
                           NEPP_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.HCN_DS_P)THEN
                           HCN_DSET_AVAIL = .TRUE.
                        ELSE IF(I.EQ.CRN_DS_P)THEN
                           CRN_DSET_AVAIL = .TRUE.
                        ENDIF
                     ENDIF
                  ELSE IF(STATUS.NE.SUCCESS_P)THEN
                     GO TO 900
                  ENDIF

 100           CONTINUE

            ELSE IF(DBASE(1:3).EQ.'FSL')THEN

               SAO_DSET_AVAIL = .TRUE.
               COOP_DSET_AVAIL = .TRUE.
               URBANET_DSET_AVAIL = .TRUE.
               HFMETAR_DSET_AVAIL = .TRUE.
               NEPP_DSET_AVAIL = .TRUE.
               HCN_DSET_AVAIL = .TRUE.
               CRN_DSET_AVAIL = .TRUE.
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/metar.template',
     1                     SLEN+15,SFCDSET_CUTOFF(1),SFCDSET_INCR(1),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/maritime.template',
     1                     SLEN+18,SFCDSET_CUTOFF(2),SFCDSET_INCR(2),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/sao.template',
     1                     SLEN+13,SFCDSET_CUTOFF(3),SFCDSET_INCR(3),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/mesonet.template',
     1                     SLEN+17,SFCDSET_CUTOFF(4),SFCDSET_INCR(4),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/coop.template',
     1                     SLEN+14,SFCDSET_CUTOFF(5),SFCDSET_INCR(5),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/urbanet.template',
     1                     SLEN+17,SFCDSET_CUTOFF(6),SFCDSET_INCR(6),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/hfmetar.template',
     1                     SLEN+17,SFCDSET_CUTOFF(7),SFCDSET_INCR(7),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/nepp.template',
     1                     SLEN+14,SFCDSET_CUTOFF(8),SFCDSET_INCR(8),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/hcn.template',
     1                     SLEN+13,SFCDSET_CUTOFF(9),SFCDSET_INCR(9),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/crn.template',
     1                     SLEN+13,SFCDSET_CUTOFF(10),SFCDSET_INCR(10),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900

            ENDIF

            SFC_NFILES = 0
            CDTYPE = SFC_DS_P
            SFC_DBTYPE = CDBTYPE

         ENDIF

      ELSE IF(SUB(1:4).EQ.'RAOB'.OR.SUB(1:3).EQ.'NPN'.OR.
     1        SUB(1:5).EQ.'ACARS'.OR.SUB(1:3).EQ.'MAP'.OR.
     2        SUB(1:5).EQ.'RDMTR')THEN

         IF(SUB(1:4).EQ.'RAOB')THEN
            I = RAOB_DS_P
         ELSE IF(SUB(1:3).EQ.'NPN')THEN
            I = NPN_DS_P
            MISS_AWIPS_VAL2 = -1
         ELSE IF(SUB(1:6).EQ.'ACARSP')THEN
            I = ACARSP_DS_P
         ELSE IF(SUB(1:5).EQ.'ACARS')THEN
            I = ACARS_DS_P
            MISS_ACARS_VAL2 = 99999.0
         ELSE IF(SUB(1:3).EQ.'MAP')THEN
            I = MAP_DS_P
            MISS_AWIPS_VAL2 = -9999
         ELSE IF(SUB(1:5).EQ.'RDMTR')THEN
            I = RDMTR_DS_P
         ENDIF

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET MUAPTINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(UAPT_INIT(I).EQ.INIT_P)CALL MUAPTCLS(I)

         IF(I.EQ.RAOB_DS_P)THEN

            CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/raobtbl.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,
     2                       STATIC_DIR(1:SLEN)//'/raobvcn.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/point/raob/netcdf/'
               UAPTDIRLEN(I) = 19
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//'/raob.template',
     1                        SLEN+14,UAPTDSET_CUTOFF(I),
     2                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I

            ENDIF

         ELSE IF(I.EQ.NPN_DS_P)THEN

            CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/npntbl.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,STATIC_DIR(1:SLEN)//'/npnvcn.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/point/profiler/netcdf/'
               UAPTDIRLEN(I) = 23
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//'/profiler.template',
     1                        SLEN+18,UAPTDSET_CUTOFF(I),
     2                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I
               HAVE_NPN_LT = .FALSE.

            ENDIF

         ELSE IF(I.EQ.ACARS_DS_P)THEN

C     ------------------------------------------------------------------
C     NOTE THAT THE AWIPS AND FSL DATABASES CONTAIN VERY DIFFERENT
C     FILES, SO WE ACTUALLY USE TWO DIFFERENT TABLES TO DEFINE THEM.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.FSL_DB_P)THEN
               CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/acarstbl.txt',
     1                        STATUS)
            ELSE IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//
     1                        '/awips_acarstbl.txt',STATUS)
            ENDIF

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,
     2                       STATIC_DIR(1:SLEN)//'/acarsvcn.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/point/acars/netcdf/'
               UAPTDIRLEN(I) = 20
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//'/acars.template',
     1                        SLEN+15,UAPTDSET_CUTOFF(I),
     2                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I

            ENDIF

         ELSE IF(I.EQ.MAP_DS_P)THEN

            CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/maptbl.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,STATIC_DIR(1:SLEN)//'/mapvcn.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/LDAD/profiler/netCDF/'
               UAPTDIRLEN(I) = 22
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//'/map.template',
     1                        SLEN+13,UAPTDSET_CUTOFF(I),
     2                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I
               HAVE_MAP_LT = .FALSE.

            ENDIF

         ELSE IF(I.EQ.RDMTR_DS_P)THEN

            CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/rdmtrtbl.txt',STATUS)

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,STATIC_DIR(1:SLEN)//'/rdmtrvcn.txt',
     2                       STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/point/radiometer/netcdf/'
               UAPTDIRLEN(I) = 25
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//
     1                        '/radiometer.template',
     1                        SLEN+20,UAPTDSET_CUTOFF(I),
     2                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I

            ENDIF

         ELSE IF(I.EQ.ACARSP_DS_P)THEN

C     ------------------------------------------------------------------
C     THE FSL & AWIPS ACARSP FILES AREN'T AS DIFFERENT AS THE ACARS
C     FILES ARE, BUT BECAUSE OF ERRORS INTRODUCED IN CONVERTING BACK
C     AND FORTH FROM TD TO RH, AND BECAUSE THE AWIPS FILES ONLY HAVE
C     RH BUT THE FSL FILES HAVE TD (WHICH IS CONVERTED TO RH IN THE FSL
C     FILES), WE'LL USE DIFFERENT TABLES SO THAT TD WILL BE USED FOR
C     THE MOISTURE VARIABLES IN THE FSL DATABASE AND RH WILL BE USED
C     IN THE AWIPS DATABASE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.FSL_DB_P)THEN
               CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//'/acarsptbl.txt',
     1                        STATUS)
            ELSE IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MUAPTINIT(I,STATIC_DIR(1:SLEN)//
     1                        '/awips_acarsptbl.txt',STATUS)
            ENDIF

            IF(STATUS.EQ.SUCCESS_P)
     1         CALL MRDVCODE(I,STATIC_DIR(1:SLEN)//'/acarspvcn.txt',
     2                       STATUS)

            IF(STATUS.EQ.SUCCESS_P)THEN

               UAPTDIR(I) = '/point/acarsProfiles/netcdf/'
               UAPTDIRLEN(I) = 28
               IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
                  CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                        UAPTDIR(I)(1:UAPTDIRLEN(I))//'template',
     2                        DLEN+UAPTDIRLEN(I)+8,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ELSE
                  CALL MTMRNG(STATIC_DIR(1:SLEN)//
     1                        '/acarsp.template',
     2                        SLEN+16,UAPTDSET_CUTOFF(I),
     3                        UAPTDSET_INCR(I),STATUS)
               ENDIF
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               UAPT_NFILES(I) = 0
               UAPT_INIT(I) = INIT_P
               UAPT_DBTYPE(I) = CDBTYPE
               CDTYPE = I

            ENDIF

         ENDIF

      ELSE IF(SUB(1:5).EQ.'HYDRO')THEN

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET HYDROINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(HYDRO_INIT.EQ.INIT_P)CALL MHYDROCLS

         CALL MHYDROINIT(STATIC_DIR(1:SLEN)//'/hydrotbl.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(HYD_DS_P,STATIC_DIR(1:SLEN)//'/hydrovcn.txt',
     2                    STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            HYDRODIR(1) = '/LDAD/hydro/netCDF/'
            HYDRODIRLEN(1) = 19

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                     HYDRODIR(1)(1:HYDRODIRLEN(1))//'template',
     2                     DLEN+HYDRODIRLEN(1)+8,HYDRODSET_CUTOFF(1),
     3                     HYDRODSET_INCR(1),STATUS)
            ELSE
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/hydro.template',
     1                     SLEN+14,HYDRODSET_CUTOFF(1),
     2                     HYDRODSET_INCR(1),STATUS)
            ENDIF
            IF(STATUS.NE.SUCCESS_P)GO TO 900

            HYDRO_NFILES = 0
            CDTYPE = HYD_DS_P
            HYDRO_DBTYPE = CDBTYPE

         ENDIF

      ELSE IF(SUB(1:6).EQ.'SATWND')THEN

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET SATWNDINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(SATW_INIT.EQ.INIT_P)CALL MSATWNDCLS

         CALL MSATWNDINIT(STATIC_DIR(1:SLEN)//'/satwndtbl.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(SATW_DS_P,
     2                    STATIC_DIR(1:SLEN)//'/satwndvcn.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            SATWDIR(1) = '/point/HDW/netcdf/'
            SATWDIRLEN(1) = 18
            SATWDIR(2) = '/point/HDW1h/netcdf/'
            SATWDIRLEN(2) = 20

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.  NOTES:
C
C     - THE HDW1H DATASET DOESN'T EXIST IN THE AWIPS DATABASE, BUT A 
C       USER MIGHT GET THIS FROM FSL.  THEREFORE WE'LL TURN OFF VERBOSE 
C       ERROR HANDLING AND TRY TO READ THE HDW1H TEMPLATE.  IF IT'S NOT 
C       THERE, WE'LL DISABLE THAT DATASET.
C     - FOR THE FSL DATABASE, ALL SATWND FILES ARE CURRENTLY USING THE
C       SAME TEMPLATE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN

               DO I = 1, MAX_SATWDSET_P
                  
                  IF(I.EQ.HDW1H_DS_P)VERBOSE = .FALSE.
                  IF(I.NE.HDW1H_DS_P)THEN
                     CALL MTMRNG(DATA_DIR(1:DLEN)//
     1                           SATWDIR(I)(1:SATWDIRLEN(I))//
     2                           'template',DLEN+SATWDIRLEN(I)+8,
     3                           SATWDSET_CUTOFF(I),SATWDSET_INCR(I),
     4                           STATUS)
                  ELSE
                     CALL MTMRNG(STATIC_DIR(1:SLEN)//'/satwnd.template',
     1                           SLEN+16,SATWDSET_CUTOFF(I),
     2                           SATWDSET_INCR(I),STATUS)
                  ENDIF
                  IF(I.EQ.HDW1H_DS_P)THEN
                     VERBOSE = ERRFLG
                     IF(STATUS.NE.SUCCESS_P)THEN
                        SATWDSET_ENBL(HDW1H_DS_P) = .FALSE.
                        HDW1H_DSET_AVAIL = .FALSE.
                     ELSE
                        HDW1H_DSET_AVAIL = .TRUE.
                     ENDIF
                  ELSE IF(STATUS.NE.SUCCESS_P)THEN
                     GO TO 900
                  ENDIF
               ENDDO

            ELSE IF(DBASE(1:3).EQ.'FSL')THEN

               HDW1H_DSET_AVAIL = .TRUE.
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/satwnd.template',
     1                     SLEN+16,SATWDSET_CUTOFF(1),SATWDSET_INCR(1),
     2                     STATUS)
               IF(STATUS.NE.SUCCESS_P)GO TO 900
               DO I = 2, MAX_SATWDSET_P
                  SATWDSET_CUTOFF(I) = SATWDSET_CUTOFF(1)
                  SATWDSET_INCR(I) = SATWDSET_INCR(1)
               ENDDO

            ENDIF

            SATW_NFILES = 0
            CDTYPE = SATW_DS_P
            SATW_DBTYPE = CDBTYPE
         
         ENDIF

      ELSE IF(SUB(1:6).EQ.'SATSND')THEN

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET SATSINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(SATS_INIT.EQ.INIT_P)CALL MSATSNDCLS

         CALL MSATSNDINIT(STATIC_DIR(1:SLEN)//'/satsndtbl.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(SATS_DS_P,
     2                    STATIC_DIR(1:SLEN)//'/satsndvcn.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            SATSDIR(1) = '/point/POES/netcdf/'
            SATSDIRLEN(1) = 19

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.  NOTES:
C     - FOR THE FSL DATABASE, ALL SATS FILES ARE CURRENTLY USING THE
C       SAME TEMPLATE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MTMRNG(DATA_DIR(1:DLEN)//
     1              SATSDIR(1)(1:SATSDIRLEN(1))//'template',
     2              DLEN+SATSDIRLEN(1)+8,SATSDSET_CUTOFF(1),
     3              SATSDSET_INCR(1),STATUS)
            ELSE
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/satsnd.template',
     1              SLEN+16,SATSDSET_CUTOFF(1),SATSDSET_INCR(1),
     2              STATUS)
            ENDIF
            IF(STATUS.NE.SUCCESS_P)GO TO 900
            DO I = 1, MAX_SATSDSET_P
               SATSDSET_CUTOFF(1) = SATSDSET_CUTOFF(1)
               SATSDSET_INCR(1) = SATSDSET_INCR(1)
            ENDDO

            SATS_NFILES = 0
            CDTYPE = SATS_DS_P
            SATS_DBTYPE = CDBTYPE
            SATSND_DSET_AVAIL = .TRUE.
         
         ENDIF

      ELSE IF(SUB(1:6).EQ.'SATRAD')THEN

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET SATRINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(SATR_INIT.EQ.INIT_P)CALL MSATRADCLS

         CALL MSATRADINIT(STATIC_DIR(1:SLEN)//'/satradtbl.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(SATR_DS_P,
     2                    STATIC_DIR(1:SLEN)//'/satradvcn.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            SATRDIR(1) = '/point/satrad/netcdf/'
            SATRDIRLEN(1) = 21

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.  NOTES:
C     - FOR THE FSL DATABASE, ALL SATR FILES ARE CURRENTLY USING THE
C       SAME TEMPLATE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MTMRNG(DATA_DIR(1:DLEN)//
     1              SATRDIR(1)(1:SATRDIRLEN(1))//'template',
     2              DLEN+SATRDIRLEN(1)+8,SATRDSET_CUTOFF(1),
     3              SATRDSET_INCR(1),STATUS)
            ELSE
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/satrad.template',
     1              SLEN+16,SATRDSET_CUTOFF(1),SATRDSET_INCR(1),
     2              STATUS)
            ENDIF
            IF(STATUS.NE.SUCCESS_P)GO TO 900
            DO I = 1, MAX_SATRDSET_P
               SATRDSET_CUTOFF(1) = SATRDSET_CUTOFF(1)
               SATRDSET_INCR(1) = SATRDSET_INCR(1)
            ENDDO

            SATR_NFILES = 0
            CDTYPE = SATR_DS_P
            SATR_DBTYPE = CDBTYPE
            SATRAD_DSET_AVAIL = .TRUE.
         
         ENDIF

      ELSE IF(SUB(1:4).EQ.'SNOW')THEN

C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET SNOWINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(SNOW_INIT.EQ.INIT_P)CALL MSNOWCLS

         CALL MSNOWINIT(STATIC_DIR(1:SLEN)//'/snowtbl.txt',
     1        STATIC_DIR(1:SLEN)//'/snowsrcin.txt',
     2        STATUS)

         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(SNOW_DS_P,
     2                    STATIC_DIR(1:SLEN)//'/snowvcn.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            SNOWDIR(1) = '/LDAD/snow/netCDF/'
            SNOWDIRLEN(1) = 18

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.  NOTES:
C     - FOR THE FSL DATABASE, ALL SNOW FILES ARE CURRENTLY USING THE
C       SAME TEMPLATE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MTMRNG(DATA_DIR(1:DLEN)//
     1              SNOWDIR(1)(1:SNOWDIRLEN(1))//'template',
     2              DLEN+SNOWDIRLEN(1)+8,SNOWDSET_CUTOFF(1),
     3              SNOWDSET_INCR(1),STATUS)
            ELSE
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/snow.template',
     1              SLEN+16,SNOWDSET_CUTOFF(1),SNOWDSET_INCR(1),
     2              STATUS)
            ENDIF
            IF(STATUS.NE.SUCCESS_P)GO TO 900
            DO I = 1, MAX_SNOWDSET_P
               SNOWDSET_CUTOFF(1) = SNOWDSET_CUTOFF(1)
               SNOWDSET_INCR(1) = SNOWDSET_INCR(1)
            ENDDO

            SNOW_NFILES = 0
            CDTYPE = SNOW_DS_P
            SNOW_DBTYPE = CDBTYPE
            SNOW_DSET_AVAIL = .TRUE.
         
         ENDIF

      ELSE IF(SUB(1:6).EQ.'WISDOM')THEN
C     ------------------------------------------------------------------
C     IF WE'VE BEEN HERE BEFORE, MAKE SURE ANY OPEN NETCDF FILES ARE
C     CLOSED.  THEN LET WISDOMINIT DO MOST OF THE WORK.
C     ------------------------------------------------------------------
         IF(WISDOM_INIT.EQ.INIT_P)CALL MWISDOMCLS

         CALL MWISDOMINIT(STATIC_DIR(1:SLEN)//'/wisdomtbl.txt',
     2        STATUS)


         IF(STATUS.EQ.SUCCESS_P)
     1      CALL MRDVCODE(WISDOM_DS_P,
     2                    STATIC_DIR(1:SLEN)//'/wisdomvcn.txt',STATUS)

         IF(STATUS.EQ.SUCCESS_P)THEN

C     ------------------------------------------------------------------
C     FILL IN DIRECTORY NAMES -- NOTE THE TRAILING /.  THIS MEANS
C     THE ROUTINES THAT USE THE DIRECTORY NAMES DON'T NEED TO BE ON A
C     UNIX MACHINE.  (E.G., USE "[...]" FOR VMS.)
C     ------------------------------------------------------------------
            WISDOMDIR(1) = '/LDAD/WISDOM/netCDF/'
            WISDOMDIRLEN(1) = 20

C     ------------------------------------------------------------------
C     USE THE AWIPS-STYLE TEMPLATES TO DETERMINE THE TIME RANGE OF
C     DATA KEPT IN EACH FILE, AND KEEP THAT INFO IN COMMON.  NOTES:
C     - FOR THE FSL DATABASE, ALL WISDOM FILES ARE CURRENTLY USING THE
C       SAME TEMPLATE.
C     ------------------------------------------------------------------
            IF(CDBTYPE.EQ.AWIPS_DB_P)THEN
               CALL MTMRNG(DATA_DIR(1:DLEN)//
     1              WISDOMDIR(1)(1:WISDOMDIRLEN(1))//'template',
     2              DLEN+WISDOMDIRLEN(1)+8,WISDOMDSET_CUTOFF(1),
     3              WISDOMDSET_INCR(1),STATUS)
            ELSE
               CALL MTMRNG(STATIC_DIR(1:SLEN)//'/wisdom.template',
     1              SLEN+16,WISDOMDSET_CUTOFF(1),WISDOMDSET_INCR(1),
     2              STATUS)
            ENDIF
            IF(STATUS.NE.SUCCESS_P)GO TO 900
            DO I = 1, MAX_WISDOMDSET_P
               WISDOMDSET_CUTOFF(1) = WISDOMDSET_CUTOFF(1)
               WISDOMDSET_INCR(1) = WISDOMDSET_INCR(1)
            ENDDO

            WISDOM_NFILES = 0
            CDTYPE = WISDOM_DS_P
            WISDOM_DBTYPE = CDBTYPE
            WISDOM_DSET_AVAIL = .TRUE.
         
         ENDIF

      ELSE IF(SUB(1:8).NE.'EXTERNAL')THEN

         STATUS = INV_SUB_P
         CALL MERROR('MINIT: INVALID SUBSYSTEM')

      ENDIF

 900  IF(STATUS.EQ.SUCCESS_P)MADIS_INIT = INIT_P

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