C***********************************************************************
C********************************  MADISCOM ****************************
C***********************************************************************
C**
C**  NAME:  MADISCOM
C**
C**
C**
C**  PURPOSE
C**  =======
C**  INCLUDE FILE                ORIGINAL VERSION   9/14/99  M. BARTH
C**
C**  02/12/01     M. BARTH       ADDED PACCUM_CODE AND SUBLEN
C**  05/03/01     M. BARTH       CHANGES FOR AWIPS-FORMATTED RAOB FILES
C**  06/28/01     M. BARTH       - ADDED SUBPROVIDERS INFO.  THIS CAUSED
C**                                NSUB, SUBNAME, ETC., TO BE REDEFINED
C**                                AND ADDED NPVD, PVDNAME ETC. FOR THE
C**                                PROVIDER INFO.
C**                              - ADDED SRAD_*_CODE, PACCUM_*_CODE, AND
C**                                SUB_CODE
C**                              - ADDED DATABASE-TYPE INFO
C**                              - ADDED DATASET CUTOFF/INCR INFO
C**                              - CHANGED SUBSRCIN_NAME LENGTH TO 255
C**  07/24/01     M. BARTH       - ADDED HYDRO DATASET
C**                              - ADDED VCNAME, VCVCN, NVCODE, VTYPE
C** 
C**  05/06/02     M. BARTH       - ADDED MAP DATASET
C**                              - EXTENDED SRC/HYDRO SUBSRCIN DATA
C**                                STRUCTURES TO INCLUDE MAP ALSO
C**  05/27/03     M. BARTH       ADDED NEWPVDNAME,NNEWPVD,ALL_ENBL,
C**                              NEW_ENBL, TO HANDLE THE FACT THAT WE'RE
C**                              NO LONGER UPDATING SUBSRCIN FILES
C**  09/24/03     M. BARTH       - ADDED STUFF FOR SATW (SATWND) DATASET
C**                              - CHANGED DSET_NAMES FROM 9 TO 20 CHARS
C**                              - ADDED VARIABLES TO ALLOW FLEXIBLE
C**                                DATA FILE INPUT METHODS (E.G., DODS)
C**  03/22/04     M. BARTH       ADDED COOP_DSET_AVAIL
C**  08/19/04     M. BARTH       ADDED TMP_DIR & TLEN
C**  09/27/04     L.BENJAMIN     ADDED SAT SOUNDING DATA SET
C**  09/22/05     L.BENJAMIN     ADDED RAWP_CODE FOR RAWPRECIP VARIABLE
C**  10/25/05     L.BENJAMIN     ADDED SAT RADIANCE DATA SET
C**  11/18/05     L.BENJAMIN     ADDED SNOW DATA SET
C**  02/13/06     L.BENJAMIN     REMOVED UNUSED SATS AND SATR VARIABLES
C**  06/08/01     L. BENJAMIN    ADDED URBANET DATASET
C**  08/06/14     L. BENJAMIN    MOVE COMMON CONSTANTS WITH UA AND MSAS
C**                              TO INTQC1COM1
C**  08/06/23     M. BARTH       ADDED HIGH FREQUENCY METAR DATASET
C**  08/07/20     L.BENJAMIN     ADDED WISDOM DATA SET
C**
C**
C**
C**  CONTAINS DATA STRUCTURES FOR THE MADIS LIBRARY
C**
C***********************************************************************
C***********************************************************************

C     INITIALIZATION-RELATED:
      INCLUDE 'INTQC1COM1'

      LOGICAL AWIPS2_DB
      INTEGER SFC_INIT,MADIS_INIT,UAPT_INIT(MAX_UAPTDSET_P),HYDRO_INIT
      INTEGER SATW_INIT,SATW_DBTYPE
      INTEGER SATS_INIT,SATS_DBTYPE
      INTEGER SATR_INIT,SATR_DBTYPE
      INTEGER SNOW_INIT,SNOW_DBTYPE
      INTEGER WISDOM_INIT,WISDOM_DBTYPE
      INTEGER UAPT_DBTYPE(MAX_UAPTDSET_P),SFC_DBTYPE,HYDRO_DBTYPE
      INTEGER DTYPE_INIT(0:MAX_DTYPE_P-1),DBTYPE(0:MAX_DTYPE_P-1)
      CHARACTER*9 LAST_SFC_ATIME,LAST_UAPT_ATIME(MAX_UAPTDSET_P)
      CHARACTER*9 LAST_HYDRO_ATIME,LAST_SATW_ATIME,LAST_SATS_ATIME
      CHARACTER*9 LAST_SATR_ATIME,LAST_SNOW_ATIME,LAST_WISDOM_ATIME
      CHARACTER*9 LAST_DTYPE_ATIME(0:MAX_DTYPE_P-1)

