|
DOUG 0.2
|
00001 ! DOUG - Domain decomposition On Unstructured Grids 00002 ! Copyright (C) 1998-2006 Faculty of Computer Science, University of Tartu and 00003 ! Department of Mathematics, University of Bath 00004 ! 00005 ! This library is free software; you can redistribute it and/or 00006 ! modify it under the terms of the GNU Lesser General Public 00007 ! License as published by the Free Software Foundation; either 00008 ! version 2.1 of the License, or (at your option) any later version. 00009 ! 00010 ! This library is distributed in the hope that it will be useful, 00011 ! but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 ! Lesser General Public License for more details. 00014 ! 00015 ! You should have received a copy of the GNU Lesser General Public 00016 ! License along with this library; if not, write to the Free Software 00017 ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 ! or contact the authors (University of Tartu, Faculty of Computer Science, Chair 00019 ! of Distributed Systems, Liivi 2, 50409 Tartu, Estonia, http://dougdevel.org, 00020 ! mailto:info(at)dougdevel.org) 00021 00023 module Partitioning_metis_mod 00024 use Partitioning_mod 00025 use Distribution_base_mod 00026 use Graph_class 00027 use SpMtx_arrangement 00028 00029 implicit none 00030 00031 contains 00032 00033 ! Create partitions using . 00034 subroutine Partitionings_metis_InitCoarse(P,D,nparts) 00035 type(Partitionings),intent(inout) :: P !< output 00036 type(Distribution),intent(inout) :: D !< mesh and data distribution 00037 integer,intent(in) :: nparts !< number of coarse partitions 00038 00039 integer :: i,j 00040 integer, dimension(:), pointer :: xadj 00041 integer, dimension(:), pointer :: adjncy 00042 integer :: nedges 00043 type(Graph) :: G 00044 integer,dimension(:),allocatable :: cnodes 00045 integer, dimension(6) :: part_opts = (/0,0,0,0,0,0/) 00046 00047 ! build on top of fine partitions 00048 if (P%fAggr%full%nagr<=0) call DOUG_Abort("Generation of coarse partitions with METIS requires fine aggregates") 00049 00050 write(stream,"(A,I0,A)") " INFO: Splitting locally into ", nparts, " partitions using METIS" 00051 00052 P%cPart%nnodes = D%mesh%ninner 00053 P%cPart%nparts = nparts 00054 allocate(P%cPart%starts(nparts+1)) 00055 allocate(P%cPart%nodes(P%cPart%nnodes)) 00056 00057 call SpMtx_buildAggrAdjncy(D%A,P%fAggr,P%max_asize1,nedges,xadj,adjncy) 00058 G=Graph_newInit(P%fAggr%full%nagr,nedges,xadj,adjncy,D_GRAPH_NODAL) 00059 call Graph_Partition(G,nparts,D_PART_VKMETIS,part_opts) 00060 00061 allocate(cnodes(P%fAggr%full%nagr)) 00062 cnodes=0 00063 do i=1,P%cPart%nnodes ! find the #nodes for each partition 00064 j=G%part(P%fAggr%inner%num(i)) 00065 if (j>0) then 00066 cnodes(j)=cnodes(j)+1 00067 endif 00068 enddo 00069 ! find where each partition starts and initialize cnodes to follow fill in 00070 P%cPart%starts(1)=1 00071 do i=1,P%cPart%nparts 00072 P%cPart%starts(i+1) = P%cPart%starts(i)+cnodes(i) 00073 cnodes(i)=P%cPart%starts(i) ! shows the place to fill the nodes 00074 enddo 00075 ! fill partitions 00076 do i=1,P%cPart%nnodes ! put the node#-s in 00077 j=G%part(P%fAggr%inner%num(i)) 00078 if (j>0) then 00079 P%cPart%nodes(cnodes(j))=i 00080 cnodes(j)=cnodes(j)+1 00081 endif 00082 enddo 00083 00084 call Graph_Destroy(G) 00085 00086 end subroutine Partitionings_metis_InitCoarse 00087 end module Partitioning_metis_mod
1.7.3-20110217