自Fortran语言运行时METIS赛格故障 [英] METIS seg faults when run from Fortran

查看:317
本文介绍了自Fortran语言运行时METIS赛格故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 METIS 库网格划分的一部分Fortran程序中的我为有限元计算写入。 METIS用C语言编写,但它应该工作得很好用的Fortran 90,但我不断收到赛格故障。

I'm trying to use the METIS library for mesh partitioning as part of a Fortran program I've written for finite element computations. METIS is written in C but it's supposed to work just fine with Fortran 90. But I keep getting seg faults.

一个潜在的打嗝是,有一些争论,而我现在给空指针。其他一些人有麻烦,从FORTRAN获得调用C函数来识别一个空指针的对象。这是这里解决,我不认为这是我遇到的问题

One potential hiccup is that there are a few arguments to which I'm giving null pointers. Some other folks have had trouble getting a call to a C function from fortran to recognize a null pointer object. That was addressed here and I don't think that's the issue I'm having.

我觉得问题越来越METIS改变开始的数组索引;用C是0,Fortran中是1.有一个选项传递给每一个这是应该有一个字段 METIS_OPTION_NUMBERING 如果您希望的Fortran约定更改为 1 。那么如果不这样做将导致C程序,尝试访问索引0,给你的赛格故障。

I think the problem is getting METIS to change the starting array index; in C it's 0, in Fortran it's 1. There's an options array passed to every function which is supposed to have a field METIS_OPTION_NUMBERING that you change to 1 if you want the Fortran convention. Failure to do so would then cause the C programs to try and access index 0, giving you the seg fault.

由edunlop1的此处表明,我只是做一个数组选项和一些商定与METIS惯例判断该数组元素应该是设置为1它一切都很重新编号。但是,这是根据变化对哪个例程你使用一样,数组的长度。

The post by edunlop1 here suggests that I just make an array options and some agreed-upon convention with METIS determines which element of that array is supposed to be set to 1 for it to renumber everythin. But what that is changes depending on which routine you're using, as does the array length.

总之,这里是我的code:

Anyhow, here's my code:

integer :: ndomains,ncommon,objval
integer :: options(0:40)
integer, dimension(:), allocatable :: eptr,eind
integer, pointer :: vwgt(:)=>null(), vsize(:)=>null(), opts(:)=>null()
real(kind=8), pointer :: tpwgts(:)=>null()

! Read in the mesh data
call getarg(1,meshname)
call readmesh(meshname)
allocate(color(ne),domain(nn))
allocate(eind(3*ne),eptr(ne+1))
do n=1,ne
    eptr(n) = 1+3*(n-1)
    do i=1,3
        eind( eptr(n)+i-1 ) = elem(i,n)
    enddo
enddo

! Try and call METIS
ncommon = 2
ndomains = 2
options = 0
options(0) = 1
options(8) = 1
call METIS_PartMeshDual(ne,nn,eptr,eind,vwgt,vsize, &
    & ncommon,ndomains,tpwgts,options,objval,color,domain)

在METIS相关code更改的编号是在文件libmetis / meshpart.c:

The relevant code in METIS for changing the numbering is in the file libmetis/meshpart.c :

/* renumber the mesh */
if (options && options[METIS_OPTION_NUMBERING] == 1) {
  ChangeMesh2CNumbering(*ne, eptr, eind);
  renumber = 1;
}

有什么想法?我可以张贴Valgrind的输出,如果这是有帮助的。

Any thoughts? I can post Valgrind output if that's helpful.

推荐答案

使用:

vwgt=>null() 

而不是

vwgt(:)=>null()

对于所有空(即vwgt,VSIZE,选择采用,tpwgts等)。问题是,vwgt(:)心不是真正定义,而不是仅仅vwgt或vwgt(1)。如果你还有问题,那么使用调试器来检查所有值。

for all nulls (i.e., vwgt, vsize, opts, tpwgts etc.). The problem is that vwgt(:) isnt really defined as opposed to just vwgt or vwgt(1). If you still have problems then use a debugger to check all values.

我是在第2段中提到的线程OP。最终溶液是不幸的答复(见时间戳)的顶部。希望有所帮助。

I was the OP in the thread mentioned in the 2nd para. The final solution is unfortunately at the top of the replies (see the time stamp). Hope that helps.

这篇关于自Fortran语言运行时METIS赛格故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