Re: How to call a METIS subroutine from my FORTRAN code.
- From: nospam@xxxxxxxxxxxxx (Richard E Maine)
- Date: Thu, 1 Dec 2005 14:32:25 -0800
AM <wiredashu@xxxxxxxxx> wrote:
> Now that i have completely lost all my dignity
Not at all!
> http://www-users.cs.umn.edu/~karypis/metis/metis/files/metis-4.0.tar.gz
Ok. Done. Hmm. This ought to be simple. Looking at the function, I see
that all its arguments are integers (some are typedefed, but that turns
out to be integer) and passed by reference. I don't happen to be using a
compiler that supports the !$DEC stuff, so I was about to do a trivial
workaround, which should be simple for a C function like this, but...
Then I took a look at the manual on pg 43 where it mentions C and
Fortran support. It comments that they specifically did all the
arguments that way to make Fortran simple, and... I see... they already
did one of the workarounds I was planning on. Namely, they made trivial
wrapper functions with names METIS_NODEND, metis_nodend, metis_nodend_,
and metis_nodend__ (the last 2 there differ in the number of trailing
underscores). Indeed I see those functions in the file frename.c
(obviously for "Fortran renames"). That pretty much covers all the
common cases. This ought to just work, even without a compiler that
supports the !$DEC stuff. Ok.
I went over to one of my Linux boxes (RedHat 7.3), untarred the metis
library and typed make. Seemed to build. Then I did the simplest Fortran
test program I could come up with without actually having to think. :-)
I took your posted code exactly as is, doing nothing other than fix a
few comment lines that wrapped in the posting. Then I threw the
following trivial main program in front of it, where I got the data
values from the comments in your code. I used slight editor trickery to
turn the values into valid array constructors without actually retyping
them (so as to lower the odds of typos). Thus my main program is:
program testmet
implicit none
integer, parameter :: n=15, m=22
integer,dimension(n+1) :: node
integer,dimension(2*m) :: link
integer,dimension(n) :: perm, iperm
node = (/1,3,6,9,12,14,17,21,25,29,32,34,37,40,43,45/)
link = (/2,6,1,3,7,2,4,8,3,5,9,4,10,1,7,11,2,6, &
8,12,3,7,9,13,4,8,10,14,5,9,15,6,12,7,11,13, &
8,12,14,9,13,15,10,14/)
call mnd(n, m, node, link, perm, iperm)
write (*,*) 'perm = ', perm
write (*,*) 'iperm = ', iperm
end
Compiled and linked it using the NAG f90 compiler with
f90 clf.f90 -Lmetis-4.0 -lmetis
Runs fine and gives the result
perm = 15 5 9 4 14 10 12 2 6 1 11 7 13 8 3
iperm = 10 8 15 4 2 9 12 14 3 6 11 7 13 5 1
which I didn't check, but sure beats a segmentation fault.
Just for kicks, did the same thing on my Mac with both the Nag and g95
compilers. That's odd. The Mac ones give different answers than the
Linux one (both Mac compilers giving the same answer). Well, I don't
think I'll try to track that one down. Doesn't look like a Fortran
interface problem anyway, as far as I can see. The stuff doesn't claim
to have been tested on OS X. Oh well.
This leaves me with two... make it three... questions about your
experience.
1. I assume that the compilation and linking did go without error?
Probably did or you wouldn't have an executable to run, but it seems
worth asking.
2. Are you sure that you have good data for the node and link arrays? I
note that the value of m doesn't get fed to the C code. Apparently it
just depends on the arrays being valid without having any handy way to
check. This seems like asking for problems where bad data causes array
bounds to be exceeded. Specifically, have you tried it with known valid
data such as the sample case in the comments (for example, using the
main program II posted above)?
3. How sure are you that the code even got to the Metis_ND invocation?
The error messages almost sound like it is still in some vsim_metis_slu
file (presumably of yours, as I don't see anything of that name in the
metis stuff. I see that your output says "Calling METIS", but I don't
see that message in either metis or in your MND subroutine. What are the
odds that you didn't yet actually get into MND sucessfully? Maybe add a
printout in it?
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- Follow-Ups:
- References:
- How to call a METIS subroutine from my FORTRAN code.
- From: AM
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Edmund
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Edmund
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Edmund
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: AM
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Richard E Maine
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: AM
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Richard E Maine
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: AM
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: Richard E Maine
- Re: How to call a METIS subroutine from my FORTRAN code.
- From: AM
- How to call a METIS subroutine from my FORTRAN code.
- Prev by Date: problem with using dll in fortran
- Next by Date: Re: OFF TOPIC, but how do y'all read these news groups?
- Previous by thread: Re: How to call a METIS subroutine from my FORTRAN code.
- Next by thread: Re: How to call a METIS subroutine from my FORTRAN code.
- Index(es):
Relevant Pages
|