<p><b>dwj07@fsu.edu</b> 2011-08-30 11:00:25 -0600 (Tue, 30 Aug 2011)</p><p><br>
        Separating out Vmix Velocity into modules and applying array masking.<br>
<br>
        Removing the error checker from the Vmix tracer modules, and putting that in mpas_core.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/performance/mpas/src/core_ocean/Makefile
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/Makefile        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/Makefile        2011-08-30 17:00:25 UTC (rev 962)
@@ -12,6 +12,9 @@
        module_OcnVmixTracer.o \
        module_OcnVmixTracerConst.o \
        module_OcnVmixTracerTanh.o \
+       module_OcnVmixVel.o \
+       module_OcnVmixVelConst.o \
+       module_OcnVmixVelTanh.o \
        module_OcnCoriolis.o \
            module_OcnThickness.o \
            module_OcnVelocityForcing.o \
@@ -39,6 +42,12 @@
 
 module_OcnVmixTracer.o: module_OcnVmixTracerConst.o module_OcnVmixTracerTanh.o
 
+module_OcnVmixVelConst.o:
+
+module_OcnVmixVelTanh.o:
+
+module_OcnVmixVel.o: module_OcnVmixVelConst.o module_OcnVmixVelTanh.o
+
 module_OcnHmixTracerDel2.o: 
 
 module_OcnHmixTracerDel4.o: 
@@ -55,7 +64,7 @@
 
 module_global_diagnostics.o: 
 
-module_mpas_core.o: module_advection.o module_global_diagnostics.o module_test_cases.o module_OcnVelocityForcing.o module_OcnThickness.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
+module_mpas_core.o: module_advection.o module_global_diagnostics.o module_test_cases.o module_OcnVelocityForcing.o module_OcnThickness.o module_OcnCoriolis.o module_OcnVmixVel.o module_OcnVmixVelConst.o module_OcnVmixVelTanh.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/module_OcnCoriolis.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnCoriolis.F        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnCoriolis.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -59,7 +59,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine OcnCoriolisTend(tend, pvEdge, hEdge, u, ke, nEdgesSolve, grid)
+   subroutine OcnCoriolisTend(tend, pvEdge, hEdge, u, ke, grid)
 
       !-----------------------------------------------------------------
       !
@@ -73,8 +73,6 @@
       type (mesh_type), intent(in) :: &amp;
          grid       !&lt; Input: grid information
 
-       integer, intent(in) :: nEdgesSolve
-
       !-----------------------------------------------------------------
       !
       ! input/output variables
@@ -96,7 +94,7 @@
       !
       !-----------------------------------------------------------------
 
-      integer :: iEdge, j, k, cell1, cell2, eoe
+      integer :: iEdge, j, k, cell1, cell2, eoe, nEdgesSolve
       real (kind=RKIND) :: q, workpv
       integer, dimension(:,:), pointer :: cellsOnEdge, edgesOnEdge
       integer, dimension(:), pointer :: maxLeveLEdgeTop, nEdgesOnEdge
@@ -112,6 +110,8 @@
       weightsOnEdge =&gt; grid % weightsOnEdge % array
       dcEdge =&gt; grid % dcEdge % array
 
+      nEdgesSolve = grid % nEdgesSolve
+
       !
       ! velocity tendency: nonlinear Coriolis term and grad of kinetic energy
       !

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnHmixVelDel4.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -263,7 +263,7 @@
                 (  delsq_divergence(k,cell2  )                    &amp;
                  - delsq_divergence(k,cell1  ) ) * invLength1     &amp;
                -(  delsq_vorticity (k,vertex2)                    &amp;
-                 - delsq_vorticity (k,vertex1) ) * invLength2
+                 - delsq_vorticity (k,vertex1) ) * invLength2 )
  
          end do
       end do

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracer.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracer.F        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracer.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -70,7 +70,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine OcnVmixTracerTend(tend, tracers, hCell, grid, err)
+   subroutine OcnVmixTracerTend(tend, tracers, hCell, grid)
 
       !-----------------------------------------------------------------
       !
@@ -102,8 +102,6 @@
       !
       !-----------------------------------------------------------------
 
-      integer, intent(inout) :: err
-
       !-----------------------------------------------------------------
       !
       ! local variables
