<p><b>laura@ucar.edu</b> 2012-06-15 13:00:14 -0600 (Fri, 15 Jun 2012)</p><p>added the calculation of the hydrostatic pressure in the middle of layers and at interface between layers, to be used in conjunction with the option do_hydrostatic_pressure<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F
===================================================================
--- branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2012-06-15 18:57:13 UTC (rev 1989)
+++ branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_interface_nhyd.F        2012-06-15 19:00:14 UTC (rev 1990)
@@ -54,6 +54,12 @@
  if(.not.allocated(qs_p)   ) allocate(qs_p(ims:ime,kms:kme,jms:jme)   )
  if(.not.allocated(qg_p)   ) allocate(qg_p(ims:ime,kms:kme,jms:jme)   )
 
+!... arrays used for calculating the hydrostatic pressure and exner function:
+ if(.not.allocated(psfc_hyd_p) ) allocate(psfc_hyd_p(ims:ime,jms:jme)         )
+ if(.not.allocated(pres_hyd_p) ) allocate(pres_hyd_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(pres2_hyd_p)) allocate(pres2_hyd_p(ims:ime,kms:kme,jms:jme))
+ if(.not.allocated(znu_hyd_p)  ) allocate(znu_hyd_p(ims:ime,kms:kme,jms:jme)  )

  end subroutine allocate_forall_physics
 
 !=============================================================================================
@@ -91,6 +97,11 @@
  if(allocated(qs_p)    ) deallocate(qs_p    )
  if(allocated(qg_p)    ) deallocate(qg_p    )
 
+ if(allocated(psfc_hyd_p) ) deallocate(psfc_hyd_p  )
+ if(allocated(pres_hyd_p) ) deallocate(pres_hyd_p  )
+ if(allocated(pres2_hyd_p)) deallocate(pres2_hyd_p )
+ if(allocated(znu_hyd_p)  ) deallocate(znu_hyd_p   )

  end subroutine deallocate_forall_physics
 
 !=============================================================================================
@@ -152,18 +163,7 @@
  u =&gt; diag  % uReconstructZonal % array
  v =&gt; diag  % uReconstructMeridional % array
 
-!ldf (2012-01-06): updates the surface pressure as is done in subroutine microphysics_to_MPAS.
-!do j = jts,jte
-!do i = its,ite
-!   sfc_pressure(i) = 0.5*g*(zgrid(2,i)-zgrid(1,i)) &amp;
-!                   * (1.25 * rho_zz(1,i) * zz(1,i) * (1. + qv(1,i))  &amp;
-!                   -  0.25 * rho_zz(2,i) * zz(2,i) * (1. + qv(1,i)))
-!   sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
-!enddo
-!enddo
-!ldf end.
-!ldf (2012-01-09): updates the surface pressure using zgrid.
-!do j = jts,jte
+!calculation of the surface pressure:
  do i = its,ite
     tem1 = zgrid(2,i)-zgrid(1,i)
     tem2 = zgrid(3,i)-zgrid(2,i)
@@ -174,9 +174,8 @@
     sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
  enddo
 !enddo
-!ldf end.
 
-!copy sounding variables from the geodesic grid to the rectangular grid:
+!arrays located at theta points:
  do j = jts, jte
  do i = its, ite
     psfc_p(i,j) = diag % surface_pressure % array(i)
@@ -216,6 +215,7 @@
  enddo
  enddo
 
+!arrays located at w points:
  do j = jts, jte
  do k = kts,kte+1
  do i = its,ite
@@ -225,38 +225,26 @@
  enddo
  enddo
 
+!check that the pressure in the layer above the surface is greater than that in the layer
+!above it:
  do j = jts,jte
  do i = its,ite
-    if(pres_p(i,1,j) .lt. pres_p(i,2,j)) then
+    if(pres_p(i,1,j) .le. pres_p(i,2,j)) then
        write(0,*)
-       write(0,*) '--- subroutine MPAS_to_phys: pres:',j,i
-       write(0,*) 'latCell=', latCell(i)
-       write(0,*) 'lonCell=', lonCell(i)
+       write(0,*) '--- subroutine MPAS_to_phys - pressure(1) &lt; pressure(2):'
+       write(0,*) 'i      =', i
+       write(0,*) 'latCell=', latCell(i)/degrad
+       write(0,*) 'lonCell=', lonCell(i)/degrad
        do k = kts,kte
-          write(0,201) j,i,k,pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j),zz(k,i), &amp;
+          write(0,201) j,i,k,dz_p(i,k,j),pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j), &amp;
              rho_p(i,k,j),th_p(i,k,j),t_p(i,k,j),qv_p(i,k,j)
        enddo
-       write(0,*)
-       do k = kts,kte
-          write(0,201) j,i,k,qv_p(i,k,j),qc_p(i,k,j),qr_p(i,k,j),qi_p(i,k,j),qs_p(i,k,j), &amp;
-                       qg_p(i,k,j)
-       enddo
-       write(0,*)
-       stop
+!      stop
     endif
  enddo
  enddo
 
 !interpolation of pressure and temperature from theta points to w points:
