home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20092 comp.lang.fortran:5136
- 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.233618.17814@chpc.utexas.edu>
- Organization: The University of Texas System - CHPC
- References: <1993Jan22.190624.23084@chpc.utexas.edu> <1993Jan22.200839.8352@sol.ctr.columbia.edu>
- Date: Fri, 22 Jan 93 23:36:18 GMT
- Lines: 63
-
- In article <1993Jan22.200839.8352@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
- >Michael Lemke (michael@chpc.utexas.edu) wrote:
- >: In article <1993Jan22.130743.27130@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
- > (edited a bit for brevity's sake)
- >: >
- >: >4) Character arrays: For each character array in the argument list, there
- >: ^^^^^^
- >
- >: 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.
- >
- > This is really just an issue of semantics, but you're right that I wasn't
- ^^^^^^^^^^^^^^^^^^
-
- Not quite. To make it really clear: The difference is
-
- CHARACTER*100 STRING
-
- or
-
- CHARACTER*1 STRING(100)
-
- which are very different data structures. The latter is an array, the
- first is a single variable. I don't care how C chews its memory, it can
- hardly distinguish these two cases. The last is pretty close in
- functionality to C's concept (except for having a length stored
- somewhere) as you'd need something like strcpy to copy data.
-
- >very clear. I was thinking in terms of an "array of type char" in C, so
- >I just wrote what I was thinking. As you point out, to a person who only
- >knows Fortran the phrase "character array" may by misleading. Unfortunately,
- >this is an area where the concepts don't map well between the two worlds,
- >since c doesn't have an official "string" type; a string is just a null-
- >terminated array of characters.
- >
- > Passing "arrays of strings" (is that clear enough?) is perhaps a little
- >bit harder, but not a whole lot. I didn't touch on null-termination and
- >blank-filling in my previous post because I didn't know whether the
- >original questioner cared and it would have taken lots more space. I
- >stuck to the simple case of passing an array of characters to the Fortran
- >routine. If the Fortran routine were going to try to pass a string back
- >to C, or if an array of strings were being passed, you have to deal with
- >these issues.
- >
- >-----------------------------------------------------------------------
- >Bob Pitha Molecular Simulations Inc.
- >bobp@msi.com 16 New England Executive Park
- >(617) 229-9800 x242 Burlington, MA 01803-5297
-
-
- --
- Michael Lemke
- Astronomy, UT Austin, Texas
- (michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
-