<p><b>mpetersen@lanl.gov</b> 2010-05-14 13:04:36 -0600 (Fri, 14 May 2010)</p><p>Merged trunk to branch.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_test_cases.F
===================================================================
--- branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_test_cases.F        2010-05-14 18:09:25 UTC (rev 275)
+++ branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_test_cases.F        2010-05-14 19:04:36 UTC (rev 276)
@@ -96,16 +96,11 @@
         block_ptr =&gt; block_ptr % next
       end do
 
-      ! mrp 100507:  This whole section is just temporary
-      ! print some diagnostics
+      ! Initialize z-level grid variables from h, read in from input file.
       block_ptr =&gt; domain % blocklist
       do while (associated(block_ptr))
          h          =&gt; block_ptr % time_levs(1) % state % h % array
-         u          =&gt; block_ptr % time_levs(1) % state % u % array
-         rho        =&gt; block_ptr % time_levs(1) % state % rho % array
          tracers    =&gt; block_ptr % time_levs(1) % state % tracers % array
-
-         u_src      =&gt; block_ptr % mesh % u_src % array
          xCell      =&gt; block_ptr % mesh % xCell % array
          yCell      =&gt; block_ptr % mesh % yCell % array
 
@@ -118,46 +113,40 @@
          nVertices   = block_ptr % mesh % nVertices
          nVertLevels = block_ptr % mesh % nVertLevels
 
-         ! mrp 100426: initialize z-level variables.
-      if (config_vert_grid_type.eq.'zlevel') then
-         ! These should eventually be in an input file.  For now
-         ! I just read them in from h(:,1).
-         hZLevel = h(:,1)
-         zTopZLevel(1) = 0.0
-         do iLevel = 1,nVertLevels
-           zMidZLevel(iLevel) = zTopZLevel(iLevel)-0.5*hZLevel(iLevel)
-           zTopZLevel(iLevel+1) = zTopZLevel(iLevel)-  hZLevel(iLevel)
-         enddo
-         if (config_vert_grid_type.eq.'isopycnal') then
-           print *, ' Using isopycnal coordinates'
-         elseif (config_vert_grid_type.eq.'zlevel') then
-           print *, ' Using z-level coordinates'
-         else 
-           print *, ' Incorrect choice of config_vert_grid_type:',&amp;
-             config_vert_grid_type
-             call dmpar_abort(dminfo)
-         endif
-
-         tracers = 0.0
-         do iCell = 1,nCells
+         if (config_vert_grid_type.eq.'zlevel') then
+           ! These should eventually be in an input file.  For now
+           ! I just read them in from h(:,1).
+           hZLevel = h(:,1)
+           zTopZLevel(1) = 0.0
            do iLevel = 1,nVertLevels
-             ! for 20 layer test
-             tracers(index_salinity,iLevel,iCell) = 1.4 + iLevel*0.6  ! salinity
-             tracers(index_temperature,iLevel,iCell) = 5.0  ! temperature
-
-             tracers(index_tracer1,iLevel,iCell) = 1.0
-             tracers(index_tracer2,iLevel,iCell) = &amp;
-               (yCell(iCell)/4000.e3 + xCell(iCell)/2500.e3 )/2.0
-
-             rho(iLevel,iCell) = 1000.0*(  1.0 &amp;
-               - 2.5e-4*tracers(index_temperature,iLevel,iCell) &amp;
-               + 7.6e-4*tracers(index_salinity,iLevel,iCell))
+             zMidZLevel(iLevel) = zTopZLevel(iLevel)-0.5*hZLevel(iLevel)
+             zTopZLevel(iLevel+1) = zTopZLevel(iLevel)-  hZLevel(iLevel)
            enddo
-         enddo
+           if (config_vert_grid_type.eq.'isopycnal') then
+             print *, ' Using isopycnal coordinates'
+           elseif (config_vert_grid_type.eq.'zlevel') then
+             print *, ' Using z-level coordinates'
+           else 
+             print *, ' Incorrect choice of config_vert_grid_type:',&amp;
+               config_vert_grid_type
+               call dmpar_abort(dminfo)
+           endif
 
