How to call a METIS subroutine from my FORTRAN code.

Hello to all METIS/FORTRAN programmers..

Despite being exceedingly embarassing - i have finally succumbed to
asking this. All i seek is to call the subroutine METIS_NODEND from my
fortran code and the sad part is that despite reading the entire
section 5.8 of the users manual where even though it is mentioned that
these routines are callable from either c or fortran, there are no
examples to actually do so.

Furthermore, reading in other places, I am lead to believe that there
might be a requirement of a fortran version of the metis.h header file
that would need to be included in the FORTRAN code. However - it is not
present in the latest distributed package. :-(

If there is anyone out there who is using FORTRAN and has managed to
successfully call the METIS subroutines - I would really appreciate
some pointers and if possible some actual example files - that i can go
through and understand. 

Much thanks,

-A

0
wiredashu (16)
11/30/2005 11:00:06 PM
comp.lang.fortran 11778 articles. 1 followers. Post Follow

20 Replies
1278 Views

Similar Articles

[PageSpeed] 55

AM,

 I know this is possible, since I received a code from the University of
Minnesota that does this.  I have this code in object format only, therefore I
don't have any examples to do this.  What Fortran and C compilers do you have
available??

Joe



On 30 Nov 2005 15:00:06 -0800, "AM" <wiredashu@gmail.com> wrote:

>Hello to all METIS/FORTRAN programmers..
>
>Despite being exceedingly embarassing - i have finally succumbed to
>asking this. All i seek is to call the subroutine METIS_NODEND from my
>fortran code and the sad part is that despite reading the entire
>section 5.8 of the users manual where even though it is mentioned that
>these routines are callable from either c or fortran, there are no
>examples to actually do so.
>
>Furthermore, reading in other places, I am lead to believe that there
>might be a requirement of a fortran version of the metis.h header file
>that would need to be included in the FORTRAN code. However - it is not
>present in the latest distributed package. :-(
>
>If there is anyone out there who is using FORTRAN and has managed to
>successfully call the METIS subroutines - I would really appreciate
>some pointers and if possible some actual example files - that i can go
>through and understand. 
>
>Much thanks,
>
>-A

0
12/1/2005 12:15:24 AM
Joe !

I am using the intel Fortran and C compilers on in a linux environment.
I did a grep to find which c files had the Metis_nodend and then - went
onto link frename.c to my fortran code. The code compiles and links
just fine - however when executing it -, just before the call to
Metis_nodend(..) it crashes.
Any hints ?

thank you taking the time to reply. Much appreciated ! 

-AM

0
wiredashu (16)
12/1/2005 11:55:09 AM
AM wrote:

> Hello to all METIS/FORTRAN programmers..
>
> Despite being exceedingly embarassing - i have finally succumbed to
> asking this. All i seek is to call the subroutine METIS_NODEND from my
> fortran code and the sad part is that despite reading the entire
> section 5.8 of the users manual where even though it is mentioned that
> these routines are callable from either c or fortran, there are no
> examples to actually do so.
>
> Furthermore, reading in other places, I am lead to believe that there
> might be a requirement of a fortran version of the metis.h header file
> that would need to be included in the FORTRAN code. However - it is not
> present in the latest distributed package. :-(
>
> If there is anyone out there who is using FORTRAN and has managed to
> successfully call the METIS subroutines - I would really appreciate
> some pointers and if possible some actual example files - that i can go
> through and understand. 
> 
> Much thanks,
> 
> -A

0
edunlop1 (5)
12/1/2005 3:46:26 PM
AM,

The following code works nicely with Intel Fortran 9.0 for Windows.
Hope this may help.

Edmund

------------------------------------------------------------------------------------

      subroutine MND(n, m, node, link, perm, iperm)
      implicit none
      integer,intent(in) :: n, m
      integer,intent(in),dimension(n+1) :: node
      integer,intent(in),dimension(2*m) :: link
      integer,intent(out),dimension(n) :: perm, iperm
      integer :: numflag
      integer,dimension(0:7) :: options
      external METIS_NodeND
!DEC$ ATTRIBUTES C,REFERENCE, ALIAS:"_METIS_NodeND" :: METIS_NodeND
!
! METIS_NodeND (N, NODE, LINK, NUMFLAG, OPTIONS, PERM, IPERM)
!
! Description
!
! This function computes fill reducing orderings of sparse matrices
! using the multilevel nested dissection algorithm. It provides the
! functionality of the onmetis program.
!
! Parameters
!
! N  The number of vertices in the graph.
!
! NODE, LINK
! The adjacency structure of the graph as described below.
!
! NUMFLAG  Used to indicate which numbering scheme is used for the
! adjacency structure of the graph. NUMFLAG can take the following two
! values:
! 0  C-style numbering is assumed that starts from 0
! 1  Fortran-style numbering is assumed that starts from 1
!
! OPTIONS  This is an array of 8 integers that is used to pass
! parameters for the various phases of the algorithm.
!
! If OPTIONS[0]=0 then default values are used. If OPTIONS[0]=1, then
! the remaining seven elements of options are interpreted as follows:
!
!   OPTIONS[1]  Determines the matching type. Possible values are:
!   1 Random Matching (RM)
!   2 Heavy-Edge Matching (HEM)
!   3 Sorted Heavy-Edge Matching (SHEM) (Default)
!   Experiments have shown that all three matching schemes perform
quite
!   well. In general SHEM is faster and RM is slower, but feel free to
!   experiment with the other matching schemes.
!
!   OPTIONS[2]  Determines the algorithm used during initial
!               partitioning. Possible values are:
!   1 Edge-based region growing (Default)
!   2 Node-based region growing
!
!   OPTIONS[3]  Determines the algorithm used for refinement. Possible
!               values are:
!   1 Two-sided node FM refinement
!   2 One-sided node FM refinement (Default)
!   One-sided FM refinement is faster than two-sided, but in some cases
!   two-sided refinement may produce better orderings. Feel free to
!   experiment with this option.
!
!   OPTIONS[4]  Used for debugging purposes. Always set it to 0
!               (Default).
!
!   OPTIONS[5]  Used to select whether or not to compress the graph and
!               to order connected components separately. The possible
!               values and their meaning are as follows:
!   0 Do not try to compress the graph and do not order each connected
!     component separately.
!   1 Try to compress the graph. (A compressed graph is actually formed
!     if the size of the graph can be reduced by at least 15%)
!     (Default).
!   2 Order each connected component of the graph separately. This
!     option is particularly useful when after a few levels of nested
!     dissection, the graph breaks up in many smaller disconnected
!     subgraphs. This is true for certain types of LP matrices.
!   3 Try to compress the graph and also order each connected component
!     separately.
!
!   OPTIONS[6]  Used to control whether or not the ordering algorithm
!               should remove any vertices with high degree (i.e.,
dense
!               columns). This is particularly helpful for certain
!               classes of LP matrices, in which there a few vertices
!               that are connected to many other vertices. By removing
!               these vertices prior to ordering, the quality and the
!               amount of time required to do the ordering improves.
The
!               possible values are as follows:
!   0  Do not remove any vertices (Default)
!   x  Where x > 0, instructs the algorithm to remove any vertices
whose
!      degree is greater than 0.1 * x * average degree). For example if
!      x = 40, and the average degree is 5, then the algorithm will
!      remove all vertices with degree greater than 20. The vertices
!      that are removed are ordered last (i.e., they are automatically
!      placed in the top-level separator). Good values are often in the
!      range of 60 to 200 (i.e., 6 to 20 times more than the average).
!
!   OPTIONS[7]  Used to determine how many separators to find at each
!               step of nested dissection. The larger the number of
!               separators found at each step, the higher the runtime
!               and better the quality is (in general). The default
!               value is 1, unless the graph has been compressed by
more
!               than a factor of 2, in which case it becomes 2.
!               Reasonable values are in the range of 1 to 5. For most
!               problems, a value of 5 increases the runtime by a
factor
!               of 3.
!
! PERM, IPERM
! These are vectors, each of size n. Upon successful completion, they
! store the fill-reducing permutation and inverse-permutation. Let A be
! the original matrix and A' be the permuted matrix. The arrays PERM
and
! IPERM are defined as follows. Row (column) i of A' is the PERM[i] row
! (column) of A, and row (column) i of A is the IPERM[i] row (column)
of
! A'. The numbering of this vector starts from either 0 or 1, depending
! on the value of numflag.
!
!
======================================================================
!
! The adjacency structure of the graph is stored using the compressed
! storage format (CSR). The CSR format is a widely used scheme for
! storing sparse graphs. In this format the adjacency structure of a
! graph with n vertices and m edges is represented using two arrays
NODE
! and LINK. The NODE array is of size n+1 whereas the LINK array is of
! size 2m (this is because for each edge between vertices v and u we
! actually store both (v,u) and (u,v)).
!
! The adjacency structure of the graph is stored as follows. Assuming
! that vertex numbering starts from 1 (Fortran style), then the
! adjacency list of vertex i is stored in array LINK starting at index
! NODE[i] and ending at (but not including) index NODE[i+1] (i.e.,
! LINK[NODE[i]] through and including LINK[NODE[i+1]-1]). That is, for
! each vertex i , its adjacency list is stored in consecutive locations
! in the array LINK, and the array NODE is used to point to where it
! begins and where it ends. Figure 1(b) illustrates the CSR format for
! the 15-vertex graph shown in Figure 1(a).
!
!
!    1-- 2-- 3-- 4-- 5
!    |   |   |   |   |
!    6-- 7-- 8-- 9--10
!    |   |   |   |   |
!   11--12--13--14--15
!
!   (a) A sample graph
!
!
!   N = 15;  M = 22
!
!   NODE(N+1)     1  3  6  9 12 14 17 21 25 29 32 34 37 40 43 45
!
!   LINK(2*M)     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
!
!   (b) CSR format
!
!   Figure 1: An example of the CSR format for storing sparse graphs.
!
!
      numflag = 1
      options(0) = 0
      call METIS_NodeND(n, node, link, numflag, options, perm, iperm)
      return
      end subroutine MND

0
edunlop1 (5)
12/1/2005 4:02:58 PM
One further thought (on the C side - I use Intel C/C++ for Windows):

I needed to modify metis.h as follows:

/*
 * Copyright 1997, Regents of the University of Minnesota
 *
 * metis.h
 *
 * This file includes all necessary header files
 *
 * Started 8/27/94
 * George
 *
 * $Id: metis.h,v 1.1 1998/11/27 17:59:21 karypis Exp $
 */


#define __VC__

#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
/*
 * #include <strings.h>
 */
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <time.h>

#ifdef DMALLOC
#include <dmalloc.h>
#endif

#include <defs.h>
#include <struct.h>
#include <macros.h>
#include <rename.h>
#include <proto.h>

I then compiled all the .c files and used the linker to make a .lib
file ( .a in Linux parlance?).

I then compiled my Fortran source and included a search of the .lib
file on the final link.

By the way, sorry about the blank response initially - my first time to
try Google with this newsgroup and I was too fast at pressing buttons.

Hope this helps,

Edmund

0
edunlop1 (5)
12/1/2005 4:23:58 PM
Hi Edmund !

Thank you for your response(s). I do still have a few questions:

Going by your above examples - i noticed that the entire section in "!"
is commented out. What leaves is that there is just a direct call to
Metis_NodeNd from external subroutine MND. I was doign the same thing -
and it's not working. The basic problem is that how does FORTRAN and C
know where to call the function from. Ideally - if there was a fortran
version of the header file - metis.c -then all this would be been more
than evident.

I am still lost a bit. Also - from what i can see - the only change you
made to your metis.c header file is the addition of #define __VC__

apart from that what i have out here is the same - (except it's on a
Linux platform). If you wish - i can post a bit of my FORTRAN code ?

Regards,

-AM

0
wiredashu (16)
12/1/2005 6:36:23 PM
I've never heard of Metis, but...

AM <wiredashu@gmail.com> wrote:

> The basic problem is that how does FORTRAN and C
> know where to call the function from. Ideally - if there was a fortran
> version of the header file - metis.c -then all this would be been more
> than evident.

Significant confusions of terminology or something here.

A procedure is "called" (invoked) from wherever the call statement or
function reference appears in the source code. I think that perhaps you
are asking about where the procedure itself comes from rather than where
it is called from. The answer to that is generally that you have either
the source code or a library for the procedure somewhere, and you have
to tell the compiler to use that. You would use compiler command-line
switches (or the GUI equivalent) to tell the compiler that. That
information is not in the invoking source code (either in C or Fortran).

And a .c file would not be a "header" file. I think you mean metis.h.

> I was doign the same thing - and it's not working.

What does "it's not working" mean? That's not very descriptive. I'm sure
you get a bit more detailed error message than that.

> i noticed that the entire section in "!" is commented out.

Ah. I just noticed this. It might be your problem. A "comment" beginning
with, for example, "!DEC$", as one of these does, is not "really" a
comment. That's a commonly used convention for a compiler directive. In
this case, that compiler directive hapens to be critically important; if
you leave it out because you think it is just a comment and therefore
doesn't matter, things probably won't work. I'm placing my money on that
being your problem.

-- 
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
0
nospam47 (9747)
12/1/2005 7:12:05 PM
To expand on Richard Maine's comments:

This line:
      external METIS_NodeND
is Fortran telling the compiler the routine is an external routine.

But this line:
!DEC$ ATTRIBUTES C,REFERENCE, ALIAS:"_METIS_NodeND" :: METIS_NodeND
is a Digital (DVF/CVF) directive, not part of the Fortran language, which tells the
compiler that the external symbol METIS_NodeND is expecting the C-language calling
and naming conventions, but the arguments are to be passed by reference (i.e.,
send addresses) and the published name to find it (in external .OBJ or .LIB) is
_METIS_NodeND which will be treated in a case-sensitive manner by the compiler since
it is in quotes.  Provided the linker preserves case during link operations, the 
symbol should be found and linked properly.  

If you are not using DVF/CVF or another compiler that supports DEV-style metacommands,
then you will need a different means of informing the compiler about the name aliasing
and calling conventions.

Isn't mixed language programming fun?
0
kgrhoads (401)
12/1/2005 7:38:07 PM
Hi there...the reason why i think it's a comment is because, there is
an entire subroutine description that is preceded by the "!". If it
were not so - then there would be more elementary problems..?

Also - yes..i meant metis.h. the package ships with the c header file,
however FORTRAN programmers seem to be tragically out of luck.

Finally when i mentioned it didnt work - well the code terminates..
Here is a replication of the same..
------------------------------------
Calling METIS...
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line
Source
vsim_metis_slu     00000000004D09F7  Unknown               Unknown
Unknown
vsim_metis_slu     00000000004C6612  Unknown               Unknown
Unknown
vsim_metis_slu     0000000000410826  Unknown               Unknown
Unknown
vsim_metis_slu     0000000000408C12  Unknown               Unknown
Unknown
vsim_metis_slu     0000000000405C76  Unknown               Unknown
Unknown
libc.so.6          0000002A95E301AE  Unknown               Unknown
Unknown
vsim_metis_slu     0000000000405BAA  Unknown               Unknown
Unknown
rank 0 in job 1  on <..>  caused collective abort of all ranks  exit
status of rank 0: return code 174
--------------------

Any hints ? 

-AM

0
wiredashu (16)
12/1/2005 7:47:09 PM
OHHHH ! ! ! ...ok..let me try something...and then will post this back.
If am successful - i swear i will post a small guide.

Be right back. :-)

-AM

0
wiredashu (16)
12/1/2005 8:08:36 PM
AM <wiredashu@gmail.com> wrote:

> Hi there...the reason why i think it's a comment is because, there is
> an entire subroutine description that is preceded by the "!". If it
> were not so - then there would be more elementary problems..?

No. Just because those are on following lines does not mean they are
part of thee directive. That one line is not a comment and *IS*
important. Really. The rest are actually comments.

Oh, but I see you said you are on Linux. Alas, that stuff is very
compiler-specific. As Kevin said, you'll probably need another way to
achieve the ends if you aren't using a compiler that supports the !$DEC
directives. Posting snippets from the C side might help.

Have I mentioned recently that I look forward to the C interop features
of f2003 so that this kind of thing can actually be done portably.  :-(

-- 
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
0
nospam47 (9747)
12/1/2005 8:17:14 PM
You were right !

It was not a comment and yes..the compiler i am using does support the
!$DEC directives. However - am not having succes. I am not sure what
you were refering to "...snippets from C side". I can do so - just let
me know - if it's the C function that needs to be ultimately called
that you refer to ! :-(

<"have I mentioned recently that I look forward to the C interop
features
of f2003 so that this kind of thing can actually be done portably.  :-(
>

Me too ! ..

-AM

0
wiredashu (16)
12/1/2005 8:28:51 PM
>However - am not having succes.

When in doubt, post all error messages without editting.  Context is also useful.
0
kgrhoads (401)
12/1/2005 8:33:48 PM
Nope..no success as yet. My compiler DOES support the !DEC$ directives.
Still no luck ! The charm of being alive fading away ... :-(

-AM

0
wiredashu (16)
12/1/2005 8:34:16 PM
AM <wiredashu@gmail.com> wrote:

> It was not a comment and yes..the compiler i am using does support the
> !$DEC directives. However - am not having succes. I am not sure what
> you were refering to "...snippets from C side". I can do so - just let
> me know - if it's the C function that needs to be ultimately called
> that you refer to ! :-(

Yes, if it is reasonable enough sized to post. The "snippets" bit was to
suggest that you could probably get by with just the beginning part of
the C function if necessary. But if the whole thing is plausibly
postable, that would be better. It is presumably the METIS_NodeND
function that we are talking about.

-- 
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
0
nospam47 (9747)
12/1/2005 8:42:33 PM
Hi Richard !
Now that i have completely lost all my dignity - may i make a
suggestion ? You mentioned you have never heard of METIS. Would it be
too much for you to actually download it and take a look ? It's a
library of Sparse matrix reordering algorithms among other things.
Available from:
http://www-users.cs.umn.edu/~karypis/metis/metis/files/metis-4.0.tar.gz

It has a users guide in there..which if you look at - will state (in
section 5.8) that there is complete support for fortran programs etc...
The function Metis_Nodend is listed in this guide.

However - this is where things get tricky. There is NO actual c file
with this name. this function is found in another c file called
"ometis.c".

Since All my problems are syntactical - so you dont even have to read
about their workings or innards. All i waiting for is to be able to
overcome this interfacing issue. 

-AM

0
wiredashu (16)
12/1/2005 9:02:19 PM
AM <wiredashu@gmail.com> 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
0
nospam47 (9747)
12/1/2005 10:32:25 PM
Well that settles it...i am just lost. Ok. let me retrace my steps -
use your suggestions on the print out and then comeback.
BTW - Richard - thank you SO much for all this.. :-)

-Ash

0
wiredashu (16)
12/1/2005 10:52:30 PM
YESS ! ! !!

<ahem> so now that is done - let me highlight - what i was doing wrong
!

deallocate(isr_a,icol_a,rv_a)
call MND(i_totalnodes,size(icol_a),isr_a,icol_a,perm,iperm)
..
..

Somehow that line of deallocate was invisible to me ! AND IT WAS RIGHT
THERE ! :-( Ofcourse there were a few other errors (such as i had ...)

allocate(iperm(i_totalnodes+1),perm(i_totalnodes+1)) - which should
have been only i_totalnodes..but ...:-(

Anyway - THANK YOU SO MUCH everyone ! Now i am going to fixing the next
step with proper usage of this routine ! Apparently - there is yet
another restriction about the structure of the "link" vector that i
will need to make sure doesn't crop up.

-Ash

ps: and what is really tragic - i have been looking at this code for
the last 2 days..(this particular problem) !

0
wiredashu (16)
12/1/2005 11:35:22 PM
AM <wiredashu@gmail.com> wrote:

> YESS ! ! !!
....
> Somehow that line of deallocate was invisible to me ! AND IT WAS RIGHT
> THERE ! :-(

Been there. Done that. :-(

-- 
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
0
nospam47 (9747)
12/1/2005 11:51:51 PM
Reply:

Similar Artilces:

Calling FORTRAN functions rather than FORTRAN subroutines via call
Hi everybody, all examples I know show how to call a FORTRAN subroutine. I have a lot of FORTRAN code regarding thermophysical properties of water, steam, smoke gas etc. This code consists of many FORTRAN functions. I wish to call them inside scilab. Is it possible? If yes how can the function return value be obtained? Thank you very much, many greetings Eberhard On 2 jan, 14:41, i...@efranz.de wrote: > Hi everybody, > > all examples I know show how to call a FORTRAN subroutine. I have a > lot of FORTRAN code regarding thermophysical properties of water, > ...

Many Fortran code! How to call Fortran code from C/C++?
Hi all, As a C/C++ programmer, there are a few reasons to use Fortran: (1) Fortran is very similar to Matlab and easy to port; (2) Fortran has support of complex numbers and vectorized numbers and the operations in Fortran are naturally element-wise, operating on a whole vector. (3) There are many scientific codes are in Fortran. ------------- So how do I call Fortran program from my C program? I am using MSVS. NET 2003, VisualC++ and Intel C++ therein, and also the Intel Visual Fortran therein. To give an example, I want to call a Fortran program from C++, which is in its bare form, it ...

c++ calling fortran and fortran calling C++
Hi, For my application in C++, I need to call a subtroutine in fortran. This subroutine must call a function of my program. I'm trying to use pointer of my function but I have segmentation fault. the fortran code is: subroutine dlltest [dllexport] (c_msg,e1,e2,e3,i,r,d,str) c implicit none integer i,l,m,length real*4 r double precision d character*128 e1,e2,e3,str,aux,aux2 external c_msg,length c first, write parameters to a file open(1,file='test.out',status='unknown') rewind(1) c write(1,*) 'function pointer: ',c_msg write(1,*) 'integer: ...

mex - matlab calls fortran which calls matlab which calls fortran
Dear All, I'm trying to link matlab and fortran with mex files and engine matlab, in linux OS. My general purpose is the following: 1) a matlab script A calls a mex function B based upon fortran source code 2) mex function B calls another function in matlab C within matlab engine 3) matlab routine C calls another mex file in fortran D While i'm able to do steps 2) and 3), I can't do step 1). Before to show the code, please reply to this simple question: Is it possible to build the overall process 1-3? On 8 Okt, 16:37, "Michele Catalano" <cata...@yahoo.it> wr...

Calling a Fortran DLL from Fortran
In calling a FORTRAN DLL, from FORTRAN code, one needs to place the DLL in = a path that is searched by the Windows operating system. Placing the DLL in= a folder other than the ones in the PATH environment variable, will cause = the call to fail. Does anyone know how to call a DLL that is stored in a fo= lder not in the Windows path? In VB one uses the Declare statement to accom= plish that. I tried GETENVQQ to get the Path environment variable, then aug= ment the path of the DLL and then using the SETENVQQ to update the PATH en= vironment variable but I haven't been able to succ...

Parallelize an existing Fortran code and generate parallel Fortran code using Maple?
Hi Folks, Here is a numerical integration program: http://people.scs.fsu.edu/~burkardt/f_src/quadpack/quadpack.f90 In evaluating the integrand functions, it is good to do two function evaluations at the same time simultaneously. I just found that I have two CPUs Pentium Xeon 2.4GHz, each supporing only up to SSE2. Although the CPUs are slow, but if I can utilize them to do parallel computing of the numerical integration. It would be great! But I am not a Fortran expert, nor am I a CS major... Could anybody give some easy-to-follow advice on how to make that code parallel on two CPUs? -...

Calling Fortran 77 from Fortran 95
When calling Fortran 77 from Fortran 95, how can I make sure the compiler will pass a contiguous array and not a dope array struct? On 2011-03-06 14:07:38 -0400, sturlamolden said: > When calling Fortran 77 from Fortran 95, how can I make sure the > compiler will pass a contiguous array and not a dope array struct? In a narrow sense your question is meaningless as F77 is a subset of F95. What you probably meant was what happens when a F95 compiler finds that it does not have an explicit interface to some procedure. That is well defined and yields what you are probably thinking of as...

Fortran subroutine to run in ADAMS/Solver FORTRAN
Hi Everyone, I am doing a project to improve damper functionality in Adams/Car to better represent its transient behaviour. I need to write a sub-routine which will calculate the damper force considering transient behaviours of the vehicle. The probelm is that I dont have much experience in Fortran so i face problems understanding the syntax given in ADAMS/Solver FORTRAN. I am not able to compile the program as there are errors to define the input and output variables properly. Also dont know how to link the program to Adams. Please go through the program and suggest any improvements neede...

how to run Fortran codes in Compaq Visual Fortran?
I have a bunch of Fortran applications from my adviser and I need use them to create a executable program. My adviser gave me a makefile to do the job. But honestly, I don't know how to run the makefile in Cygwin. I changed the makefile to a two simple command line file and created an executable program. But due to some memory problem, the results are not complete. My adviser uses Compaq Visual Fotran 6.5 and generate an executable program works fine. However when I add all the Fortran application files into one project, I got tons of error message. I don't know what I did wrong. Pleas...

Matlab call in fortran code
Hi all, I have a little question concerning Matlab in fortran code. I know that in Matlab, you can reallocate a matrix without doing anything. For example, A=eye(3) A = 1 0 0 0 1 0 0 0 1 >> A=[A;A] A = 1 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 In my fortran code, I read a mat file that contains matrices. As an example, let's consider a 1000 by 10 matrix (real data). My fortran code produces a 20 by 10 matrix (real data) and I want to apend this computed array to th...

Backtracing the Fortran subroutine calls
Hi All, When compiled in the debug mode with runtime error checks, most Fortran com= pilers like Intel or Gfortran can trace back to the original caller when a = run time error such as 'out of bound array access' happens. This helps a lo= t to debug the big codes.=20 I was wondering if somehow it is possible to access this traceback informat= ion when calling the 'STOP' command. Basically, this means that when a STOP= function is called, then all the traceback information is printed on the s= creen. It is of course ok if it is compiler dependent. Thanks. Hossei...

Calling Fortran code with Photran?
Hey We have some old Fortran code that we would like to be able to use from a Java application. Have downloaded Photran and I am now looking for how to call Fortran subroutines from a Java program, but their documentation doesn't mention that and I have not been able to find the answer elsewhere on the Web. Anyone have any experience or a reference to a good source of info? Regards. On 10/25/2013 02:26 PM, Hawkan wrote: > > Hey > > We have some old Fortran code that we would like to be able to use from > a Java application. Have downloaded Photr...

how to call Fortran subroutines from Matlab?
as title hnliuhy wrote: > as title http://www.google.com/search?ie=UTF-8&q=calling+fortran+from+matlab Madhusudan Singh wrote: > > > hnliuhy wrote: > >> as title > > <http://www.google.com/search?ie=UTF-8&q=calling+fortran+from+matlab> > I have editted an example, and try to run it, it won't work. Would any one check my code? thanks 1) I make a fortran-matlab interface code, test_mex.f subroutine mexFunction(prhs, nrhs, plhs, nlhs) integer prhs(*), plhs(*), nrhs, nlhs ! pointer between Matlab and For real*8 ypr, tr, yr C Copy array point...

failed to call fortran subroutine
Hello, I followed the procedure in the example (\scilab\modules \dynamci_link_c_and_fortran) I tried to call a fortran subroutine by: ilib_for_link('B_generator','B_generator.f',[],"f") but it always shows an error message: ============================ Generate a loader file Generate a Makefile Running the Makefile !--error 10000 A Fortran or C compiler is required. at line 12 of function ilib_compile called by : at line 86 of function ilib_for_link called by : ilib_for_link('B_generator','B_generator.f',[],"...

Web resources about - How to call a METIS subroutine from my FORTRAN code. - comp.lang.fortran

Subroutine - Wikipedia, the free encyclopedia
In computer programming , a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can ...

Subroutine - Wikipedia, the free encyclopedia
In computer programming , a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can ...

Apple-Samsung jury discovers joys of subroutines, class libraries
... jury hearing Apple's patent infringement case against Samsung was thrown into the deep end Monday and subjected to some heady talk of subroutines ...

Mitt Romney humor subroutine activated: 'If I were to coin a term, it would be Obamalogna'
Oh, Mitt. I'm afraid his rejoinder to Barack Obama's "Romney Hood" line is just ... well ... "If I were to coin a term, it would Obamalogna. ...

Bad AppleScript: Subroutines and file paths
... have line numbers–I think it was Pascal—I couldn’t comprehend it. Well, we’ve come a long way. I can’t type GOSUB 5000 anymore, but subroutines ...

Apple-Samsung jury discovers joys of subroutines, class libraries
... jury hearing Apple's patent infringement case against Samsung was thrown into the deep end Monday and subjected to some heady talk of subroutines ...

Apple-Samsung jury discovers joys of subroutines, class libraries
... jury hearing Apple’s patent infringement case against Samsung was thrown into the deep end Monday and subjected to some heady talk of subroutines ...

Subroutine - Wikipedia, the free encyclopedia
In computer programming , a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can ...

Subroutine - Wikipedia, the free encyclopedia
In computer science , a subroutine , also termed procedure , function , routine , method , or subprogram , is a part of source code within a ...

Subroutine - Wikipedia, the free encyclopedia
In computer science , a subroutine , also termed procedure , function , routine , method , or subprogram , is a part of source code within a ...

Resources last updated: 2/7/2016 10:52:58 AM