home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20115 comp.lang.fortran:5148
- Newsgroups: comp.lang.c,comp.lang.fortran
- Path: sparky!uunet!newsflash.concordia.ca!nstn.ns.ca!cs.dal.ca!biome!silvert
- From: silvert@biome.bio.ns.ca (Bill Silvert)
- Subject: Re: calling a Fortran subroutine from a C program
- Message-ID: <1993Jan23.152153.7178@biome.bio.ns.ca>
- Reply-To: silvert@biome.bio.dfo.ca (Bill Silvert)
- Organization: Habitat Ecology Div., Bedford Inst. Oceanography
- References: <1993Jan22.190624.23084@chpc.utexas.edu> <1993Jan22.200839.8352@sol.ctr.columbia.edu> <1993Jan22.233618.17814@chpc.utexas.edu>
- Distribution: na
- Date: Sat, 23 Jan 1993 15:21:53 GMT
- Lines: 30
-
- In <1993Jan22.233618.17814@chpc.utexas.edu> michael@chpc.utexas.edu (Michael Lemke) writes:
-
- >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.
-
- It seems to me that there would be absolutely no difference in memory
- allocation between these two cases, and that they would appear identically
- to a C program. Thus in terms of passing them to a C program I can't
- see what the difference would be. The only difference is how the Fortran
- code refers to them.
-
- So far as C is concerned, the value of string_(n-1) can be interpreted
- equally well as the nth byte in the string string_, or as the nth
- member of an array of one-byte strings.
-
- Caveat: I have been told in the past that there is no requirement for
- Fortran to allocate contiguous memory for arrays, but since I have never
- run into a case where this was not done I don't worry about it.
- --
- ------------------------------------------------------------------------
- William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography
- P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2. Tel. (902)426-1577
- InterNet Address: silvert@biome.bio.dfo.ca
-