-      endif
-         ! mrp 100426 end: initialize z-level variables.
+           !tracers = 0.0
+           !do iCell = 1,nCells
+           !  do iLevel = 1,nVertLevels
+           !   ! for 20 layer test
+           !    tracers(index_temperature,iLevel,iCell) = 5.0  ! temperature
+           !    tracers(index_salinity,iLevel,iCell) = 1.4 + iLevel*0.6  ! salinity
+           !    tracers(index_tracer1,iLevel,iCell) = 1.0
+           !    tracers(index_tracer2,iLevel,iCell) = &amp;
+           !      (yCell(iCell)/4000.e3 + xCell(iCell)/2500.e3 )/2.0
+           !  enddo
+           !enddo
 
+        endif
+
+         ! print some diagnostics
          print '(10a)', 'ilevel',&amp;
             '  rho      ',&amp;
             '  min u       max u     ',&amp;
@@ -173,7 +162,6 @@
               hZLevel(iLevel),zMidZlevel(iLevel),zTopZlevel(iLevel)
          enddo
 
-         ! print some diagnostics
          print '(10a)', 'itracer ilevel  min tracer  max tracer'
          do iTracer=1,num_tracers
          do iLevel = 1,nVertLevels

Modified: branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_time_integration.F
===================================================================
--- branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_time_integration.F        2010-05-14 18:09:25 UTC (rev 275)
+++ branches/ocean_projects/z_level_mrp/mpas/src/core_ocean/module_time_integration.F        2010-05-14 19:04:36 UTC (rev 276)
@@ -494,7 +494,7 @@
          do k=2,nVertLevels
            fluxVertTop(k) = config_vert_viscosity &amp;
               * ( u(k-1,iEdge) - u(k,iEdge) ) &amp;
-              / (zMidEdge(k-1,iEdge) -zMidEdge(k,iEdge))
+              / (zMidEdge(k-1,iEdge) - zMidEdge(k,iEdge))
          enddo
          do k=1,nVertLevels
            tend_u(k,iEdge) = tend_u(k,iEdge) &amp;

Modified: branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_input.F
===================================================================
--- branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_input.F        2010-05-14 18:09:25 UTC (rev 275)
+++ branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_input.F        2010-05-14 19:04:36 UTC (rev 276)
@@ -103,6 +103,7 @@
       type (exchange_list), pointer :: sendEdgeList, recvEdgeList
       type (exchange_list), pointer :: sendVertexList, recvVertexList
       type (exchange_list), pointer :: sendVertLevelList, recvVertLevelList
+      type (exchange_list), pointer :: sendVertLevelP1List, recvVertLevelP1List
       type (exchange_list), pointer :: send1Halo, recv1Halo
       type (exchange_list), pointer :: send2Halo, recv2Halo
       type (graph) :: partial_global_graph_info
@@ -693,7 +694,28 @@
       deallocate(local_vertlevel_list)
       deallocate(needed_vertlevel_list)
 
+      if (domain % dminfo % my_proc_id == 0) then
+         allocate(local_vertlevel_list(nVertLevels+1))
+         do i=1,nVertLevels+1
+            local_vertlevel_list(i) = i
+         end do
+      else
+         allocate(local_vertlevel_list(0))
+      end if
+      allocate(needed_vertlevel_list(nVertLevels+1))
+      do i=1,nVertLevels+1
+         needed_vertlevel_list(i) = i
+      end do
 
+      call dmpar_get_owner_list(domain % dminfo, &amp;
+                                size(local_vertlevel_list), size(needed_vertlevel_list), &amp;
+                                local_vertlevel_list, needed_vertlevel_list, &amp;
+                                sendVertLevelP1List, recvVertLevelP1List)
+
+      deallocate(local_vertlevel_list)
+      deallocate(needed_vertlevel_list)
+
+
       !
       ! Read and distribute all fields given ownership lists and exchange lists (maybe already in block?)
       !
@@ -765,7 +787,7 @@
                                       readCellStart, nReadCells, readEdgeStart, nReadEdges, readVertexStart, nReadVertices, &amp;
                                       readVertLevelStart, nReadVertLevels, &amp;
                                       sendCellList, recvCellList, sendEdgeList, recvEdgeList, sendVertexList, recvVertexList, &amp;
-                                      sendVertLevelList, recvVertLevelList) 
+                                      sendVertLevelList, recvVertLevelList, sendVertLevelP1List, recvVertLevelP1List) 
 
 
       call io_input_finalize(input_obj, domain % dminfo)
