Zoltan is added as thirdParty package

This commit is contained in:
Hamidreza
2025-05-15 21:58:43 +03:30
parent 83a6e4baa1
commit d7479cf1bd
3392 changed files with 318142 additions and 1 deletions

View File

@ -0,0 +1,13 @@
TRIBITS_ADD_EXECUTABLE_AND_TEST(
simpleRCB_f90
SOURCES simpleRCB.f90 zoltanRCBmod.f90 mpi_h.f
ARGS
COMM mpi
NUM_MPI_PROCS 1-4
)
TRIBITS_COPY_FILES_TO_BINARY_DIR(FortranExamplesCopyFiles
SOURCE_FILES mesh.txt
)

View File

@ -0,0 +1,31 @@
##
## a basic makefile to build examples
##
BLD=../../Obj_autotools/
ZOLTAN_INCLUDE=-I. -I$(BLD)/src
FC=mpif90
FCFLAGS =$(ID_TYPE_FLAG)
EXAMPLE_NAMES= simpleRCB
all: $(EXAMPLE_NAMES)
mpi_h.mod:
$(FC) $(FCFLAGS) -c mpi_h.f
zoltanRCBex.mod: mpi_h.mod
$(FC) $(FCFLAGS) \
$(TPL_INCLUDE) $(ZOLTAN_INCLUDE) \
-c zoltanRCBmod.f90
simpleRCB: mpi_h.mod zoltanRCBex.mod
$(FC) $(FCFLAGS) $(TPL_LIB_DIR) \
$(TPL_INCLUDE) $(ZOLTAN_INCLUDE) \
-o $@ simpleRCB.f90 zoltanRCBmod.o mpi_h.o $(BLD)/src/libzoltan.a $(TPL_LIBS) -lm
clean:
@rm -rf $(EXAMPLE_NAMES) *.mod

View File

@ -0,0 +1,37 @@
36
1 0 0
2 0 1
3 0 2
4 0 3
5 0 4
6 0 5
7 1 0
8 1 1
9 1 2
10 1 3
11 1 4
12 1 5
13 2 0
14 2 1
15 2 2
16 2 3
17 2 4
18 2 5
19 3 0
20 3 1
21 3 2
22 3 3
23 3 4
24 3 5
25 4 0
26 4 1
27 4 2
28 4 3
29 4 4
30 4 5
31 5 0
32 5 1
33 5 2
34 5 3
35 5 4
36 5 5

View File

@ -0,0 +1,59 @@
!!
!! @HEADER
!!
!!!!**********************************************************************
!!
!! Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring
!! Copyright 2012 Sandia Corporation
!!
!! Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
!! the U.S. Government retains certain rights in this software.
!!
!! Redistribution and use in source and binary forms, with or without
!! modification, are permitted provided that the following conditions are
!! met:
!!
!! 1. Redistributions of source code must retain the above copyright
!! notice, this list of conditions and the following disclaimer.
!!
!! 2. Redistributions in binary form must reproduce the above copyright
!! notice, this list of conditions and the following disclaimer in the
!! documentation and/or other materials provided with the distribution.
!!
!! 3. Neither the name of the Corporation nor the names of the
!! contributors may be used to endorse or promote products derived from
!! this software without specific prior written permission.
!!
!! THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
!! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
!! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
!! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
!! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
!! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
!! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
!! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
!! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!!
!! Questions? Contact Karen Devine kddevin@sandia.gov
!! Erik Boman egboman@sandia.gov
!!
!!!!**********************************************************************
!!
!! @HEADER
!!
!--------------------------------------------------------------------------
! Purpose: Provide the MPI include file as a module.
!--------------------------------------------------------------------------
! Author(s): William F. Mitchell
!--------------------------------------------------------------------------
!--------------------------------------------------------------------------
! Revision History:
! 2 September 1999: Date of creation.
!--------------------------------------------------------------------------
module mpi_h
include "mpif.h"
end module mpi_h

View File