C     TIME WINDOW:

      INTEGER MINBCK,MINFWD,RECWIN

C     DATASETS:

      LOGICAL SFCDSET_ENBL(MAX_SFCDSET_P)
      CHARACTER*20 SFCDSET_NAME(MAX_SFCDSET_P)
      CHARACTER*20 UAPTDSET_NAME(MAX_UAPTDSET_P)
      INTEGER SFCDSET_CUTOFF(MAX_SFCDSET_P)
      INTEGER SFCDSET_INCR(MAX_SFCDSET_P)
      INTEGER UAPTDSET_CUTOFF(MAX_UAPTDSET_P)
      INTEGER UAPTDSET_INCR(MAX_UAPTDSET_P)
      LOGICAL HYDRODSET_ENBL(MAX_HYDRODSET_P)
      CHARACTER*20 HYDRODSET_NAME(MAX_HYDRODSET_P)
      INTEGER HYDRODSET_CUTOFF(MAX_HYDRODSET_P)
      INTEGER HYDRODSET_INCR(MAX_HYDRODSET_P)
      LOGICAL SATWDSET_ENBL(MAX_SATWDSET_P)
      CHARACTER*20 SATWDSET_NAME(MAX_SATWDSET_P)
      INTEGER SATWDSET_CUTOFF(MAX_SATWDSET_P)
      INTEGER SATWDSET_INCR(MAX_SATWDSET_P)
      LOGICAL SATSDSET_ENBL(MAX_SATSDSET_P)
      CHARACTER*20 SATSDSET_NAME(MAX_SATSDSET_P)
      INTEGER SATSDSET_CUTOFF(MAX_SATSDSET_P)
      INTEGER SATSDSET_INCR(MAX_SATSDSET_P)
      LOGICAL SATRDSET_ENBL(MAX_SATRDSET_P)
      CHARACTER*20 SATRDSET_NAME(MAX_SATRDSET_P)
      INTEGER SATRDSET_CUTOFF(MAX_SATRDSET_P)
      INTEGER SATRDSET_INCR(MAX_SATRDSET_P)
      LOGICAL SNOWDSET_ENBL(MAX_SNOWDSET_P)
      CHARACTER*20 SNOWDSET_NAME(MAX_SNOWDSET_P)
      INTEGER SNOWDSET_CUTOFF(MAX_SNOWDSET_P)
      INTEGER SNOWDSET_INCR(MAX_SNOWDSET_P)

      LOGICAL WISDOMDSET_ENBL(MAX_WISDOMDSET_P)
      CHARACTER*20 WISDOMDSET_NAME(MAX_WISDOMDSET_P)
      INTEGER WISDOMDSET_CUTOFF(MAX_WISDOMDSET_P)
      INTEGER WISDOMDSET_INCR(MAX_WISDOMDSET_P)


C     DATABASES:

      LOGICAL SAO_DSET_AVAIL,HDW1H_DSET_AVAIL,COOP_DSET_AVAIL
      LOGICAL URBANET_DSET_AVAIL,HFMETAR_DSET_AVAIL
      LOGICAL NEPP_DSET_AVAIL,HCN_DSET_AVAIL,CRN_DSET_AVAIL
      LOGICAL SATSND_DSET_AVAIL
      LOGICAL SATRAD_DSET_AVAIL
      LOGICAL SNOW_DSET_AVAIL
      LOGICAL WISDOM_DSET_AVAIL

C     VARIABLES:

      CHARACTER*1 VQC(MAX_VARCOD_P,MAX_DSET_P)
      CHARACTER*1 VDTYPE(MAX_VARCOD_P,MAX_DSET_P)
      CHARACTER*24 VNAME(MAX_VARCOD_P,MAX_DSET_P)
      INTEGER VLEN(MAX_VARCOD_P,MAX_DSET_P)
      INTEGER VCLEN(MAX_VARCOD_P,MAX_DSET_P)
      INTEGER VQCSTG(MAX_VARCOD_P,0:MAX_DTYPE_P-1)
      INTEGER NVCODE(0:MAX_DTYPE_P-1)
      INTEGER VCVCN(MAX_VARCOD_P,0:MAX_DTYPE_P-1)
      CHARACTER*7 VCNAME(MAX_VARCOD_P,0:MAX_DTYPE_P-1)
      CHARACTER*1 VTYPE(MAX_VARCOD_P,0:MAX_DTYPE_P-1)
      
