C$$$  SUBPROGRAM DOCUMENTATION BLOCK
C                .      .    .                                       .
C SUBPROGRAM:    MSFCPRS     GET SURFACE PRESSURE OR ALTIMETER OBS
C   PRGMMR: M. BARTH         ORG: FSL        DATE: 01-07-20
C
C ABSTRACT: GET THE SURFACE PRESSURE OR ALTIMETER OBS (WHICH CAN
C   BE CALCULATED FROM ONE ANOTHER), OR P FROM STATION ELEV (COOP)
C
C PROGRAM HISTORY LOG:
C   01-07-20  M. BARTH    ORIGINAL VERSION
C   02-05-29  M. BARTH    RESTRUCTURED TEMPORARY MEMORY ARRAY USAGE
C   03-06-06  M. BARTH    ADDED VALIDITY CHECK BEFORE DOING CONVERSIONS.
C                         (SEE REMARKS BELOW).
C   03-10-15  M. BARTH    FIXED MINOR BUG WHERE MESONET AWIPS2 DATABASE
C                         (NO QC) RETURNED NULLS IN QCDESC.
C   04-03-22  M. BARTH    ADDED COOP -- NO PRESSURE OBS, BUT P IS
C                         NEEDED FOR MOISTURE/TEMPERATURE CONVERSIONS,
C                         AND WE'LL USE STANDARD ATMOSPHERE ALGORITHM.
C   04-10-16  L. BENJAMIN ADDED NO SUCH VARIABLE CHECK FOR QCA CHECKS
C   06-10-12  L. BENJAMIN ADDED COMMENT FOR URBANET PRESSURE
C   08-08-14  L. BENJAMIN CHANGED MIN VALUE CHECK TO 0.3 FROM 0.0 FOR
C                         M_PRSALT CALLS.  
C   08-08-15  L. BENJAMIN ADDED MISS_P AS MISSING DATA ARGUMENT FOR
C                         M_ZTOPSA.
C   10-08-05  M. BARTH    ADDED CRN -- NO PRESSURE OBS, BUT LIKE COOP,
C                         P IS NEEDED.
C
C USAGE:    CALL MSFCPRS (VCN,DSN,FNUM,OB,QCDESC,QCAPP,QCRES,STATUS)
C
C   INPUT ARGUMENT LIST:
C     VCN      - I       VARIABLE CODE NUMBER FOR ALTIMETER OR SFC P
C     DSN      - I       DATASET CODE NUMBER
C     FNUM     - I       FILE NUMBER (INDEX IN COMMON) OF NETCDF FILE
C
C   OUTPUT ARGUMENT LIST:
C     OB       - RA      OBSERVATIONS IN M/K/S UNITS
C     QCDESC   - CA      QC DATA DESCRIPTORS
C     QCAPP    - RA      QC APPLIED WORD (SHOWS CHECKS APPLIED)
C     QCRES    - RA      QC RESULTS WORD (GOOD/BAD FOR EACH CHECK)
C     STATUS   - I       SUCCESS_P OR ERROR CODE
C
C   INPUT FILES:
C     NETCDF FILE OPENED USING DATA STRUCTURES FOR FNUM IN STRCCOM
C
C SUBPROGRAMS CALLED:
C     UNIQUE:    MGTNUM, MGTCHR, M_ALTPRS, M_PRSALT, M_MARELV, M_ZTOPSA
C
C REMARKS:
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   - ALTIMETER AND STATION PRESSURE CAN BE DIRECTLY CALCULATED
C     FROM ONE ANOTHER (PLUS ELEV) SO WE CAN GIVE THE USER WHICHEVER 
C     HE WANTS.
C   - BAD OBSERVATIONS WON'T BE CONVERTED, MISSING WILL BE RETURNED.
C   - A VALIDITY CHECK IS PERFORMED BEFORE DOING CERTAIN CONVERSIONS.
C     THIS IS NEEDED TO COVER THE CASE OF *REALLY* BAD DATA FROM THE
C     AWIPS DATABASE, WHICH DOESN'T HAVE ANY QC DONE ON IT, FROM 
C     BLOWING UP A CALCULATION.  THE VALIDITY CHECK LIMITS ARE VERY
C     GROSS, AND ARE DESIGNED SIMPLY TO KEEP CALCULATIONS FROM 
C     BLOWING UP.
C   - THE COOP DATASET HAS NO PRESSURE OBS, BUT P IS NEEDED FOR 
C     MOISTURE/TEMPERATURE CONVERSIONS.  WE'LL USE STANDARD 
C     ATMOSPHERE ALGORITHM.
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 MSFCPRS (VCN,DSN,FNUM,OB,QCDESC,QCAPP,QCRES,STATUS)

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

