梅蒂斯与 Fortran

发布于 2024-12-15 19:07:44 字数 846 浏览 6 评论 0原文

我正在使用 metis 5 和 Fortran。我正在使用 PartGraphRecursive 函数以及手册中给出的简单示例。给出的代码不是工作条件。

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。

PS 我正在使用带有 pgf90 Fortran 编译器的 Linux,并且我使用以下命令来编译和链接该文件。

Pgf90 –o main main.f90 libmetis.a

libmetis.a 文件与 main 位于同一目录中。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不可一世的女人 2024-12-22 19:07:44

Fortran 2003 模块 ISO_C_BINDING 定义了一个常量 C_NULL_PTR,其类型为 type(C_PTR)。您可以使用此模块定义子例程的接口。

它将是这样的,

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 ,但您必须为它们定义指针并使用函数 C_LOC

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文