      SUBROUTINE SKY80P(nlev,pd,pd8,gtemp)
C****IN THIS APPLICATION,SKY80P TAKES IN PSTAR AND RETURNS DATA
C****LEVEL PRESSURES PD.(DIM 82,PD(1)=0,PD(82)=PSTAR)
C***  THE INPUT,OUTPUT PRESSURES ARE IN MB******
      implicit real(selected_real_kind(15)) (a-h,o-z)
      dimension q(80),qmh(81),qi(80),pd(200),pd8(200),gtemp(200)
      dimension plm(200)
      DATA Q/3.0048389E-07,7.7225698E-07,1.6748142E-06,3.2701594E-06,
     1     5.9000549E-06, 1.0061819E-05, 1.6268606E-05, 2.4933648E-05,
     2     3.6552699E-05, 5.1701686E-05, 7.1004114E-05, 9.5131055E-05,
     3     1.2480116E-04, 1.6078072E-04, 2.0392604E-04, 2.5549930E-04,
     4     3.1701189E-04, 3.8987631E-04, 4.7564623E-04, 5.7602575E-04,
     5     6.9316870E-04, 8.3003441E-04, 9.8990388E-04, 1.1760961E-03,
     6     1.3933353E-03, 1.6476632E-03, 1.9453214E-03, 2.2933711E-03,
     7     2.6999937E-03, 3.1746642E-03, 3.7283529E-03, 4.3737555E-03,
     8     5.1255595E-03, 6.0007491E-03, 7.0189556E-03, 8.2028578E-03,
     9     9.5786412E-03, 1.1176520E-02, 1.3031334E-02, 1.5183222E-02,
     A     1.7678386E-02, 2.0569954E-02, 2.3918942E-02, 2.7795333E-02,
     1     3.2279265E-02, 3.7462350E-02, 4.3449095E-02, 5.0358442E-02,
     2     5.8306312E-02, 6.7394856E-02, 7.7744210E-02, 8.9501313E-02,
     3     1.0282456E-01, 1.1788332E-01, 1.3485707E-01, 1.5393386E-01,
     4     1.7530822E-01, 1.9917813E-01, 2.2571259E-01, 2.5473484E-01,
     5     2.8597155E-01, 3.1939434E-01, 3.5494172E-01, 3.9251494E-01,
     6     4.3197377E-01, 4.7313236E-01, 5.1575521E-01, 5.5955356E-01,
     7     6.0418221E-01, 6.4923710E-01, 6.9425381E-01, 7.3870736E-01,
     8     7.8201346E-01, 8.2353171E-01, 8.6257094E-01, 8.9839709E-01,
     9     9.3024409E-01, 9.5732772E-01, 9.7886309E-01, 9.9408549E-01/
      DATA QMH/    0.0, 5.0947389E-07, 1.1705817E-06, 2.3962467E-06,
     1     4.4627886E-06, 7.8002008E-06, 1.2979178E-05, 2.0391704E-05,
     2     3.0487240E-05, 4.3824885E-05, 6.0994211E-05, 8.2656765E-05,
     3     1.0948792E-04, 1.4225615E-04, 1.8171755E-04, 2.2884873E-04,
     4     2.8525346E-04, 3.5230612E-04, 4.3145301E-04, 5.2436611E-04,
     5     6.3277482E-04, 7.5932675E-04, 9.0732629E-04, 1.0799970E-03,
     6     1.2807462E-03, 1.5158220E-03, 1.7909715E-03, 2.1129734E-03,
     7     2.4891705E-03, 2.9286727E-03, 3.4413176E-03, 4.0393293E-03,
     8     4.7358696E-03, 5.5473149E-03, 6.4912468E-03, 7.5895646E-03,
     9     8.8657096E-03, 1.0348903E-02, 1.2070324E-02, 1.4068858E-02,
     A     1.6385852E-02, 1.9072877E-02, 2.2184541E-02, 2.5788941E-02,
     1     2.9957823E-02, 3.4780597E-02, 4.0350880E-02, 4.6785197E-02,
     2     5.4204596E-02, 6.2718409E-02, 7.2419991E-02, 8.3459859E-02,
     3     9.5980093E-02, 1.1015711E-01, 1.2615144E-01, 1.4416346E-01,
     4     1.6436642E-01, 1.8697840E-01, 2.1217386E-01, 2.4011521E-01,
     5     2.7024459E-01, 3.0261376E-01, 3.3710545E-01, 3.7372171E-01,
     6     4.1225322E-01, 4.5263768E-01, 4.9455500E-01, 5.3786422E-01,
     7     5.8211753E-01, 6.2708324E-01, 6.7217362E-01, 7.1705931E-01,
     8     7.6100896E-01, 8.0359771E-01, 8.4396020E-01, 8.8159207E-01,
     9 9.1552246E-01, 9.4520244E-01, 9.6960855E-01, 9.8820596E-01,1.0/
