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