Re: FortranForm
- To: mathgroup at smc.vnet.net
- Subject: [mg109568] Re: FortranForm
- From: Gerry Flanagan <flanagan at materials-sciences.com>
- Date: Wed, 5 May 2010 06:07:40 -0400 (EDT)
There is a library package available by Mark Sofroniou. http://library.wolfram.com/infocenter/MathSource/60/ It is a much more general approach than the built-in FotranForm, and there are options to do just what you're asking. Unfortunately, it hasn't been maintained for the latest Mathematica versions (to my knowledge), so you may get a few warnings and errors, particularly related to subexpression optimization. I've generally managed work-arounds. Gerry F. On 5/4/2010 6:30 AM, Gideon wrote: > I have two, possibly related, questions on the FortranForm command. > > 1. Is it possible to get Fortran 90/95 style output? In particular, > I'd like to have long lines broken up with the end of line& > character, rather than the sixth column indicator as it is now. > > 2. Is it possible to get it to output decimals where it has whole > numbers? For instance, in some code I have, a factor of sqrt(2) > appears. FortranForm renders this as Sqrt(2). My compiler (gfortran > 4.4) doesn't like this because it sees this as the square root of an > integer. I have been resolving this with find-replace, and suspect I > could also deal with it by compiler flags, but it's annoying. > > >