FORALL (j=0:nlat,i=0:nlon) t36(i,j) = 0.25*f(i,j)*(hxt(i,j)*hyt(i
     .  ,j)+hxt(i,j+1)*hyt(i,j+1)+hxt(i+1,j)*hyt(i+1,j)+hxt(i+1,j+1)*hy
     .  t(i+1,j+1))
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon+1) e(i,j,k) = 0.25*((PVZ(i,j
     .  ,k)**2*hxv(i,j)+PVZ(i,j-1,k)**2*hxv(i,j-1))/hxt(i,j)+(PUZ(i,j,k
     .  )**2*hyu(i,j)+PUZ(i-1,j,k)**2*hyu(i-1,j))/hyt(i,j))
      FORALL (k=1:nlev+1,j=0:nlat+2,i=0:nlon+2) p(i,j,k) = AHYB(k)+BHYB
     .  (k)*PS(i,j)
      FORALL (k=2:nlev+1,j=0:nlat+1,i=0:nlon+1) t13(i,j,k) = LOG(p(i,j,
     .  k))*p(i,j,k)
CMIC$ DO ALL
      DO 1000 k = 1,nlev
         DO 1010 j = 0,nlat+1
            DO 1020 i = 0,nlon+1
               IF (k.LE.1) THEN
                  lnp(i,j,k) = t13(i,j,2)/(p(i,j,k+1)-p(i,j,k))
               ELSE
                  lnp(i,j,k) = (t13(i,j,k+1)-t13(i,j,k))/(p(i,j,k+1)-p(
     .  i,j,k))
               ENDIF
1020        CONTINUE
1010     CONTINUE
1000  CONTINUE
      FORALL (k=2:nlev,j=1:nlat+1,i=1:nlon+1) t18(i,j,k) = LOG(p(i,j,k)
     .  /p(i,j,k+1))
      FORALL (j=1:nlat+1,i=1:nlon+1) t20(i,j,nlev) = 0
      DO 1030 k = nlev,2,-1
         FORALL (j=1:nlat+1,i=1:nlon+1) t20(i,j,k-1) = t20(i,j,k)+PTZ(i
     .  ,j,k)*t18(i,j,k)*(0.607824693422519*PQZ(i,j,k)+1)
1030  CONTINUE
      FORALL (k=2:nlev,j=1:nlat+1,i=1:nlon+1) t26(i,j,k) = p(i,j,k)*t18
     .  (i,j,k)/(p(i,j,k+1)-p(i,j,k))+1
CMIC$ DO ALL
      DO 1040 k = 1,nlev
         DO 1050 j = 1,nlat+1
            DO 1060 i = 1,nlon+1
               IF (k.LE.1) THEN
                  phi(i,j,k) = phis(i,j)+198.960966707927*PTZ(i,j,k)*(0
     .  .607824693422519*PQZ(i,j,1)+1)-287.04*t20(i,j,1)
               ELSE
                  phi(i,j,k) = phis(i,j)-287.04*(t20(i,j,k)-PTZ(i,j,k)*
     .  t26(i,j,k)*(0.607824693422519*PQZ(i,j,k)+1))
               ENDIF