C     ------------------------------------------------------------------
C     ARGUMENTS
C     ------------------------------------------------------------------
      INTEGER VCN,DSN,FNUM,STATUS
      REAL OB(*),QCAPP(*),QCRES(*)
      CHARACTER*1 QCDESC(*)

C     ------------------------------------------------------------------
C     LOCAL
C     ------------------------------------------------------------------
      REAL OBTMP(MXSFC_P,2),ELEVTMP(MXSFC_P),LATTMP(MXSFC_P)
      REAL LONTMP(MXSFC_P)
      REAL M_ALTPRS,M_PRSALT,M_ZTOPSA
      INTEGER I,LEN1REC
      REAL QCATMP(MXSFC_P,2),QCRTMP(MXSFC_P,2)
      CHARACTER*1 QCDTMP(MXSFC_P,2)
      LOGICAL QCMISS(2)
C     ------------------------------------------------------------------
C     TEMPORARY STORAGE DEFINITIONS
C     ------------------------------------------------------------------
      EQUIVALENCE(OBTMP,TMP_L4_N1)
      EQUIVALENCE(QCATMP,TMP_L4_N2)
      EQUIVALENCE(QCRTMP,TMP_L4_N3)
      EQUIVALENCE(QCDTMP,TMP_L4_C1)
      EQUIVALENCE(ELEVTMP,TMP_L4_N4)
      EQUIVALENCE(LATTMP,TMP_L4_N4(MXSFC_P+1))
      EQUIVALENCE(LONTMP,TMP_L4_N4(MXSFC_P*2+1))

C     ------------------------------------------------------------------
C     IF THE DATASET ISN'T MESONET/COOP/CRN READ THE VARIABLE AND ITS QC 
C     INFO.  THEN, IF THE STORED VARIABLE ISN'T THE ONE DESIRED BY THE 
C     CALLER, CONVERT IT.
C     ------------------------------------------------------------------

      IF(DSN.NE.MESONET_DS_P.AND.DSN.NE.COOP_DS_P.AND.
     1   DSN.NE.CRN_DS_P)THEN

         CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN)),SFC_NCID(FNUM),
     1               SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),MISS_P,OB,
     2               STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

