home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / fortrn2c / readme < prev   
Text File  |  1992-06-21  |  6KB  |  151 lines

  1. f2c - FORTRAN to C translator - OS/2 2.0 version
  2. ================================================
  3.  
  4. 1. Introduction
  5. ===============
  6.  
  7. This package contains f2c, a FORTRAN to C translator available from 
  8. netlib@ornl.gov, compiled for OS/2 v 2.0 using the GNU gcc21 compiler.
  9. Support libraries for both GNU ports currently obtainable ('gcc21' and 
  10. 'emx') are provided.
  11.  
  12. Using f2c, a FORTRAN77 program can be translated to C and can then be compiled
  13. using gcc from one of the above GNU compilers. Tests indicate that this 
  14. procedure works well, even with some large and messy FORTRAN programs (3500
  15. lines of spaghetti code). An improvement in execution time of up to a factor
  16. of two can be expected, relative to the same program compiled with a 16-bit 
  17. compiler such as MS Fortran 5.x.
  18.  
  19. The package contains, in addition to this file, the following files:
  20.  
  21. f2c.exe         -- FORTRAN to C translator
  22. f2c.1           -- UN*X man page for f2c
  23. f2c.1t          -- man page in troff format
  24. f2c.ps          -- PostScript note on implementation of f2c
  25. f2c.h           -- C header file needed for C compilation
  26. notice          -- copyright stuff
  27. disclaim        -- disclaimer
  28. libi77.a       )
  29. libf77.a       )-- libraries for use with 'emx' compiler
  30. libi77.lib     )
  31. libf77.lib     )-- libraries for use ith 'gcc21' compiler
  32. libc.zoo        -- replacement C library for 'gcc21' with faster math
  33.  
  34. The last file contains a replacement C library for the 'gcc21' compiler
  35. (libc.lib), which incorporates the assembler-based math functions from
  36. the emx distribution, rather than the C-based math functions from the
  37. gcc21 distribution. This leads to a large enhancement in performance.
  38. Note, however, that the sin, cos and tan functions should have arguments
  39. restricted to |x|<2^63 (and if you feel the need to calculate the sin of 
  40. such a large number, ponder a while on the representation of real numbers
  41. on computers). 
  42.  
  43.  
  44. 2. Installation
  45. ===============
  46.  
  47. After unpacking the archive in any convenient subdirectory, the various 
  48. bits and pieces can be installed as follows:
  49.  
  50. f2c.exe     -- place somewhere in PATH.
  51. f2c.h       -- place in directory with other C header files.
  52. *.a         -- place in directory with other emx library files (e.g.\emx\lib)
  53. *.lib       -- place in directory with other gcc21 library files (e.g.\gnu\lib)
  54.  
  55. The documentation can be placed anywhere you find convenient.
  56.  
  57. If you want to use the modified C library with 'gcc21', rename your original 
  58. libc.lib (so you have it in reserve...) in, e.g. \gnu\lib, and copy in 
  59. the libc.lib from libc.zoo. 
  60.  
  61.  
  62. 3. Use
  63. ======
  64.  
  65. f2c is restricted to translating one fortran file at a time (owing to
  66. a lack of 'fork()' under OS/2). A file <name>.f is translated to a file 
  67. <name>.c.
  68.  
  69. The C file(s) are then compiled using gcc, and linked to the libraries
  70. libi77 and libf77. In addition, the library libos2.a must be linked
  71. when using the 'emx' compiler. For compilation of the C files, the file f2c.h 
  72. should be accessible to the compiler.
  73.  
  74. Example
  75. -------
  76. Compile a FORTRAN program consisting of two files proga.f and progb.f:
  77.  
  78. At command line...                      Comments...    
  79.  
  80. f2c proga.f                             produces proga.c
  81. f2c progb.f                             produces progb.c
  82.  
  83.                                         For 'gcc21' compiler ...
  84.  
  85. gcc -c -O2 proga.c progb.c              produces proga.obj, progb.obj
  86. link386 proga+progb,,,libi77 libf77;    produces proga.exe
  87.                                         (or)
  88. link386 proga+progb,prog,proglst,libi77 libf77;
  89.                                         produces prog.exe, proglst.lst
  90.                                         (linker map)
  91.  
  92.                                         For 'emx' compiler ...
  93. gcc -o prog.exe -O2 proga.c progb.c -li77 -lf77 -los2
  94.                                         produces prog.exe
  95.  
  96. ---
  97. link386 as used above will produce a default exe file that can be run in both
  98. windowed or full screen OS/2 cmd sessions. If this as what you require,
  99. the L4071 warning can be ignored. For other cases, you will need to construct
  100. a .def file; consult the link386 documentation (16-bit link docs might also
  101. help you).
  102.  
  103.  
  104. 4. Notes
  105. ========
  106.  
  107. 4.1)  The port of f2c was complicated by differing behaviour of the two C
  108. libraries (gcc21 and emx). No doubt, there are things in libi77 and libf77 
  109. that still don't work under one or the other compiler (or both). 
  110. If you suspect a problem with the libraries, please let me know at the 
  111. address below. If you suspect a problem with f2c itself, report it
  112. as suggested in the f2c docs.
  113.  
  114. 4.2)  A few things have been added to the library to make it behave a little
  115. more like other PC fortran libraries:
  116.  
  117. 4.2.1 A null filename in an 'open' statement (i.e. OPEN(UNIT=6, FILE=' ',....)
  118. will cause the next name on the command line to be used as the filename.
  119. (f2c also has other ways of accessing the command line, see f2c.ps)
  120.  
  121. 4.2.2 Time and date subroutines have been added:
  122.  
  123. subroutine gettim( ihour, imin, isec, i100 )
  124. integer *2 ihour, imin, isec, i100
  125.  
  126. Returns current time, in ihour, imin and isec. (i100 is set to zero).
  127.  
  128. subroutine getdat( iyear, imonth, iday )
  129. integer*2 iyear, imonth, iday
  130.  
  131. Returns current date.
  132.  
  133. 4.2.3 Output to a device has carriage control characters expanded.
  134.  
  135. 4.3)  Note that f2c is a translator and probably won't let you get away
  136. with a few things that your favourite FORTRAN compiler will permit. 
  137. For instance, the MS 5.0 compiler will allow you to branch to a block
  138. of code that is physically outside a DO loop, but logically contained
  139. within it (I don't think this is allowed in the FORTRAN77 standard).
  140. f2c cannot analyse the code flow and will generate incorrect code,
  141. but will issue a warning.
  142.  
  143.  
  144. 5 Comments, complaints, etc to:
  145. ===============================
  146. Roger Fearick
  147. Dept. of Physics,
  148. University of Cape Town.
  149. fearick@physci.uct.ac.za      (yes, that's physci)
  150.  
  151.