1060        CONTINUE
1050     CONTINUE
1040  CONTINUE
      FORALL (k=1:nlev,j=0:nlat+1,i=0:nlon+1) t31(i,j,k) = hxt(i,j)*hyt
     .  (i,j)*(p(i,j,k+1)-p(i,j,k))
      FORALL (k=1:nlev,j=0:nlat,i=0:nlon) z(i,j,k) = 4*((t36(i,j)-1.569
     .  61230576048E-7*(rdlam*(hyv(i,j)*PVZ(i,j,k)-hyv(i+1,j)*PVZ(i+1,j
     .  ,k))-rdth*(hxu(i,j)*PUZ(i,j,k)-hxu(i,j+1)*PUZ(i,j+1,k))))/(t31(
     .  i,j,k)+t31(i,j+1,k)+t31(i+1,j,k)+t31(i+1,j+1,k)))
      FORALL (k=1:nlev,j=1:nlat+1,i=0:nlon+1) t47(i,j,k) = p(i,j,k)+p(i
     .  +1,j,k)-p(i,j,k+1)-p(i+1,j,k+1)
      FORALL (k=1:nlev,j=1:nlat,i=1:nlon+1) t102(i,j,k) = -0.5*hyu(i-1,
     .  j)*t47(i-1,j,k)*PUZ(i-1,j,k)*(lnp(i,j,k)-lnp(i-1,j,k))
      FORALL (k=1:nlev,j=1:nlat,i=1:nlon+1) t103(i,j,k) = t102(i,j,k)*(
     .  PTZ(i,j,k)*PQZ(i,j,k)+PTZ(i-1,j,k)*PQZ(i-1,j,k))
      FORALL (k=1:nlev,j=1:nlat,i=1:nlon+1) t116(i,j,k) = -0.5*hyu(i-1,
     .  j)*t47(i-1,j,k)*PUZ(i-1,j,k)*(PTZ(i,j,k)-PTZ(i-1,j,k))
      FORALL (k=1:nlev,j=1:nlat,i=1:nlon+1) t151(i,j,k) = -0.5*hyu(i-1,
     .  j)*t47(i-1,j,k)*PUZ(i-1,j,k)*(PQZ(i,j,k)-PQZ(i-1,j,k))
      FORALL (k=1:nlev,j=0:nlat+1,i=1:nlon+1) t49(i,j,k) = p(i,j,k)+p(i
     .  ,j+1,k)-p(i,j,k+1)-p(i,j+1,k+1)
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon) t107(i,j,k) = -0.5*hxv(i,j-
     .  1)*t49(i,j-1,k)*PVZ(i,j-1,k)*(lnp(i,j,k)-lnp(i,j-1,k))
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon) t108(i,j,k) = t107(i,j,k)*(
     .  PTZ(i,j,k)*PQZ(i,j,k)+PTZ(i,j-1,k)*PQZ(i,j-1,k))
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon) t120(i,j,k) = -0.5*hxv(i,j-
     .  1)*t49(i,j-1,k)*PVZ(i,j-1,k)*(PTZ(i,j,k)-PTZ(i,j-1,k))
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon) t155(i,j,k) = -0.5*hxv(i,j-
     .  1)*t49(i,j-1,k)*PVZ(i,j-1,k)*(PQZ(i,j,k)-PQZ(i,j-1,k))
      FORALL (j=1:nlat+1,i=1:nlon+2) t61(i,j,nlev+1) = 0
      DO 1070 k = nlev,1,-1
         FORALL (j=1:nlat+1,i=1:nlon+2) t61(i,j,k) = t61(i,j,k+1)+t47(i
     .  -1,j,k)*PUZ(i-1,j,k)
1070  CONTINUE
      FORALL (k=1:nlev+1,j=1:nlat+1,i=1:nlon+2) t61(i,j,k) = -0.5*t61(i
     .  ,j,k)
      FORALL (j=1:nlat+2,i=1:nlon+1) t65(i,j,nlev+1) = 0
      DO 1080 k = nlev,1,-1
         FORALL (j=1:nlat+2,i=1:nlon+1) t65(i,j,k) = t65(i,j,k+1)+t49(i
     .  ,j-1,k)*PVZ(i,j-1,k)
1080  CONTINUE
      FORALL (k=1:nlev+1,j=1:nlat+2,i=1:nlon+1) t65(i,j,k) = -0.5*t65(i
     .  ,j,k)
      FORALL (k=1:nlev+1,j=1:nlat+1,i=1:nlon+1) t70(i,j,k) = 1.56961230
     .  576048E-7*((rdlam*(hyu(i,j)*t61(i+1,j,k)-hyu(i-1,j)*t61(i,j,k))
     .  +rdth*(hxv(i,j)*t65(i,j+1,k)-hxv(i,j-1)*t65(i,j,k)))/(hxt(i,j)*
     .  hyt(i,j)))
      FORALL (j=1:nlat+1,i=1:nlon+1) PDPSDT(i,j) = -t70(i,j,1)
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon+1) etap(i,j,k) = t70(i,j,k)+
     .  PDPSDT(i,j)*(1-BHYB(k))
      FORALL (k=2:nlev,j=1:nlat,i=1:nlon) t144(i,j,k) = etap(i,j,k)*(PT
     .  Z(i,j,k-1)-PTZ(i,j,k))
      FORALL (k=2:MAX(2,nlev),j=1:nlat,i=1:nlon) t166(i,j,k) = etap(i,j
     .  ,k)*(PQZ(i,j,k)-PQZ(i,j,k-1))
