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

  1. Xref: sparky comp.lang.c:20086 comp.lang.fortran:5132
  2. Newsgroups: comp.lang.c,comp.lang.fortran
  3. Path: sparky!uunet!usc!sol.ctr.columbia.edu!phoenix!bobp
  4. From: bobp@msi.com (Bob Pitha)
  5. Subject: Re: calling a Fortran subroutine from a C program
  6. Followup-To: comp.lang.c,comp.lang.fortran
  7. References: <1993Jan22.190624.23084@chpc.utexas.edu>
  8. Sender: nobody@ctr.columbia.edu
  9. Organization: Molecular Simulations, Inc.
  10. Date: Fri, 22 Jan 1993 20:08:39 GMT
  11. X-Newsreader: TIN [version 1.1 PL8]
  12. Message-ID: <1993Jan22.200839.8352@sol.ctr.columbia.edu>
  13. X-Posted-From: phoenix.msi.com
  14. NNTP-Posting-Host: sol.ctr.columbia.edu
  15. Lines: 40
  16.  
  17. Michael Lemke (michael@chpc.utexas.edu) wrote:
  18. : In article <1993Jan22.130743.27130@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
  19.    (edited a bit for brevity's sake)
  20. : >
  21. : >4) Character arrays: For each character array in the argument list, there
  22. :               ^^^^^^
  23.  
  24. : You are not talking about character arrays at all in your post.  A 
  25. : character array is something you declare as
  26.  
  27. :     character*(*) string(10)
  28.  
  29. : which is an array of strings.  You talked just about plain character
  30. : strings.  Keep the terms clear.  Passing of character arrays is a bit
  31. : harder than what you described I believe (I might be wrong) but I don't
  32. : have my Sun manual handy to point out the differences.  Someone else
  33. : might.  But as you have suggested (which I deleted for brevity) reading
  34. : the Sun Fortran manual is worth doing.  It deals with all these issues.
  35.  
  36.   This is really just an issue of semantics, but you're right that I wasn't
  37. very clear.  I was thinking in terms of an "array of type char" in C, so
  38. I just wrote what I was thinking.  As you point out, to a person who only
  39. knows Fortran the phrase "character array" may by misleading.  Unfortunately,
  40. this is an area where the concepts don't map well between the two worlds,
  41. since c doesn't have an official "string" type; a string is just a null-
  42. terminated array of characters.
  43.  
  44.   Passing "arrays of strings" (is that clear enough?) is perhaps a little
  45. bit harder, but not a whole lot.  I didn't touch on null-termination and
  46. blank-filling in my previous post because I didn't know whether the
  47. original questioner cared and it would have taken lots more space.  I
  48. stuck to the simple case of passing an array of characters to the Fortran
  49. routine.  If the Fortran routine were going to try to pass a string back
  50. to C, or if an array of strings were being passed, you have to deal with
  51. these issues.
  52.  
  53. -----------------------------------------------------------------------
  54. Bob Pitha                      Molecular Simulations Inc.
  55. bobp@msi.com                   16 New England Executive Park
  56. (617) 229-9800 x242            Burlington, MA 01803-5297
  57.