@@ -977,7 +999,8 @@
                                      sendCellsList, recvCellsList, &amp;
                                      sendEdgesList, recvEdgesList, &amp;
                                      sendVerticesList, recvVerticesList, &amp;
-                                     sendVertLevelsList, recvVertLevelsList) 
+                                     sendVertLevelsList, recvVertLevelsList, &amp; 
+                                     sendVertLevelsP1List, recvVertLevelsP1List) 
       
       implicit none
 
@@ -990,6 +1013,7 @@
       type (exchange_list), pointer :: sendEdgesList, recvEdgesList
       type (exchange_list), pointer :: sendVerticesList, recvVerticesList
       type (exchange_list), pointer :: sendVertLevelsList, recvVertLevelsList
+      type (exchange_list), pointer :: sendVertLevelsP1List, recvVertLevelsP1List
 
       type (field1dInteger) :: int1d
       type (field2dInteger) :: int2d

Modified: branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_output.F
===================================================================
--- branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_output.F        2010-05-14 18:09:25 UTC (rev 275)
+++ branches/ocean_projects/z_level_mrp/mpas/src/framework/module_io_output.F        2010-05-14 19:04:36 UTC (rev 276)
@@ -23,6 +23,7 @@
       type (exchange_list), pointer :: sendEdgesList, recvEdgesList
       type (exchange_list), pointer :: sendVerticesList, recvVerticesList
       type (exchange_list), pointer :: sendVertLevelsList, recvVertLevelsList
+      type (exchange_list), pointer :: sendVertLevelsP1List, recvVertLevelsP1List
    end type io_output_object
 
 
@@ -66,6 +67,8 @@
       nullify(output_obj % recvVerticesList)
       nullify(output_obj % sendVertLevelsList)
       nullify(output_obj % recvVertLevelsList)
+      nullify(output_obj % sendVertLevelsP1List)
+      nullify(output_obj % recvVertLevelsP1List)
       output_obj % validExchangeLists = .false.
 
 #include &quot;output_dim_inits.inc&quot;
@@ -110,6 +113,7 @@
       integer, dimension(:), pointer :: neededEdgeList
       integer, dimension(:), pointer :: neededVertexList
       integer, dimension(:), pointer :: neededVertLevelList
+      integer, dimension(:), pointer :: neededVertLevelP1List
       integer, dimension(:,:), pointer :: cellsOnCell, edgesOnCell, verticesOnCell, &amp;
                                           cellsOnEdge, verticesOnEdge, edgesOnEdge, cellsOnVertex, edgesOnVertex
       integer, dimension(:,:), pointer :: cellsOnCell_save, edgesOnCell_save, verticesOnCell_save, &amp;
@@ -210,6 +214,7 @@
          allocate(neededEdgeList(nEdgesGlobal))
          allocate(neededVertexList(nVerticesGlobal))
          allocate(neededVertLevelList(nVertLevelsGlobal))
+         allocate(neededVertLevelP1List(nVertLevelsGlobal+1))
          do i=1,nCellsGlobal
             neededCellList(i) = i
          end do
@@ -222,11 +227,15 @@
          do i=1,nVertLevelsGlobal
             neededVertLevelList(i) = i
          end do
+         do i=1,nVertLevelsGlobal+1
+            neededVertLevelP1List(i) = i
+         end do
       else
          allocate(neededCellList(0))
          allocate(neededEdgeList(0))
          allocate(neededVertexList(0))
          allocate(neededVertLevelList(0))
+         allocate(neededVertLevelP1List(0))
       end if
 
       if (.not. output_obj % validExchangeLists) then
@@ -250,6 +259,11 @@
                                    neededVertLevelList, neededVertLevelList, &amp;
                                    output_obj % sendVertLevelsList, output_obj % recvVertLevelsList)
 
+         call dmpar_get_owner_list(domain % dminfo, &amp;
+                                   size(neededVertLevelP1List), size(neededVertLevelP1List), &amp;
+                                   neededVertLevelP1List, neededVertLevelP1List, &amp;
+                                   output_obj % sendVertLevelsP1List, output_obj % recvVertLevelsP1List)
+
          output_obj % validExchangeLists = .true.
       end if
 