CMIC$ DO ALL
      DO 1090 k = 1,nlev
         DO 1100 j = 1,nlat
            DO 1110 i = 1,nlon
               IF (nlev.LE.k) THEN
                  PDQDT(i,j,k) = (7.84806152880239E-8*((rdlam*((-t151(i
     .  ,j,nlev))-t151(i+1,j,nlev))+rdth*((-t155(i,j,nlev))-t155(i,j+1,
     .  nlev)))/(hxt(i,j)*hyt(i,j)))-0.5*t166(i,j,nlev))/(p(i,j,k+1)-p(
     .  i,j,k))
               ELSE IF (k.LE.1) THEN
                  PDQDT(i,j,k) = (7.84806152880239E-8*((rdlam*((-t151(i
     .  ,j,1))-t151(i+1,j,1))+rdth*((-t155(i,j,1))-t155(i,j+1,1)))/(hxt
     .  (i,j)*hyt(i,j)))-0.5*t166(i,j,2))/(p(i,j,k+1)-p(i,j,k))
               ELSE
                  PDQDT(i,j,k) = (7.84806152880239E-8*((rdlam*((-t151(i
     .  ,j,k))-t151(i+1,j,k))+rdth*((-t155(i,j,k))-t155(i,j+1,k)))/(hxt
     .  (i,j)*hyt(i,j)))-0.5*(t166(i,j,k)+t166(i,j,k+1)))/(p(i,j,k+1)-p
     .  (i,j,k))
               ENDIF
1110        CONTINUE
1100     CONTINUE
1090  CONTINUE
      FORALL (k=2:MAX(2,nlev),j=1:nlat,i=1:nlon) t192(i,j,k) = (PUZ(i,j
     .  ,k)-PUZ(i,j,k-1))*(etap(i,j,k)+etap(i+1,j,k))
      FORALL (k=2:MAX(2,nlev),j=1:nlat,i=1:nlon) t219(i,j,k) = (PVZ(i,j
     .  ,k)-PVZ(i,j,k-1))*(etap(i,j,k)+etap(i,j+1,k))
      FORALL (k=1:nlev,j=1:nlat,i=1:nlon+1) t90(i,j,k) = t102(i,j,k)*(P
     .  TZ(i,j,k)*(1-PQZ(i,j,k))+PTZ(i-1,j,k)*(1-PQZ(i-1,j,k)))
      FORALL (k=1:nlev,j=1:nlat+1,i=1:nlon) t95(i,j,k) = t107(i,j,k)*(P
     .  TZ(i,j,k)*(1-PQZ(i,j,k))+PTZ(i,j-1,k)*(1-PQZ(i,j-1,k)))