C  THE GENERAL FORMULAS FOR SKYHI PRESSURES ARE: 
C   FOR THE UPPER SANDWICH-K=1,60(LH)-----
C
C     QI(I,K)=1013250.*Q(K)/PSS(I)
C
C  FOR THE LOWER SANDWICH K=61,80
C
C    QI(I,K)=PC*(1.-Q(K))+PSS(I)*(Q(K)-QMH(61))
C            ---------------------------------
C             PSS(I)*(1.-QMH(61))
C
C    WHERE PC=1013250.*QMH(61),PSS(I)=SFC PRESSURE AT POINT I,
C    AND Q,QMH ARE SPECIFIED LEVELS
C
C    FOR THE CASE PSS=1013250. (STANDARD PRESSURE) BOTH FORMULAS
C     REDUCE TO QI(I,K)=Q(K) FOR ALL K.
      kd=80
      kp=kd+1
      lh=60
      km=kd-1
      lhp=lh+1
      kp2=kd+2
      PSS=1.0*1013250.
      DO 1 K=1,LH
      QI(K)=1013250.*Q(K)/PSS
      PD(K+1)=QI(K)*PSS
1     CONTINUE
      DO 2 K=LHP,KD
      QI(K)=(1013250.*QMH(LHP)*(1.-Q(K))+PSS*(Q(K)-QMH(LHP)))/
     1   (PSS*(1.-QMH(LHP)))
      PD(K+1)=QI(K)*PSS
2     CONTINUE
      PD(1)=0.
      PD(KP2)=PSS
      PLM(1)=0.
      DO 3 K=1,KM
      PLM(K+1)=0.5*(PD(K+1)+PD(K+2))
3     CONTINUE
      PLM(KP)=PSS
      DO 4 K=1,KD
      GTEMP(K)=PD(K+1)**0.2*(1.+PD(K+1)/30000.)**0.8/1013250.
4     CONTINUE
      GTEMP(KP)=0.
      WRITE (10,100) (GTEMP(K),K=1,KD)
      WRITE (10,100) (PD(K),K=1,KP2)
      WRITE (10,100) (PLM(K),K=1,KP)
C  THE FOLLOWING PUTS P-DATA INTO MB
      DO 11 I=1,KP
      PD(I)=PD(I)*1.0E-3
      PLM(I)=PLM(I)*1.0E-3
11    CONTINUE
      PD(KP2)=PD(KP2)*1.0E-3
C***TAPES 41,42 ARE OUTPUT TO THE CO2 INTERPOLATION PROGRAM(PS=1013 MB)
      WRITE (41,101) (PD(K),K=1,KP2)
      WRITE (41,101) (PLM(K),K=1,KP)
      WRITE (42,101) (PLM(K),K=1,KP)
C***SECOND PASS: PSS=810 MB,GTEMP NOT COMPUTED
      PSS=0.8*1013250.
      DO 201 K=1,LH
      QI(K)=1013250.*Q(K)/PSS
      PD8(K+1)=QI(K)*PSS
201   CONTINUE
      DO 202 K=LHP,KD
      QI(K)=(1013250.*QMH(LHP)*(1.-Q(K))+PSS*(Q(K)-QMH(LHP)))/
     1   (PSS*(1.-QMH(LHP)))
      PD8(K+1)=QI(K)*PSS
202   CONTINUE
      PD8(1)=0.
      PD8(KP2)=PSS
      PLM(1)=0.
      DO 203 K=1,KM
      PLM(K+1)=0.5*(PD8(K+1)+PD8(K+2))
203   CONTINUE
      PLM(KP)=PSS
      WRITE (10,100) (PD8(K),K=1,KP2)
      WRITE (10,100) (PLM(K),K=1,KP)
C  THE FOLLOWING PUTS P-DATA INTO MB
      DO 211 I=1,KP
      PD8(I)=PD8(I)*1.0E-3
      PLM(I)=PLM(I)*1.0E-3
211   CONTINUE
      PD8(KP2)=PD8(KP2)*1.0E-3
C***TAPES 43,44 ARE OUTPUT TO THE CO2 INTERPOLATION PROGRAM(PS=810 MB)
      WRITE (43,101) (PD8(K),K=1,KP2)
      WRITE (43,101) (PLM(K),K=1,KP)
      WRITE (44,101) (PLM(K),K=1,KP)
100   FORMAT (1X,5E20.13)
101   FORMAT (5E16.9)
      RETURN
      END