C     ASOS STATION DICTIONARY:

      INTEGER TOTAL_STNS
      CHARACTER*5 STN_VEC(2000)

C     FOR DATASETS WITH PROVIDER & SUBPROVIDER IDENTIFICATION
C     AND SPECIAL-HANDLING FLAGS BASED ON PROVIDER/SUBPROVIDER
C     (SURFACE = ROW 1, HYDRO = ROW 2, MAP = ROW 3, 
C     RADIOMETER = ROW 4, SATWND = ROW 5, SATSND = ROW 6,
C     SATRAD = ROW 7, SNOW = ROW 8, WISDOM = ROW 9)
      CHARACTER*255 SUBSRCIN_NAME(9)

      CHARACTER*10 PVDNAME(MAX_SUBSRC_P,9)
      CHARACTER*10 NEWPVDNAME(MAX_SUBSRC_P,9)
      LOGICAL PROVDR_ENBL(MAX_SUBSRC_P,9)
      LOGICAL NEW_ENBL(MAX_SUBSRC_P,9)
      LOGICAL ALL_ENBL(9)
      INTEGER PACCUM_P_CODE(MAX_SUBSRC_P,9)
      INTEGER SRAD_P_CODE(MAX_SUBSRC_P,9)
      INTEGER SUB_CODE(MAX_SUBSRC_P,9)
      INTEGER RAWP_CODE(MAX_SUBSRC_P,9)
      INTEGER PVDLEN(MAX_SUBSRC_P,9)
      INTEGER NPVD(9),OLD_NPVD(9),NNEWPVD(9)

      CHARACTER*11 SUBNAME(MAX_SUBPVDR_P,9)
      INTEGER SUBLEN(MAX_SUBPVDR_P,9)
      INTEGER NSUB(9),OLD_NSUB(9)
      INTEGER PACCUM_S_CODE(MAX_SUBPVDR_P,9)
      INTEGER SRAD_S_CODE(MAX_SUBPVDR_P,9)

C     GRIDDED ELEVATION NEEDED BY MARELV:

      REAL GE(NX_TOPO_P,NY_TOPO_P)

C     DOMAIN:

      INTEGER DMTYPE,NX_U,NY_U
      REAL LAT_LL_U,LAT_UR_U,LON_LL_U,LON_UR_U
      REAL X_POLE_U,Y_POLE_U,LON_XX_U,LAT_TRUE_U,LAT_PS_U
      REAL ROTCON_U,LAT_TAN_U,DM_U
      REAL XLIMN_U,XLIMX_U,YLIMN_U,YLIMX_U

C     QC FILTERING:

      INTEGER QCTYPE

C     CURRENT VARIABLE QC STATUS

      INTEGER QCSTATUS


C     VERTICAL COORDINATES:

      INTEGER VCTYPE,VCNLEV,VCLEVEL(200)

C     NPN HEIGHT & LEVEL TYPE INFO:

      REAL NPN_ELEV(MXNPN_P),NPN_LT(64,MXNPN_P)
      LOGICAL HAVE_NPN_LT

C     MAP LEVEL TYPE INFO:

      REAL MAP_LT(MXMAPLEV_P,MXMAP_P)
      LOGICAL HAVE_MAP_LT

C     RAOB INFO:

      LOGICAL RAOB_HT_QC,RAOB_WIND_QC

C     SATWND LEVEL TYPE INFO:

      REAL SATW_LT(MXSATW_P)
      LOGICAL HAVE_SATW_LT

C     CORRECTION SELECTION:

      INTEGER CORTYP