@@ -118,8 +116,8 @@
       !
       !-----------------------------------------------------------------
 
-      call OcnVmixTracerConstTend(tend, tracers, hCell, grid, err)
-      call OcnVmixTracerTanhTend(tend, tracers, hCell, grid, err)
+      call OcnVmixTracerConstTend(tend, tracers, hCell, grid)
+      call OcnVmixTracerTanhTend(tend, tracers, hCell, grid)
 
    !--------------------------------------------------------------------
 
@@ -142,7 +140,7 @@
 !-----------------------------------------------------------------------
 
 
-   subroutine OcnVmixTracerInit(err)
+   subroutine OcnVmixTracerInit
 
    !--------------------------------------------------------------------
 
@@ -151,8 +149,6 @@
       ! Output Variables
       !
       !-----------------------------------------------------------------
-      
-        integer, intent(out) :: err
 
       !-----------------------------------------------------------------
       !
@@ -160,8 +156,8 @@
       !
       !-----------------------------------------------------------------
 
-      call OcnVmixTracerConstInit(err)
-      call OcnVmixTracerTanhInit(err)
+      call OcnVmixTracerConstInit
+      call OcnVmixTracerTanhInit
 
    !--------------------------------------------------------------------
 

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerConst.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerConst.F        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerConst.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -65,7 +65,7 @@
 !&gt;  based on a constant form for the mixing. 
 !-----------------------------------------------------------------------
 
-   subroutine OcnVmixTracerConstTend(tend, tracers, h, grid, err)
+   subroutine OcnVmixTracerConstTend(tend, tracers, h, grid)
 
       !-----------------------------------------------------------------
       !
@@ -97,8 +97,6 @@
       !
       !-----------------------------------------------------------------
 
-      integer, intent(out) :: err
-
       !-----------------------------------------------------------------
       !
       ! local variables
@@ -123,7 +121,6 @@
       !-----------------------------------------------------------------
 
       if (.not. VmixConstOn) return
-      err = 0
 
       !-----------------------------------------------------------------
       !
@@ -189,7 +186,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine OcnVmixTracerConstInit(err)
+   subroutine OcnVmixTracerConstInit
 
 
    !--------------------------------------------------------------------
@@ -198,8 +195,6 @@
    !
    !--------------------------------------------------------------------
 
-    integer, intent(out) :: err
-
    !--------------------------------------------------------------------
    !
    ! set some local module variables based on input config choices
@@ -207,7 +202,6 @@
    !--------------------------------------------------------------------
 
    VmixConstOn = .false.
-   err = 0
 
    if ( config_vert_diff_type .EQ. 'const' ) then
         VmixConstOn = .true.

Modified: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerTanh.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerTanh.F        2011-08-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixTracerTanh.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -69,7 +69,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine OcnVmixTracerTanhTend(tend, tracers, hCell, grid, err)
+   subroutine OcnVmixTracerTanhTend(tend, tracers, hCell, grid)
 
       !-----------------------------------------------------------------
       !
@@ -101,8 +101,6 @@
       !
       !-----------------------------------------------------------------
 
-      integer, intent(out) :: err
-
       !-----------------------------------------------------------------
       !
       ! local variables
@@ -130,7 +128,6 @@
       !-----------------------------------------------------------------
 
       if (.not. VmixTanhOn) return
-      err = 0
 
       !-----------------------------------------------------------------
       !
@@ -199,7 +196,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine OcnVmixTracerTanhInit(err)
+   subroutine OcnVmixTracerTanhInit
 
    !--------------------------------------------------------------------
    !
@@ -207,8 +204,6 @@
    !
    !--------------------------------------------------------------------
 
-   integer, intent(out) :: err
-
    !--------------------------------------------------------------------
    !
    ! set some local module variables based on input config choices
@@ -216,15 +211,8 @@
    !--------------------------------------------------------------------
 
    VmixTanhOn = .false.
-   err = 0
 
    if ( config_vert_diff_type .EQ. 'tanh' ) then
