<p><b>mpetersen@lanl.gov</b> 2012-04-09 12:47:14 -0600 (Mon, 09 Apr 2012)</p><p>Changes to zstar_restart branch.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/zstar_restart/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/ocean_projects/zstar_restart/src/core_ocean/mpas_ocn_mpas_core.F        2012-04-09 15:32:57 UTC (rev 1759)
+++ branches/ocean_projects/zstar_restart/src/core_ocean/mpas_ocn_mpas_core.F        2012-04-09 18:47:14 UTC (rev 1760)
@@ -102,6 +102,10 @@
 
       call ocn_compute_max_level(domain)
 
+      if (config_vert_grid_type.eq.'zstar') then
+         call ocn_init_h_zstar(domain)
+      endif
+
       call ocn_init_z_level(domain)
 
       print *, ' Vertical grid type is: ',config_vert_grid_type
@@ -605,6 +609,96 @@
 
    end subroutine ocn_init_z_level!}}}
 
+   subroutine ocn_init_h_zstar(domain)!{{{
+   ! Initialize maxLevel and bouncary grid variables.
+
+      use mpas_grid_types
+      use mpas_configure
+
+      implicit none
+
+      type (domain_type), intent(inout) :: domain
+
+      type (block_type), pointer :: block
+
+      integer :: i, iCell, iEdge, iVertex, k, nVertLevels
+      integer, dimension(:), pointer :: maxLevelCell
+
+      real (kind=RKIND) :: hSum, sumZstarWeights
+      real (kind=RKIND), dimension(:), allocatable :: zstarWeight
+      real (kind=RKIND), dimension(:), pointer :: referenceBottomDepth, hZLevel
+      real (kind=RKIND), dimension(:,:), pointer :: h
+
+      ! Initialize z-level grid variables from h, read in from input file.
+      block =&gt; domain % blocklist
+      do while (associated(block))
+
+         h          =&gt; block % state % time_levs(1) % state % h % array
+         nVertLevels = block % mesh % nVertLevels
+         hZLevel =&gt; block % mesh % hZLevel % array
+         maxLevelCell =&gt; block % mesh % maxLevelCell % array
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! WARNING: referenceBottomDepth needs to be initialized before this in the code
+! right now it is not, so this wont work.
+
+         referenceBottomDepth =&gt; block % mesh % referenceBottomDepth % array
+
+         allocate(zstarWeight(nVertLevels))
+
+         ! Initialization of zstarWeights.  This determines how SSH perturbations
+         ! are distributed throughout the column.
+         ! mrp 120313 note: zstarWeights should be moved to a variable in 
+         ! 
+         if (config_vert_grid_type.eq.'zlevel') then
+
+           zstarWeight = 0.0
+           zstarWeight(1) = 1.0
+
+         elseif (config_vert_grid_type.eq.'zstar') then
+
+            do k = 1,nVertLevels
+               zstarWeight(k) = hZLevel(k)
+            enddo
+
+         elseif (config_vert_grid_type.eq.'zstarWeights') then
+
+           ! This is a test with other weights, not meant to be permanent.
+   
+           zstarWeight = 0.0
+           zstarWeight(1:5) = 1.0
+           do k=1,10
+              zstarWeight(5+k) = 1.0-k*0.1
+           end do
+
+         endif
+
+
+         do iCell=1,block % mesh % nCells
+            hSum = 0.0
+            sumZstarWeights = 0.0
+            do k = 1,maxLevelCell(iCell)
+               hSum = hSum + h(k,iCell) 
+               sumZstarWeights = sumZstarWeights + zstarWeight(k)
+            enddo
+
+            ! h_k = h_k^{zlevel} + zeta * W_k/sum(W_k)
+            ! where zeta is SSH and W_k are weights
+            do k = 1,maxLevelCell(iCell)
+               h(k,iCell) = hZLevel(k) &amp;
+                 + (hSum - referenceBottomDepth(maxLevelCell(iCell))) &amp;
+                  * zstarWeight(k)/sumZstarWeights
+            enddo
+
+         enddo
+
+         deallocate(zstarWeight)
+
+      block =&gt; block % next
+      end do
+
+   end subroutine ocn_init_h_zstar!}}}
+
 subroutine ocn_compute_max_level(domain)!{{{
 ! Initialize maxLevel and bouncary grid variables.
 

</font>
</pre>