Re: Fortran and LaTeX



On Fri, 16 Nov 2007, Patrick Begou wrote:

May be a little bit H.S. But who use Latex to write documentations on fortran codes ? My goal is to have two columns per page, one with the Fortran code and the second one with the comments, related equations.. etc.

Thanks for advices if someone has yet found good latex style for this as I do not find any working solution...

Have you seen Knuth's papers on literate programming? His approach is to create a document that can be processed (with programs called tangle and weave) to produce either the program source or the .tex file. Someone has mentioned fweb, which I have used with excellent results to rescue a big heap of legacy code while porting from CDC to RISC unix. Fweb is no longer supported, and with modern machines TeX can handle everything, so
with one pass you can both typeset the document and produce the sources.
This has been implemented by Eitan Gurari. His book is now out of print,
but he has some examples on his web site and the macros (which I use with latex, plain tex, and ConTeXt) are readily available (e.g., as
"protex" MiKTeX package and in major TeX distros).

The main thing I miss with protex is indexing and cross-reference support. This could be implemented by writing an external tool to sort the entries, but somehow I never get the time to do it.

Knuth's approach tends to make heavy use of macros, and results in sources that are not highly readable. This does allow you to produce a document in which variables, say "alpha" are shown using the Greek letter rather that the name. I find that people want to use our sources on different platforms and aren't willing to learn the literate programming tools, so all I use from literate programming is the ability to present source in fragments and then assemble them in the proper order for the final program.

A big advantage of protex is that it transparently supports arbitrary source languages, so I can include configuration files, shell scripts, sample data, etc. in the document.

--
George N. White III <aa056@xxxxxxxxxxxxxx>

.



Relevant Pages

  • Re: pictures as comments
    ... The WEB system did not become as hugely successful as TeX, ... sources, so if you think WEB was a key element in the success of TeX, then WEB has be considered a success. ... There are a number of literate programming systems still being actively used. ... ProTeX doesn't need tangle and weave -- all the heavy lifting is done by TeX. ...
    (comp.lang.fortran)
  • Re: On what basis are people going to spend an eternity in hell?
    ... As is TeX itself, well okay so it's written in Literate Programming style ... but perhaps I'm a weirdo. ...
    (uk.religion.christian)
  • Re: Why I am unwilling to use Mathematica if I can help it
    ... there *is* a TeX front end (the WEB system of ... literate programming) that DLK himself wrote in 1982 to ... the original source of TeX is ... It was not a tool suitable for team development because ...
    (sci.math.num-analysis)
  • Re: On what basis are people going to spend an eternity in hell?
    ... As is TeX itself, well okay so it's written in Literate Programming style ... but perhaps I'm a weirdo. ... I'd pay good money to witness a Knuth-Dawkins debate, ...
    (uk.religion.christian)