Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parallel processing Metis与Fortran_Parallel Processing_Fortran_Task Parallel Library_Mpi_Fortran Iso C Binding - Fatal编程技术网

Parallel processing Metis与Fortran

Parallel processing Metis与Fortran,parallel-processing,fortran,task-parallel-library,mpi,fortran-iso-c-binding,Parallel Processing,Fortran,Task Parallel Library,Mpi,Fortran Iso C Binding,我正在使用metis 5和Fortran。我使用的是partgraphrescursive函数和手册中给出的简单示例。给出的代码不是工作条件 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, 2

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

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\u partgraphrescursive
,因为我想使用的大多数输入都是空的

另外,我正在使用Linux和
pgf90
Fortran编译器,并使用以下命令编译和链接文件

Pgf90 –o main main.f90 libmetis.a
libmetis.a文件与main位于同一目录中。

Fortran 2003模块定义了一个常量C_NULL_PTR,其类型为(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,但您必须为它们定义指针,并使用function

Fortran 2003模块定义一个常量c_NULL_ptr,它的类型为(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,但您必须为它们定义指针并使用function

@Vladimir F非常感谢,它确实非常有用,现在示例代码给出了一些合理的输出。如果有人需要此代码,请发送电子邮件至zahoorswati@hotmail.com.@Vladimir F非常感谢,它真的非常有用,现在示例代码给出了一些合理的输出。如果有人需要此代码,请发送电子邮件至zahoorswati@hotmail.com.