C$$$  SUBPROGRAM DOCUMENTATION BLOCK

C                .      .    .                                       .
C SUBPROGRAM:    MRDDBL      READ A DOUBLE PRECISION NETCDF VARIABLE
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 00-02-09
C
C ABSTRACT: READ A DOUBLE PRECISION NETCDF VARIABLE ON AN OPEN NETCDF
C           FILE.
C
C PROGRAM HISTORY LOG:
C   00-02-09  M. BARTH    ORIGINAL VERSION -- COPIED FROM MRDNUM.F
C   01-07-06  M. BARTH    - ADDED VAR_NOTINDB_P ERROR RETURN.
C                         - CHANGED HANDLING OF VNAME IN MERROR CALLS
C                           TO CONFORM WITH G77 COMPILER
C   02-05-29  M. BARTH    RESTRUCTURED TEMPORARY MEMORY ARRAY USAGE
C   02-07-29  M. BARTH    KEEP NAN'S OUT OF VARIABLES FOR FILLVALS.
C   08-06-19  L. BENJAMIN MOVED GUTS TO MRDDBL1.  THIS SUBROUTINE 
C                         PASSES REQUEST TO MRDDBL1 ALONG WITH THE 
C                         TEMPORARY PROCESSING AREA.
C
C USAGE:    CALL MRDDBL (VNAME,NCID,RECDIM,STARTR,NRECS,SPVAL,
C                        VDATA,STATUS)
C
C   INPUT ARGUMENT LIST:
C     VNAME    - C       NETCDF VARIABLE NAME
C     NCID     - I       ID OF THE OPEN NETCDF QC FILE
C     RECDIM   - I       DIMENSION ID OF THE FILE'S RECORD DIMENSION
C     STARTR   - I       STARTING RECORD TO READ
C     NRECS    - I       NUMBER OF RECORDS TO READ
C     SPVAL    - R       DESIRED MISSING DATA FLAG
C
C   OUTPUT ARGUMENT LIST:
C     VDATA    - RA      DOUBLE PRECISION ARRAY WITH DATA AND SPVALS
C                        FILLED IN
C     STATUS   - I       SUCCESS_P OR ERROR CODE
C
C   INPUT FILES:
C     WHATEVER NETCDF FILE'S OPEN ON NCID.
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MERROR, M_LSTCHR
C     NETCDF:    NCVID, NCVINQ, NCDINQ, NCVGT, NCAGT, NCAINQ
C
C REMARKS:
C   - THE EXTENDED FORTRAN BYTE DATA TYPE IS USED.  IF THIS DOESN'T
C     COMPILE ON YOUR MACHINE, SEE IF INTEGER*1 IS AVAILABLE
C     AND CHANGE THIS ROUTINE TO USE THAT INSTEAD (THE PROBLEM
C     EXISTS WITH IRIX FORTRAN 90, AND THIS WILL SOLVE IT.)
C   - THIS ROUTINE IS ASSUMED TO BE CALLED BY A HIGHER-LEVEL MADIS
C     ROUTINE, SO NO ERROR CHECKING IS DONE ON THE INPUT VARIABLES.
C   - WHATEVER THE DATA TYPE OF THE VARIABLE, IT'S CONVERTED TO
C     DOUBLE PRECISION.
C   - THE TEST FOR -999 AS A MISSING VALUE IS NEEDED BECAUSE SOME
C     MESONET VARIABLES MISTAKENLY HAVE THIS VALUE (INSTEAD OF
C     THE LEGITIMATE MISSING_VALUE ATTRIBUTE).  ALSO NOTE THAT
C     AS THERE ARE NO BYTE DATA TYPES IN MESONET FILES WHERE THIS
C     BUG MAY BE EXTANT, WE DON'T BOTHER WITH THIS LOGIC IN THE
C     BYTE HANDLING BELOW.
C   - YET ANOTHER MESONET BUG CAUSES THE FUNKY USE OF DMISS BELOW.
C     THE MISSING_VALUE ATTRIBUTE MENTIONED IN THE PREVIOUS
C     REMARK ISN'T QUITE AS "LEGITIMATE" AS IT OUGHT TO BE...
C     INSTEAD, FOR FLOAT TYPES IT HAS BEEN SPECIFIED WITH A DOUBLE
C     PRECISION CONSTANT WHEN IT SHOULD BE A FLOAT TYPE.  THE
C     CODE IN THIS ROUTINE SHOULD HANDLE EITHER VERSION.
C   - LOCAL ARRAYS ARE DIMENSIONED TO MXDBL_P.  IF THIS NUMBER
C     PROVES TOO LARGE FOR A GIVEN COMPUTER, THEN PORTIONS OF THE
C     MADIS API (E.G., RAOB) THAT RELY ON THIS VOLUME OF DATA
C     BEING HANDLED IN A SINGLE NETCDF CALL MAY NEED TO BE
C     RESTRUCTURED!
C   - SEE madistmp.f FOR AN EXPLANATION OF HOW TEMPORARY STORAGE
C     IS HANDLED (ALL ARRAYS NAMED *TMP*).
C
C ATTRIBUTES:
C   LANGUAGE: FORTRAN-77 + EXTENSIONS
C   MACHINE:  UNIX
C$$$

      SUBROUTINE MRDDBL(VNAME,NCID,RECDIM,STARTR,NRECS,SPVAL,VDATA,
     1                  STATUS)

C     ------------------------------------------------------------------
C     INCLUDES AND COMMONS
C     ------------------------------------------------------------------
      INCLUDE 'IMPLICIT'
      INCLUDE 'NETCDFI'
      INCLUDE 'MADISCON'
      INCLUDE 'MADISTMP'

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      CHARACTER*(*) VNAME
      INTEGER NCID,RECDIM,STARTR,NRECS,STATUS
      REAL SPVAL
      DOUBLE PRECISION VDATA(*)

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------

      DOUBLE PRECISION DDATA(MXDBL_P)
      REAL RDATA(MXDBL_P)
      INTEGER IDATA(MXDBL_P)
      INTEGER*2 I2DATA(MXDBL_P)
      BYTE BDATA(MXDBL_P)
      CHARACTER*(MAXNCNAM) VARNAM,DIMNAM,ERRVAR
      INTEGER I,J,K,L,N,RCODE,VARTYP,NVDIMS,VDIMS(MAXVDIMS),NVATTS,LN
      INTEGER DIMSIZ,START(MAXVDIMS),COUNT(MAXVDIMS),ATRTYP,M_LSTCHR
      REAL MISVAL1
      PARAMETER (MISVAL1 = -999.0)
      LOGICAL HAVE_FILL,HAVE_MISS
      DOUBLE PRECISION DFILL
      REAL RFILL
      INTEGER IFILL
      INTEGER*2 I2FILL
      BYTE BFILL
      EQUIVALENCE (RFILL,IFILL,I2FILL,BFILL,DFILL)
      REAL RMISS
      INTEGER IMISS
      INTEGER*2 I2MISS
      BYTE BMISS
      DOUBLE PRECISION DMISS
      EQUIVALENCE (RMISS,IMISS,I2MISS,BMISS,DMISS)

C     ------------------------------------------------------------------
C     TEMPORARY STORAGE DEFINITIONS
C     ------------------------------------------------------------------
      EQUIVALENCE(RDATA,IDATA,I2DATA,BDATA,DDATA,TMP_L0_N1)


      CALL MRDDBL1(VNAME,NCID,RECDIM,STARTR,NRECS,SPVAL,VDATA,
     1     MXDBL_P,RDATA,IDATA,I2DATA,BDATA,DDATA,STATUS)



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