<p><b>duda</b> 2009-08-10 12:30:46 -0600 (Mon, 10 Aug 2009)</p><p>Two bug fixes:<br>
<br>
1) In the quicksort routine, return immediately if the array to be sorted <br>
   has 0 size, since the main loop doesn't correctly handle 0-sized arrays.<br>
<br>
2) In dmpar_get_owner_list, don't assume that Fortran will tolerate <br>
   assignments between two 0-sized arrays (ending index &lt; starting index).<br>
<br>
M    module_sort.F<br>
M    module_dmpar.F<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/swmodel/module_dmpar.F
===================================================================
--- trunk/swmodel/module_dmpar.F        2009-08-10 15:17:03 UTC (rev 18)
+++ trunk/swmodel/module_dmpar.F        2009-08-10 18:30:46 UTC (rev 19)
@@ -760,8 +760,13 @@
                kk = min(BUFSIZE, nNeededList - bufStart + 1)
                kk = max(kk, 0)
 
-               buffer(1:kk) = neededList(bufStart:needEnd)
-               buffer(kk+1:BUFSIZE) = -1
+               if (kk == 0) then
+                  buffer(1:BUFSIZE) = -1
+               else
+                  buffer(1:kk) = neededList(bufStart:needEnd)
+                  buffer(kk+1:BUFSIZE) = -1
+               end if
+
                call MPI_Bcast(buffer, BUFSIZE, MPI_INTEGER, i, dminfo % comm, mpi_ierr)
    
                ! OPTIMIZATION: Maybe needToRecv could be set based on a running total of how many we have

Modified: trunk/swmodel/module_sort.F
===================================================================
--- trunk/swmodel/module_sort.F        2009-08-10 15:17:03 UTC (rev 18)
+++ trunk/swmodel/module_sort.F        2009-08-10 18:30:46 UTC (rev 19)
@@ -79,6 +79,8 @@
       integer, dimension(2) :: temp
       integer, dimension(1000) :: lstack, rstack
 
+      if (nArray &lt; 1) return
+
       top = 1
       lstack(top) = 1
       rstack(top) = nArray

</font>
</pre>