CMIC$ DO ALL
      DO 1120 k = 1,nlev
         DO 1130 j = 1,nlat
            DO 1140 i = 1,nlon
               IF (k.LE.1) THEN
                  PDTDT(i,j,k) = (0.5*t144(i,j,2)+(1.55424620615724E-8*
     .  PTZ(i,j,k)*(1/(0.860825768434464*PQZ(i,j,1)+1)+0.60782469342251
     .  9*(PQZ(i,j,1)/(0.860825768434464*PQZ(i,j,1)+1)))*(rdlam*(hyu(i,
     .  j)*t47(i,j,1)*PUZ(i,j,1)-hyu(i-1,j)*t47(i-1,j,1)*PUZ(i-1,j,1))+
     .  rdth*(hxv(i,j)*t49(i,j,1)*PVZ(i,j,1)-hxv(i,j-1)*t49(i,j-1,1)*PV
     .  Z(i,j-1,1)))+7.84806152880239E-8*(rdlam*((-t116(i,j,1))-t116(i+
     .  1,j,1))+rdth*((-t120(i,j,1))-t120(i,j+1,1)))-0.285714285714286*
     .  ((3.92403076440119E-8*(rdlam*((-t90(i,j,1))-t90(i+1,j,1))+rdth*
     .  ((-t95(i,j,1))-t95(i,j+1,1)))+6.30915356075388E-8*(rdlam*((-t10
     .  3(i,j,1))-t103(i+1,j,1))+rdth*((-t108(i,j,1))-t108(i,j+1,1))))/
     .  (0.860825768434464*PQZ(i,j,1)+1)))/(hxt(i,j)*hyt(i,j)))/(p(i,j,
     .  k+1)-p(i,j,k))
               ELSE IF (nlev.LE.k) THEN
                  PDTDT(i,j,k) = (0.285714285714286*PTZ(i,j,k)*(7.84806
     .  152880239E-8*((t18(i,j,nlev)+t26(i,j,nlev))*(rdlam*(hyu(i,j)*t4
     .  7(i,j,nlev)*PUZ(i,j,nlev)-hyu(i-1,j)*t47(i-1,j,nlev)*PUZ(i-1,j,
     .  nlev))+rdth*(hxv(i,j)*t49(i,j,nlev)*PVZ(i,j,nlev)-hxv(i,j-1)*t4
     .  9(i,j-1,nlev)*PVZ(i,j-1,nlev)))/(hxt(i,j)*hyt(i,j)))-t18(i,j,nl
     .  ev)*(PDPSDT(i,j)+t70(i,j,nlev+1)))*(1/(0.860825768434464*PQZ(i,
     .  j,nlev)+1)+0.607824693422519*(PQZ(i,j,nlev)/(0.860825768434464*
     .  PQZ(i,j,nlev)+1)))+0.5*t144(i,j,nlev)+(7.84806152880239E-8*(rdl
     .  am*((-t116(i,j,nlev))-t116(i+1,j,nlev))+rdth*((-t120(i,j,nlev))
     .  -t120(i,j+1,nlev)))-0.285714285714286*((3.92403076440119E-8*(rd
     .  lam*((-t90(i,j,nlev))-t90(i+1,j,nlev))+rdth*((-t95(i,j,nlev))-t
     .  95(i,j+1,nlev)))+6.30915356075388E-8*(rdlam*((-t103(i,j,nlev))-
     .  t103(i+1,j,nlev))+rdth*((-t108(i,j,nlev))-t108(i,j+1,nlev))))/(
     .  0.860825768434464*PQZ(i,j,nlev)+1)))/(hxt(i,j)*hyt(i,j)))/(p(i,
     .  j,k+1)-p(i,j,k))
               ELSE
                  PDTDT(i,j,k) = (0.285714285714286*PTZ(i,j,k)*(7.84806
     .  152880239E-8*((t18(i,j,k)+t26(i,j,k))*(rdlam*(hyu(i,j)*t47(i,j,
     .  k)*PUZ(i,j,k)-hyu(i-1,j)*t47(i-1,j,k)*PUZ(i-1,j,k))+rdth*(hxv(i
     .  ,j)*t49(i,j,k)*PVZ(i,j,k)-hxv(i,j-1)*t49(i,j-1,k)*PVZ(i,j-1,k))
     .  )/(hxt(i,j)*hyt(i,j)))-t18(i,j,k)*(PDPSDT(i,j)+t70(i,j,k+1)))*(
     .  1/(0.860825768434464*PQZ(i,j,k)+1)+0.607824693422519*(PQZ(i,j,k
     .  )/(0.860825768434464*PQZ(i,j,k)+1)))+0.5*(t144(i,j,k)+t144(i,j,
     .  k+1))+(7.84806152880239E-8*(rdlam*((-t116(i,j,k))-t116(i+1,j,k)
     .  )+rdth*((-t120(i,j,k))-t120(i,j+1,k)))-0.285714285714286*((3.92
     .  403076440119E-8*(rdlam*((-t90(i,j,k))-t90(i+1,j,k))+rdth*((-t95
     .  (i,j,k))-t95(i,j+1,k)))+6.30915356075388E-8*(rdlam*((-t103(i,j,
     .  k))-t103(i+1,j,k))+rdth*((-t108(i,j,k))-t108(i,j+1,k))))/(0.860
     .  825768434464*PQZ(i,j,k)+1)))/(hxt(i,j)*hyt(i,j)))/(p(i,j,k+1)-p
     .  (i,j,k))
               ENDIF