C     DATA FILE ACCESS INFO:

      CHARACTER*11 FEXT
      CHARACTER*255 DATA_DIR,TMP_DIR
      INTEGER DLEN,TLEN

      COMMON/MADISCOM1/SFCDSET_NAME,VQC,LAST_DTYPE_ATIME,STN_VEC,
     1                 SUBNAME,SUBSRCIN_NAME,VNAME,VDTYPE,UAPTDSET_NAME,
     2                 PVDNAME,HYDRODSET_NAME,VCNAME,VTYPE,NEWPVDNAME,
     3                 SATWDSET_NAME,SATSDSET_NAME,FEXT,DATA_DIR,
     4                 TMP_DIR,SATRDSET_NAME,SNOWDSET_NAME,
     5     WISDOMDSET_NAME


      COMMON/MADISCOM2/MADIS_INIT,DTYPE_INIT,VLEN,SFCDSET_ENBL,
     1                 MINBCK,MINFWD,RECWIN,NSUB,PROVDR_ENBL,
     2                 OLD_NSUB,GE,TOTAL_STNS,DMTYPE,NX_U,NY_U,
     3                 LAT_LL_U,LAT_UR_U,LON_LL_U,LON_UR_U,X_POLE_U,
     4                 Y_POLE_U,LON_XX_U,LAT_TRUE_U,LAT_PS_U,
     5                 ROTCON_U,LAT_TAN_U,DM_U,XLIMN_U,XLIMX_U,
     6                 YLIMN_U,YLIMX_U,QCTYPE,VQCSTG,VCLEN,
     7                 VCTYPE,VCNLEV,VCLEVEL,NPN_ELEV,NPN_LT,
     8                 HAVE_NPN_LT,RAOB_HT_QC,RAOB_WIND_QC,
     9                 PACCUM_P_CODE,PACCUM_S_CODE,SUBLEN,NPVD,OLD_NPVD,
     1                 PVDLEN,SRAD_P_CODE,SRAD_S_CODE,SUB_CODE,CORTYP,
     2                 DBTYPE,AWIPS2_DB,SFCDSET_CUTOFF,
     3                 SFCDSET_INCR,UAPTDSET_CUTOFF,UAPTDSET_INCR,
     4                 SAO_DSET_AVAIL,NVCODE,VCVCN,HYDRODSET_ENBL,
     5                 HYDRODSET_CUTOFF,HYDRODSET_INCR,MAP_LT,
     6                 HAVE_MAP_LT,NNEWPVD,ALL_ENBL,NEW_ENBL,
     7                 SATWDSET_ENBL,SATWDSET_CUTOFF,SATWDSET_INCR,
     8                 SATSDSET_ENBL,SATSDSET_CUTOFF,SATSDSET_INCR,
     9                 HDW1H_DSET_AVAIL,HAVE_SATW_LT,SATW_LT,DLEN,
     1                 COOP_DSET_AVAIL,TLEN,QCSTATUS,SATSND_DSET_AVAIL,
     2                 RAWP_CODE,SATRDSET_ENBL,SATRDSET_CUTOFF,
     3                 SATRDSET_INCR,SATRAD_DSET_AVAIL,SNOWDSET_ENBL,
     4                 SNOWDSET_CUTOFF,SNOWDSET_INCR,URBANET_DSET_AVAIL,
     5                 HFMETAR_DSET_AVAIL,WISDOMDSET_ENBL,
     6                 WISDOMDSET_CUTOFF,WISDOMDSET_INCR,
     7                 NEPP_DSET_AVAIL,HCN_DSET_AVAIL,CRN_DSET_AVAIL



      EQUIVALENCE (DTYPE_INIT(0), SFC_INIT)
      EQUIVALENCE (DTYPE_INIT(1), UAPT_INIT)
      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+1), HYDRO_INIT)
      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+MAX_HYDRODSET_P+1), 
     1             SATW_INIT)
      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+1), 
     2             SATS_INIT)

      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+1), 
     2             SATR_INIT)

      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+1), 
     2             SNOW_INIT)
      EQUIVALENCE (DTYPE_INIT(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+ 
     2             MAX_SNOWDSET_P+1),
     3             WISDOM_INIT)

      EQUIVALENCE (DBTYPE(0), SFC_DBTYPE)
      EQUIVALENCE (DBTYPE(1), UAPT_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+1), HYDRO_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+MAX_HYDRODSET_P+1),SATW_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+1),
     2             SATS_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+1),
     2             SATR_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+1),
     2             SNOW_DBTYPE)
      EQUIVALENCE (DBTYPE(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+
     2             MAX_SNOWDSET_P+1),
     3             WISDOM_DBTYPE)

      EQUIVALENCE (LAST_DTYPE_ATIME(0), LAST_SFC_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(1), LAST_UAPT_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+1), LAST_HYDRO_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+MAX_HYDRODSET_P+1),
     1             LAST_SATW_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+1),
     2             LAST_SATS_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+1),
     2             LAST_SATR_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+1),
     2             LAST_SNOW_ATIME)
      EQUIVALENCE (LAST_DTYPE_ATIME(MAX_UAPTDSET_P+MAX_HYDRODSET_P+
     1             MAX_SATWDSET_P+MAX_SATSDSET_P+MAX_SATRDSET_P+
     2             MAX_SNOWDSET_P+1),
     3             LAST_WISDOM_ATIME)
