<p><b>pwjones@lanl.gov</b> 2011-08-29 10:48:20 -0600 (Mon, 29 Aug 2011)</p><p><br>
changes to horizontal velocity mixing for the pointer hiding performance improvement and increased modularity for future additions<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/performance/mpas/namelist.input.ocean
===================================================================
--- branches/ocean_projects/performance/mpas/namelist.input.ocean        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/namelist.input.ocean        2011-08-29 16:48:20 UTC (rev 958)
@@ -24,8 +24,8 @@
    config_rho0 = 1015
 /
 &amp;hmix
-   config_h_mom_eddy_visc2 = 0.0
-   config_h_mom_eddy_visc4 = 5.0e8
+   config_OcnHmixVelDel2Visc    = 0.0
+   config_OcnHmixVelDel4Visc    = 5.0e8
    config_OcnHmixTracerDel2Diff = 10.0
    config_OcnHmixTracerDel4Diff = 0.0
 /

Modified: branches/ocean_projects/performance/mpas/namelist.input.sw
===================================================================
--- branches/ocean_projects/performance/mpas/namelist.input.sw        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/namelist.input.sw        2011-08-29 16:48:20 UTC (rev 958)
@@ -24,8 +24,8 @@
    config_rho0 = 1000
 /
 &amp;hmix
-   config_h_mom_eddy_visc2 = 1.0e5
-   config_h_mom_eddy_visc4 = 0.0
+   config_OcnHmixVelDel2Visc    = 1.0e5
+   config_OcnHmixVelDel4Visc    = 0.0
    config_OcnHmixTracerDel2Diff = 1.0e4
    config_OcnHmixTracerDel4Diff = 0.0
 /

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/Makefile
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/Makefile        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/Makefile        2011-08-29 16:48:20 UTC (rev 958)
@@ -6,10 +6,13 @@
        module_OcnHmixTracer.o \
        module_OcnHmixTracerDel2.o \
        module_OcnHmixTracerDel4.o \
-           module_OcnVmixTracer.o \
-           module_OcnVmixTracerConst.o \
-           module_OcnVmixTracerTanh.o \
-           module_OcnCoriolis.o \
+       module_OcnHmixVel.o \
+       module_OcnHmixVelDel2.o \
+       module_OcnHmixVelDel4.o \
+       module_OcnVmixTracer.o \
+       module_OcnVmixTracerConst.o \
+       module_OcnVmixTracerTanh.o \
+       module_OcnCoriolis.o \
        module_time_integration.o \
        module_global_diagnostics.o
 
@@ -36,11 +39,17 @@
 
 module_OcnHmixTracer.o: module_OcnHmixTracerDel2.o module_OcnHmixTracerDel4.o 
 
+module_OcnHmixVelDel2.o: 
+
+module_OcnHmixVelDel4.o: 
+
+module_OcnHmixVel.o: module_OcnHmixVelDel2.o module_OcnHmixVelDel4.o 
+
 module_time_integration.o: 
 
 module_global_diagnostics.o: 
 
-module_mpas_core.o: module_advection.o module_global_diagnostics.o module_test_cases.o module_OcnCoriolis.o module_OcnVmixTracer.o module_OcnVmixTracerConst.o module_OcnVmixTracerTanh.o module_OcnHmixTracer.o module_OcnHmixTracerDel2.o module_OcnHmixTracerDel4.o module_time_integration.o
+module_mpas_core.o: module_advection.o module_global_diagnostics.o module_test_cases.o module_OcnCoriolis.o module_OcnVmixTracer.o module_OcnVmixTracerConst.o module_OcnVmixTracerTanh.o module_OcnHmixTracer.o module_OcnHmixTracerDel2.o module_OcnHmixTracerDel4.o module_OcnHmixVel.o module_OcnHmixVelDel2.o module_OcnHmixVelDel4.o module_time_integration.o
 
 clean:
         $(RM) *.o *.mod *.f90 libdycore.a

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/Registry
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/Registry        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/Registry        2011-08-29 16:48:20 UTC (rev 958)
@@ -16,8 +16,8 @@
 namelist real      restart  config_restart_time      172800.0
 namelist character grid     config_vert_grid_type    isopycnal
 namelist real      grid     config_rho0              1028
