<p><b>qchen3@fsu.edu</b> 2012-05-15 10:09:17 -0600 (Tue, 15 May 2012)</p><p>BRANCH COMMIT<br>
<br>
GM closure for pv is implemented. <br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/accgm/namelist.input.ocean
===================================================================
--- branches/ocean_projects/accgm/namelist.input.ocean        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/namelist.input.ocean        2012-05-15 16:09:17 UTC (rev 1912)
@@ -42,7 +42,9 @@
    config_h_mom_eddy_visc2 = 0.0
    config_h_mom_eddy_visc4 = 0.0
    config_h_kappa = 800.0
-   config_h_kappa_q = 0.0
+   config_h_kappa_q = 200.0
+   config_uTPV = .true.
+   config_diffPV = .true.
    config_visc_vorticity_term = .true.
    config_h_tracer_eddy_diff2 = 1.0e5
    config_h_tracer_eddy_diff4 = 0.0

Modified: branches/ocean_projects/accgm/src/core_ocean/Registry
===================================================================
--- branches/ocean_projects/accgm/src/core_ocean/Registry        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/src/core_ocean/Registry        2012-05-15 16:09:17 UTC (rev 1912)
@@ -47,6 +47,8 @@
 namelist logical   hmix     config_include_KE_vertex false
 namelist real      hmix     config_h_tracer_eddy_diff2  0.0
 namelist real      hmix     config_h_tracer_eddy_diff4  0.0
+namelist logical   hmix     config_uTPV              false
+namelist logical   hmix     config_diffPV            false
 namelist real      hmix     config_h_kappa              0.0
 namelist real      hmix     config_h_kappa_q            0.0
 namelist logical   hmix     config_rayleigh_friction    false

Modified: branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_tendency.F
===================================================================
--- branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_tendency.F        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_tendency.F        2012-05-15 16:09:17 UTC (rev 1912)
@@ -169,9 +169,9 @@
       type (mesh_type), intent(in) :: grid !&lt; Input: Grid information
 
       real (kind=RKIND), dimension(:,:), pointer :: &amp;
-        h_edge, h, u, rho, zMid, pressure, &amp;
+        h_edge, h, u, uTransport, rho, zMid, pressure, &amp;
         tend_u, circulation, vorticity, ke, ke_edge, Vor_edge, &amp;
-        MontPot, wTop, divergence, vertViscTopOfEdge
+        MontPot, wTop, divergence, vertViscTopOfEdge, Vor_vertex
 
       real (kind=RKIND), dimension(:,:), pointer :: u_src
 
@@ -179,18 +179,20 @@
 
       call mpas_timer_start(&quot;ocn_tend_u&quot;)
 
-      u           =&gt; s % u % array
-      rho         =&gt; s % rho % array
-      wTop        =&gt; s % wTop % array
-      zMid        =&gt; s % zMid % array
-      h_edge      =&gt; s % h_edge % array
-      vorticity   =&gt; s % vorticity % array
-      divergence  =&gt; s % divergence % array
-      ke          =&gt; s % ke % array
-      ke_edge     =&gt; s % ke_edge % array
-      Vor_edge     =&gt; s % Vor_edge % array
-      MontPot     =&gt; s % MontPot % array
-      pressure    =&gt; s % pressure % array
+      u                 =&gt; s % u % array
+      uTransport        =&gt; s % uTransport % array
+      rho               =&gt; s % rho % array
+      wTop              =&gt; s % wTop % array
+      zMid              =&gt; s % zMid % array
+      h_edge            =&gt; s % h_edge % array
+      vorticity         =&gt; s % vorticity % array
+      Vor_vertex        =&gt; s % Vor_vertex % array
+      divergence        =&gt; s % divergence % array
+      ke                =&gt; s % ke % array
+      ke_edge           =&gt; s % ke_edge % array
+      Vor_edge          =&gt; s % Vor_edge % array
+      MontPot           =&gt; s % MontPot % array
+      pressure          =&gt; s % pressure % array
       vertViscTopOfEdge =&gt; d % vertViscTopOfEdge % array
 
       tend_u      =&gt; tend % u % array
@@ -208,7 +210,11 @@
       !
 
       call mpas_timer_start(&quot;coriolis&quot;, .false., velCorTimer)