-       if (config_vert_grid_type.ne.'zlevel') then
-           write(0,*) 'Abort: config_vert_diff_type.eq.tanh may only', &amp;
-                      '       use config_vert_grid_type of zlevel at this time'
-           err = 1
-       endif
-
        VmixTanhOn = .true.
 
        diff = config_vert_diffusion

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVel.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVel.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVel.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -0,0 +1,168 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnVmixVel
+!
+!&gt; \brief MPAS ocean vertical momentum mixing driver
+!&gt; \author Doug Jacobsen
+!&gt; \date   30 August 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains the main driver routine for computing 
+!&gt;  vertical 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 OcnVmixVel
+
+   use grid_types
+   use configure
+   use OcnVmixVelConst
+   use OcnVmixVelTanh
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnVmixVelTend, &amp;
+             OcnVmixVelInit
+
+   !--------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnVmixVelTend
+!
+!&gt; \brief   Computes tendency term for vertical momentum mixing
+!&gt; \author  Doug Jacobsen
+!&gt; \date    30 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the vertical 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 OcnVmixVelTend(tend, u, hEdge, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         u    !&lt; Input: current velocity
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         hEdge     !&lt; Input: edge thickness
+
+      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
+      !
+      !-----------------------------------------------------------------
+
+      !
+      ! velocity tendency: vertical mixing d/dz( nu_v du/dz))
+      !
+
+      call OcnVmixVelConstTend(tend, u, hEdge, grid)
+      call OcnVmixVelTanhTend(tend, u, hEdge, grid)
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVmixVelTend
+
+!***********************************************************************
+!
+!  routine OcnVmixVelInit
+!
+!&gt; \brief   Initializes ocean momentum vertical mixing quantities
+!&gt; \author  Doug Jacobsen
+!&gt; \date    30 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  vertical 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 OcnVmixVelInit
+
+   !--------------------------------------------------------------------
+
+      !-----------------------------------------------------------------
+      !
+      ! call individual init routines for each parameterization
+      !
+      !-----------------------------------------------------------------
+
+      call OcnVmixVelConstInit
+      call OcnVmixVelTanhInit
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVmixVelInit
+
+!***********************************************************************
+
+end module OcnVmixVel
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelConst.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelConst.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelConst.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -0,0 +1,189 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnVMixVelConst
+!
+!&gt; \brief Ocean vertical mixing - constant parameterization 
+!&gt; \author Doug Jacobsen
+!&gt; \date   22 August 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains routines for computing vertical mixing 
+!&gt;  tendencies using a constant formulation.
+!
+!-----------------------------------------------------------------------
+
+module OcnVMixVelConst
+
+   use grid_types
+   use configure
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnVMixVelConstTend, &amp;
+             OcnVMixVelConstInit
+
+   !-------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   logical :: &amp;
+      vmixConstOn         !&lt; local flag to determine whether Const chosen
+
+   real (kind=RKIND) :: &amp;
+      vertViscTop        !&lt; viscosity for vertical mixing
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnVMixVelConstTend
+!
+!&gt; \brief   Computes tendency term for constant vertical momentum mixing
+!&gt; \author  Doug Jacobsen
+!&gt; \date    22 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the vertical mixing tendency for momentum
+!&gt;  with a constant mixing parameterization
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnVMixVelConstTend(tend, u, hEdge, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         u      !&lt; Input: current velocity 
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         hEdge       !&lt; Input: thickness at edges
+
+      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             ! loop counters
+
+      integer, dimension(:), pointer :: maxLevelEdgeTop
+
+      real (kind=RKIND), dimension(:), allocatable :: fluxVertTop
+
+      !-----------------------------------------------------------------
+      !
+      ! exit if this mixing is not selected
+      !
+      !-----------------------------------------------------------------
+
+      if (.not. vmixConstOn) return
+
+      !-----------------------------------------------------------------
+      !
+      ! initialize some arrays and sizes
+      !
+      !-----------------------------------------------------------------
+
+      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
+
+      allocate(fluxVertTop(grid % nVertLevels+1))
+
+      fluxVertTop(1) = 0.0
+
+      do iEdge=1,grid % nEdgesSolve
+
+        do k=2,maxLevelEdgeTop(iEdge)
+          fluxVertTop(k) = vertViscTop &amp;
+              * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
+              * 2 / (hEdge(k-1,iEdge) + hEdge(k,iEdge))
+        enddo
+
+        fluxVertTop(maxLevelEdgeTop(iEdge)+1) = 0.0
+
+        do k=1,maxLevelEdgeTop(iEdge)
+          tend(k,iEdge) = tend(k,iEdge) &amp;
+              + (fluxVertTop(k) - fluxVertTop(k+1)) &amp;
+              / hEdge(k,iEdge)
+        enddo
+
+      enddo
+
+      deallocate(fluxVertTop)
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVMixVelConstTend
+
+!***********************************************************************
+!
+!  routine OcnVMixVelConstInit
+!
+!&gt; \brief   Initializes ocean momentum constant vertical mixing
+!&gt; \author  Doug Jacobsen
+!&gt; \date    30 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  constant vertical momentum mixing in the ocean.  
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnVMixVelConstInit
+
+   !--------------------------------------------------------------------
+   !
+   ! set some local module variables based on input config choices
+   !
+   !--------------------------------------------------------------------
+
+   vmixConstOn = .false.
+
+   if (config_vert_visc_type.eq.'const') then 
+      vertViscTop = config_vert_viscosity
+
+      vmixConstOn = .true.
+   endif
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVMixVelConstInit
+
+!***********************************************************************
+
+end module OcnVMixVelConst
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Added: branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelTanh.F
===================================================================
--- branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelTanh.F                                (rev 0)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_OcnVmixVelTanh.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -0,0 +1,198 @@
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+!
+!  OcnVMixVelTanh
+!
+!&gt; \brief Ocean vertical mixing - Tanhant parameterization 
+!&gt; \author Doug Jacobsen
+!&gt; \date   22 August 2011
+!&gt; \version SVN:$Id:$
+!&gt; \details
+!&gt;  This module contains routines for computing vertical mixing 
+!&gt;  tendencies using a Tanhant formulation.
+!
+!-----------------------------------------------------------------------
+
+module OcnVMixVelTanh
+
+   use grid_types
+   use configure
+
+   implicit none
+   private
+   save
+
+   !--------------------------------------------------------------------
+   !
+   ! Public parameters
+   !
+   !--------------------------------------------------------------------
+
+   !--------------------------------------------------------------------
+   !
+   ! Public member functions
+   !
+   !--------------------------------------------------------------------
+
+   public :: OcnVMixVelTanhTend, &amp;
+             OcnVMixVelTanhInit
+
+   !-------------------------------------------------------------------
+   !
+   ! Private module variables
+   !
+   !--------------------------------------------------------------------
+
+   logical :: &amp;
+      vmixTanhOn         !&lt; local flag to determine whether Tanh chosen
+
+   real (kind=RKIND) :: &amp;
+      vertViscTop        !&lt; viscosity for vertical mixing
+
+!***********************************************************************
+
+contains
+
+!***********************************************************************
+!
+!  routine OcnVMixVelTanhTend
+!
+!&gt; \brief   Computes tendency term for Tanhant vertical momentum mixing
+!&gt; \author  Doug Jacobsen
+!&gt; \date    22 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine computes the vertical mixing tendency for momentum
+!&gt;  with a Tanhant mixing parameterization
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnVMixVelTanhTend(tend, u, hEdge, grid)
+
+      !-----------------------------------------------------------------
+      !
+      ! input variables
+      !
+      !-----------------------------------------------------------------
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         u      !&lt; Input: current velocity 
+
+      real (kind=RKIND), dimension(:,:), intent(in) :: &amp;
+         hEdge       !&lt; Input: thickness at edges
+
+      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              ! loop counters
+
+      integer, dimension(:), pointer :: maxLevelEdgeTop 
+      real (kind=RKIND), dimension(:), pointer :: zTopZLevel
+
+      real (kind=RKIND), dimension(:), allocatable :: fluxVertTop, viscTop
+
+      !-----------------------------------------------------------------
+      !
+      ! exit if this mixing is not selected
+      !
+      !-----------------------------------------------------------------
+
+      if (.not. vmixTanhOn) return
+
+      !-----------------------------------------------------------------
+      !
+      ! initialize some arrays and sizes
+      !
+      !-----------------------------------------------------------------
+
+      maxLevelEdgeTop   =&gt; grid % maxLevelEdgeTop % array
+      zTopZLevel        =&gt; grid % zTopZLevel % array
+
+
+      allocate(fluxVertTop(grid % nVertLevels+1))
+      allocate(viscTop(grid % nVertLevels+1))
+
+      fluxVertTop(1) = 0.0
+
+      do k=1,grid % nVertLevels+1
+         viscTop(k) = -(config_vmixTanhViscMax-config_vmixTanhViscMin)/2.0 &amp;
+           *tanh(-(zTopZLevel(k)-config_vmixTanhZMid) &amp;
+                 /config_vmixTanhZWidth) &amp;
+           + (config_vmixTanhViscMax+config_vmixTanhViscMin)/2
+      enddo
+
+
+      do iEdge=1,grid % nEdgesSolve
+        do k=2,maxLevelEdgeTop(iEdge)
+          fluxVertTop(k) = viscTop(k) &amp;
+              * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
+              * 2 / (hEdge(k-1,iEdge) + hEdge(k,iEdge))
+        enddo
+
+        fluxVertTop(maxLevelEdgeTop(iEdge)+1) = 0.0
+
+        do k=1,maxLevelEdgeTop(iEdge)
+          tend(k,iEdge) = tend(k,iEdge) &amp;
+              + (fluxVertTop(k) - fluxVertTop(k+1)) &amp;
+              / hEdge(k,iEdge)
+        enddo
+
+      enddo
+
+      deallocate(fluxVertTop, viscTop)
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVMixVelTanhTend
+
+!***********************************************************************
+!
+!  routine OcnVMixVelTanhInit
+!
+!&gt; \brief   Initializes ocean momentum Tanhant vertical mixing
+!&gt; \author  Doug Jacobsen
+!&gt; \date    30 August 2011
+!&gt; \version SVN:$Id$
+!&gt; \details 
+!&gt;  This routine initializes a variety of quantities related to 
+!&gt;  Tanhant vertical momentum mixing in the ocean.  
+!
+!-----------------------------------------------------------------------
+
+   subroutine OcnVMixVelTanhInit
+
+   !--------------------------------------------------------------------
+   !
+   ! set some local module variables based on input config choices
+   !
+   !--------------------------------------------------------------------
+
+   vmixTanhOn = .false.
+
+   if (config_vert_visc_type.eq.'tanh') then 
+      vmixTanhOn = .true.
+   endif
+
+   !--------------------------------------------------------------------
+
+   end subroutine OcnVMixVelTanhInit
+
+!***********************************************************************
+
+end module OcnVMixVelTanh
+
+!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

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-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_mpas_core.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -5,6 +5,7 @@
    use test_cases
    use OcnHmixVel
    use OcnHmixTracer
+   use OcnVmixVel
    use OcnVmixTracer
 
    type (io_output_object) :: restart_obj
@@ -26,7 +27,6 @@
       real (kind=RKIND) :: dt
       type (block_type), pointer :: block
       type (dm_info) :: dminfo
-      integer :: err
 
       if (.not. config_do_restart) call setup_sw_test_case(domain)
 
@@ -59,12 +59,33 @@
 
       call OcnHmixTracerInit
       call OcnHmixVelInit
-      call OcnVmixTracerInit(err)
 
-      if(err .ne. 0) then
+      if (config_vert_diff_type .eq.'tanh') then
+        if(config_vert_grid_type .ne. 'zlevel') then
+          write(0,*) 'Abort: config_vert_visc_type.eq.tanh may only', &amp;
+            ' use config_vert_grid_type of zlevel at this time'
           call dmpar_abort(dminfo)
+        endif
+      else if (config_vert_diff_type .ne. 'const') then
+        write(0,*) 'Abort: unrecognized config_vert_visc_type'
+        call dmpar_abort(dminfo)
       endif
 
+      call OcnVmixTracerInit
+
+      if (config_vert_visc_type.eq.'tanh') then
+        if (config_vert_grid_type.ne.'zlevel') then
+          write(0,*) 'Abort: config_vert_visc_type.eq.tanh may only', &amp;
+            ' use config_vert_grid_type of zlevel at this time'
+          call dmpar_abort(dminfo)
+        endif
+      else if (config_vert_visc_type.ne.'const') then
+        write(0,*) 'Abort: unrecognized config_vert_visc_type'
+        call dmpar_abort(dminfo)
+      endif
+
+      call OcnVmixVelInit
+
    ! mrp 100316 In order for this to work, we need to pass domain % dminfo as an 
    ! input arguement into mpas_init.  Ask about that later.  For now, there will be
    ! no initial statistics write.

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-30 16:03:43 UTC (rev 961)
+++ branches/ocean_projects/performance/mpas/src/core_ocean/module_time_integration.F        2011-08-30 17:00:25 UTC (rev 962)
@@ -12,6 +12,7 @@
    use OcnHmixTracer
    use OcnHmixVel
    use OcnVmixTracer
+   use OcnVmixVel
    use OcnCoriolis
    use OcnThickness
    use OcnVelocityForcing
@@ -442,7 +443,7 @@
       call timer_stop(&quot;vel dissipation&quot;)
       call timer_start(&quot;coriolis&quot;)
 
-      call OcnCoriolisTend(tend_u, pv_edge, h_edge, u, ke, nEdgesSolve, grid)
+      call OcnCoriolisTend(tend_u, pv_edge, h_edge, u, ke, grid)
 
       call timer_stop(&quot;coriolis&quot;)
       call timer_start(&quot;vel forcing&quot;)
@@ -451,52 +452,10 @@
 
       call timer_stop(&quot;vel forcing&quot;)
       call timer_start(&quot;vel vmix&quot;)
-      !
-      ! velocity tendency: vertical mixing d/dz( nu_v du/dz))
-      !
-      allocate(vertViscTop(nVertLevels+1))
-      if (config_vert_visc_type.eq.'const') then
-        vertViscTop = config_vert_viscosity
-      elseif (config_vert_visc_type.eq.'tanh') then
-        if (config_vert_grid_type.ne.'zlevel') then
-          write(0,*) 'Abort: config_vert_visc_type.eq.tanh may only', &amp;
-            ' use config_vert_grid_type of zlevel at this time'
-          call dmpar_abort(dminfo)
-        endif
-  
-        do k=1,nVertLevels+1
-          vertViscTop(k) = -(config_vmixTanhViscMax-config_vmixTanhViscMin)/2.0 &amp;
-            *tanh(-(zTopZLevel(k)-config_vmixTanhZMid) &amp;
-                  /config_vmixTanhZWidth) &amp;
-            + (config_vmixTanhViscMax+config_vmixTanhViscMin)/2
-        enddo
-      else
-        write(0,*) 'Abort: unrecognized config_vert_visc_type'
-        call dmpar_abort(dminfo)
-      endif
+      call OcnVmixVelTend(tend_u, h_edge, u, grid)
 
