F2c

From Computer History Wiki
Revision as of 02:05, 26 October 2009 by Neozeed (talk | contribs) (New page: While not really a compiler, f2c is based on the UNIX FORTRAN compiler, but as it used the same backend as the C compiler, f2c emits C, which in turn can be compiled by the nat...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

While not really a compiler, f2c is based on the UNIX FORTRAN compiler, but as it used the same backend as the C compiler, f2c emits C, which in turn can be compiled by the native compiler.

F2C can be downloaded from http://www.netlib.org/f2c/

installing

F2c is easy to install, you can download the source here: http://vpsland.superglobalmegacorp.com/install/f2c/f2c.tar.gz

Simply extract and run:

make -f makefile.u

Then run:

cp f2c /usr/local/bin
cp f2c.h /usr/local/include

If all went well you should have a f2c command.

Next you'll need to download and build the IO library http://vpsland.superglobalmegacorp.com/install/f2c/libf2c.zip

Simply extract and run:

make -f makefile.u

Then run:

cp libf2c.a /usr/local/lib

Now you should be able to build a simple FORTRAN program like this:

hello.f

      program hello 
      print *, 'Hello!' 
      end

Then run:

bash-2.01$ f2c hello.f 
hello.f: 
   MAIN hello: 
bash-2.01$ cc hello.c -lf2c -o hello 
bash-2.01$ file hello 
hello:  Mach-O executable (for architecture m68k) not stripped 
bash-2.01$ ./hello 
Hello!