Difference between revisions of "F2c"
(f2c defaulted to some XSUM nonsense, so tell it to make f2c... ooops.) |
(fix some things...) |
||
Line 3: | Line 3: | ||
F2C can be downloaded from http://www.netlib.org/f2c/ | F2C can be downloaded from http://www.netlib.org/f2c/ | ||
− | == | + | == Installing == |
− | F2c is | + | F2C will build for MS-DOS (DPMI), Win32, and most UNIX. The biggest issue I've had testing has been the [[Dec Alpha]] because it's floating point seems to be too different. |
+ | |||
+ | F2c is somewhat straightforward to install... The two big 'camps' are Unix and Windows. | ||
+ | |||
+ | === Unix/MinGW === | ||
+ | For UNIX systems it's easier to install tar.gz's here: | ||
+ | *http://vpsland.superglobalmegacorp.com/install/f2c/f2c.tar.gz | ||
+ | *http://vpsland.superglobalmegacorp.com/install/f2c/libf2c.tar.gz | ||
Simply extract and run: | Simply extract and run: | ||
<pre> | <pre> | ||
+ | tar -zxvf f2c.tar.gz | ||
+ | cd f2c | ||
make -f makefile.u f2c | make -f makefile.u f2c | ||
</pre> | </pre> | ||
Line 19: | Line 28: | ||
If all went well you should have a f2c command. | If all went well you should have a f2c command. | ||
− | Next you'll need to download and build the IO library | + | Next you'll need to download and build the IO library |
Simply extract and run: | Simply extract and run: | ||
<pre> | <pre> | ||
+ | tar -zxvf libf2c.tar.gz | ||
+ | cd libf2c | ||
make -f makefile.u | make -f makefile.u | ||
</pre> | </pre> | ||
Line 30: | Line 41: | ||
cp libf2c.a /usr/local/lib | cp libf2c.a /usr/local/lib | ||
</pre> | </pre> | ||
+ | |||
+ | === Visual C++/MS-DOS === | ||
+ | F2c can also be built using Visual C++. The key here is that you'll have to use the .vc makefiles. | ||
+ | For Windows/MS-DOS users it's easier to download these zip files: | ||
+ | |||
+ | *http://vpsland.superglobalmegacorp.com/install/f2c/f2c.zip | ||
+ | *http://vpsland.superglobalmegacorp.com/install/f2c/libf2c.zip | ||
+ | |||
+ | then simply unzip f2c.zip somewhere, then using the CLI tools simply | ||
+ | |||
+ | <pre> | ||
+ | nmake -f makefile.vc f2c.exe | ||
+ | </pre> | ||
+ | |||
+ | == Test program == | ||
Now you should be able to build a simple FORTRAN program like this: | Now you should be able to build a simple FORTRAN program like this: |
Revision as of 18:43, 14 April 2010
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 will build for MS-DOS (DPMI), Win32, and most UNIX. The biggest issue I've had testing has been the Dec Alpha because it's floating point seems to be too different.
F2c is somewhat straightforward to install... The two big 'camps' are Unix and Windows.
Unix/MinGW
For UNIX systems it's easier to install tar.gz's here:
- http://vpsland.superglobalmegacorp.com/install/f2c/f2c.tar.gz
- http://vpsland.superglobalmegacorp.com/install/f2c/libf2c.tar.gz
Simply extract and run:
tar -zxvf f2c.tar.gz cd f2c make -f makefile.u f2c
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
Simply extract and run:
tar -zxvf libf2c.tar.gz cd libf2c make -f makefile.u
Then run:
cp libf2c.a /usr/local/lib
Visual C++/MS-DOS
F2c can also be built using Visual C++. The key here is that you'll have to use the .vc makefiles. For Windows/MS-DOS users it's easier to download these zip files:
- http://vpsland.superglobalmegacorp.com/install/f2c/f2c.zip
- http://vpsland.superglobalmegacorp.com/install/f2c/libf2c.zip
then simply unzip f2c.zip somewhere, then using the CLI tools simply
nmake -f makefile.vc f2c.exe
Test program
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!