-      allocate(fluxVertTop(nVertLevels+1))
-      fluxVertTop(1) = 0.0
-      do iEdge=1,grid % nEdgesSolve
-         
-         do k=2,maxLevelEdgeTop(iEdge)
-           fluxVertTop(k) = vertViscTop(k) &amp;
-              * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
-              * 2 / (h_edge(k-1,iEdge) + h_edge(k,iEdge))
-         enddo
-         fluxVertTop(maxLevelEdgeTop(iEdge)+1) = 0.0
-
-         do k=1,maxLevelEdgeTop(iEdge)
-           tend_u(k,iEdge) = tend_u(k,iEdge) &amp;
-             + (fluxVertTop(k) - fluxVertTop(k+1)) &amp;
-             / h_edge(k,iEdge)
-         enddo
-
-      end do
       call timer_stop(&quot;vel vmix&quot;)
       call timer_stop(&quot;velocity&quot;)
-      deallocate(fluxVertTop, vertViscTop)
-
    end subroutine compute_tend
 
 
@@ -553,8 +512,6 @@
       real (kind=RKIND), dimension(:,:,:),allocatable :: &amp;
          tracersA, tend_trA
 
-      integer :: err
-
       u           =&gt; s % u % array
       h           =&gt; s % h % array
       boundaryCell=&gt; grid % boundaryCell % array
@@ -927,11 +884,7 @@
       ! tracer tendency: vertical diffusion h d/dz( \kappa_v d\phi/dz)
       !
       call timer_start(&quot;scalar vdiff&quot;)
-      call OcnVmixTracerTend(tend_tr, tracers, h, grid, err)
-
-      if(err .ne. 0) then
-        call dmpar_abort(dminfo)
-      endif
+      call OcnVmixTracerTend(tend_tr, tracers, h, grid)
       call timer_stop(&quot;scalar vdiff&quot;)
 
       call timer_stop(&quot;scalar&quot;)

</font>
</pre>