1140        CONTINUE
1130     CONTINUE
1120  CONTINUE
CMIC$ DO ALL
      DO 1150 k = 1,nlev
         DO 1160 j = 1,nlat
            DO 1170 i = 1,nlon
               IF (nlev.LE.k) THEN
                  PDUDT(i,j,k) = 0.5*(t192(i,j,nlev)/t47(i,j,nlev))+(rd
     .  lam*(1.56961230576048E-7*(e(i,j,k)+phi(i,j,nlev)-e(i+1,j,k)-phi
     .  (i+1,j,nlev))+2.25270758122744E-5*(0.30391234671126*(PQZ(i,j,nl
     .  ev)+PQZ(i+1,j,nlev))+1)*(lnp(i,j,k)-lnp(i+1,j,k))*(PTZ(i,j,k)+P
     .  TZ(i+1,j,k)))-0.0625*(z(i,j,k)+z(i,j-1,k))*(hyv(i,j)*t49(i,j,nl
     .  ev)*PVZ(i,j,nlev)+hyv(i,j-1)*t49(i,j-1,nlev)*PVZ(i,j-1,nlev)+hy
     .  v(i+1,j)*t49(i+1,j,nlev)*PVZ(i+1,j,nlev)+hyv(i+1,j-1)*t49(i+1,j
     .  -1,nlev)*PVZ(i+1,j-1,nlev)))/hxu(i,j)
               ELSE IF (k.LE.1) THEN
                  PDUDT(i,j,k) = 0.5*(t192(i,j,2)/t47(i,j,1))+(rdlam*(1
     .  .56961230576048E-7*(e(i,j,k)+phi(i,j,1)-e(i+1,j,k)-phi(i+1,j,1)
     .  )+2.25270758122744E-5*(0.30391234671126*(PQZ(i,j,1)+PQZ(i+1,j,1
     .  ))+1)*(lnp(i,j,k)-lnp(i+1,j,k))*(PTZ(i,j,k)+PTZ(i+1,j,k)))-0.06
     .  25*(z(i,j,k)+z(i,j-1,k))*(hyv(i,j)*t49(i,j,1)*PVZ(i,j,1)+hyv(i,
     .  j-1)*t49(i,j-1,1)*PVZ(i,j-1,1)+hyv(i+1,j)*t49(i+1,j,1)*PVZ(i+1,
     .  j,1)+hyv(i+1,j-1)*t49(i+1,j-1,1)*PVZ(i+1,j-1,1)))/hxu(i,j)
               ELSE
                  PDUDT(i,j,k) = 0.5*((t192(i,j,k)+t192(i,j,k+1))/t47(i
     .  ,j,k))+(rdlam*(1.56961230576048E-7*(e(i,j,k)+phi(i,j,k)-e(i+1,j
     .  ,k)-phi(i+1,j,k))+2.25270758122744E-5*(0.30391234671126*(PQZ(i,
     .  j,k)+PQZ(i+1,j,k))+1)*(lnp(i,j,k)-lnp(i+1,j,k))*(PTZ(i,j,k)+PTZ
     .  (i+1,j,k)))-0.0625*(z(i,j,k)+z(i,j-1,k))*(hyv(i,j)*t49(i,j,k)*P
     .  VZ(i,j,k)+hyv(i,j-1)*t49(i,j-1,k)*PVZ(i,j-1,k)+hyv(i+1,j)*t49(i
     .  +1,j,k)*PVZ(i+1,j,k)+hyv(i+1,j-1)*t49(i+1,j-1,k)*PVZ(i+1,j-1,k)
     .  ))/hxu(i,j)
               ENDIF
