I am looking for an rpm or simple install instructions for getting f2c to work on my redhat linux os. I am new to linux and it is difficult finding something like this on google.
(The goal is to use f2c to convert a simple fortran77 file to c, then compile)
Does anybody have any suggestions?
You can get a precompiled f2c package from ATrpms: http://atrpms.net/name/f2c/ It does include both the headers (such as
f2c.h
) and the library (libf2c
) in standard directories, so you shouldn't have any trouble compiling after that.Otherwise, you could try to compile directly with a free Fortran compiler; try
gfortran
. If not installed, it's in packagegcc-gfortran
, so you can install it with the command:yum install gcc-gfortran
.Getting the source with rsync (recommended):
Getting the sources via FTP:
To build the sources, in the f2c/src directory do:
To install the binary, copy it to a directory in your $PATH:
To compile Fortran programs you will also need libf2c:
libf2c is a combination of the libF77 and libI77 libraries. You can install these libraries separately and then link with "-lF77 -lI77". Assuming f2c/src is available from the current directory, save libF77 and libI77 and do the following (not necessary if you have already installed libf2c above):
The fc shell script is a nice frontend to use with f2c. Save it somewhere and do:
I renamed it to f77 to avoid conflicts, since fc is a bash builtin. The fc script expects libf2c rather than libF77 and libI77, so you have to edit it and replace "-lf2c" with "-lF77 -lI77" if you have installed these libraries instead of libf2c above.
Finally, to compile your program you can do:
Also check out the f2c parent directory. It contains getopt.c, f2c.pdf and some other stuff that may be useful.
For more further information about f2c consult the readme (less f2c/src/readme) and the manpage (man f2c). For further information about the fc script look at the comments at the beginning of the file.