-!do j = jts,jte
-!do k = kts+1,kte
-!do i = its,ite
-!   t2_p(i,k,j)    = fzm(k)*t_p(i,k,j) + fzp(k)*t_p(i,k-1,j)
-!   pres2_p(i,k,j) = fzm(k)*pres_p(i,k,j) + fzp(k)*pres_p(i,k-1,j)
-!enddo
-!enddo
-!enddo
-!ldf(2011-01-10):
  do j = jts,jte
  do k = kts+1,kte
  do i = its,ite
@@ -300,27 +288,27 @@
     !pres2_p(i,k,j) = w1*pres_p(i,k,j)+w2*pres_p(i,k+1,j)
     pres2_p(i,k,j) = psfc_p(i,j)
  enddo
- enddo 
+ enddo
+
+!calculation of the hydrostatic pressure:
  do j = jts,jte
  do i = its,ite
-    if(pres2_p(i,1,j) .lt. pres2_p(i,2,j)) then
-       write(0,*)
-       write(0,*) '--- subroutine MPAS_to_phys: pres2:',j,i
-       do k = kts,kte+1
-          write(0,201) j,i,k,pres2_p(i,k,j)
-      enddo
-!      write(0,*)
-!      do k = kts,kte
-!         write(0,201) j,i,k,pressure_b(k,i),pressure_p(k,i),pres_p(i,k,j),zz(k,i), &amp;
-!            rho_p(i,k,j),th_p(i,k,j),t_p(i,k,j),qv_p(i,k,j)
-!      enddo
-!      write(0,*)
-!      do k = kts,kte
-!         write(0,201) j,i,k,qv_p(i,k,j),qc_p(i,k,j),qr_p(i,k,j),qi_p(i,k,j),qs_p(i,k,j), &amp;
-!                     qg_p(i,k,j)
-!      enddo
-       stop
-    endif
+    !pressure at w-points:
+    k = kte+1
+    pres2_hyd_p(i,k,j) = pres2_p(i,k,j)
+    do k = kte,1,-1
+       pres2_hyd_p(i,k,j) = pres2_hyd_p(i,k+1,j) + g*rho_p(i,k,j)*dz_p(i,k,j)
+    enddo
+    !pressure at theta-points:
+    do k = kte,1,-1
+       pres_hyd_p(i,k,j) = 0.5*(pres2_hyd_p(i,k+1,j)+pres2_hyd_p(i,k,j))
+    enddo
+    !surface pressure:
+    psfc_hyd_p(i,j) = pres2_hyd_p(i,1,j)
+    !znu:
+    do k = kte,1,-1
+       znu_hyd_p(i,k,j) = pres_hyd_p(i,k,j) / psfc_hyd_p(i,j) 
+    enddo
  enddo
  enddo
 
@@ -546,15 +534,6 @@
  enddo
 
 !updates the surface pressure.
-!do j = jts,jte
-!do i = its,ite
-!   sfc_pressure(i) = 0.5*g*(zgrid(2,i)-zgrid(1,i)) &amp;
-!                   * (1.25 * rho_zz(1,i) * zz(1,i) * (1. + qv_p(i,1,j))  &amp;
-!                   -  0.25 * rho_zz(2,i) * zz(2,i) * (1. + qv_p(i,2,j)))
-!   sfc_pressure(i) = sfc_pressure(i) + pressure_p(1,i) + pressure_b(1,i)
-!enddo
-!enddo
-!ldf (2012-01-09):
  do j = jts,jte
  do i = its,ite
     tem1 = zgrid(2,i)-zgrid(1,i)

Modified: branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_vars.F
===================================================================
--- branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_vars.F        2012-06-15 18:57:13 UTC (rev 1989)
+++ branches/atmos_physics/src/core_atmos_physics/mpas_atmphys_vars.F        2012-06-15 19:00:14 UTC (rev 1990)
@@ -96,6 +96,14 @@
     pres2_p,          &amp;!pressure                                                         [hPa]
     t2_p               !temperature                                                        [K]
 
+!... arrays used for calculating the hydrostatic pressure and exner function:
+ real(kind=RKIND),dimension(:,:),allocatable:: &amp;
+    psfc_hyd_p         !surface pressure                                                 [hPa]
+ real(kind=RKIND),dimension(:,:,:),allocatable:: &amp;
+    pres_hyd_p,       &amp;!pressure located at theta levels                                 [hPa]
+    pres2_hyd_p,      &amp;!pressure located at w-velocity levels                            [hPa]     
+    znu_hyd_p          !(pres_hyd_p / P0) needed in the Tiedtke convection scheme        [hPa]
+
 !=============================================================================================
 !... variables and arrays related to parameterization of cloud microphysics:
 !    warm_phase: logical that determines if we want to run warm-phase cloud microphysics only.

</font>
</pre>