Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!agate!brahms.berkeley.edu!raymond From: raymond@brahms.berkeley.edu (Raymond Chen) Newsgroups: comp.lang.c Subject: (Fortran|Pascal) to C conversion, a summary Message-ID: <1990Sep22.042603.17404@agate.berkeley.edu> Date: 22 Sep 90 04:26:03 GMT Sender: usenet@agate.berkeley.edu (USENET Administrator) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Followup-To: poster Organization: U.C. Berkeley Lines: 272 Seeing as (Fortran|Pascal)-to-C conversion seems to be going the rounds again (doesn't anyone read the FAQ any more...), I thought I'd post my prerecorded messages for public perusal/comment. I would greatly appreciate any additions, corrections, complaints, regarding the information presented below. Fortran to C conversion: Karen Anderson (anderson@eecs.cs.pdx.edu) did a lot of work in collecting this information. Standard disclaimers apply. Opinions are those of the original authors. Typing and editing errors are mine. =============================================================================== f2c ------------------------------------------------------------------------------- Article by Mark.Maimone@a.gp.cs.cmu.edu Source for f2c, a Fortran 77 to C translator jointly developed by folks from Bell Labs, Bellcore, and Carnegie Mellon, is now freely available. The main "problems" are that f2c does no code restructuring (e.g., gotos are preserved) and that Fortran I/O gets converted into a bunch of calls; thus the translated C code doesn't look too pretty, and in general one would need to maintain the Fortran rather than its translation into C. [Indeed, maintainable C code was specifically *not* an objective of the f2c project. The intent is that you maintain the Fortran. The f2c tech report comments that producing maintainable C automatically seems to require some amount of manual intervention even using commercial ($$$) translator programs. -- Henry Spencer] For additional info, send E-mail to netlib@research.att.com or research!netlib consisting of the single line "send index from f2c". To get it using anonymous FTP, ftp research.att.com and cd to directory dist/f2c. All files are stored in compressed format. [Make sure to pick up the runtime libraries libf77 and/or libi77.] ------------------------------------------------------------------------------- black@seismo.CSS.GOV (Mike Black) reports: I tried using f2c from the at&t distribution. If your desperate, it might be worth it. But the code is a nightmare to read. I've done hand conversions before with much better results than f2c. ------------------------------------------------------------------------------- Larry Jones writes: I haven't used f2c myself, but it's gotten rave reviews from others here who have used it: ------------------------------------------------------------------------------- zardoz!tmiuv0!rick@decwrl.dec.com (Rick Stevens) says: There's a huge bugger from ATT Bellcore called F2C. It's written in C (natch) and is FTPable. It's big, and you'll have to build it for your system, however it does work and works quite well. ------------------------------------------------------------------------------- And from Hans Georg v. Zezschwitz : I'm am currently trying to work with the standart f2c (from netlib@att...) Till now I made only one attempt with a Fortran program from a microVax. It was for parametrization of eeg-segments. Apart from screen-specific adaptions I had to edit it worked directly on a Unix (Xenix) system (under C - of course). For I rather don't know much about Unix nor Fortran I otherwise anyway would not have coped with occuring problems. =============================================================================== Cobalt Blue ------------------------------------------------------------------------------- ubbpc!wgh@PRC.Unisys.COM (William G. Hutchison) writes: We have had a client port an X-window application successfully from FORTRAN to C using the Cobalt Blue converter. ------------------------------------------------------------------------------- Tim.Ouellette@FtCollins.ncr.com says: Of the Fortran-to-C convertors I've seen. They've dealt with the simple commands okay. The main downfall I've seen is that they don't have any way of dealing with the FORTRAN 'EQUIVALENCE' statement. I've listed one's I seen advertised below. Hope it helps. FOR_C by Cobalt Blue 2940 Union Ave, Ste C San Jose CA 95124 (408)723-0474 ------------------------------------------------------------------------------- Ralph Carpenter (ralphc@tekcae.CAX.TEK.COM) adds, A demo disk is available for around $10. It converts subroutines that are less than 1K in size. The address and phone of a mail order source: The Programmer's Connection 7249 Whipple Ave NW North Canton, OH 44720-7137 (800) 336-1166 Price as of 1 Jan 1990 (including surface UPS shipping): $442 with binary runtime, ($575 list). $673 with runtime sources, ($875 list). =============================================================================== Promula.Fortran ------------------------------------------------------------------------------- orszak@cfa243.harvard.edu (Jeff Orszak) sent a post which appeared on comp.lang.fortran written by tohanson@gonzo.lerc.nasa.gov (Jeff Hanson). In Digital Review (June 18, 1990) there is a review of Promula.Fortran, a Fortran to C source code translator on pages 29 - 31. The Test Brief follows Vendor: Promula Development Corp. 3620 N. High St. Suite 301 Columbus, OH 43214 (614) 263-5454 Test configuration: Promula.Fortran version 2.01 installed on a VAXstation II/GPX running VMS 5.2 Price as Tested: $995. Pros: Includes many command line options Can produce various "flavors" of C code Supports all VAX Fortran data types except REAL*16 Successfully translated STRUCTURE and RECORD decalarations including UNION and MAP statements Cons: I/O subroutine library did not work properly with ANALYSIS and PHILCO (2 of the DR Labs test programs) Defaulted to pointer notation for representing arrays, which is unclear and less efficient in VAX C Required dialect and error message files to be copied to current working directory for translation Used double quotes for include file specifications but incorrectly defines VAXC$INCLUDE rather than C$INCLUDE Non VMS-style command line options The final 2 paragraphs of the review are: With the exception of some undesirable default options, less-than-ideal handling of some I/O statements and unsatisfactory handling of the DATA statement, Promula.Fortran is a very useful utility for users who must translate large amounts of Fortran to C. It translates quickly and generates well-written and - with some expections - immediately executable C code. Promula.Fortran has options that give users control over the C code produced. Promula.Fortran's C code is very amenable to C programmers; it uses C language conventions and, to put it simply, "feels" like C. I have not seen this product and this posting should not be seen as an endorsement for Promula. It should be seen as a high endorsement for DR Labs. =============================================================================== for2c ------------------------------------------------------------------------------- daveo@mipon3.intel.com (David O'Brien) writes: I worked with a program about 18 months ago called for2c or something like that. It was DOS based. I delt with the designer himself and had good success. If you would like, I can go dig the name/company up for you. I know right were they are at home. Let me know. =============================================================================== A masters thesis ------------------------------------------------------------------------------- Roger Christman (dvl@psuvm.bitnet) is working on a Fortran-to-C translator for his Masters thesis at Penn State U. Here's what he says: It is designed to accept any Fortran 66 program and translate it into an equivalent C source. Program flow structure is analyzed so that even the messiest GOTO arrangements should find themselves better approximating such things as loops and switches. ... The upshot of all this is that the resulting program will be more intuitively structured, as well as more efficient than the original. As an example of current benchmarks, using the F77 and CC compilers on a Sun Workstation Unix machine, my program is doing quite well. The time required to translate into C and compile there is less than the original Fortran compilation time. Also, the object code in C executes faster than the original Fortran. If you would like to find out more later on, when I approach the end of the project, please send me mail at this address. I must warn you that this project is for academic reasons alone, and is not designed with production-scale error-checking. If your program will not compile in Fortran 66, don't expect this translator to give you very meaningful results. =============================================================================== General comments ------------------------------------------------------------------------------- On the subject of source code conversions in general ittc!fbresz@uunet.UU.NET gets the last word: Hi, I have seen this question asked a few time and I finally decided to send an email to someone so .. I used to work for a company involved in such business. We would for a price take your working FORTRAN code and convert it to C. Now this was not cheap nor was it easy. I spent 1 entire year of my life on a project which bore little fruit. So I am of the opinion that it might just be easier to recode. Also you might want to think about waht you mean by translation, we of course had the bizarre definition, runs identically to FORTRAN. This leads into reproducing all the bizarre behaviours of FORTRAN and if you think thats hard try doing PL/I => C we also did that or how about PL/I => Ada. For these reasons (i.e. my brain is fried) I no longer do much programming. I run a medium sized network for Westinghouse in which the biggest programming task is getting sendmail.cf files workking correctly . But seriously if you would care to have even more information about translation, the company I used to work for has long since evaporated. I can then tell you anything you want to know without problems of revealing corporate secrets. Frank P. Bresz }*{ ITTC Network Administrator [In the realm of Pascal-to-C conversion, I don't quite have so much to report, perhaps because Mr. Gillespie's converter is so comprehensive.] Pascal-to-C conversion: Two different Pascal-to-C converters are available from a comp.sources.unix archive near you. volume10: ptoc/part[01-02] Pascal to C translator volume13: pas2c.pch Patches for Pascal-to-C translator volume21: p2c/part[01-32] Pascal to C translator " p2c/patch1 Fix to incomplete shar files for p2c, Patch1 I do not know whether or not they are essentially distinct programs. Here is the blurb that came with the one in Volume 21: |Submitted-by: Dave Gillespie | |This is p2c a Pascal to C translator. This is the second one in |comp.sources.unix; the first one ptoc, appeared in volume 10. | |P2c understands several Pascal dialects (HP, partial Turbo, etc) and |is very flexible and configurable. | |P2c was originally developed on a homebrew C compiler on the HP Pascal |Workstation operating system. Current development takes place on HP-UX, |which is System V based. The translator has also been compiled and used |on Sun-3's, so presumably it is fairly portable among 32-bit Unix machines. The p2c package is also available for ftp from csvax.caltech.edu. Phillip A. McReynolds (pam1@pam1@ra.MsState.Edu) mentioned the program mars.ee.msstate.edu[130.18.64.3]:/files/sources/tpc.arc when the question was raised on 26 June 1990 on comp.sys.ibm.pc. Many other IBM-specific "pascal-to-c" conversion programs can be found in the standard places, as described in the Frequently Asked Questions for comp.sys.ibm.pc.misc.