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

  1. Xref: sparky comp.lang.c:20082 comp.lang.fortran:5129
  2. Newsgroups: comp.lang.c,comp.lang.fortran
  3. Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!michael
  4. From: michael@chpc.utexas.edu (Michael Lemke)
  5. Subject: Re: calling a Fortran subroutine from a C program
  6. Message-ID: <1993Jan22.190624.23084@chpc.utexas.edu>
  7. Organization: The University of Texas System - CHPC
  8. References: <1jmqdaINN11g@mudhoney.mathcs.emory.edu> <1993Jan22.130743.27130@sol.ctr.columbia.edu>
  9. Date: Fri, 22 Jan 93 19:06:24 GMT
  10. Lines: 48
  11.  
  12. In article <1993Jan22.130743.27130@sol.ctr.columbia.edu> bobp@msi.com (Bob Pitha) writes:
  13. >Scott White (swhite@mathcs.emory.edu) wrote:
  14. >: Can someone please tell me how to call a Fortran subroutine from a C program?
  15. >: The environment is sun4, OS 4.1.2.
  16. >
  17. >Sure, this isn't really that hard as long as you keep a few basic issues in
  18. >mind:
  19. >
  20. [...]
  21. >
  22. >4) Character arrays: For each character array in the argument list, there
  23.               ^^^^^^
  24. > should be a long int at the end of the argument list specifying the
  25. > *declared* length of the array - that is, how much space is allocated
  26. > for it.  Since Fortran blank-fills character arrays, this number will
  27. > specify how many places to fill.  If you have more than one character
  28. > array in the argument list, the length arguments should be in the same
  29. > order as the character arguments.
  30. >
  31. [...]
  32. > (and now the Fortran part)
  33. >
  34. >      subroutine MyFortranSub (int_arg, float_arg, int_array,
  35. >     +                         int_matrix, string)
  36. >      integer       int_arg
  37. >      real          float_arg
  38. >      integer       int_array (3)
  39. >      integer       int_matrix (3, 4)
  40. >      character*(*) string
  41.                      ^^^^^^
  42.  
  43. You are not talking about character arrays at all in your post.  A 
  44. character array is something you declare as
  45.  
  46.     character*(*) string(10)
  47.  
  48. which is an array of strings.  You talked just about plain character
  49. strings.  Keep the terms clear.  Passing of character arrays is a bit
  50. harder than what you described I believe (I might be wrong) but I don't
  51. have my Sun manual handy to point out the differences.  Someone else
  52. might.  But as you have suggested (which I deleted for brevity) reading
  53. the Sun Fortran manual is worth doing.  It deals with all these issues.
  54.  
  55. Michael
  56. -- 
  57. Michael Lemke
  58. Astronomy, UT Austin, Texas
  59. (michael@io.as.utexas.edu or UTSPAN::UTADNX::IO::MICHAEL [SPAN])
  60.