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

  1. Xref: sparky comp.lang.c:20115 comp.lang.fortran:5148
  2. Newsgroups: comp.lang.c,comp.lang.fortran
  3. Path: sparky!uunet!newsflash.concordia.ca!nstn.ns.ca!cs.dal.ca!biome!silvert
  4. From: silvert@biome.bio.ns.ca (Bill Silvert)
  5. Subject: Re: calling a Fortran subroutine from a C program
  6. Message-ID: <1993Jan23.152153.7178@biome.bio.ns.ca>
  7. Reply-To: silvert@biome.bio.dfo.ca (Bill Silvert)
  8. Organization: Habitat Ecology Div., Bedford Inst. Oceanography
  9. References: <1993Jan22.190624.23084@chpc.utexas.edu> <1993Jan22.200839.8352@sol.ctr.columbia.edu> <1993Jan22.233618.17814@chpc.utexas.edu>
  10. Distribution: na
  11. Date: Sat, 23 Jan 1993 15:21:53 GMT
  12. Lines: 30
  13.  
  14. In <1993Jan22.233618.17814@chpc.utexas.edu> michael@chpc.utexas.edu (Michael Lemke) writes:
  15.  
  16. >Not quite.  To make it really clear:  The difference is
  17. >    CHARACTER*100 STRING
  18. >or
  19. >    CHARACTER*1 STRING(100)
  20. >which are very different data structures.   The latter is an array, the
  21. >first is a single variable.  I don't care how C chews its memory, it can
  22. >hardly distinguish these two cases.  The last is pretty close in
  23. >functionality to C's concept (except for having a length stored
  24. >somewhere) as you'd need something like strcpy to copy data.
  25.  
  26. It seems to me that there would be absolutely no difference in memory
  27. allocation between these two cases, and that they would appear identically
  28. to a C program.  Thus in terms of passing them to a C program I can't
  29. see what the difference would be.  The only difference is how the Fortran
  30. code refers to them.
  31.  
  32. So far as C is concerned, the value of string_(n-1) can be interpreted
  33. equally well as the nth byte in the string string_, or as the nth
  34. member of an array of one-byte strings.
  35.  
  36. Caveat: I have been told in the past that there is no requirement for
  37. Fortran to allocate contiguous memory for arrays, but since I have never
  38. run into a case where this was not done I don't worry about it.
  39. -- 
  40. ------------------------------------------------------------------------
  41. William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography
  42. P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2.  Tel. (902)426-1577
  43. InterNet Address: silvert@biome.bio.dfo.ca
  44.