f90 language translation example



On 7/13/07, Todd Hay <haymeister at gmail.com> wrote:

> I'd like to be able to write a file from maxima that I can paste directly
> into a fortran 90 subroutine. The 'f90' module seems to be suited for this
> but I don't know how to gain access to the string that f90(expr); prints to
> the screen (f90 always returns 'done' by design). I need access to the
> string so that I can manipulate it and concatenate another string to the
> expression before writing to the file.

Todd, that's an interesting question and unfortunately I don't see
a simple answer.

Aside from modifying share/contrib/f90.lisp, I think the place to
look is $WITH_STDOUT in src/macsys.lisp.
The Maxima function with_stdout("foo", ...) redirects *STANDARD-OUTPUT*
into the file "foo". I would hope, then, that with_stdout(false, ...)
captures *STANDARD-OUTPUT* into a string and returns it ---
this is analogous to the behavior of Lisp FORMAT.

However, with_stdout(false, ...) actually writes a file named "nil",
and after looking at the code & trying a few experiments,
I don't see a way to change that behavior. Maybe someone else
can take a look. I think it is worth trying.

best
Robert Dodier