<p><b>duda</b> 2012-03-27 18:23:25 -0600 (Tue, 27 Mar 2012)</p><p>BRANCH COMMIT<br>
<br>
Separate out identical code sections into an include file. We can't just<br>
move this code into a subroutine because, although the variable names are<br>
the same, the types of the variables are different (e.g., field1dreal v. <br>
field2dreal) in each section.<br>
<br>
<br>
A    src/framework/add_field_indices.inc<br>
M    src/framework/mpas_io_streams.F<br>
</p><hr noshade><pre><font color="gray">Added: branches/omp_blocks/io/src/framework/add_field_indices.inc
===================================================================
--- branches/omp_blocks/io/src/framework/add_field_indices.inc                                (rev 0)
+++ branches/omp_blocks/io/src/framework/add_field_indices.inc        2012-03-28 00:23:25 UTC (rev 1728)
@@ -0,0 +1,48 @@
+      idim = ndims
+      totalDimSize = 0
+      field_ptr =&gt; field
+      if (trim(field % dimNames(idim)) == 'nCells') then
+write(0,*) '... outer dimension is nCells'
+         allocate(indices(0))
+         do while (associated(field_ptr))
+            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
+            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
+            field_ptr =&gt; field_ptr % next
+         end do
+         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
+         isDecomposed = .true.
+      else if (trim(field % dimNames(idim)) == 'nEdges') then
+write(0,*) '... outer dimension is nEdges'
+         allocate(indices(0))
+         do while (associated(field_ptr))
+            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
+            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
+            field_ptr =&gt; field_ptr % next
+         end do
+         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
+         isDecomposed = .true.
+      else if (trim(field % dimNames(idim)) == 'nVertices') then
+write(0,*) '... outer dimension is nVertices'
+         allocate(indices(0))
+         do while (associated(field_ptr))
+            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
+            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
+            field_ptr =&gt; field_ptr % next
+         end do
+         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
+         isDecomposed = .true.
+      else
+         isDecomposed = .false.
+         globalDimSize = field % dimSizes(idim)
+         totalDimSize = globalDimSize
+
+         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
+            ndims = 1
+            allocate(indices(field % dimSizes(ndims)))
+            do i=1,field % dimSizes(ndims)
+               indices(i) = i
+            end do
+         else
+            allocate(indices(0))
+         end if
+      end if

Modified: branches/omp_blocks/io/src/framework/mpas_io_streams.F
===================================================================
--- branches/omp_blocks/io/src/framework/mpas_io_streams.F        2012-03-27 21:47:50 UTC (rev 1727)
+++ branches/omp_blocks/io/src/framework/mpas_io_streams.F        2012-03-28 00:23:25 UTC (rev 1728)
@@ -232,55 +232,8 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
+#include &quot;add_field_indices.inc&quot;
 
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_INT, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
@@ -350,55 +303,8 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
+#include &quot;add_field_indices.inc&quot;
 
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_INT, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
@@ -468,57 +374,7 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-!!!!!!!!!!!!!!!!!!!!!!! Is all of this constant, and could it be put in an include file? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
-
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-!!!!!!!!!!!!!!!!!!!!!!! Is all of this constant, and could it be put in an include file? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
+#include &quot;add_field_indices.inc&quot;
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_INT, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
@@ -666,55 +522,8 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
+#include &quot;add_field_indices.inc&quot;
 
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_DOUBLE, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
@@ -784,55 +593,8 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
+#include &quot;add_field_indices.inc&quot;
 
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_DOUBLE, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)
@@ -902,57 +664,8 @@
       ! Determine whether the field is decomposed, the indices that are owned by this task's blocks,
       !    and the total number of outer-indices owned by this task
       ! 
-!!!!!!!!!!!!!!!!!!!!!!! Is all of this constant, and could it be put in an include file? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      idim = ndims
-      totalDimSize = 0
-      field_ptr =&gt; field
-      if (trim(field % dimNames(idim)) == 'nCells') then
-write(0,*) '... outer dimension is nCells'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToCellID % array(1:field_ptr % block % mesh % nCellsSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nCellsSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nEdges') then
-write(0,*) '... outer dimension is nEdges'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToEdgeID % array(1:field_ptr % block % mesh % nEdgesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nEdgesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else if (trim(field % dimNames(idim)) == 'nVertices') then
-write(0,*) '... outer dimension is nVertices'
-         allocate(indices(0))
-         do while (associated(field_ptr)) 
-            call mergeArrays(indices, field_ptr % block % mesh % indexToVertexID % array(1:field_ptr % block % mesh % nVerticesSolve))
-            totalDimSize = totalDimSize + field_ptr % block % mesh % nVerticesSolve
-            field_ptr =&gt; field_ptr % next
-         end do 
-         call mpas_dmpar_sum_int(field % block % domain % dminfo, totalDimSize, globalDimSize)
-         isDecomposed = .true.
-      else
-         isDecomposed = .false.
-         globalDimSize = field % dimSizes(idim)
-         totalDimSize = globalDimSize
+#include &quot;add_field_indices.inc&quot;
 
-         if (field % block % domain % dminfo % my_proc_id == IO_NODE) then
-            ndims = 1
-            allocate(indices(field % dimSizes(ndims)))
-            do i=1,field % dimSizes(ndims)
-               indices(i) = i 
-            end do
-         else
-            allocate(indices(0))
-         end if
-      end if
-!!!!!!!!!!!!!!!!!!!!!!! Is all of this constant, and could it be put in an include file? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
       
       call MPAS_streamAddField_generic(stream, trim(field % fieldName), MPAS_IO_DOUBLE, field % dimNames, field % dimSizes, &amp;
                                        field % hasTimeDimension, isDecomposed, totalDimSize, globalDimSize, indices, io_err)

</font>
</pre>