-namelist real      hmix     config_h_mom_eddy_visc2     0.0
-namelist real      hmix     config_h_mom_eddy_visc4     0.0
+namelist real      hmix     config_OcnHmixVelDel2Visc   0.0
+namelist real      hmix     config_OcnHmixVelDel4Visc   0.0
 namelist real      hmix     config_OcnHmixTracerDel2Diff  0.0
 namelist real      hmix     config_OcnHmixTracerDel4Diff  0.0
 namelist real      hmix     config_apvm_upwinding       0.5

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVel.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVel.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVel.F        2011-08-29 16:48:20 UTC (rev 958)
@@ -0,0 +1,164 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnHmixVel
+!
+!&gt; \brief MPAS ocean horizontal momentum mixing driver
+!&gt; \author Phil Jones
+!&gt; \date   26 July 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains the main driver routine for computing 
+!&gt;  horizontal mixing tendencies.  It primarily decides which mixing
+!&gt;  parameterizations are being used and calls them individually.
+!&gt;  Detailed mixing parameterizations are contained in their own
+!&gt;  modules.
+!
+!-----------------------------------------------------------------------
+
+module OcnHmixVel
+
+   use grid_types
+   use configure
+   use OcnHmixVelDel2
+   use OcnHmixVelDel4
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnHmixVelTend, &amp;
+             OcnHmixVelInit
+
+   !--------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnHmixVelTend
+!
+!&gt; \brief   Computes tendency term for horizontal momentum mixing
+!&gt; \author  Phil Jones
+!&gt; \date    26 July 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the horizontal mixing tendency for momentum
+!&gt;  based on current state and user choices of mixing parameterization.
+!&gt;  Multiple parameterizations may be chosen and added together.  These
+!&gt;  tendencies are generally computed by calling the specific routine
+!&gt;  for the chosen parameterization, so this routine is primarily a
+!&gt;  driver for managing these choices.
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnHmixVelTend(tend, divergence, vorticity, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         divergence    !&lt; Input: velocity divergence
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         vorticity     !&lt; Input: vorticity
+
+      type (mesh_type), intent(in) :: &amp;
+         grid          !&lt; Input: grid information
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
+         tend          !&lt; Input/Output: velocity tendency
+
+      !-----------------------------------------------------------------
+      !
+      ! output variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! call relevant routines for computing tendencies
+      ! note that the user can choose multiple options and the 
+      !   tendencies will be added together
+      !
+      !-----------------------------------------------------------------
+
+      call OcnHmixVelDel2Tend(tend, divergence, vorticity, grid)
+      call OcnHmixVelDel4Tend(tend, divergence, vorticity, grid)
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHmixVelTend
+
+!***********************************************************************
+!
+!  routine OcnHmixVelInit
+!
+!&gt; \brief   Initializes ocean momentum horizontal mixing quantities
+!&gt; \author  Phil Jones
+!&gt; \date    26 July 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  horizontal velocity mixing in the ocean. Since a variety of 
+!&gt;  parameterizations are available, this routine primarily calls the
+!&gt;  individual init routines for each parameterization. 
+!
+!-----------------------------------------------------------------------
+
+
+   subroutine OcnHmixVelInit
+
+   !--------------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! call individual init routines for each parameterization
+      !
+      !-----------------------------------------------------------------
+
+      call OcnHmixVelDel2Init
+      call OcnHmixVelDel4Init
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHmixVelInit
+
+!***********************************************************************
+
+end module OcnHmixVel
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel2.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel2.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel2.F        2011-08-29 16:48:20 UTC (rev 958)
@@ -0,0 +1,215 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnHMixVelDel2
+!
+!&gt; \brief Ocean horizontal mixing - Laplacian parameterization 
+!&gt; \author Phil Jones
+!&gt; \date   22 August 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains routines for computing horizontal mixing 
+!&gt;  tendencies using a Laplacian formulation.
+!
+!-----------------------------------------------------------------------
+
+module OcnHMixVelDel2
+
+   use grid_types
+   use configure
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnHMixVelDel2Tend, &amp;
+             OcnHMixVelDel2Init
+
+   !-------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   logical :: &amp;
+      hmixDel2On         !&lt; local flag to determine whether del2 chosen
+
+   real (kind=RKIND) :: &amp;
+      eddyVisc2          !&lt; base eddy diffusivity for Laplacian
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnHMixVelDel2Tend
+!
+!&gt; \brief   Computes tendency term for Laplacian horizontal momentum mixing
+!&gt; \author  Phil Jones
+!&gt; \date    22 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the horizontal mixing tendency for momentum
+!&gt;  based on a Laplacian form for the mixing, </font>
<font color="black">u_2 </font>
<font color="blue">abla^2 u
+!&gt;  This tendency takes the
+!&gt;  form </font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity ),
+!&gt;  where </font>
<font color="blue">u is a viscosity and k is the vertical unit vector.
+!&gt;  This form is strictly only valid for constant </font>
<font color="blue">u .
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnHMixVelDel2Tend(tend, divergence, vorticity, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         divergence      !&lt; Input: velocity divergence
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         vorticity       !&lt; Input: vorticity
+
+      type (mesh_type), intent(in) :: &amp;
+         grid            !&lt; Input: grid information
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
+         tend             !&lt; Input/Output: velocity tendency
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      integer ::               &amp;
+         iEdge, k,             &amp;! loop counters
+         cell1, cell2,         &amp;! cell indices
+         vertex1, vertex2,     &amp;! vertex indices
+         nEdgesSolve            ! array sizes
+
+      real (kind=RKIND), dimension(:), pointer :: &amp;
+         dvEdge, dcEdge
+
+      integer, dimension(:), pointer :: maxLevelEdgeTop
+
+      integer, dimension(:,:), pointer :: &amp;
+         cellsOnEdge,                  &amp;! cell   index on edges
+         verticesOnEdge                 ! vertex index on edges
+
+      !-----------------------------------------------------------------
+      !
+      ! exit if this mixing is not selected
+      !
+      !-----------------------------------------------------------------
+
+      if (.not. hmixDel2On) return
+
+      !-----------------------------------------------------------------
+      !
+      ! initialize some arrays and sizes
+      !
+      !-----------------------------------------------------------------
+
+      cellsOnEdge       =&gt; grid % cellsOnEdge % array
+      verticesOnEdge    =&gt; grid % verticesOnEdge % array
+      dvEdge            =&gt; grid % dvEdge % array
+      dcEdge            =&gt; grid % dcEdge % array
+      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
+
+      nEdgesSolve       =  grid % nEdgesSolve
+
+      !-----------------------------------------------------------------
+      !
+      ! del2 horizontal momentum diffusion
+      !
+      ! Here -( vort(k,vertex2) - vort(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="gray">abla vorticity pointing from cell1 to 
+      ! cell2.
+      !
+      !-----------------------------------------------------------------
+
+      do iEdge=1,nEdgesSolve
+
+         cell1   = cellsOnEdge(1,iEdge)
+         cell2   = cellsOnEdge(2,iEdge)
+         vertex1 = verticesOnEdge(1,iEdge)
+         vertex2 = verticesOnEdge(2,iEdge)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+
+            tend(k,iEdge) = tend(k,iEdge) + eddyVisc2 *(               &amp;
+                            ( divergence(k,cell2  ) -                  &amp;
+                              divergence(k,cell1  ) ) / dcEdge(iEdge)  &amp;
+                           -( vorticity (k,vertex2) -                  &amp;
+                              vorticity (k,vertex1) ) / dvEdge(iEdge))
+
+         end do
+      end do
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHMixVelDel2Tend
+
+!***********************************************************************
+!
+!  routine OcnHMixVelDel2Init
+!
+!&gt; \brief   Initializes ocean momentum Laplacian horizontal mixing
+!&gt; \author  Phil Jones
+!&gt; \date    26 July 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  Laplacian horizontal momentum mixing in the ocean.  
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnHMixVelDel2Init
+
+   !--------------------------------------------------------------------
+   !
+   ! set some local module variables based on input config choices
+   !
+   !--------------------------------------------------------------------
+
+   hmixDel2On = .false.
+
+   if (config_OcnHmixVelDel2Visc &gt; 0.0 ) then
+
+      hmixDel2On = .true.
+
+      eddyVisc2 = config_OcnHmixVelDel2Visc
+
+   endif
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHMixVelDel2Init
+
+!***********************************************************************
+
+end module OcnHMixVelDel2
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F        2011-08-29 16:48:20 UTC (rev 958)
@@ -0,0 +1,317 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnHMixVelDel4
+!
+!&gt; \brief Ocean horizontal mixing - biharmonic parameterization
+!&gt; \author Phil Jones
+!&gt; \date   1 August 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains routines and variables for computing 
+!&gt;  horizontal mixing tendencies using a biharmonic formulation. 
+!
+!-----------------------------------------------------------------------
+
+module OcnHMixVelDel4
+
+   use grid_types
+   use configure
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnHMixVelDel4Tend, &amp;
+             OcnHMixVelDel4Init
+
+   !--------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   logical :: &amp;
+      hmixDel4On       !&lt; local flag to determine whether del4 chosen
+
+   real (kind=RKIND) :: &amp;
+      eddyVisc4        !&lt; base eddy diffusivity for biharmonic
+
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnHMixVelDel4Tend
+!
+!&gt; \brief   Computes tendency term for biharmonic horizontal momentum mixing
+!&gt; \author  Phil Jones
+!&gt; \date    22 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the horizontal mixing tendency for momentum
+!&gt;  based on a biharmonic form for the mixing.  This mixing tendency
+!&gt;  takes the form  -</font>
<font color="black">u_4 </font>
<font color="blue">abla^4 u
+!&gt;  but is computed as 
+!&gt;  </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="blue">abla vorticity
+!&gt;  applied recursively.
+!&gt;  This formulation is only valid for constant </font>
<font color="blue">u_4 .
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnHMixVelDel4Tend(tend, divergence, vorticity, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         divergence      !&lt; Input: velocity divergence
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         vorticity       !&lt; Input: vorticity
+
+      type (mesh_type), intent(in) :: &amp;
+         grid           !&lt; Input: grid information
+
+      !-----------------------------------------------------------------
+      !
+      ! input/output variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
+         tend       !&lt; Input/Output: velocity tendency
+
+      !-----------------------------------------------------------------
+      !
+      ! local variables
+      !
+      !-----------------------------------------------------------------
+
+      integer :: &amp;
+         i, k, iCell, iEdge,         &amp;! loop counters
+         cell1, cell2,               &amp;! cell indices
+         vertex1, vertex2,           &amp;! vertex indices
+         nEdges, nCells, nVertices,  &amp;! array sizes 
+         nVertLevels                  ! array sizes
+
+      real (kind=RKIND) :: &amp;
+         invArea1, invArea2,         &amp;! reciprocal of cell areas
+         flux                         ! flux across edge
+
+      real (kind=RKIND), dimension(:), pointer :: &amp;
+         dvEdge, dcEdge, areaCell,   &amp;! grid quantities
+         areaTriangle
+
+      integer, dimension(:), pointer :: &amp;
+         maxLevelCell,              &amp;! max vert level index for cells
+         maxLevelEdgeTop,           &amp;! max vert level index for top edge
+         maxLevelVertexBot           ! max vert level index for bot vertex
+
+      integer, dimension(:,:), pointer :: &amp;
+         cellsOnEdge,               &amp;! cell   index on edges
+         verticesOnEdge              ! vertex index on edges
+
+      real (kind=RKIND), dimension(:,:), allocatable :: &amp;
+         delsq_u,                   &amp;! temp for first del2 application
+         delsq_divergence,          &amp;! temp for first del2 application
+         delsq_vorticity             ! temp for first del2 application
+
+      !-----------------------------------------------------------------
+      !
+      ! exit if this mixing is not selected
+      !
+      !-----------------------------------------------------------------
+
+      if (.not. hmixDel4On) return
+
+      !-----------------------------------------------------------------
+      !
+      ! initialize some arrays and sizes
+      !
+      !-----------------------------------------------------------------
+
+      areaCell          =&gt; grid % areaCell % array
+      areaTriangle      =&gt; grid % areaTriangle % array
+      cellsOnEdge       =&gt; grid % cellsOnEdge % array
+      verticesOnEdge    =&gt; grid % verticesOnEdge % array
+      dvEdge            =&gt; grid % dvEdge % array
+      dcEdge            =&gt; grid % dcEdge % array
+      maxLevelCell      =&gt; grid % maxLevelCell % array
+      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
+      maxLevelVertexBot =&gt; grid % maxLevelVertexBot % array
+
+      nEdges      = grid % nEdges
+      nCells      = grid % nCells
+      nVertices   = grid % nVertices
+      nVertLevels = size(vorticity,dim=1)
+
+      allocate(delsq_u          (nVertLevels, nEdges+1))
+      allocate(delsq_divergence (nVertLevels, nCells+1))
+      allocate(delsq_vorticity  (nVertLevels, nVertices+1))
+
+      !-----------------------------------------------------------------
+      !
+      ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="blue">abla divergence + 
+      !                      k \times </font>
<font color="blue">abla vorticity
+      !
+      !-----------------------------------------------------------------
+
+      do iEdge=1,nEdges
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         vertex1 = verticesOnEdge(1,iEdge)
+         vertex2 = verticesOnEdge(2,iEdge)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+
+            delsq_u(k,iEdge) =                             &amp; 
+                  ( divergence(k,cell2)  -                 &amp;
+                    divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
+                 -( vorticity(k,vertex2) -                 &amp;
+                    vorticity(k,vertex1)) / dvEdge(iEdge)
+
+         end do
+         do k=maxLevelEdgeTop(iEdge)+1,nVertLevels
+            delsq_u(:,:) = 0.d0
+         end do
+
+      end do
+
+      !***
+      !*** vorticity using </font>
<font color="blue">abla^2 u
+      !***
+
+      delsq_vorticity(:,:) = 0.0
+
+      do iEdge=1,nEdges
+
+         vertex1 = verticesOnEdge(1,iEdge)
+         vertex2 = verticesOnEdge(2,iEdge)
+         invArea1 = 1.d0 / areaTriangle(vertex1)
+         invArea2 = 1.d0 / areaTriangle(vertex2)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+            delsq_vorticity(k,vertex1) = delsq_vorticity(k,vertex1) &amp;
+               - dcEdge(iEdge) * delsq_u(k,iEdge) * invArea1
+            delsq_vorticity(k,vertex2) = delsq_vorticity(k,vertex2) &amp;
+               + dcEdge(iEdge) * delsq_u(k,iEdge) * invArea2
+         end do
+      end do
+
+      !***
+      !*** Divergence using </font>
<font color="blue">abla^2 u
+      !***
+
+      delsq_divergence(:,:) = 0.d0
+
+      do iEdge=1,nEdges
+
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         invArea1 = 1.d0 / areaCell(cell1)
+         invArea2 = 1.d0 / areaCell(cell2)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+           delsq_divergence(k,cell1) = delsq_divergence(k,cell1) &amp;
+                + delsq_u(k,iEdge)*dvEdge(iEdge)*invArea1
+           delsq_divergence(k,cell2) = delsq_divergence(k,cell2) &amp;
+                - delsq_u(k,iEdge)*dvEdge(iEdge)*invArea2
+         end do
+      end do
+
+      !-----------------------------------------------------------------
+      !
+      ! Compute \kappa </font>
<font color="blue">abla^4 u 
+      ! as  </font>
<font color="black">abla div(</font>
<font color="blue">abla^2 u) + 
+      !     k \times </font>
<font color="black">abla ( k \cross curl(</font>
<font color="gray">abla^2 u) )
+      !
+      !-----------------------------------------------------------------
+
+      do iEdge=1,grid % nEdgesSolve
+         cell1 = cellsOnEdge(1,iEdge)
+         cell2 = cellsOnEdge(2,iEdge)
+         vertex1 = verticesOnEdge(1,iEdge)
+         vertex2 = verticesOnEdge(2,iEdge)
+
+         do k=1,maxLevelEdgeTop(iEdge)
+
+            tend(k,iEdge) = tend(k,iEdge) - eddyVisc4 * (         &amp;
+                (  delsq_divergence(k,cell2  )                    &amp;
+                 - delsq_divergence(k,cell1  ) ) / dcEdge(iEdge)  &amp;
+               -(  delsq_vorticity (k,vertex2)                    &amp;
+                 - delsq_vorticity (k,vertex1) ) / dvEdge(iEdge))

+         end do
+      end do
+
+      !***
+      !*** release storage
+      !***
+
+      deallocate(delsq_divergence)
+      deallocate(delsq_u)
+      deallocate(delsq_vorticity)
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHMixVelDel4Tend
+
+!***********************************************************************
+!
+!  routine OcnHMixVelDel4Init
+!
+!&gt; \brief   Initializes ocean momentum biharmonic horizontal mixing
+!&gt; \author  Phil Jones
+!&gt; \date    22 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  biharmonic horizontal tracer mixing in the ocean.  
+!
+!-----------------------------------------------------------------------
+
+
+   subroutine OcnHMixVelDel4Init
+
+   !--------------------------------------------------------------------
+   !
+   ! set some local module variables based on input config choices
+   !
+   !--------------------------------------------------------------------
+
+   hmixDel4On = .false.
+
+   if (config_OcnHmixVelDel4Visc /= 0.0 ) then
+
+      hmixDel4On = .true.
+
+      eddyVisc4 = config_OcnHmixVelDel4Visc
+
+   endif
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnHMixVelDel4Init
+
+!***********************************************************************
+
+end module OcnHMixVelDel4
+
+!||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_mpas_core.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_mpas_core.F        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_mpas_core.F        2011-08-29 16:48:20 UTC (rev 958)
@@ -3,6 +3,7 @@
    use mpas_framework
    use dmpar
    use test_cases
+   use OcnHmixVel
    use OcnHmixTracer
    use OcnVmixTracer
 
@@ -57,6 +58,7 @@
       !***
 
       call OcnHmixTracerInit
+      call OcnHmixVelInit
       call OcnVmixTracerInit(err)
 
       if(err .ne. 0) then

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_time_integration.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_time_integration.F        2011-08-26 21:10:30 UTC (rev 957)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_time_integration.F        2011-08-29 16:48:20 UTC (rev 958)
@@ -9,6 +9,7 @@
    use vector_reconstruction
    use spline_interpolation
    use timer
+   use OcnHmixVel
    use OcnHmixTracer
    use OcnVmixTracer
    use OcnCoriolis
@@ -133,7 +134,7 @@
                                             block % mesh % nVertLevels, block % mesh % nEdges, &amp;
                                             block % parinfo % edgesToSend, block % parinfo % edgesToRecv)
 
-           if (config_h_mom_eddy_visc4 &gt; 0.0) then
+           if (config_OcnHmixVelDel4Visc &gt; 0.0) then
               call dmpar_exch_halo_field2dReal(domain % dminfo, block % state % time_levs(2) % state % divergence % array(:,:), &amp;
                                                block % mesh % nVertLevels, block % mesh % nCells, &amp;
                                                block % parinfo % cellsToSend, block % parinfo % cellsToRecv)
@@ -459,121 +460,12 @@
       endif
 
       call timer_stop(&quot;press grad&quot;)
+
       call timer_start(&quot;vel dissipation&quot;)
-      !
-      ! velocity tendency: del2 dissipation, </font>
<font color="black">u_2 </font>
<font color="red">abla^2 u
-      !   computed as </font>
<font color="black">u( </font>
<font color="black">abla divergence + k \times </font>
<font color="red">abla vorticity )
-      !   strictly only valid for config_h_mom_eddy_visc2 == constant
-      !
-      if ( config_h_mom_eddy_visc2 &gt; 0.0 ) then
-         do iEdge=1,grid % nEdgesSolve
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
-            vertex1 = verticesOnEdge(1,iEdge)
-            vertex2 = verticesOnEdge(2,iEdge)
+      call OcnHmixVelTend(tend_u, divergence, vorticity, grid)
+      call timer_stop(&quot;vel dissipation&quot;)
 
-            do k=1,maxLevelEdgeTop(iEdge)
-
-               ! 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="red">abla vorticity pointing from cell1 to cell2.
-
-               u_diffusion = ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
-                            -( vorticity(k,vertex2) - vorticity(k,vertex1) ) / dvEdge(iEdge)
-               u_diffusion = config_h_mom_eddy_visc2 * u_diffusion
-
-               tend_u(k,iEdge) = tend_u(k,iEdge) + u_diffusion
-
-            end do
-         end do
-      end if
-
       !
-      ! velocity tendency: del4 dissipation, -</font>
<font color="black">u_4 </font>
<font color="red">abla^4 u
-      !   computed as </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="red">abla vorticity
-      !   applied recursively.
-      !   strictly only valid for config_h_mom_eddy_visc4 == constant
-      !
-      if ( config_h_mom_eddy_visc4 &gt; 0.0 ) then
-
-         allocate(delsq_divergence(nVertLevels, nCells+1))
-         allocate(delsq_u(nVertLevels, nEdges+1))
-         allocate(delsq_circulation(nVertLevels, nVertices+1))
-         allocate(delsq_vorticity(nVertLevels, nVertices+1))
-
-         delsq_u(:,:) = 0.0
-         delsq_circulation(:,:) = 0.0
-
-         ! Compute </font>
<font color="black">abla^2 u = </font>
<font color="black">abla divergence + k \times </font>
<font color="red">abla vorticity
-         do iEdge=1,grid % nEdges
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
-            vertex1 = verticesOnEdge(1,iEdge)
-            vertex2 = verticesOnEdge(2,iEdge)
-
-            do k=1,maxLevelEdgeTop(iEdge)
-
-               delsq_u(k,iEdge) = &amp; 
-                  ( divergence(k,cell2)  - divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
-                 -( vorticity(k,vertex2) - vorticity(k,vertex1)) / dvEdge(iEdge)
-
-                 !---- DWJ Testing Comments for loop merging
-            end do
-         end do
-
-         ! vorticity using </font>
<font color="red">abla^2 u
-         do iEdge=1,nEdges
-            vertex1 = verticesOnEdge(1,iEdge)
-            vertex2 = verticesOnEdge(2,iEdge)
-            do k=1,maxLevelEdgeTop(iEdge)
-               delsq_circulation(k,vertex1) = delsq_circulation(k,vertex1) &amp;
-                  - dcEdge(iEdge) * delsq_u(k,iEdge) / areaTriangle(vertex1)
-               delsq_circulation(k,vertex2) = delsq_circulation(k,vertex2) &amp;
-                  + dcEdge(iEdge) * delsq_u(k,iEdge) / areaTriangle(vertex2)
-            end do
-         end do
-
-         ! Divergence using </font>
<font color="red">abla^2 u
-         delsq_divergence(:,:) = 0.0
-         do iEdge=1,nEdges
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
-            do k=1,maxLevelEdgeTop(iEdge)
-              delsq_divergence(k,cell1) = delsq_divergence(k,cell1) &amp;
-                + delsq_u(k,iEdge)*dvEdge(iEdge) / areaCell(cell1) 
-              delsq_divergence(k,cell2) = delsq_divergence(k,cell2) &amp;
-                - delsq_u(k,iEdge)*dvEdge(iEdge) / areaCell(cell2) 
-            end do
-         end do
-
-         ! Compute - \kappa </font>
<font color="red">abla^4 u 
-         ! as  </font>
<font color="black">abla div(</font>
<font color="black">abla^2 u) + k \times </font>
<font color="black">abla ( k \cross curl(</font>
<font color="red">abla^2 u) )
-         do iEdge=1,grid % nEdgesSolve
-            cell1 = cellsOnEdge(1,iEdge)
-            cell2 = cellsOnEdge(2,iEdge)
-            vertex1 = verticesOnEdge(1,iEdge)
-            vertex2 = verticesOnEdge(2,iEdge)
-
-            do k=1,maxLevelEdgeTop(iEdge)
-
-               u_diffusion = (  delsq_divergence(k,cell2) &amp;
-                              - delsq_divergence(k,cell1) ) / dcEdge(iEdge)  &amp;
-                            -(  delsq_vorticity(k,vertex2) &amp;
-                              - delsq_vorticity(k,vertex1) ) / dvEdge(iEdge)

-               tend_u(k,iEdge) = tend_u(k,iEdge) - config_h_mom_eddy_visc4 * u_diffusion
-            end do
-         end do
-
-         deallocate(delsq_divergence)
-         deallocate(delsq_u)
-         deallocate(delsq_circulation)
-         deallocate(delsq_vorticity)
-
-      end if
-
-      call timer_stop(&quot;vel dissipation&quot;)
-      !
       ! velocity tendency: nonlinear Coriolis term and grad of kinetic energy
       !
       call timer_start(&quot;coriolis&quot;)

</font>
</pre>