home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
prgramer
/
fortrn2c
/
readme
< prev
Wrap
Text File
|
1992-06-21
|
6KB
|
151 lines
f2c - FORTRAN to C translator - OS/2 2.0 version
================================================
1. Introduction
===============
This package contains f2c, a FORTRAN to C translator available from
netlib@ornl.gov, compiled for OS/2 v 2.0 using the GNU gcc21 compiler.
Support libraries for both GNU ports currently obtainable ('gcc21' and
'emx') are provided.
Using f2c, a FORTRAN77 program can be translated to C and can then be compiled
using gcc from one of the above GNU compilers. Tests indicate that this
procedure works well, even with some large and messy FORTRAN programs (3500
lines of spaghetti code). An improvement in execution time of up to a factor
of two can be expected, relative to the same program compiled with a 16-bit
compiler such as MS Fortran 5.x.
The package contains, in addition to this file, the following files:
f2c.exe -- FORTRAN to C translator
f2c.1 -- UN*X man page for f2c
f2c.1t -- man page in troff format
f2c.ps -- PostScript note on implementation of f2c
f2c.h -- C header file needed for C compilation
notice -- copyright stuff
disclaim -- disclaimer
libi77.a )
libf77.a )-- libraries for use with 'emx' compiler
libi77.lib )
libf77.lib )-- libraries for use ith 'gcc21' compiler
libc.zoo -- replacement C library for 'gcc21' with faster math
The last file contains a replacement C library for the 'gcc21' compiler
(libc.lib), which incorporates the assembler-based math functions from
the emx distribution, rather than the C-based math functions from the
gcc21 distribution. This leads to a large enhancement in performance.
Note, however, that the sin, cos and tan functions should have arguments
restricted to |x|<2^63 (and if you feel the need to calculate the sin of
such a large number, ponder a while on the representation of real numbers
on computers).
2. Installation
===============
After unpacking the archive in any convenient subdirectory, the various
bits and pieces can be installed as follows:
f2c.exe -- place somewhere in PATH.
f2c.h -- place in directory with other C header files.
*.a -- place in directory with other emx library files (e.g.\emx\lib)
*.lib -- place in directory with other gcc21 library files (e.g.\gnu\lib)
The documentation can be placed anywhere you find convenient.
If you want to use the modified C library with 'gcc21', rename your original
libc.lib (so you have it in reserve...) in, e.g. \gnu\lib, and copy in
the libc.lib from libc.zoo.
3. Use
======
f2c is restricted to translating one fortran file at a time (owing to
a lack of 'fork()' under OS/2). A file <name>.f is translated to a file
<name>.c.
The C file(s) are then compiled using gcc, and linked to the libraries
libi77 and libf77. In addition, the library libos2.a must be linked
when using the 'emx' compiler. For compilation of the C files, the file f2c.h
should be accessible to the compiler.
Example
-------
Compile a FORTRAN program consisting of two files proga.f and progb.f:
At command line... Comments...
f2c proga.f produces proga.c
f2c progb.f produces progb.c
For 'gcc21' compiler ...
gcc -c -O2 proga.c progb.c produces proga.obj, progb.obj
link386 proga+progb,,,libi77 libf77; produces proga.exe
(or)
link386 proga+progb,prog,proglst,libi77 libf77;
produces prog.exe, proglst.lst
(linker map)
For 'emx' compiler ...
gcc -o prog.exe -O2 proga.c progb.c -li77 -lf77 -los2
produces prog.exe
---
link386 as used above will produce a default exe file that can be run in both
windowed or full screen OS/2 cmd sessions. If this as what you require,
the L4071 warning can be ignored. For other cases, you will need to construct
a .def file; consult the link386 documentation (16-bit link docs might also
help you).
4. Notes
========
4.1) The port of f2c was complicated by differing behaviour of the two C
libraries (gcc21 and emx). No doubt, there are things in libi77 and libf77
that still don't work under one or the other compiler (or both).
If you suspect a problem with the libraries, please let me know at the
address below. If you suspect a problem with f2c itself, report it
as suggested in the f2c docs.
4.2) A few things have been added to the library to make it behave a little
more like other PC fortran libraries:
4.2.1 A null filename in an 'open' statement (i.e. OPEN(UNIT=6, FILE=' ',....)
will cause the next name on the command line to be used as the filename.
(f2c also has other ways of accessing the command line, see f2c.ps)
4.2.2 Time and date subroutines have been added:
subroutine gettim( ihour, imin, isec, i100 )
integer *2 ihour, imin, isec, i100
Returns current time, in ihour, imin and isec. (i100 is set to zero).
subroutine getdat( iyear, imonth, iday )
integer*2 iyear, imonth, iday
Returns current date.
4.2.3 Output to a device has carriage control characters expanded.
4.3) Note that f2c is a translator and probably won't let you get away
with a few things that your favourite FORTRAN compiler will permit.
For instance, the MS 5.0 compiler will allow you to branch to a block
of code that is physically outside a DO loop, but logically contained
within it (I don't think this is allowed in the FORTRAN77 standard).
f2c cannot analyse the code flow and will generate incorrect code,
but will issue a warning.
5 Comments, complaints, etc to:
===============================
Roger Fearick
Dept. of Physics,
University of Cape Town.
fearick@physci.uct.ac.za (yes, that's physci)