-      call ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend_u, err)
+      if (config_uTPV) then
+          call ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, uTransport, ke, tend_u, err)
+      else
+          call ocn_vel_coriolis_tend(grid, Vor_edge, h_edge, u, ke, tend_u, err)
+      end if
       call mpas_timer_stop(&quot;coriolis&quot;, velCorTimer)
 
       !
@@ -235,7 +241,7 @@
       !   strictly only valid for config_h_mom_eddy_visc2 == constant
       !
       call mpas_timer_start(&quot;hmix&quot;, .false., velHmixTimer)
-      call ocn_vel_hmix_tend(grid, divergence, vorticity, tend_u, err)
+      call ocn_vel_hmix_tend(grid, divergence, vorticity, Vor_vertex, h_edge, tend_u, err)
       call mpas_timer_stop(&quot;hmix&quot;, velHmixTimer)
 
       !
@@ -404,7 +410,7 @@
       integer, dimension(:,:), pointer :: cellsOnEdge, cellsOnVertex, &amp;
         verticesOnEdge, edgesOnEdge, edgesOnVertex,boundaryCell, vertexMask
 
-      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2, coef_3rd_order, r_tmp, invAreaCell1, invAreaCell2, invAreaTri1, invAreaTri2, invLength, h_vertex
+      real (kind=RKIND) :: d2fdx2_cell1, d2fdx2_cell2, coef_3rd_order, r_tmp, invAreaCell1, invAreaCell2, invAreaTri1, invAreaTri2, invLength, h_vertex, areaEdge
 
       real (kind=RKIND), dimension(:), allocatable:: pTop
 
@@ -610,6 +616,7 @@
             r_tmp = r_tmp * dcEdge(iEdge) * u(k,iEdge)
             ke(k,cell1) = ke(k,cell1) + 0.25 * r_tmp * invAreaCell1
             ke(k,cell2) = ke(k,cell2) + 0.25 * r_tmp * invAreaCell2
+
          end do
 
          ! Compute v (tangential) velocities
@@ -870,6 +877,21 @@
          uBolusGM = 0.0
       end if
 
+      !
+      ! Adjust the definition of kinetic energy when GM is applied to PV
+      !
+      if (config_uTPV) then
+         do iEdge = 1, nEdges
+            cell1 = cellsOnEdge(1,iEdge)
+            cell2 = cellsOnEdge(2,iEdge)
+            areaEdge = dvEdge(iEdge) * dcEdge(iEdge)
+            do k = 1,nVertLevels
+               ke(k,iCell) = ke(k,iCell) + 0.5 * areaEdge * u(k,iEdge) * uBolusGM(k,iEdge)
+            end do
+         end do
+      end if
+            
+
    end subroutine ocn_diagnostic_solve!}}}
 
 !***********************************************************************

Modified: branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_time_integration_rk4.F
===================================================================
--- branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_time_integration_rk4.F        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_time_integration_rk4.F        2012-05-15 16:09:17 UTC (rev 1912)
@@ -320,16 +320,15 @@
             !
             call ocn_vel_vmix_tend_implicit(block % mesh, dt, ke_edge, vertvisctopofedge, h, h_edge, u, err)
 
-          !  mrp 110718 filter btr mode out of u
-           if (config_rk_filter_btr_mode) then
-               call filter_btr_mode_u(block % state % time_levs(2) % state, block % mesh)
-               !block % tend % h % array(:,:) = 0.0 ! I should not need this
-           endif
+            !  mrp 110718 filter btr mode out of u
+            if (config_rk_filter_btr_mode) then
+                call filter_btr_mode_u(block % state % time_levs(2) % state, block % mesh)
+                !block % tend % h % array(:,:) = 0.0 ! I should not need this
+            endif
 
             !
             !  Implicit vertical solve for tracers
             !
-
             call ocn_tracer_vmix_tend_implicit(block % mesh, dt, vertdifftopofcell, h, tracers, err)
             call mpas_timer_stop(&quot;RK4-implicit vert mix&quot;)
          end if

