<p><b>duda</b> 2010-07-23 11:58:22 -0600 (Fri, 23 Jul 2010)</p><p>Add code to the registry to initialize all fields in the grid/mesh data<br>
structure to zero after allocating them. This initialization is needed<br>
especially for the &quot;garbage cell&quot; allocated at nCells+1 (or nEdges+1,<br>
nVertices+1), which, if not initialized, can lead to segmentation faults as<br>
in the following example, where either cell1 or cell2 may equal nCells+1<br>
when iEdge is at the boundary of a block, and the nCells+1 element of<br>
nEdgesOnCell could take on any value:<br>
<br>
   do iEdge=1,nEdges<br>
      cell1 = cellsOnEdge(1,iEdge)<br>
      cell2 = cellsOnEdge(2,iEdge)<br>
<br>
      do k=1,grid % nVertLevels<br>
<br>
         d2fdx2_cell1 = deriv_two(1,1,iEdge) * theta(k,cell1)<br>
         d2fdx2_cell2 = deriv_two(1,2,iEdge) * theta(k,cell2)<br>
         do i=1, grid % nEdgesOnCell % array (cell1)<br>
            d2fdx2_cell1 = d2fdx2_cell1 + deriv_two(i+1,1,iEdge) * theta(k,grid % CellsOnCell % array (i,cell1))<br>
         end do<br>
<br>
         ...<br>
<br>
      end do<br>
   end do<br>
<br>
Thanks to Jeff Painter at LLNL for providing this fix.<br>
<br>
M    src/registry/gen_inc.c<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/mpas/src/registry/gen_inc.c
===================================================================
--- trunk/mpas/src/registry/gen_inc.c        2010-07-21 19:51:00 UTC (rev 389)
+++ trunk/mpas/src/registry/gen_inc.c        2010-07-23 17:58:22 UTC (rev 390)
@@ -421,6 +421,7 @@
                dimlist_ptr = dimlist_ptr-&gt;next;
             }
             fortprintf(fd, &quot;))</font>
<font color="blue">&quot;);
+            fortprintf(fd, &quot;      g %% %s %% array = 0</font>
<font color="black">&quot;, var_ptr2-&gt;super_array ); /* initialize field to zero */
 
             if (var_ptr2-&gt;iostreams &amp; INPUT0) 
                fortprintf(fd, &quot;      g %% %s %% ioinfo %% input = .true.</font>
<font color="gray">&quot;, var_ptr2-&gt;super_array);
@@ -463,7 +464,8 @@
                   dimlist_ptr = dimlist_ptr-&gt;next;
                }
                fortprintf(fd, &quot;))</font>
<font color="red">&quot;);
-   
+               fortprintf(fd, &quot;      g %% %s %% array = 0</font>
<font color="blue">&quot;, var_ptr-&gt;name_in_code ); /* initialize field to zero */
+
             }
             if (var_ptr-&gt;iostreams &amp; INPUT0) 
                fortprintf(fd, &quot;      g %% %s %% ioinfo %% input = .true.</font>
<font color="black">&quot;, var_ptr-&gt;name_in_code);

</font>
</pre>