No announcement yet.

Summary about Fortran to C request

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Summary about Fortran to C request

    Dear Biomch-l Readers,

    Here is the summary of the request I made a few days ago.

    Original Request:

    > I'm looking for a software able to translate Fortran 77 source
    > into ANSI C. Does someone know the name of such a tool and/or the name of the
    > company for the distribution ?
    > Thank you for any help !

    ************************************************** ************************

    In summary: there is a public software F2C available via Netlib. FTP
    protocol as well as e-mail request can be used (see message from
    T. van den Bogert).
    I tried several time via FTP, but despite all the advices I received
    (see below) no attempt succeed. So, at last I used e-mail and it worked very
    A mention to another software (FORC) is made by Rene Steiner.
    Note the mail from Jesus Dapena about the structure of the Makefile to
    use with F2c.

    Serge Van Sint Jan (sabattical)
    Paul W. Brand Research Laboratory
    Carville, Louisiana

    PS: Networks and mailing-lists are really nice tools, aren't they ?!

    **** Ulrich Hahn's first mail*******************************************

    Try using f2c, here is how to get it:

    F2c is being maintained at; ftp there, login as netlib
    and cd to f2c.

    Hope this helps,

    PS: Since this topic could be of interest for others too, how about
    a summary of replies.

    : Ulrich Hahn : Sorry I got only 4 lines, :
    : Department of biomechanics : thats not enough space for:
    : Institute of Theoretical Astrophysics : my lifetime story ... :

    **** Rene Steiner mail ************************************************** ******

    I had the same problem some time ago and I found out that there is a
    public domain package by AT&T called f2c. This is available on many FTP
    sites. However, the authors do not claim that the conversion program
    provides maintainable code. In my experience (which dates from early
    1992) the code could only provide a basis for a manual conversion,
    especially because I/O and array management is very clumsy. This comes
    from the goal that the executable be exactly identical to the one produced
    by a specific FORTRAN compiler in their lab...

    More useful, but unfortunately beyond our budget at the time is FORC
    by Cobalt Blue, 875 Old Roswell Road, Suite D-400, Roswell, GA 30076, USA
    (Tel. (404) 518-1116, FAX: (404) 640-1182). They sent me a demo of their
    program which was limited to some 50 lines of FORTRAN source code. The
    C code produced by this was close to the maximum one could expect from
    a mechanical conversion. At the time the package cost about 1000$.

    What I finally did was to use the f2c output as a base and to use the
    demo version of FORC for seperate critical code segments - and to do
    most of the work manually. However, to me standard programming philosophy
    of FORTRAN77 differs significantly from current C practice so that one
    cannot avoid considerable additional programming when switching languages.

    Hope this helps a bit, although it is probably encouraging only if you
    are either rich or do not need maintainable code :-)

    Cheers, Rene

    | Rene Steiner | |
    | Neurologisches Therapiecentrum | phone: +49-211-7816-159 |
    | Hohensandweg 37 | FAX: +49-211-784 353 |
    | D-40591 Duesseldorf | |
    | Germany | |
    | A nod's as good as a wink to a blind bat (Monty Python, Nudge Nudge) |

    **** Ian Nimmo-Smith's mail ************************************************

    The package called f2c is what you want. You will be able to find it on
    a variety of ftp servers, though it is maintained in the netlib server
    at (AT&T I Think) in the directory /netlib/f2c You
    have to build a version for your system. There are MSDOS and Unix

    You use f2c to translate prog.f to prog.c Then, apply cc to prog.c
    and link prog.o with two special libraries (supplied in the f2c

    I have used it quite successfully to port substantial Fortran code to
    run on a system that does not have a Fortran compiler. The new
    executable performed identically (at the level of numerical input and
    output) to the original. The resulting C code is n o t readily
    maintained or adapted.

    Best wishes



    Ian Nimmo-Smith MRC Applied Psychology Unit
    15 Chaucer Road
    Tel: +44 223-355294 Cambridge CB2 2EF
    Fax: +44 223-359062 email:

    **** Taieb Argoubi's mail **********************************************


    There is a public program called f2c .... you can get it from this public site: in /pub/f2c/src

    Good luck

    ################################################## ###############
    # Med Taieb ARGOUBI, Graduate Student # Ecole Polytechnique #
    # Institut de Genie Biomedical # C.P. 6079, Succ. A #
    # e-mail: # Montreal H3C3A7, Canada #
    # Tel: (514) 340-4182 # Fax: (514) 340-4611 #
    ################################################## ###############

    **** John Peach's first mail ******************************************

    There is a program called F2C there is many FTP sites that have a copy of this
    program. I do not know right off the top of my head any specific site
    that has it. Use Archie and try to locate it. If you do not know how to
    due this I can do it for you. I have a meeting and cannot due it right
    now. Let me know if you want a search done.



    * John P. Peach * Dalhousie Univerisy *
    * JPEACH@AC.DAL.CA * Halifax, Nova Scotia *
    * PEACH@UG.CS.DAL.CA * Canada *

    **** Ton van den Bogert's mail ********************************************

    A public domain version is available from Netlib. See the
    'Introduction to Netlib', appended to this message. The Biomch-L
    archives for September 1991 and January 1992 contain some useful
    information about this particular translator software. Further
    comments are welcome.

    -- Ton van den Bogert, Biomch-L moderator

    Forwarded message:
    From: (Frederick W. Chapman)
    Newsgroups: sci.math.num-analysis
    Subject: Introduction to NETLIB (Revised July 1992)
    Date: 27 May 93 15:19:13 GMT
    Organization: Lehigh University

    Introduction to NETLIB

    Frederick W. Chapman
    Senior User Consultant
    Lehigh University Computing Center

    July 7, 1992

    1. General Description

    NETLIB is a network-based facility for the automated
    distribution of the source code for public domain scientific
    software. Most of this software is written in FORTRAN, but some
    software is available in C, C++, and PASCAL. Software is
    available for a wide variety of applications. The following list
    -- which is far from exhaustive -- should give the reader an idea
    of the scope of the NETLIB collection.


    * Linear Algebra (eigenvalue and eigenvector computations,
    matrix factorizations, least squares)
    * Sparse Matrix Calculations
    * Numerical Optimization
    * Spline Interpolation
    * Ordinary and Partial Differential Equations
    * Fast Fourier Transforms
    * Special Functions


    * Collected algorithms of the ACM "Transactions on
    Mathematical Software" (TOMS)
    * LAPACK, LINPACK, EISPACK, and BLAS subroutine libraries
    * AMS TeX and SIAM typesetting macros
    * MATLAB applications packages


    * Libraries for supporting parallel computation
    * Libraries for computation on vector-processor machines


    * Packages supporting multiple-precision floating-point arith-
    metic (e.g., Brent's MP; Smith's FM, from TOMS algorithms)
    * Benchmark programs for comparing computing platforms
    * Collections of problems for testing numerical software
    * Programming aids such as single-precision-to-double-
    precision and FORTRAN-to-C conversion utilities
    * Companion software to various textbooks (e.g., Cheney and
    Kincaid; Forsythe, Malcolm, and Moler)
    * Bibliographies

    2. NETLIB Mail Servers

    Information (such as NETLIB usage instructions) and software
    (such a routine from LAPACK or an algorithm from the ACM TOMS)
    can be obtained by sending requests -- via electronic mail -- to
    a NETLIB mail server at one of the following Internet addresses: (AT&T Bell Labs, New Jersey, USA) (Oak Ridge Nat. Lab, Tenn., USA) (Univ. of Kent, UK) (Oslo, Norway) (U. of Wollongong, NSW, Australia)

    Upon receipt of an appropriately worded request, the NETLIB
    mail server responds by sending the information or software
    requested to the electronic mail address of the requestor.
    Depending on your location, the amount of network traffic, and
    other factors, you may actually receive a reply within minutes of
    submitting your request! Note that the software available may
    differ slightly from one NETLIB site to another.

    3. Accessing NETLIB via Electronic Mail

    To obtain more detailed instructions on the use of NETLIB,
    as well as an index of the software currently available from a
    particular NETLIB site, send an electronic mail (e-mail) message
    containing the line

    send index

    to a NETLIB mail server listed in Section 2 (usually the site
    which is geographically closest).

    The collected algorithms of the ACM journal, "Transactions
    on Mathematical Software" (TOMS), constitute a particularly
    worthwhile part of the NETLIB collection. To obtain an index to
    the ACM TOMS algorithms available from NETLIB, include the
    following line in your e-mail message to a NETLIB mail server:

    send index from toms

    Many of the NETLIB packages make use of a collection of
    routines referred to as the CORE library, which contains routines
    for determining machine-dependent constants (e.g., the machine
    epsilon), and a set of Level 1, 2, and 3 Basic Linear Algebra
    Subprograms (BLAS). To obtain an index to the CORE library,
    include this line in your e-mail message:

    send index from core

    Note that some mail trailers may "confuse" the NETLIB mail
    servers. If you encounter problems, you might consider
    suppressing the use of your usual signature file when sending
    requests to NETLIB via e-mail.

    4. Accessing NETLIB via FTP

    In addition to the standard e-mail method for accessing the
    NETLIB software, the AT&T Bell Laboratories site also provides
    access to the NETLIB software via FTP; simply run FTP locally and
    connect to the Internet node "", login with user-
    name "netlib" (in lowercase), and give anything as the password.
    The individual NETLIB libraries are arranged in separate subdi-
    rectories; for example, the ACM TOMS algorithms are stored in a
    subdirectory named "toms", and the CORE library is stored in a
    subdirectory named "cor" (*not* "core", oddly enough).

    Note that accessing NETLIB via FTP makes it easier to obtain
    *all* of the routines in a particular library, but requires a
    greater degree of sophistication on the part of the user; i.e.,
    the user must possess a certain amount of network and UNIX savvy,
    and a solid understanding of how the NETLIB collection is
    organized. Accessing NETLIB via e-mail rather than FTP is
    recommended for new users, since the NETLIB mail servers
    automatically resolve subroutine dependencies (which must
    otherwise be resolved manually).

    5. X-Windows Version of NETLIB

    In addition to the standard e-mail based NETLIB, the Oak
    Ridge National Laboratory site supports "XNETLIB" -- a new, X-
    Windows version of NETLIB. According to a recent announcement,
    "XNETLIB uses an X-Window graphical user interface and a socket-
    based connection between the user's machine and the XNETLIB
    server machine to process software requests". Of course, XNETLIB
    requires that the user's computer or terminal be capable of
    supporting X-Windows. The user will therefore need an engineering
    workstation that runs X-Windows, or an X-terminal, or a personal
    computer with X-terminal emulation software in order to take
    advantage of the benefits of XNETLIB.

    To obtain a copy of XNETLIB, send e-mail to the NETLIB mail
    server "" containing the lines

    mailsize 300k
    send xnetlib.shar from xnetlib

    Upon receiving the shar file via e-mail, save the message to a
    file (say, a file named "xnetlib.temp"), edit the file to remove
    the mail header, and then issue the UNIX commands

    sh xnetlib.temp
    sh xnetlib.shar

    After this, follow the instructions in the README file. Comments
    on XNETLIB should be directed via e-mail to "".


    o ------------------------------------------------------------------------- o
    | Frederick W. Chapman, User Services, Computing Center, Lehigh University |
    | Campus Phone: 8-3218 Preferred E-mail Address: fc03@Lehigh.Edu |
    o ------------------------------------------------------------------------- o
    | Ecstasy is transitory, but a theorem is forever! |
    o ------------------------------------------------------------------------- o

    **** Jesus Dapena's mail **************************************************


    Let's try to do this through ftp. Try the following:

    ftp (or ftp

    To the prompt "Name", answer: anonymous
    To the prompt "Password", answer: anything
    You will find yourself in the directory "ftp"
    Then type the following:

    get f2c.h

    Then, you can use f2c.h to translate your fortran programs. Here is an
    example of a standard script file (or procedure file) of the type that I use
    (in Unix) to run my programs (which are always in fortran) with a
    translation into c inserted in the instructions. I thought you might find
    it useful.

    # Procedure file PROCGHJPROF
    ln /well/dapena/hj/mtri/t/wri48t FILE2
    ln /well/dapena/hj/mtri/b/wri48b FILE3
    ln /well/dapena/hj/mtri/r/wri48xr FILE4
    ln /well/dapena/hj/mtri/g/wri48xg FILE55
    ln reuse FILE7
    f2c /well/dapena/hj/prog/ghjprof.f
    cc -w -I/usr/include/f2c -c ghjprof.c
    cc ghjprof.o /well/dapena/grafbm/grafbmu.o /well/dapena/grafbm/gbmtran.o
    -lplotF -lplot -lf2c
    chmod u+x a.out
    rm -f out
    a.out > out
    #psplot -g/usr/lib/transcript/ Can you help me, please ?
    > I login, go to the f2c/src directory, ask to get the files with SEND f2tc.1.z.
    > Then I receive the following prompt:
    > to remote file:
    > I presume I have to type the name of the file of our system, but it doesn't
    > work. I only receive an error message "bad file format".
    > Any suggestion ?

    **** John Peach's second mail ********************************************


    ftp defaults to ascii mode ie. it thinks that everything that you want to
    transfer is a text file. You have to tell it that you want to transfer a
    binary file. To do this just type BIN. Then use the GET command to have
    the file sent to you. It will ask you for a remote name. Just press RETURN
    and it will use the current file name.

    I hope that this helps



    * John P. Peach * Dalhousie Univerisy *
    * JPEACH@AC.DAL.CA * Halifax, Nova Scotia *
    * PEACH@UG.CS.DAL.CA * Canada *

    **** Ulrich Hahn's second mail **************************************

    I can't see what's wrong! I tried it myself without any problem.
    But if you want to get all the files try:
    $ftp [cant.remember].com
    [the machine will prompt with something like]
    (user-name) netlib
    ftp> cd f2c
    ftp> cd src
    ftp> prompt
    [this will toggle prompting]
    promtping turned off
    ftp> mget *
    [that's all]

    If this doesn't work ask me again.

    : Ulrich Hahn : Sorry I got only 4 lines, :
    : Department of biomechanics : thats not enough space for:
    : Institute of Theoretical Astrophysics : my lifetime story ... :