Modified: branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix.F
===================================================================
--- branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix.F        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix.F        2012-05-15 16:09:17 UTC (rev 1912)
@@ -72,7 +72,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_tend(grid, divergence, vorticity, tend, err)!{{{
+   subroutine ocn_vel_hmix_tend(grid, divergence, vorticity, Vor_vertex, h_edge, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -86,6 +86,12 @@
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          vorticity     !&lt; Input: vorticity
 
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         Vor_vertex     !&lt; Input: pv on vertices
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         h_edge          !&lt; Input: thickness on edge
+
       type (mesh_type), intent(in) :: &amp;
          grid          !&lt; Input: grid information
 
@@ -123,7 +129,7 @@
       !-----------------------------------------------------------------
 
       call mpas_timer_start(&quot;del2&quot;, .false., del2Timer)
-      call ocn_vel_hmix_del2_tend(grid, divergence, vorticity, tend, err1)
+      call ocn_vel_hmix_del2_tend(grid, divergence, vorticity, Vor_vertex, h_edge, tend, err1)
       call mpas_timer_stop(&quot;del2&quot;, del2Timer)
       call mpas_timer_start(&quot;del4&quot;, .false., del4Timer)
       call ocn_vel_hmix_del4_tend(grid, divergence, vorticity, tend, err2)

Modified: branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix_del2.F
===================================================================
--- branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2012-05-15 00:07:23 UTC (rev 1911)
+++ branches/ocean_projects/accgm/src/core_ocean/mpas_ocn_vel_hmix_del2.F        2012-05-15 16:09:17 UTC (rev 1912)
@@ -70,7 +70,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_vel_hmix_del2_tend(grid, divergence, vorticity, tend, err)!{{{
+   subroutine ocn_vel_hmix_del2_tend(grid, divergence, vorticity, Vor_vertex, h_edge, tend, err)!{{{
 
       !-----------------------------------------------------------------
       !
@@ -84,6 +84,12 @@
       real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
          vorticity       !&lt; Input: vorticity
 
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         Vor_vertex      !&lt; Input: pv on vertices
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         h_edge          !&lt; Input: thickness on edge
+
       type (mesh_type), intent(in) :: &amp;
          grid            !&lt; Input: grid information
 
@@ -149,17 +155,21 @@
          invLength2 = 1.0 / dvEdge(iEdge)
 
          do k=1,maxLevelEdgeTop(iEdge)
+            if (config_diffPV) then
+                 u_diffusion = -( Vor_vertex(k,vertex2) - Vor_vertex(k,vertex1) ) / dvEdge(iEdge)
+                 u_diffusion = config_h_kappa_q * h_edge(k,iEdge) * u_diffusion
+            else
+                 ! Here -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
+                 ! is - </font>
<font color="blue">abla vorticity pointing from vertex 2 to vertex 1, or equivalently 
+                 !    + k \times </font>
<font color="red">abla vorticity pointing from cell1 to cell2.
+                 u_diffusion = ( divergence(k,cell2)  - divergence(k,cell1) ) * invLength1 &amp;
+                                 -viscVortCoef &amp;
+                                 *( vorticity(k,vertex2) - vorticity(k,vertex1) ) * invLength2
 
-            ! Here -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-            ! is - </font>
<font color="red">abla vorticity pointing from vertex 2 to vertex 1, or equivalently 
-            !    + k \times </font>
<font color="gray">abla vorticity pointing from cell1 to cell2.
+                 u_diffusion = meshScalingDel2(iEdge) * eddyVisc2 * u_diffusion
 
-            u_diffusion = ( divergence(k,cell2)  - divergence(k,cell1) ) * invLength1 &amp;
-                          -viscVortCoef &amp;
-                          *( vorticity(k,vertex2) - vorticity(k,vertex1) ) * invLength2
+            end if
 
-            u_diffusion = meshScalingDel2(iEdge) * eddyVisc2 * u_diffusion
-
             tend(k,iEdge) = tend(k,iEdge) + edgeMask(k, iEdge) * u_diffusion
 
          end do
@@ -198,7 +208,7 @@
 
    hmixDel2On = .false.
 
-   if ( config_h_mom_eddy_visc2 &gt; 0.0 ) then
+   if ( config_h_mom_eddy_visc2 &gt; 0.0 .or. config_diffPV ) then
       hmixDel2On = .true.
       eddyVisc2 = config_h_mom_eddy_visc2
 

</font>
</pre>