<p><b>dwj07@fsu.edu</b> 2011-09-30 09:48:35 -0600 (Fri, 30 Sep 2011)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Fixing up equation of state. Changes are in the 12th decimal place now.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -4,7 +4,7 @@
 !
 !&gt; \brief MPAS ocean equation of state driver
 !&gt; \author Doug Jacobsen
-!&gt; \date   19 September 2011
+!&gt; \date   29 September 2011
 !&gt; \version SVN:$Id:$
 !&gt; \details
 !&gt;  This module contains the main driver routine for calling
@@ -17,8 +17,8 @@
    use grid_types
    use configure
    use timer
-!  use ocn_equation_of_stateLinear
-!  use ocn_equation_of_stateJM
+   use ocn_equation_of_state_linear
+   use ocn_equation_of_state_jm
 
    implicit none
    private
@@ -46,6 +46,7 @@
    !--------------------------------------------------------------------
 
    logical :: eosON
+   logical :: linearEos, jmEos
 
 
 !***********************************************************************
@@ -58,14 +59,14 @@
 !
 !&gt; \brief   Calls equation of state
 !&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
+!&gt; \date    29 September 2011
 !&gt; \version SVN:$Id$
 !&gt; \details 
 !&gt;  This routine calls the equation of state to update the density
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_rho(s, grid, k_displaced, displacement_type)!{{{
+   subroutine ocn_equation_of_state_rho(s, grid, k_displaced, displacement_type, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -84,6 +85,7 @@
 
       type (state_type), intent(inout) :: s
       type (mesh_type), intent(in) :: grid
+      integer, intent(out) :: err
       integer :: k_displaced
       character(len=8), intent(in) :: displacement_type
 
@@ -93,17 +95,22 @@
       integer :: nCells, iCell, k, indexT, indexS
       type (dm_info) :: dminfo
 
+      err = 0
+
+      if(.not.eosOn) return
+
       call timer_start(&quot;ocn_equation_of_state_rho&quot;)
 
-      if (config_eos_type.eq.'linear') then
+      tracers =&gt; s % tracers % array
+      indexT = s % index_temperature
+      indexS = s % index_salinity
 
-         call ocn_equation_of_state_linear_rho(s, grid, k_displaced, displacement_type)
+      if (linearEos) then
+         rho =&gt; s % rho % array
 
-      elseif (config_eos_type.eq.'jm') then
+         call ocn_equation_of_state_linear_rho(grid, indexT, indexS, tracers, rho, err)
 
-         tracers =&gt; s % tracers % array
-         indexT = s % index_temperature
-         indexS = s % index_salinity
+      elseif (jmEos) then
 
          if(k_displaced == 0) then
              rho =&gt; s % rho % array
@@ -111,13 +118,8 @@
              rho =&gt; s % rhoDisplaced % array
          endif
 
-         call ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho)
-!        call ocn_equation_of_state_rho_jm_bak(s, grid, k_displaced, displacement_type)
+         call ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho, err)
 
-      else 
-         print *, ' Incorrect choice of config_eos_type:',&amp;
-            config_eos_type
-         call dmpar_abort(dminfo)
       endif
 
       call timer_stop(&quot;ocn_equation_of_state_rho&quot;)
@@ -130,7 +132,7 @@
 !
 !&gt; \brief   Initializes ocean momentum horizontal mixing quantities
 !&gt; \author  Doug Jacobsen
-!&gt; \date    19 September 2011
+!&gt; \date    29 September 2011
 !&gt; \version SVN:$Id$
 !&gt; \details 
 !&gt;  This routine initializes a variety of quantities related to 
@@ -138,7 +140,7 @@
 !&gt;  parameterizations are available, this routine primarily calls the
 !&gt;  individual init routines for each parameterization. 
 !
-!-----------------------------------------------------------------------
+!----------------------------------------------------------------------
 
    subroutine ocn_equation_of_state_init(err)!{{{
 
@@ -152,324 +154,29 @@
 
       integer, intent(out) :: err
 
-      integer :: err1, err2
-
       err = 0
-      ! For an isopycnal model, density should remain constant.
-      ! For zlevel, calculate in-situ density
       eosON = .false.
+      linearEos = .false.
+      jmEos = .false.
 
       if(config_vert_grid_type.eq.'zlevel') then
           eosON = .true.
-!         call ocn_equation_of_stateLinearInit(err1)
-!         call ocn_equation_of_stateJMInit(err2)
 
-          err = err1 .or. err2
+          if (config_eos_type.eq.'linear') then
+              linearEos = .true.
+          elseif (config_eos_type.eq.'jm') then
+              jmEos = .true.
+          else
+              print *,'Invalid choice for config_eos_type.'
+              print *,'  Choices are: linear, jm'
+              err = 1
+          endif
       endif
 
-
    !--------------------------------------------------------------------
 
    end subroutine ocn_equation_of_state_init!}}}
 
-   subroutine ocn_equation_of_state_linear_rho(s, grid, k_displaced, displacement_type)!{{{
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !  This module contains routines necessary for computing the density
-   !  from model temperature and salinity using an equation of state.
-   !
-   ! Input: grid - grid metadata
-   !        s - state: tracers
-   !        k_displaced 
-   !  If k_displaced&lt;=0, state % rho is returned with no displaced
-   !  If k_displaced&gt;0,the state % rhoDisplaced is returned, and is for
-   !  a parcel adiabatically displaced from its original level to level 
-   !  k_displaced.  This does not effect the linear EOS.
-   !
-   ! Output: s - state: computed density
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      implicit none
-
-      type (state_type), intent(inout) :: s
-      type (mesh_type), intent(in) :: grid
-      integer :: k_displaced
-      character(len=8), intent(in) :: displacement_type
-
-      integer, dimension(:), pointer :: maxLevelCell
-      real (kind=RKIND), dimension(:,:), pointer :: rho
-      real (kind=RKIND), dimension(:,:,:), pointer :: tracers
-      integer :: nCells, iCell, k
-      type (dm_info) :: dminfo
-
-      call timer_start(&quot;ocn_equation_of_state_linear&quot;)
-
-      rho         =&gt; s % rho % array
-      tracers     =&gt; s % tracers % array
-      maxLevelCell      =&gt; grid % maxLevelCell % array
-      nCells      = grid % nCells
-
-      do iCell=1,nCells
-         do k=1,maxLevelCell(iCell)
-            ! Linear equation of state
-            rho(k,iCell) = 1000.0*(  1.0 &amp;
-               - 2.5e-4*tracers(s % index_temperature,k,iCell) &amp;
-               + 7.6e-4*tracers(s % index_salinity,k,iCell))
-         end do
-      end do
-
-      call timer_stop(&quot;ocn_equation_of_state_linear&quot;)
-
-   end subroutine ocn_equation_of_state_linear_rho!}}}
-
-   subroutine ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho)!{{{
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-   !  This module contains routines necessary for computing the density
-   !  from model temperature and salinity using an equation of state.
-   !
-   !  The UNESCO equation of state computed using the
-   !  potential-temperature-based bulk modulus from Jackett and
-   !  McDougall, JTECH, Vol.12, pp 381-389, April, 1995.
-   !
-   ! Input: grid - grid metadata
-   !        s - state: tracers
-   !        k_displaced 
-
-   !  If k_displaced&lt;=0, density is returned with no displaced
-   !  If k_displaced&gt;0,the density returned is that for a parcel
-   !  adiabatically displaced from its original level to level 
-   !  k_displaced.
-
-   !
-   ! Output: s - state: computed density
-   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      implicit none
-
-      type (mesh_type), intent(in) :: grid
-      integer :: k_displaced, indexT, indexS
-      character(len=8), intent(in) :: displacement_type
-
-      type (dm_info) :: dminfo
-      integer :: iEdge, iCell, iVertex, k
-
-      integer :: nCells, nEdges, nVertices, nVertLevels
-
-
-      real (kind=RKIND), dimension(:), pointer :: &amp;
-        zMidZLevel, pRefEOS
-      real (kind=RKIND), dimension(:,:), intent(inout) :: &amp;
-        rho
-      real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers
-
-      integer, dimension(:), pointer :: maxLevelCell
-
-   real (kind=RKIND) :: &amp;
-      TQ,SQ,             &amp;! adjusted T,S
-      BULK_MOD,          &amp;! Bulk modulus
-      RHO_S,             &amp;! density at the surface
-      DRDT0,             &amp;! d(density)/d(temperature), for surface
-      DRDS0,             &amp;! d(density)/d(salinity   ), for surface
-      DKDT,              &amp;! d(bulk modulus)/d(pot. temp.)
-      DKDS,              &amp;! d(bulk modulus)/d(salinity  )
-      SQR,DENOMK,        &amp;! work arrays
-      WORK1, WORK2, WORK3, WORK4, T2, depth
-
-   real (kind=RKIND) :: &amp; 
-      tmin, tmax,        &amp;! valid temperature range for level k
-      smin, smax          ! valid salinity    range for level k
-
-   real (kind=RKIND), dimension(:), allocatable :: &amp;
-      p, p2 ! temporary pressure scalars
-
-!-----------------------------------------------------------------------
-!
-!  UNESCO EOS constants and JMcD bulk modulus constants
-!
-!-----------------------------------------------------------------------
-
-   !*** for density of fresh water (standard UNESCO)
-
-   real (kind=RKIND), parameter ::              &amp;
-      unt0 =   999.842594,           &amp;
-      unt1 =  6.793952e-2,           &amp;
-      unt2 = -9.095290e-3,           &amp;
-      unt3 =  1.001685e-4,           &amp;
-      unt4 = -1.120083e-6,           &amp;
-      unt5 =  6.536332e-9
-
-   !*** for dependence of surface density on salinity (UNESCO)
-
-   real (kind=RKIND), parameter ::              &amp;
-      uns1t0 =  0.824493 ,           &amp;
-      uns1t1 = -4.0899e-3,           &amp;
-      uns1t2 =  7.6438e-5,           &amp;
-      uns1t3 = -8.2467e-7,           &amp;
-      uns1t4 =  5.3875e-9,           &amp;
-      unsqt0 = -5.72466e-3,          &amp;
-      unsqt1 =  1.0227e-4,           &amp;
-      unsqt2 = -1.6546e-6,           &amp;
-      uns2t0 =  4.8314e-4
-
-   !*** from Table A1 of Jackett and McDougall
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup0s0t0 =  1.965933e+4,       &amp;
-      bup0s0t1 =  1.444304e+2,       &amp;
-      bup0s0t2 = -1.706103   ,       &amp;
-      bup0s0t3 =  9.648704e-3,       &amp;
-      bup0s0t4 = -4.190253e-5
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup0s1t0 =  5.284855e+1,       &amp;
-      bup0s1t1 = -3.101089e-1,       &amp;
-      bup0s1t2 =  6.283263e-3,       &amp;
-      bup0s1t3 = -5.084188e-5
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup0sqt0 =  3.886640e-1,       &amp;
-      bup0sqt1 =  9.085835e-3,       &amp;
-      bup0sqt2 = -4.619924e-4
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup1s0t0 =  3.186519   ,       &amp;
-      bup1s0t1 =  2.212276e-2,       &amp;
-      bup1s0t2 = -2.984642e-4,       &amp;
-      bup1s0t3 =  1.956415e-6 
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup1s1t0 =  6.704388e-3,       &amp;
-      bup1s1t1 = -1.847318e-4,       &amp;
-      bup1s1t2 =  2.059331e-7,       &amp;
-      bup1sqt0 =  1.480266e-4 
-
-   real (kind=RKIND), parameter ::              &amp;
-      bup2s0t0 =  2.102898e-4,       &amp;
-      bup2s0t1 = -1.202016e-5,       &amp;
-      bup2s0t2 =  1.394680e-7,       &amp;
-      bup2s1t0 = -2.040237e-6,       &amp;
-      bup2s1t1 =  6.128773e-8,       &amp;
-      bup2s1t2 =  6.207323e-10
-
-   integer :: k_test, k_ref
-
-      call timer_start(&quot;ocn_equation_of_state_jm&quot;)
-
-      nCells      = grid % nCells
-      maxLevelCell      =&gt; grid % maxLevelCell % array
-      nVertLevels = grid % nVertLevels
-      zMidZLevel        =&gt; grid % zMidZLevel % array
-
-
-!  Jackett and McDougall
-      tmin = -2.0  ! valid pot. temp. range
-      tmax = 40.0 
-      smin =  0.0  ! valid salinity, in psu   
-      smax = 42.0 
-
-      ! This could be put in a startup routine.
-      ! Note I am using zMidZlevel, so pressure on top level does
-      ! not include SSH contribution.  I am not sure if that matters.
-
-!  This function computes pressure in bars from depth in meters
-!  using a mean density derived from depth-dependent global 
-!  average temperatures and salinities from Levitus 1994, and 
-!  integrating using hydrostatic balance.
-
-      allocate(pRefEOS(nVertLevels),p(nVertLevels),p2(nVertLevels))
-      do k = 1,nVertLevels
-        depth = -zMidZLevel(k)
-        pRefEOS(k) = 0.059808*(exp(-0.025*depth) - 1.0) &amp;
-            + 0.100766*depth + 2.28405e-7*depth**2
-      enddo
-
-   !  If k_displaced=0, in-situ density is returned (no displacement)
-   !  If k_displaced/=0, potential density is returned
-
-   !  if displacement_type = 'relative', potential density is calculated
-   !     referenced to level k + k_displaced
-   !  if displacement_type = 'absolute', potential density is calculated
-   !     referenced to level k_displaced for all k
-   !  NOTE: k_displaced = 0 or &gt; nVertLevels is incompatible with 'absolute'
-   !     so abort if necessary
-
-   if (displacement_type == 'absolute' .and.   &amp;
-       (k_displaced &lt;= 0 .or. k_displaced &gt; nVertLevels) ) then
-      write(0,*) 'Abort: In ocn_equation_of_state_jm', &amp;
-         ' k_displaced must be between 1 and nVertLevels for ', &amp;
-         'displacement_type = absolute'
-      call dmpar_abort(dminfo)
-   endif
-
-   if (k_displaced == 0) then
-      do k=1,nVertLevels
-         p(k)   = pRefEOS(k)
-         p2(k)  = p(k)*p(k)
-      enddo
-   else ! k_displaced /= 0
-      do k=1,nVertLevels
-         if (displacement_type == 'relative') then
-            k_test = min(k + k_displaced, nVertLevels)
-            k_ref  = max(k_test, 1)
-         else
-            k_test = min(k_displaced, nVertLevels)
-            k_ref  = max(k_test, 1)
-         endif
-         p(k)   = pRefEOS(k_ref)
-         p2(k)  = p(k)*p(k)
-      enddo
-   endif
-
-  do iCell=1,nCells
-    do k=1,maxLevelCell(iCell)
-
-      SQ  = max(min(tracers(indexS,k,iCell),smax),smin)
-      TQ  = max(min(tracers(indexT,k,iCell),tmax),tmin)
-
-      SQR = sqrt(SQ)
-      T2  = TQ*TQ
-
-      !***
-      !*** first calculate surface (p=0) values from UNESCO eqns.
-      !***
-
-      WORK1 = uns1t0 + uns1t1*TQ + &amp; 
-             (uns1t2 + uns1t3*TQ + uns1t4*T2)*T2
-      WORK2 = SQR*(unsqt0 + unsqt1*TQ + unsqt2*T2)
-
-      RHO_S = unt1*TQ + (unt2 + unt3*TQ + (unt4 + unt5*TQ)*T2)*T2 &amp;
-                      + (uns2t0*SQ + WORK1 + WORK2)*SQ
-
-      !***
-      !*** now calculate bulk modulus at pressure p from 
-      !*** Jackett and McDougall formula
-      !***
-
-      WORK3 = bup0s1t0 + bup0s1t1*TQ +                    &amp;
-             (bup0s1t2 + bup0s1t3*TQ)*T2 +                &amp;
-              p(k) *(bup1s1t0 + bup1s1t1*TQ + bup1s1t2*T2) + &amp;
-              p2(k)*(bup2s1t0 + bup2s1t1*TQ + bup2s1t2*T2)
-      WORK4 = SQR*(bup0sqt0 + bup0sqt1*TQ + bup0sqt2*T2 + &amp;
-                   bup1sqt0*p(k))
-
-      BULK_MOD  = bup0s0t0 + bup0s0t1*TQ +                    &amp;
-                  (bup0s0t2 + bup0s0t3*TQ + bup0s0t4*T2)*T2 + &amp;
-                  p(k) *(bup1s0t0 + bup1s0t1*TQ +                &amp;
-                     (bup1s0t2 + bup1s0t3*TQ)*T2) +           &amp;
-                  p2(k)*(bup2s0t0 + bup2s0t1*TQ + bup2s0t2*T2) + &amp;
-                  SQ*(WORK3 + WORK4)
-
-      DENOMK = 1.0/(BULK_MOD - p(k))
-
-      rho(k,iCell) = (unt0 + RHO_S)*BULK_MOD*DENOMK
-
-    end do
-  end do
-
-   deallocate(pRefEOS,p,p2)
-
-   call timer_stop(&quot;ocn_equation_of_state_jm&quot;)
-
-   end subroutine ocn_equation_of_state_jm_rho!}}}
-
 !***********************************************************************
 
 end module ocn_equation_of_state

Modified: branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_jm.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_jm.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_jm.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -60,7 +60,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho)!{{{
+   subroutine ocn_equation_of_state_jm_rho(grid, k_displaced, displacement_type, indexT, indexS, tracers, rho, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -87,6 +87,7 @@
       type (mesh_type), intent(in) :: grid
       integer :: k_displaced, indexT, indexS
       character(len=8), intent(in) :: displacement_type
+      integer, intent(out) :: err
 
       type (dm_info) :: dminfo
       integer :: iEdge, iCell, iVertex, k
@@ -191,6 +192,8 @@
 
    integer :: k_test, k_ref
 
+      err = 0
+
       call timer_start(&quot;equation_of_state_jm&quot;)
 
       nCells      = grid % nCells

Modified: branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_linear.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_equation_of_state_linear.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -60,7 +60,7 @@
 !
 !-----------------------------------------------------------------------
 
-   subroutine ocn_equation_of_state_linear_rho(s, grid, k_displaced, displacement_type)!{{{
+   subroutine ocn_equation_of_state_linear_rho(grid, indexT, indexS, tracers, rho, err)!{{{
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !  This module contains routines necessary for computing the density
    !  from model temperature and salinity using an equation of state.
@@ -77,34 +77,33 @@
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       implicit none
 
-      type (state_type), intent(inout) :: s
       type (mesh_type), intent(in) :: grid
-      integer :: k_displaced
-      character(len=8), intent(in) :: displacement_type
+      real (kind=RKIND), dimension(:,:), intent(inout) :: rho
+      real (kind=RKIND), dimension(:,:,:), intent(in) :: tracers
+      integer, intent(in) :: indexT, indexS
+      integer, intent(out) :: err
 
       integer, dimension(:), pointer :: maxLevelCell
-      real (kind=RKIND), dimension(:,:), pointer :: rho
-      real (kind=RKIND), dimension(:,:,:), pointer :: tracers
       integer :: nCells, iCell, k
       type (dm_info) :: dminfo
 
-      call timer_start(&quot;equation_of_state_linear&quot;)
+      call timer_start(&quot;ocn_equation_of_state_linear&quot;)
 
-      rho         =&gt; s % rho % array
-      tracers     =&gt; s % tracers % array
       maxLevelCell      =&gt; grid % maxLevelCell % array
       nCells      = grid % nCells
 
+      err = 0
+
       do iCell=1,nCells
          do k=1,maxLevelCell(iCell)
             ! Linear equation of state
             rho(k,iCell) = 1000.0*(  1.0 &amp;
-               - 2.5e-4*tracers(s % index_temperature,k,iCell) &amp;
-               + 7.6e-4*tracers(s % index_salinity,k,iCell))
+               - 2.5e-4*tracers(indexT,k,iCell) &amp;
+               + 7.6e-4*tracers(indexS,k,iCell))
          end do
       end do
 
-      call timer_stop(&quot;equation_of_state_linear&quot;)
+      call timer_stop(&quot;ocn_equation_of_state_linear&quot;)
 
    end subroutine ocn_equation_of_state_linear_rho!}}}
 

Modified: branches/ocean_projects/performance/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_mpas_core.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_mpas_core.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -52,6 +52,23 @@
 
       integer :: err
 
+      ! Initialize submodules before initializing blocks.
+      call ocn_timestep_init(err)
+
+      call ocn_vel_pressure_grad_init(err)
+      call ocn_vel_vadv_init(err)
+      call ocn_vel_hmix_init(err)
+      call ocn_vel_forcing_init(err)
+
+      call ocn_tracer_hadv_init(err)
+      call ocn_tracer_vadv_init(err)
+      call ocn_tracer_hmix_init(err)
+      call ocn_restoring_init(err)
+
+      call ocn_vmix_init(err)
+
+      call ocn_equation_of_state_init(err)
+
       if (.not. config_do_restart) call setup_sw_test_case(domain)
 
       call compute_maxLevel(domain)
@@ -74,7 +91,6 @@
          call dmpar_abort(dminfo)
       endif
 
-
       !
       ! Initialize core
       !
@@ -92,22 +108,6 @@
          ! temperature and salinity tracers from state.
       end do
 
-      call ocn_timestep_init(err)
-
-      call ocn_vel_pressure_grad_init(err)
-      call ocn_vel_vadv_init(err)
-      call ocn_vel_hmix_init(err)
-      call ocn_vel_forcing_init(err)
-
-      call ocn_tracer_hadv_init(err)
-      call ocn_tracer_vadv_init(err)
-      call ocn_tracer_hmix_init(err)
-      call ocn_restoring_init(err)
-
-      call ocn_vmix_init(err)
-
-      call ocn_equation_of_state_init(err)
-
    ! 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/src/core_ocean/mpas_ocn_tendency.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_tendency.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_tendency.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -610,7 +610,7 @@
       integer :: iEdge, iCell, iVertex, k, cell1, cell2, vertex1, vertex2, eoe, i, j, cov
       real (kind=RKIND) :: flux, vorticity_abs, h_vertex, workpv, rho0Inv
 
-      integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree, fCoef
+      integer :: nCells, nEdges, nVertices, nVertLevels, vertexDegree, fCoef, err
 
 
       real (kind=RKIND), dimension(:), pointer :: &amp;
@@ -1008,9 +1008,9 @@
       ! For an isopycnal model, density should remain constant.
       ! For zlevel, calculate in-situ density
       if (config_vert_grid_type.eq.'zlevel') then
-         call ocn_equation_of_state_rho(s, grid, 0, 'relative')
+         call ocn_equation_of_state_rho(s, grid, 0, 'relative', err)
       ! mrp 110324 In order to visualize rhoDisplaced, include the following
-         call ocn_equation_of_state_rho(s, grid, 1, 'relative')
+         call ocn_equation_of_state_rho(s, grid, 1, 'relative', err)
       endif
 
       !

Modified: branches/ocean_projects/performance/src/core_ocean/mpas_ocn_vmix_coefs_rich.F
===================================================================
--- branches/ocean_projects/performance/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2011-09-30 13:52:48 UTC (rev 1043)
+++ branches/ocean_projects/performance/src/core_ocean/mpas_ocn_vmix_coefs_rich.F        2011-09-30 15:48:35 UTC (rev 1044)
@@ -139,8 +139,8 @@
       rhoDisplaced =&gt; s % rhoDisplaced % array
       tracers =&gt; s % tracers % array
 
-      call ocn_equation_of_state_rho(s, grid, 0, 'relative')
-      call ocn_equation_of_state_rho(s, grid, 1, 'relative')
+      call ocn_equation_of_state_rho(s, grid, 0, 'relative', err)
+      call ocn_equation_of_state_rho(s, grid, 1, 'relative', err)
 
       call ocn_vmix_get_rich_numbers(grid, indexT, indexS, u, h, h_edge, &amp; 
                                   rho, rhoDisplaced, tracers, RiTopOfEdge, RiTopOfCell, err1)

</font>
</pre>