home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20082 comp.lang.fortran:5129
- Newsgroups: comp.lang.c,comp.lang.fortran
- Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!michael
- From: michael@chpc.utexas.edu (Michael Lemke)
- Subject: Re: calling a Fortran subroutine from a C program
- Message-ID: <1993Jan22.190624.23084@chpc.utexas.edu>
- Organization: The University of Texas System - CHPC
- References: <1jmqdaINN11g@mudhoney.mathcs.emory.edu> <1993Jan22.130743.27130@sol.ctr.columbia.edu>
- Date: Fri, 22 Jan 93 19:06:24 GMT
- Lines: 48
-
- In article <1993Jan22.130743.27130@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
- >Scott White (swhite@mathcs.emory.edu) wrote:
- >: Can someone please tell me how to call a Fortran subroutine from a C program?
- >: The environment is sun4, OS 4.1.2.
- >
- >Sure, this isn't really that hard as long as you keep a few basic issues in
- >mind:
- >
- [...]
- >
- >4) Character arrays: For each character array in the argument list, there
- ^^^^^^
- > should be a long int at the end of the argument list specifying the
- > *declared* length of the array - that is, how much space is allocated
- > for it. Since Fortran blank-fills character arrays, this number will
- > specify how many places to fill. If you have more than one character
- > array in the argument list, the length arguments should be in the same
- > order as the character arguments.
- >
- [...]
- > (and now the Fortran part)
- >
- > subroutine MyFortranSub (int_arg, float_arg, int_array,
- > + int_matrix, string)
- > integer int_arg
- > real float_arg
- > integer int_array (3)
- > integer int_matrix (3, 4)
- > character*(*) string
- ^^^^^^
-
- You are not talking about character arrays at all in your post. A
- character array is something you declare as
-
- character*(*) string(10)
-
- which is an array of strings. You talked just about plain character
- strings. Keep the terms clear. Passing of character arrays is a bit
- harder than what you described I believe (I might be wrong) but I don't
- have my Sun manual handy to point out the differences. Someone else
- might. But as you have suggested (which I deleted for brevity) reading
- the Sun Fortran manual is worth doing. It deals with all these issues.
-
- Michael
- --
- Michael Lemke
- Astronomy, UT Austin, Texas
- (michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
-