I'm trying to partition a mesh using METIS through Fortran, I built the lib file using Visual Studio 10.0 X64 on an X64 Windows 7 system, my program is as the following:
module metis_vars
use iso_c_binding
! Variables
integer :: ia, ic
integer(kind=c_int) :: ne, nn
integer(kind=c_int) :: ncommon, objval
integer(kind=c_int) :: nparts
integer(kind=c_int), allocatable, dimension(:) :: eptr, eind
integer(kind=c_int), allocatable, dimension(:) :: epart, npart
type(c_ptr) :: vwgt, vsize, tpwgts
integer :: opts(0:40)
interface
subroutine METIS_PartMeshDual(ne,nn,eptr,eind,vwgt,vsize,ncommon,nparts,tpwgts,opts,objval,epart,npart) bind(C, name="METIS_PartMeshDual")
! use binding module
use iso_c_binding
! declare variables with C++ types semantics
integer(kind=c_int) :: ne, nn, ncommon, objval
integer(kind=c_int), dimension(*) :: eptr, eind
integer(kind=c_int), dimension(*) :: epart, npart
type(c_ptr), value :: vwgt, vsize, tpwgts
integer(kind=c_int) :: opts(0:40)
end subroutine METIS_PartMeshDual
end interface
end module
program METIS_PART_1
use iso_c_binding
use metis_vars
implicit none
open(unit=1, file='metis_test.mesh')
read(1,*), ne
nn = ne * 8
allocate( eptr(ne), eind(8*ne) )
allocate( epart(ne), npart(nn) )
do ic=1,ne
ia = (ic-1) * 8 + 1
read(1,*), eind(ia:ia+7)
eptr(ic) = ia
enddo
nparts = 4
ncommon = 2
vwgt = c_null_ptr
vsize = c_null_ptr
tpwgts = c_null_ptr
opts(0) = 1
opts(7) = 1
call METIS_PartMeshDual(ne,nn,eptr,eind,vwgt,vsize,ncommon,nparts,tpwgts,opts,objval,epart,npart)
end program METIS_PART_1
I revised all the input arrays and they're correct (I already partitioned this mesh using the EXE's successfully), however, when I use the API, I get the following error:
Current memory used: zu bytes Maximum memory used: zu bytes ***Memory allocation failed for CreateGraphDual: nind. Requested size: zu bytes
I have no clue what's wrong or how to debug it