0

I am using metis 5 with Fortran. I am using the PartGraphRecursive function with the simple example given in the manual. The code is given as which is not the working condition.

program main    
implicit none     
integer,parameter::nvtxs=15, Edges=22

integer::xadj(nvtxs+1),adjncy(2*Edges)    
integer::objval, part(nvtxs)

xadj=[0, 2, 5, 8, 11, 13, 16, 20, 24, 28, 31, 33, 36, 39, 42, 44]    
adjncy=[1, 5, 0, 2, 6, 1, 3, 7, 2, 4, 8, 3, 9, 0, 6, 10, 1, 5, 7, 11, 2, 6, 8, 12, 3, 7, 9, 13, 4, 8, 14, 5, 11, 6, 10, 12, 7, 11, 13, 8, 12, 14, 9, 13]

call METIS_PartGraphRecursive(vortices,1,xadj,adjncy,,,,2,,,,objval,part)

end program main

Can anybody complete this code? I am not very clear how to use the different inputs to the METIS_PartGraphRecursive call as most of the input I want to use is NULL.

P.S. I am using Linux with the pgf90 Fortran compiler and I am using the following command to compile and link the file.

Pgf90 –o main main.f90 libmetis.a

The libmetis.a file is in the same directory as main.

4

1 に答える 1

3

Fortran 2003 module ISO_C_BINDING defines a constant C_NULL_PTR which is of type type(C_PTR). You can define an interface to the subroutine using this module.

It would be something as

interface

 subroutine METIS_PartGraphRecursive(n,xadj,adjncy,vwght,adjwgt,wgtflag,numflag,nparts,options,edgecut,part) bind(C)

   use iso_c_binding

   integer(c_int) :: !here the parameters you pass as integers
   type(c_ptr),value :: !here the parameters you want to pass c_null_ptr to
 end subroutine

endinterface

You could use type(c_ptr),value for all parameters, but you would have to define pointers for them and use function C_LOC

于 2011-11-16T19:03:50.413 に答える