Modified: branches/ocean_projects/z_level_mrp/mpas/src/registry/gen_inc.c
===================================================================
--- branches/ocean_projects/z_level_mrp/mpas/src/registry/gen_inc.c        2010-05-14 18:09:25 UTC (rev 275)
+++ branches/ocean_projects/z_level_mrp/mpas/src/registry/gen_inc.c        2010-05-14 19:04:36 UTC (rev 276)
@@ -576,20 +576,30 @@
             fortprintf(fd, &quot;      allocate(s %% %s %% ioinfo)</font>
<font color="red">&quot;, var_ptr-&gt;name_in_code);
             fortprintf(fd, &quot;      allocate(s %% %s %% array(&quot;, var_ptr-&gt;name_in_code);
             dimlist_ptr = var_ptr-&gt;dimlist;
-            if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
-                !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nEdges&quot;, 1024) ||
-                !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
-               fortprintf(fd, &quot;b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
-            else
-               fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
-            dimlist_ptr = dimlist_ptr-&gt;next;
-            while (dimlist_ptr) {
+            if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0) {
                if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nEdges&quot;, 1024) ||
                    !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
-                  fortprintf(fd, &quot;, b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  fortprintf(fd, &quot;b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
                else
-                  fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  fortprintf(fd, &quot;b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+            }
+            else {
+               fortprintf(fd, &quot;%i&quot;, dimlist_ptr-&gt;dim-&gt;constant_value);
+            }
+            dimlist_ptr = dimlist_ptr-&gt;next;
+            while (dimlist_ptr) {
+               if (dimlist_ptr-&gt;dim-&gt;constant_value &lt; 0) {
+                  if (!strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nCells&quot;, 1024) ||
+                      !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nEdges&quot;, 1024) ||
+                      !strncmp(dimlist_ptr-&gt;dim-&gt;name_in_file, &quot;nVertices&quot;, 1024))
+                     fortprintf(fd, &quot;, b %% mesh %% %s + 1&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+                  else
+                     fortprintf(fd, &quot;, b %% mesh %% %s&quot;, dimlist_ptr-&gt;dim-&gt;name_in_code);
+               }
+               else {
+                  fortprintf(fd, &quot;, %i&quot;, dimlist_ptr-&gt;dim-&gt;constant_value);
+               }
                dimlist_ptr = dimlist_ptr-&gt;next;
             }
             fortprintf(fd, &quot;))</font>
<font color="gray">&quot;);
@@ -1024,10 +1034,7 @@
          fortprintf(fd, &quot;, block %% mesh %% %s, &amp;</font>
<font color="red">&quot;, lastdim-&gt;dim-&gt;name_in_code);
    
          if (is_derived_dim(lastdim-&gt;dim-&gt;name_in_code)) {
-            split_derived_dim_string(lastdim-&gt;dim-&gt;name_in_code, &amp;cp1, &amp;cp2);
-            fortprintf(fd, &quot;                                send%sList, recv%sList)</font>
<font color="red">&quot;, cp1, cp1);
-            free(cp1);
-            free(cp2);
+            fortprintf(fd, &quot;                                send%sList, recv%sList)</font>
<font color="black">&quot;, lastdim-&gt;dim-&gt;name_in_file+1, lastdim-&gt;dim-&gt;name_in_file+1);
          }
          else
             fortprintf(fd, &quot;                                send%sList, recv%sList)</font>
<font color="gray">&quot;, lastdim-&gt;dim-&gt;name_in_code+1, lastdim-&gt;dim-&gt;name_in_code+1);
@@ -1537,7 +1544,7 @@
          if (is_derived_dim(lastdim-&gt;dim-&gt;name_in_code)) {
             split_derived_dim_string(lastdim-&gt;dim-&gt;name_in_code, &amp;cp1, &amp;cp2);
             fortprintf(fd, &quot;, n%sGlobal%s, &amp;</font>
<font color="red">&quot;, cp1, cp2);
-            fortprintf(fd, &quot;                                output_obj %% send%sList, output_obj %% recv%sList)</font>
<font color="blue">&quot;, cp1, cp1);
+            fortprintf(fd, &quot;                                output_obj %% send%sList, output_obj %% recv%sList)</font>
<font color="black">&quot;, lastdim-&gt;dim-&gt;name_in_file+1, lastdim-&gt;dim-&gt;name_in_file+1);
             free(cp1);
             free(cp2);
          }

</font>
</pre>