1170        CONTINUE
1160     CONTINUE
1150  CONTINUE
CMIC$ DO ALL
      DO 1180 k = 1,nlev
         DO 1190 j = 1,nlat
            DO 1200 i = 1,nlon
               IF (nlev.LE.k) THEN
                  PDVDT(i,j,k) = 0.5*(t219(i,j,nlev)/t49(i,j,nlev))+(rd
     .  th*(1.56961230576048E-7*(e(i,j,k)+phi(i,j,nlev)-e(i,j+1,k)-phi(
     .  i,j+1,nlev))+2.25270758122744E-5*(0.30391234671126*(PQZ(i,j,nle
     .  v)+PQZ(i,j+1,nlev))+1)*(lnp(i,j,k)-lnp(i,j+1,k))*(PTZ(i,j,k)+PT
     .  Z(i,j+1,k)))+0.0625*(z(i,j,k)+z(i-1,j,k))*(hxu(i,j)*t47(i,j,nle
     .  v)*PUZ(i,j,nlev)+hxu(i,j+1)*t47(i,j+1,nlev)*PUZ(i,j+1,nlev)+hxu
     .  (i-1,j)*t47(i-1,j,nlev)*PUZ(i-1,j,nlev)+hxu(i-1,j+1)*t47(i-1,j+
     .  1,nlev)*PUZ(i-1,j+1,nlev)))/hyv(i,j)
               ELSE IF (k.LE.1) THEN
                  PDVDT(i,j,k) = 0.5*(t219(i,j,2)/t49(i,j,1))+(rdth*(1.
     .  56961230576048E-7*(e(i,j,k)+phi(i,j,1)-e(i,j+1,k)-phi(i,j+1,1))
     .  +2.25270758122744E-5*(0.30391234671126*(PQZ(i,j,1)+PQZ(i,j+1,1)
     .  )+1)*(lnp(i,j,k)-lnp(i,j+1,k))*(PTZ(i,j,k)+PTZ(i,j+1,k)))+0.062
     .  5*(z(i,j,k)+z(i-1,j,k))*(hxu(i,j)*t47(i,j,1)*PUZ(i,j,1)+hxu(i,j
     .  +1)*t47(i,j+1,1)*PUZ(i,j+1,1)+hxu(i-1,j)*t47(i-1,j,1)*PUZ(i-1,j
     .  ,1)+hxu(i-1,j+1)*t47(i-1,j+1,1)*PUZ(i-1,j+1,1)))/hyv(i,j)
               ELSE
                  PDVDT(i,j,k) = 0.5*((t219(i,j,k)+t219(i,j,k+1))/t49(i
     .  ,j,k))+(rdth*(1.56961230576048E-7*(e(i,j,k)+phi(i,j,k)-e(i,j+1,
     .  k)-phi(i,j+1,k))+2.25270758122744E-5*(0.30391234671126*(PQZ(i,j
     .  ,k)+PQZ(i,j+1,k))+1)*(lnp(i,j,k)-lnp(i,j+1,k))*(PTZ(i,j,k)+PTZ(
     .  i,j+1,k)))+0.0625*(z(i,j,k)+z(i-1,j,k))*(hxu(i,j)*t47(i,j,k)*PU
     .  Z(i,j,k)+hxu(i,j+1)*t47(i,j+1,k)*PUZ(i,j+1,k)+hxu(i-1,j)*t47(i-
     .  1,j,k)*PUZ(i-1,j,k)+hxu(i-1,j+1)*t47(i-1,j+1,k)*PUZ(i-1,j+1,k))
     .  )/hyv(i,j)
               ENDIF
1200        CONTINUE
1190     CONTINUE
1180  CONTINUE