LAPACK Archives

[Lapack] Conversion of LaPack to C

This is to let you know: I did a dry run yesterday to test out a semi-automated 
process for converting Fortran source en-masse to C, restricting the effort to 
the Blas library. This is the initial result I got after about 10 hours so far:

* First, to start: the source files are collated, with the resulting (Line, 
Word, Byte) count being (40926, 159883, 1225494).

* Second, the documentation and segregated from the code, with the result 
(after removal of empty lines and empty comment lines) being (17254, 59920, 
573480) for the code, (13837, 73269, 426641) for the documentation.

* Third, the conversion proper, so far, yields code that is about 90% of the 
way from Fortran to C with the a resulting file (9229, 58469, 338985) for 
Blas.c and (12993, 67656, 394278) for Blas.txt. This includes the elimination 
of labels (replaced by loops and branches), conversion of the K&R style 
parametrization to ANSI form, introduction of update operators (e.g. ++, --, 
+=, -=, ...), etc.

* Subsequent refinements the following day have so far led to further reduction 
to (8959, 58465, 334922) for Blas.c and (12197, 68514, 377417) for Blas.txt, 
with the introduction of structured types (e.g. for SPARAM and DPARAM). The 
documentation is undergoing regularization and normalization to a consistent 
style and format and undergoing the elimination of redundancies. I expect it to 
end up under 2000 lines when the process is through. For the source: I expect 
it may end up under 5000 lines, and possibly as far as down to about 3000 when 

The dry run was a proof of concept of the methods used. Now that I've worked 
out the kinks in the process, I'm positining myself to do the same for the 
entire source code body -- which is about 500000 lines at present. The end 
result may bring it down as far as 25000-30000 lines.

If and when the process is complete I will contact you again and offer you the 
translated source (and translated documentation) as a contribution. There will 
be notes provided to establish the equivalencies between the C and Fortran 
function calls. There is also a possibility that this may be moved up into C++ 
in order to take advantage of C++'s "template" facility so as to effect a yet 
further reduction in source by merging the differently-typed instantiations of 
otherwise-identical that contribute as much as a 4-fold increase in the Fortran 

Finally: back in 1993 I released a significantly expanded version of the 
arbitrary precision language BC, calling it C-BC. Verging on a full-scale C 
interpreter, it has sufficient capacity to directly embody the original Fortran 
source. Thus, I may also end up re-releasing C-BC in Source Forge ... and 
include a library with the distribution based on Blas or LaPack if permission 
is granted. Since I've been working on upgrading C-BC to a multithreaded 
language, by including a simple multi-threading runtime system, I may also be 
able to go as far as making the library multi-threaded in a way similar to (but 
substantially simpler than) how AlgLib was converted to multi-threaded form 
after it was translated by the AlgLib developers to C++.

-- Mark Hopkins
Odd Trick Fights Diabetes
"Unique" Proven Method To Control Blood Sugar In 3 Weeks. Watch Video.

<Prev in Thread] Current Thread [Next in Thread>
  • [Lapack] Conversion of LaPack to C, federation2005 at <=

For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or