home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20258 < prev    next >
Encoding:
Internet Message Format  |  1993-01-29  |  1.8 KB

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