[petsc-users] METIS 5 in PETSc 3, 3 [not directly related to PETSc]

Sanjay Govindjee s_g at berkeley.edu
Fri Jun 8 10:30:18 CDT 2012


I tried to make Metis 5 work with fortran for quite some time but was 
not able to make
it work; in the end there were some things that I could not make work so 
I ended up with
a C function which I call out of fortran; the C function is attached -- 
calling it is straightforward just pass in the indicated integers and 
arrays.  [I went this route, because in the end I think I figured out 
that the Fortran interface in Metis 5 was missing some feature to allow 
it work properly -- the details escape me at the moment since I did this 
about 1 month back.]

-sanjay

On 6/8/12 8:35 AM, Tabrez Ali wrote:
> Here it is for the 3 compilers.
>
> GNU FC http://bpaste.net/show/31029/
>
> Intel FC http://bpaste.net/show/QJ6k5jc52t7MGUlvrlEV/
>
> PGI FC http://bpaste.net/show/DZzY6Re5iXMgLSHydOgJ/
>
>
> On 06/08/2012 09:15 AM, John Mousel wrote:
>> Attaching the Valgrind output would probably help a lot.
>>
>> On Fri, Jun 8, 2012 at 9:02 AM, Tabrez Ali <stali at geology.wisc.edu 
>> <mailto:stali at geology.wisc.edu>> wrote:
>>
>>     Thanks for your answer. Unfortunately its not that.
>>
>>     Based on past experience I am sure I am overlooking something
>>     very simple but I cant seem to find out what. Btw METIS 4 worked
>>     fine before.
>>
>>     On 06/08/2012 08:39 AM, John Mousel wrote:
>>>     It's hard to tell from the info you provided, but you seem to be
>>>     playing fast and loose with your type declarations. METIS is
>>>     expecting real_t, which is a 32 bit real if you haven't changed
>>>     the definition in metis.h. I know this has caused me problems in
>>>     the past.
>>>
>>>     On Fri, Jun 8, 2012 at 7:38 AM, Tabrez Ali
>>>     <stali at geology.wisc.edu <mailto:stali at geology.wisc.edu>> wrote:
>>>
>>>         Sorry about a question not directly related to PETSc but has
>>>         anyone here been able to use the METIS 5.0 (that PETSc
>>>         3.3/dev downloads/builds) with Fortran? There has been an
>>>         API change from 4 to 5 but I am having some trouble and
>>>         METIS manual/forums havent been useful.
>>>
>>>         For example consider the simple code (below) that partitions
>>>         a two element mesh made of linear quads into two. The
>>>         elements are numbered 0 1 2 3 and 1 4 5 2.It works fine with
>>>         GNU FC (no valgrind errors). With Intel FC it works fines
>>>         (though valgrind throws a bunch of errors). However with PGI
>>>         compilers I get a segfault.
>>>
>>>          program test
>>>          implicit none
>>>          integer, parameter   :: nels=2, nnds=6, npel=4
>>>          integer              :: eptr(nels+1), nodes(nels*npel),
>>>         epart(nels), npart(nnds), n
>>>          integer, pointer     :: vwgt(:)=>null(), vsize(:)=>null(),
>>>         mopts(:)=>null()
>>>          real(8), pointer     :: tpwgts(:)=>null()
>>>          eptr=(/0,4,7/)
>>>          nodes=(/0,1,2,3,1,4,5,2/)
>>>          call
>>>         METIS_PartMeshNodal(nels,nnds,eptr,nodes,vwgt,vsize,2,tpwgts,mopts,n,epart,npart)
>>>          print*, npart; print*, epart
>>>         end program test
>>>
>>>         According to the manual moving from METIS 4 to 5 only
>>>         involves passing some additional nulls. I am not sure what I
>>>         missed.
>>>
>>>         http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/manual.pdf
>>>
>>>         Thanks in advance.
>>>
>>>         Tabrez
>>>
>>
>>     -- 
>>     No one trusts a model except the one who wrote it; Everyone trusts an observation except the one who made it- Harlow Shapley
>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120608/42659f79/attachment-0001.html>
-------------- next part --------------
/*
c      * * F E A P * * A Finite Element Analysis Program

c....  Copyright (c) 1984-2012: Regents of the University of California
c                               All rights reserved

c-----[--.----+----.----+----.-----------------------------------------]
c     Modification log                                Date (dd/mm/year)
c       Original version                                    06/05/2012
c-----[--.----+----.----+----.-----------------------------------------]
c     Purpose:  C cover function to partition mesh using METIS ver 5.x

c     Inputs:
c        numnp   -- number of nodes
c        xadj    -- pointers into adjaceny matrix
c        adjncy  -- adjaceny matrix for node graph
c        domains -- number of domains to partition graph into

c     Outputs:
c        part    -- partitioned graph
c-----[--.----+----.----+----.-----------------------------------------]
*/

#include <stdio.h>
#include "metis.h"

int smetis_(int *numnp,int *xadj,int *adjncy,int *domains, int *part) {

	int rval;
 	int ncon = 1;
        int edgecut = 0;
        int options[METIS_NOPTIONS];
        
        // Default options 
        METIS_SetDefaultOptions(options);

        options[METIS_OPTION_OBJTYPE]   = 0;
        options[METIS_OPTION_CTYPE]     = 1;
        options[METIS_OPTION_DBGLVL]    = 0;
        options[METIS_OPTION_NITER]     = 10;
        options[METIS_OPTION_NCUTS]     = 1;
        options[METIS_OPTION_MINCONN]   = 0;
        options[METIS_OPTION_CONTIG]    = 0;
        options[METIS_OPTION_NUMBERING] = 1;

        if (*domains < 8) {
	//  Recursive
       		options[METIS_OPTION_IPTYPE]    = 0;
        	options[METIS_OPTION_RTYPE]     = 0;
        	options[METIS_OPTION_UFACTOR]   = 1;

        	rval = METIS_PartGraphRecursive(numnp,&ncon,xadj,adjncy,
                       NULL,NULL,NULL,
                       domains,NULL,NULL,options,&edgecut,part);
	}
	else {
	// Kway
        	options[METIS_OPTION_IPTYPE]    = 4;
       		options[METIS_OPTION_RTYPE]     = 1;
        	options[METIS_OPTION_UFACTOR]   = 30;

        	rval = METIS_PartGraphKway(numnp,&ncon,xadj,adjncy,
                       NULL,NULL,NULL,
                       domains,NULL,NULL,options,&edgecut,part);
	}

     	return(rval);

}


More information about the petsc-users mailing list