home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16341 < prev    next >
Encoding:
Text File  |  1992-11-11  |  2.8 KB  |  59 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!utcsri!newsflash.concordia.ca!mizar.cc.umanitoba.ca!access.usask.ca!news
  3. From: reeves@rocky1 (Malcolm Reeves)
  4. Subject: Re: Fortran to C conversion: Why bother?
  5. Message-ID: <1992Nov11.181159.23196@access.usask.ca>
  6. Sender: news@access.usask.ca (USENET News System)
  7. Nntp-Posting-Host: rocky1.usask.ca
  8. Reply-To: reeves@rocky1
  9. Organization: University of Saskatchewan
  10. References: <20849@fritz.filenet.com>
  11. Date: Wed, 11 Nov 1992 18:11:59 GMT
  12. Lines: 45
  13.  
  14. From article <20849@fritz.filenet.com>, by scotth@felix.filenet.com (Scott Hopson):
  15. > Keywords
  16. > In article <1992Nov9.131601.167@gems.vcu.edu> hleaves@gems.vcu.edu writes:
  17. >>I was wondering why anyone would bother using the f2c (or similar) program to
  18. >>translate fortran code directly into C. All you end up with is C code that
  19. >>exactly mimics the functionality of the original fortran code. Its not as if
  20. >>the translating program rewrites your algorithms to use the parts of C that
  21. >>make C really useful. Its just fortran code expressed in C. What's the point?
  22. >>If you're going to write programs in fortran, use a fortran compiler. If you
  23. >>want to use the features of C, learn C and use a C compiler. Using f2c doesnt
  24. >>give you any of the advantages of designing and writing the original program 
  25. >>in C.
  26.  
  27. Having tried all three options:
  28.  
  29. (1) maintain the fortran code and call it from C
  30. (2) use f2c to convert
  31. (3) rewrite the functions in C
  32.  
  33. I find that (3) is by far the most effective and often the fastest way of
  34. generating useable low maintenance code. (1) works well if the fortran does
  35. little or no I/O ,for example, numerical algorithms etc. (2) generates
  36. C code will all the advantages of fortran! The only situation in which it
  37. is useful is if you don't have a fortran compiler - you can use your C
  38. compiler only.
  39.  
  40. I would recommend hacking out all standalone fortran routines into a C
  41. callable library and rewriting I/O and user interfaces in C. When time is
  42. available - it never happens but just imagine - convert the fortran routines
  43. to C if you can't live with library calls.
  44.  
  45. There are a few problems with interfacing C and fortran but for a lot of 
  46. fortran code, learning how interface is a small overhead.
  47.  
  48. None of this should be taken as a critisism of f2c. It's a great utility
  49. and does exactly what it promises. You could consider turning your
  50. fortran code into a C library with f2c - but I find f2c C very hard to
  51. maintain - much more difficult than the original fortran - but then I'm
  52. old enough to remember fortran before f66.
  53.  
  54. --
  55. ------------------------------------------------------------------------------
  56. Malcolm Reeves, Geological Engineering, University of Saskatchewan, Saskatoon,
  57. SK, S7N 0W0 aka reeves@rocky1.usask.ca aka reeves@dvinci.usask.ca
  58. ------------------------------------------------------------------------------
  59.