@ -0,0 +1,271 @@
!!
!! @HEADER
!!
!!!!**********************************************************************
!!
!! Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring
!! Copyright 2012 Sandia Corporation
!!
!! Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
!! the U.S. Government retains certain rights in this software.
!!
!! Redistribution and use in source and binary forms, with or without
!! modification, are permitted provided that the following conditions are
!! met:
!!
!! 1. Redistributions of source code must retain the above copyright
!! notice, this list of conditions and the following disclaimer.
!!
!! 2. Redistributions in binary form must reproduce the above copyright
!! notice, this list of conditions and the following disclaimer in the
!! documentation and/or other materials provided with the distribution.
!!
!! 3. Neither the name of the Corporation nor the names of the
!! contributors may be used to endorse or promote products derived from
!! this software without specific prior written permission.
!!
!! THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
!! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
!! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
!! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
!! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
!! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
!! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
!! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
!! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!!
!! Questions? Contact Karen Devine kddevin@sandia.gov
!! Erik Boman egboman@sandia.gov
!!
!!!!**********************************************************************
!!
!! @HEADER
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! //
!! File: driver.cc //
!! Project: Local HSFC Ordering //
!! Author: Michael Wolf //
!! Date Started: 11/02/2009 //
!! //
!! Description: //
!! File tests local HSFC ordering for simple test problem //
!! //
!! $Id: driver.cc 11 2009-11-10 00:15:18Z mmwolf $ //
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
program exampleRCB
use mpi_h
use zoltan
use zoltanRCBex
implicit none
integer(Zoltan_INT) :: error
real(Zoltan_FLOAT) :: version
!!! numGlobObjs, numLocObjs, GIDs, xcoords, ycoords defined in zoltanRCBex module
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
interface
subroutine readInputObjects(fname,numGlobObjs,numLocObjs,GIDs,xs,ys)
character (len=*) :: fname
integer :: numGlobObjs, numLocObjs
integer, allocatable :: GIDs(:)
real, allocatable :: xs(:), ys(:)
end subroutine readInputObjects
end interface
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Body of program
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call MPI_Init(error)
error = Zoltan_Initialize(version)
call readInputObjects("mesh.txt",numGlobObjs,numLocObjs,GIDs,xcoords,ycoords)
call partitionMeshWithRCB()
call visualizePartition()
deallocate(GIDs)
deallocate(xcoords,ycoords)
!! function in zoltanRCBex module that cleans up Zoltan data structures
call zoltanCleanUp()
call MPI_Finalize(error)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end program exampleRCB
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine readInputObjects(fname, numGlobObjs, numLocObjs,GIDs,xcoords,ycoords)
use mpi_h
implicit none
character (len=*) :: fname
integer :: numGlobObjs, numLocObjs
integer, allocatable :: GIDs(:)
real, allocatable :: xcoords(:), ycoords(:)
! Local declarations
integer :: fnum = 2, i, currIndx
integer :: myRank, numProcs, mpi_ierr
integer :: tmpGID
real :: tmpX, tmpY
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call MPI_Comm_rank(MPI_COMM_WORLD, myrank, mpi_ierr)
call MPI_Comm_size(MPI_COMM_WORLD, numProcs, mpi_ierr)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Scan data to determine # local objects
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
open(unit = fnum, file = fname)
read(fnum,*) numGlobObjs
numLocObjs=0
do i = 1, numGlobObjs, 1
read(fnum,*) tmpGID, tmpX, tmpY
!! assumes gids start at 1, gives round robin initial distribution
if ( MOD(tmpGID-1,numProcs) == myRank) then
numLocObjs = numLocObjs + 1
end if
end do
close(fnum)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Allocate data for my part of mesh
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
allocate(GIDs(numLocObjs))
allocate(xcoords(numLocObjs))
allocate(ycoords(numLocObjs))
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Fill data for my part of mesh
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
open(unit = fnum, file = fname)
read(fnum,*) numGlobObjs
currIndx = 1
do i = 1, numGlobObjs, 1
read(fnum,*) tmpGID, tmpX, tmpY
!! assumes gids start at 1, gives round robin initial distribution
if ( MOD(tmpGID-1,numProcs) == myRank) then
GIDs(currIndx) = tmpGID
xcoords(currIndx) = tmpX
ycoords(currIndx) = tmpY
currIndx = currIndx + 1
end if
end do
close(fnum)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine readInputObjects
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Works for this specific 6x6 mesh
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine showSimpleMeshPartitions(myProc, numIDs, GIDs, parts)
use mpi_h
implicit none
integer :: myProc, numIDs
integer :: GIDs(*), parts(*)
!! Local variables
integer :: partAssign(36)
integer :: allPartAssign(36)
integer :: i, j, part, mpi_ierr
integer :: partRow(6)
data partAssign/ 36 * 0/
do i = 1, numIDs, 1
partAssign(GIDs(i)) = parts(i);
end do
call MPI_Reduce(partAssign, allPartAssign, 36, MPI_INTEGER, MPI_MAX, 0, MPI_COMM_WORLD, mpi_ierr);
if (myProc == 0) then
do i=30, 0, -6
do j = 1, 6, 1
partRow(j) = allPartAssign(i+j);
end do
write(*,'(I1,A,I1,A,I1,A,I1,A,I1,A,I1)') partRow(1), '-----', partRow(2), '-----', partRow(3), '-----', &
partRow(4), '-----', partRow(5), '-----', partRow(6)
if (i > 0) then
write(*,'(A)') '| | | | | |'
end if
end do
write(*,*)
end if
end subroutine showSimpleMeshPartitions
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine visualizePartition()
use mpi_h
use zoltanRCBex
implicit none
!! Variables defined in zoltanRCBex module:
!! numLocObjs, GIDs, numExport, exportLocalGids, exportToPart
!! local variables
integer :: parts(numLocObjs)
integer :: myrank, i, error
call MPI_Comm_rank(MPI_COMM_WORLD, myrank, error)
do i=1, numLocObjs, 1
parts(i) = myRank;
end do
if (myRank== 0) then
write (*,*) 'Mesh part assignments before calling Zoltan'
end if
call showSimpleMeshPartitions(myRank, numLocObjs, GIDs, parts);
do i=1, numExport, 1
parts(exportLocalGids(i)) = exportToPart(i)
end do
if (myRank == 0) then
write (*,*) 'Mesh part assignments after calling Zoltan'
end if
call showSimpleMeshPartitions(myRank, numLocObjs, GIDs, parts)
end subroutine visualizePartition
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -0,0 +1,262 @@
!!
!! @HEADER
!!
!!!!**********************************************************************
!!
!! Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring
!! Copyright 2012 Sandia Corporation
!!
!! Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
!! the U.S. Government retains certain rights in this software.
!!
!! Redistribution and use in source and binary forms, with or without
!! modification, are permitted provided that the following conditions are
!! met:
!!
!! 1. Redistributions of source code must retain the above copyright
!! notice, this list of conditions and the following disclaimer.
!!
!! 2. Redistributions in binary form must reproduce the above copyright
!! notice, this list of conditions and the following disclaimer in the
!! documentation and/or other materials provided with the distribution.
!!
!! 3. Neither the name of the Corporation nor the names of the
!! contributors may be used to endorse or promote products derived from
!! this software without specific prior written permission.
!!
!! THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
!! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
!! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
!! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
!! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
!! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
!! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
!! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
!! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!!
!! Questions? Contact Karen Devine kddevin@sandia.gov
!! Erik Boman egboman@sandia.gov
!!
!!!!**********************************************************************
!!
!! @HEADER
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! //
!! File: driver.cc //
!! Project: Local HSFC Ordering //
!! Author: Michael Wolf //
!! Date Started: 11/02/2009 //
!! //
!! Description: //
!! File tests local HSFC ordering for simple test problem //
!! //
!! $Id: driver.cc 11 2009-11-10 00:15:18Z mmwolf $ //
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module zoltanRCBex
use mpi_h
use zoltan
implicit none
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Mesh data for RCB
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
integer :: numGlobObjs, numLocObjs
integer(ZOLTAN_INT), dimension(:), allocatable :: GIDs
real, dimension(:), allocatable :: xcoords, ycoords
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Zoltan data to store in module
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
LOGICAL :: changes
INTEGER(Zoltan_INT) :: numGidEntries, numLidEntries
INTEGER(Zoltan_INT) :: numImport, numExport
INTEGER(Zoltan_INT), POINTER, DIMENSION(:) :: importGlobalGids, exportGlobalGids
INTEGER(Zoltan_INT), POINTER, DIMENSION(:) :: importLocalGids, exportLocalGids
INTEGER(Zoltan_INT), POINTER, DIMENSION(:) :: importProcs, exportProcs
INTEGER(Zoltan_INT), POINTER, DIMENSION(:) :: importToPart, exportToPart
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine partitionMeshWithRCB()
use zoltan
use mpi_h
implicit none
!!!!!!!!!!!!!!!!!!!!!!!
!! local variables
!!!!!!!!!!!!!!!!!!!!!!!
type(Zoltan_Struct), pointer :: zz_obj
integer(ZOLTAN_INT) :: ierr
!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Body of subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nullify(zz_obj)
zz_obj => Zoltan_Create(MPI_COMM_WORLD)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! General Zoltan Parameters
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ierr = Zoltan_Set_Param(zz_obj, "LB_METHOD", "RCB")
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! register query functions
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_OBJ_FN_TYPE,zoltNumObjs)
ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_OBJ_LIST_FN_TYPE,zoltGetObjs)
ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_NUM_GEOM_FN_TYPE,zoltNumGeom)
ierr = Zoltan_Set_Fn(zz_obj, ZOLTAN_GEOM_FN_TYPE, zoltGeom)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Use Zoltan to partition the vertices in the simple mesh.
!!
!! Params:
!! zz_obj -- input (all remaining fields are output)
!! changes -- 1 if partition was changed, 0 otherwise
!! numGidEntries -- Number of integers used for a global ID
!! numLidEntries -- Number of integers used for a local ID
!! numImport -- Number of vertices to be sent to me
!! importGlobalGids -- Global IDs of vertices to be sent to me
!! importLocalGids -- Local IDs of vertices to be sent to me
!! importProcs -- Process rank for source of each incoming vertex
!! importToPart -- New part for each incoming vertex
!! numExport -- Number of vertices I must send to other processes
!! exportGlobalGids -- Global IDs of the vertices I must send
!! exportLocalGids -- Local IDs of the vertices I must send
!! exportProcs -- Process to which I send each of the vertices
!! exportToPart -- Part to which each vertex will belong
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ierr = Zoltan_LB_Partition(zz_obj, changes, numGidEntries, numLidEntries, &
numImport, importGlobalGids, importLocalGids, importProcs, importToPart, &
numExport, exportGlobalGids, exportLocalGids, exportProcs, exportToPart)
call Zoltan_Destroy(zz_obj)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine partitionMeshWithRCB
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Frees arrays allocated by Zoltan_LB_Partition
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine zoltanCleanup()
use zoltan
implicit none
integer :: error
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
error = Zoltan_LB_Free_Part(importGlobalGids, importLocalGids, importProcs, importToPart)
error = Zoltan_LB_Free_Part(exportGlobalGids, exportLocalGids, exportProcs, exportToPart)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine zoltanCleanup
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! User defined query function to register with Zoltan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
integer function zoltNumObjs(data, ierr)
use zoltan
implicit none
! Local declarations
INTEGER(Zoltan_INT), intent(in) :: data(*)
integer(ZOLTAN_INT), intent(out) :: ierr
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
zoltNumObjs = numLocObjs
ierr = ZOLTAN_OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end function zoltNumObjs
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! User defined query function to register with Zoltan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine zoltGetObjs (data, num_gid_entries, num_lid_entries, global_ids, &
local_ids, wgt_dim, obj_wgts, ierr)
use zoltan
implicit none
integer(ZOLTAN_INT), intent(in) :: data(*)
integer(ZOLTAN_INT), intent(in) :: num_gid_entries
integer(ZOLTAN_INT), intent(in) :: num_lid_entries
integer(ZOLTAN_INT), intent(out) :: global_ids(*)
integer(ZOLTAN_INT), intent(out) :: local_ids(*)
integer(ZOLTAN_INT), intent(in) :: wgt_dim
real(ZOLTAN_FLOAT), intent(out) :: obj_wgts(*)
integer(ZOLTAN_INT), intent(out) :: ierr
! local declarations
integer :: i
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do i= 1, numLocObjs
global_ids(i) = GIDs(i)
local_ids(i) = i
end do
ierr = ZOLTAN_OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! User defined query function to register with Zoltan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
integer function zoltNumGeom(data, ierr)
use zoltan
implicit none
integer(ZOLTAN_INT), intent(in) :: data(*)
integer(ZOLTAN_INT) :: ierr
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
zoltNumGeom = 2
ierr = ZOLTAN_OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end function zoltNumGeom
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! User defined query function to register with Zoltan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine zoltGeom(data, num_gid_entries, num_lid_entries, global_id, &
local_id, geom_vec, ierr)
use zoltan
implicit none
integer(ZOLTAN_INT), intent(in) :: data(*)
integer(ZOLTAN_INT), intent(in) :: num_gid_entries
integer(ZOLTAN_INT), intent(in) :: num_lid_entries
integer(ZOLTAN_INT), intent(in) :: global_id
integer(ZOLTAN_INT), intent(in) :: local_id
real(ZOLTAN_DOUBLE), intent(out) :: geom_vec(*)
integer(ZOLTAN_INT), intent(out) :: ierr
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
geom_vec(1) = xcoords(local_id)
geom_vec(2) = ycoords(local_id)
ierr = ZOLTAN_OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end subroutine zoltGeom
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end module zoltanRCBex