C     ASSUME QC OK, SET FOR DIFFERNET CONDITIONS
         QCSTATUS = EQCOK_P

         IF(VQC(VCN,DSN).EQ.'Q')THEN

            CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'QCA',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCAPP,STATUS)
            IF(STATUS.EQ.VAR_NOTINDB_P)THEN
               QCSTATUS = EQCFAILED_P
               STATUS = SUCCESS_P
               DO I = 1, SFC_NRECS(FNUM)
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'
               ENDDO
            ELSE IF(STATUS.NE.SUCCESS_P)THEN
               RETURN
            ELSE
               CALL MGTNUM(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'QCR',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCRES,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN

               CALL MGTCHR(VNAME(VCN,DSN)(1:VLEN(VCN,DSN))//'DD',
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),QCDESC,LEN1REC,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
            ENDIF
         ELSE
            QCSTATUS = EQCFAILED_P

            DO 1 I = 1, SFC_NRECS(FNUM)
               QCAPP(I) = 0
               QCRES(I) = 0
               QCDESC(I) = 'Z'
 1          CONTINUE

         ENDIF

C     ------------------------------------------------------------------
C     FOR THE SAO DATASET, CONVERT THE ALT OBS FROM MB TO PASCALS.
C     ------------------------------------------------------------------
         IF(DSN.EQ.SAO_DS_P)THEN

            DO 22 I = 1, SFC_NRECS(FNUM)
               IF(OB(I).NE.MISS_P)OB(I) = OB(I) * 100.0
 22         CONTINUE

         ENDIF

C     ------------------------------------------------------------------
C     RETURN IF WE'VE ALREADY GOT WHAT WE WANT.
C     ------------------------------------------------------------------
         IF((VCN.EQ.SFCP_VN_P.AND.DSN.EQ.MARITIME_DS_P).OR.
     1      (VCN.EQ.ALT_VN_P.AND.DSN.NE.MARITIME_DS_P))THEN
            RETURN
         ENDIF
C     ------------------------------------------------------------------
C     GET THE STATION ELEVATIONS.
C     ------------------------------------------------------------------
         CALL MGTNUM(VNAME(ELEV_VN_P,DSN)(1:VLEN(ELEV_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2               MISS_P,ELEVTMP,STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

         IF(DSN.EQ.MARITIME_DS_P)THEN

C     ------------------------------------------------------------------
C     FOR MARITIME, WE HAVE TO ALSO READ THE LAT/LON, THEN TRY TO FILL
C     IN ZERO/MISSING VALUES, WHERE POSSIBLE, WITH VALUES INTERPOLATED 
C     FROM GRIDDED TOPOGRAPHY (PRIMARILY A GREAT LAKES FIX).
C     ------------------------------------------------------------------
            CALL MGTNUM(VNAME(LAT_VN_P,DSN)(1:VLEN(LAT_VN_P,DSN)),
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,LATTMP,STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN

            CALL MGTNUM(VNAME(LON_VN_P,DSN)(1:VLEN(LON_VN_P,DSN)),
     1                  SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,LONTMP,STATUS)
            IF(STATUS.NE.SUCCESS_P)RETURN

            CALL M_MARELV(SFC_NRECS(FNUM),MISS_P,LATTMP,LONTMP,ELEVTMP)

C     ------------------------------------------------------------------
C     MARITIME:  P, ELEV --> ALT  (THE 100'S ARE TO PUT P INTO MB AND
C     THEN BACK INTO PASCALS)
C     ------------------------------------------------------------------
     
            DO 10 I = 1, SFC_NRECS(FNUM)
               IF(OB(I).NE.MISS_P.AND.QCDESC(I).NE.'B'.AND.
     1            QCDESC(I).NE.'X'.AND.QCDESC(I).NE.'Q'.AND.
     2            ELEVTMP(I).NE.MISS_P.AND.OB(I).GT.0.3.AND.
     3            OB(I).LE.110000.0)THEN

                  OB(I) = M_PRSALT(OB(I)/100.,ELEVTMP(I)) * 100.

               ELSE

                  OB(I) = MISS_P
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'
                  
               ENDIF

 10         CONTINUE

         ELSE

C     ------------------------------------------------------------------
C     METAR, SAO, AND URBANET:  ALT, ELEV --> P (THE 100'S ARE TO PUT P 
C     INTO MB AND THEN BACK INTO PASCALS).  
C     ------------------------------------------------------------------
            DO 20 I = 1, SFC_NRECS(FNUM)
               IF(OB(I).NE.MISS_P.AND.QCDESC(I).NE.'B'.AND.
     1            QCDESC(I).NE.'X'.AND.QCDESC(I).NE.'Q'.AND.
     2            ELEVTMP(I).NE.MISS_P.AND.OB(I).GT.0.0.AND.
     3            OB(I).LE.110000.0)THEN

                  OB(I) = M_ALTPRS(OB(I)/100.,ELEVTMP(I)) * 100.

               ELSE

                  OB(I) = MISS_P
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'
                  
               ENDIF

 20         CONTINUE

         ENDIF

      ELSE IF(DSN.EQ.MESONET_DS_P)THEN
C     ------------------------------------------------------------------
C     FOR MESONET, WE'LL READ BOTH VARIABLES, AND THEIR QC STRUCTURES.
C     WE'LL ALSO READ ELEVATION, BECAUSE WE'LL NEED IT TO DO ANY
C     CONVSERSIONS TO EITHER DESIRED VARIABLE.  THEN, WE'LL RETURN 
C     EITHER THE READ-IN VALUE OR THE CALCULATED VALUE FOR THE FORM OF 
C     THE VARIABLE DESIRED BY THE CALLER.  
C     ------------------------------------------------------------------
         CALL MGTNUM(VNAME(ALT_VN_P,DSN)(1:VLEN(ALT_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2               MISS_P,OBTMP(1,1),STATUS)

         IF(STATUS.NE.SUCCESS_P)RETURN
         QCMISS(1) = .TRUE.
         IF(VQC(ALT_VN_P,DSN).EQ.'Q')THEN
               
            CALL MGTNUM(VNAME(ALT_VN_P,DSN)(1:VLEN(ALT_VN_P,DSN))//
     2           'QCA',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     3           SFC_NRECS(FNUM),MISS_P,QCATMP(1,1),STATUS)
            IF(STATUS.EQ.VAR_NOTINDB_P)THEN
               STATUS = SUCCESS_P
               DO I = 1, SFC_NRECS(FNUM)
                  QCATMP(I,1) = 0
                  QCRTMP(I,1) = 0
                  QCDTMP(I,1) = 'Z'
               ENDDO
            ELSE IF(STATUS.NE.SUCCESS_P)THEN
               RETURN
            ELSE
               CALL MGTNUM(VNAME(ALT_VN_P,DSN)(1:VLEN(ALT_VN_P,DSN))
     2              //'QCR',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     3              SFC_NRECS(FNUM),MISS_P,QCRTMP(1,1),STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
               CALL MGTCHR(VNAME(ALT_VN_P,DSN)(1:VLEN(ALT_VN_P,DSN))
     2              //'DD',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     3              SFC_NRECS(FNUM),QCDTMP(1,1),LEN1REC,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
               QCMISS(1) = .FALSE.
            ENDIF
         ELSE
            DO 21 I = 1, SFC_NRECS(FNUM)
               QCATMP(I,1) = 0
               QCRTMP(I,1) = 0
               QCDTMP(I,1) = 'Z'
 21         CONTINUE

         ENDIF

         CALL MGTNUM(VNAME(SFCP_VN_P,DSN)(1:VLEN(SFCP_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2               SFC_NRECS(FNUM),MISS_P,OBTMP(1,2),STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

         QCMISS(2) = .TRUE.
         IF(VQC(SFCP_VN_P,DSN).EQ.'Q')THEN

            CALL MGTNUM(VNAME(SFCP_VN_P,DSN)(1:VLEN(SFCP_VN_P,DSN))//
     1                  'QCA',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCATMP(1,2),STATUS)
            IF(STATUS.EQ.VAR_NOTINDB_P)THEN
               QCSTATUS = EQCFAILED_P
               STATUS = SUCCESS_P
               DO I = 1, SFC_NRECS(FNUM)
                  QCATMP(I,2) = 0
                  QCRTMP(I,2) = 0
                  QCDTMP(I,2) = 'Z'
               ENDDO
            ELSE IF(STATUS.NE.SUCCESS_P)THEN
               RETURN
            ELSE
               CALL MGTNUM(VNAME(SFCP_VN_P,DSN)(1:VLEN(SFCP_VN_P,DSN))//
     1                  'QCR',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),MISS_P,QCRTMP(1,2),STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
               CALL MGTCHR(VNAME(SFCP_VN_P,DSN)(1:VLEN(SFCP_VN_P,DSN))//
     1                  'DD',SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,
     2                  SFC_NRECS(FNUM),QCDTMP(1,2),LEN1REC,STATUS)
               IF(STATUS.NE.SUCCESS_P)RETURN
               QCMISS(2) = .FALSE.
            ENDIF
         ELSE
            QCSTATUS = EQCFAILED_P

            DO 11 I = 1, SFC_NRECS(FNUM)
               QCATMP(I,2) = 0
               QCRTMP(I,2) = 0
               QCDTMP(I,2) = 'Z'
 11         CONTINUE

         ENDIF

C     ------------------------------------------------------------------
C     GET THE STATION ELEVATIONS.
C     ------------------------------------------------------------------
         CALL MGTNUM(VNAME(ELEV_VN_P,DSN)(1:VLEN(ELEV_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2               MISS_P,ELEVTMP,STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

C     ------------------------------------------------------------------
C     HANDLE MESONET ALT.
C     ------------------------------------------------------------------
         IF(VCN.EQ.ALT_VN_P)THEN

            IF(QCMISS(1) .AND. QCMISS(2))THEN
               QCSTATUS = EQCFAILED_P
            ELSE
               QCSTATUS = EQCOK_P
            ENDIF

            DO 31 I = 1, SFC_NRECS(FNUM)

               IF(.NOT.QCMISS(1) .AND. OBTMP(I,1).NE.MISS_P)THEN
                  OB(I) = OBTMP(I,1)
                  QCAPP(I) = QCATMP(I,1)
                  QCRES(I) = QCRTMP(I,1)
                  QCDESC(I) = QCDTMP(I,1)                  

               ELSE IF(.NOT.QCMISS(2) .AND. OBTMP(I,2).NE.MISS_P.AND.
     1                 ELEVTMP(I).NE.MISS_P.AND.QCDTMP(I,2).NE.'B'.AND.
     2                 QCDTMP(I,2).NE.'X'.AND.QCDTMP(I,2).NE.'Q'.AND.
     3                 OBTMP(I,2).GT.0.3.AND.OBTMP(I,2).LE.110000.0)THEN

                  OB(I) = M_PRSALT(OBTMP(I,2)/100.,ELEVTMP(I)) * 100.
                  QCAPP(I) = QCATMP(I,2)
                  QCRES(I) = QCRTMP(I,2)
                  QCDESC(I) = QCDTMP(I,2)

               ELSE IF(OBTMP(I,1).NE.MISS_P)THEN

                  OB(I) = OBTMP(I,1)
                  QCAPP(I) = QCATMP(I,1)
                  QCRES(I) = QCRTMP(I,1)
                  QCDESC(I) = QCDTMP(I,1)

               ELSE IF(OBTMP(I,2).NE.MISS_P.AND.
     1                 ELEVTMP(I).NE.MISS_P.AND.QCDTMP(I,2).NE.'B'.AND.
     2                 QCDTMP(I,2).NE.'X'.AND.QCDTMP(I,2).NE.'Q'.AND.
     3                 OBTMP(I,2).GT.0.3.AND.OBTMP(I,2).LE.110000.0)THEN

                  OB(I) = M_PRSALT(OBTMP(I,2)/100.,ELEVTMP(I)) * 100.
                  QCAPP(I) = QCATMP(I,2)
                  QCRES(I) = QCRTMP(I,2)
                  QCDESC(I) = QCDTMP(I,2)

               ELSE
                  OB(I) = MISS_P
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'

               ENDIF

 31         CONTINUE

C     ------------------------------------------------------------------
C     HANDLE MESONET SFC P.  NOTE THAT IF ALTIMETER QC IS AVAILABLE, WE 
C     USE THAT FOR THE P QC (BECAUSE OF THE SPATIAL C.C.).
C     ------------------------------------------------------------------
         ELSE

            DO 41 I = 1, SFC_NRECS(FNUM)

               IF(OBTMP(I,2).NE.MISS_P)THEN

                  OB(I) = OBTMP(I,2)

C     ------------------------------------------------------------------
C     HERE'S WHERE WE USE THE ALT QC, IF AVAILABLE, WHEN RETURNING P.
C     ------------------------------------------------------------------
                  IF(OBTMP(I,1).NE.MISS_P)THEN
                     QCAPP(I) = QCATMP(I,1)
                     QCRES(I) = QCRTMP(I,1)
                     QCDESC(I) = QCDTMP(I,1)
                  ELSE
                     QCAPP(I) = QCATMP(I,2)
                     QCRES(I) = QCRTMP(I,2)
                     QCDESC(I) = QCDTMP(I,2)
                  ENDIF

               ELSE IF(OBTMP(I,1).NE.MISS_P.AND.OBTMP(I,1).GT.0.AND.
     1                 QCDTMP(I,1).NE.'B'.AND.QCDTMP(I,1).NE.'X'.AND.
     2                 QCDTMP(I,1).NE.'Q'.AND.OBTMP(I,1).GT.0.0.AND.
     3                 OBTMP(I,1).LE.110000.0)THEN

                  OB(I) = M_ALTPRS(OBTMP(I,1)/100.,ELEVTMP(I)) * 100.
                  QCAPP(I) = QCATMP(I,1)
                  QCRES(I) = QCRTMP(I,1)
                  QCDESC(I) = QCDTMP(I,1)

               ELSE

                  OB(I) = MISS_P
                  QCAPP(I) = 0
                  QCRES(I) = 0
                  QCDESC(I) = 'Z'

               ENDIF

 41         CONTINUE

         ENDIF

      ELSE IF((DSN.EQ.COOP_DS_P.OR.DSN.EQ.CRN_DS_P)
     1         .AND.VCN.EQ.SFCP_VN_P)THEN

C     ------------------------------------------------------------------
C     GET THE STATION ELEVATIONS, THEN USE THE U.S. STANDARD ATMOSPHERE
C     CALCULATION TO RETURN PRESSURE.  (NOTE THAT M_ZTOPSA RETURNS
C     MB, WE RETURN PA.)
C     ------------------------------------------------------------------
         CALL MGTNUM(VNAME(ELEV_VN_P,DSN)(1:VLEN(ELEV_VN_P,DSN)),
     1               SFC_NCID(FNUM),SFC_RECDIM(FNUM),1,SFC_NRECS(FNUM),
     2               MISS_P,ELEVTMP,STATUS)
         IF(STATUS.NE.SUCCESS_P)RETURN

         DO I = 1, SFC_NRECS(FNUM)

            IF(ELEVTMP(I).NE.MISS_P)THEN
               
               OB(I) = M_ZTOPSA(ELEVTMP(I),MISS_P) * 100.0
               
            ELSE

               OB(I) = MISS_P
               
            ENDIF

            QCAPP(I) = 0
            QCRES(I) = 0
            QCDESC(I) = 'Z'

         ENDDO

      ELSE IF((DSN.EQ.COOP_DS_P.OR.DSN.EQ.CRN_DS_P)
     1         .AND.VCN.NE.SFCP_VN_P)THEN

C     ------------------------------------------------------------------
C     IF THE CALLER HAS ASKED FOR COOP/CRN ALTIMETER, NO CAN DO...  THIS
C     SHOULDN'T HAPPEN EXCEPT FOR A PROGRAMMING ERROR -- THE USER ISN'T
C     DIRECTLY OFFERRED ANY PRESSURE OBS FOR COOP.
C     ------------------------------------------------------------------
         STATUS = INV_VCN_P

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