home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20258 comp.lang.fortran:5194
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!asuvax!ncar!vexcel!copper!aspen.craycos.com!jrbd
- From: jrbd@craycos.com (James Davies)
- Newsgroups: comp.lang.c,comp.lang.fortran
- Subject: Re: calling a Fortran subroutine from a C program
- Message-ID: <1993Jan26.174244.26236@craycos.com>
- Date: 26 Jan 93 17:42:44 GMT
- References: <1993Jan23.152153.7178@biome.bio.ns.ca> <ig25.728061129@fg30> <1993Jan26.160622.24483@sol.ctr.columbia.edu>
- Distribution: na
- Organization: Cray Computer Corporation
- Lines: 30
-
- In article <1993Jan26.160622.24483@sol.ctr.columbia.edu> shenkin@still3.chem.columbia.edu (Peter Shenkin) writes:
- >In article <ig25.728061129@fg30> ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig) writes:
- >>An implementation might very well choose to start every character
- >>variable on a word boundary, for speed reasons.
- >>
- >> CHARACTER*1 STRING(100)
- >>
- >>would then appear to C to be an array of ints, instead of chars.
- >
- >I think Cray in fact does this, while placing CHARACTER*1 scalars
- >on byte boundaries.
-
- While it's true that Cray compilers will align local variables on word
- boundaries, it isn't possible to do that for character arrays or character
- variables in COMMON. This is due to the storage layout rules imposed by the
- Fortran 77 standard, which requires that
- CHARACTER*1 A,B,C
- COMMON/A/ A,B,C
- in one routine, and
- CHARACTER*3 A
- COMMON/A/ A
- in another must refer to the same three character locations. Also,
- it's legal to map the storage in ways like this (an example from the
- standard):
- CHARACTER A*4, B*4, C(2)*3
- EQUIVALENCE (A,C(1)), (B,C(2))
- 01 02 03 04 05 06 07
- ------------A--------------
- -------------B-------------
- --------C(1)------- -------C(2)--------
-