home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20086 comp.lang.fortran:5132
- Newsgroups: comp.lang.c,comp.lang.fortran
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!phoenix!bobp
- From: bobp@msi.com (Bob Pitha)
- Subject: Re: calling a Fortran subroutine from a C program
- Followup-To: comp.lang.c,comp.lang.fortran
- References: <1993Jan22.190624.23084@chpc.utexas.edu>
- Sender: nobody@ctr.columbia.edu
- Organization: Molecular Simulations, Inc.
- Date: Fri, 22 Jan 1993 20:08:39 GMT
- X-Newsreader: TIN [version 1.1 PL8]
- Message-ID: <1993Jan22.200839.8352@sol.ctr.columbia.edu>
- X-Posted-From: phoenix.msi.com
- NNTP-Posting-Host: sol.ctr.columbia.edu
- Lines: 40
-
- 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
- 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
-