Metis与Fortran [英] Metis with Fortran
问题描述
我在Fortran中使用metis 5.我将PartGraphRecursive
函数与手册中给出的简单示例一起使用.给出的代码不是工作条件.
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
任何人都可以完成此代码吗?我不太清楚如何在METIS_PartGraphRecursive
调用中使用不同的输入,因为我要使用的大多数输入都是NULL.
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.我正在使用Linux和pgf90
Fortran编译器,并且正在使用以下命令来编译和链接文件.
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
libmetis.a文件与main在同一目录中.
The libmetis.a file is in the same directory as main.
推荐答案
Fortran 2003模块 ISO_C_BINDING 定义类型C(P_PTR)的常量C_NULL_PTR.您可以使用此模块定义子程序的接口.
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.
那将是
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
您可以对所有参数使用type(c_ptr),value,但是必须为它们定义指针并使用功能
You could use type(c_ptr),value for all parameters, but you would have to define pointers for them and use function C_LOC
这篇关于Metis与Fortran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!