Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re> FORTRAN

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re> FORTRAN
  • From: ross at macadam.mpce.mq.edu.au
  • Date: Mon, 22 Jun 1992 14:09:04 +1000

Here is an elegant way to do what John Pender wants:

First recreate his example ...

In[1]:= 
ata=Table[Exp[-5 x],{x,10}]//N;

In[2]:= 
InputForm /@ ata

Out[2]= 
{0.00673794699908547, 0.00004539992976248488, 
 
  3.05902320501826*10^-7, 2.061153622438559*10^-9, 
 
  1.388794386496403*10^-11, 9.35762296884019*10^-14, 
 
  6.305116760146998*10^-16, 4.248354255291597*10^-18, 
 
  2.8625185805494*10^-20, 1.928749847963922*10^-22}

Note the use of InputForm[] to get the * and ^ explicitly shown.


Next define a function:

In[3]:= 
FortranString = StringReplace[
		ToString[InputForm[#]]
	,"^"->"**"
	]&

Out[3]= 
StringReplace[ToString[#1], ^ -> **] &


In[4]:= 
FortranString /@ ata //ColumnForm

Out[4]= 
0.00673794699908547
0.00004539992976248488
3.05902320501826*10**-7
2.061153622438559*10**-9
1.388794386496403*10**-11
9.35762296884019*10**-14
6.305116760146998*10**-16
4.248354255291597*10**-18
2.8625185805494*10**-20
1.928749847963922*10**-22

These are now text strings which can be read into a file.

(It took a lot of false starts using  Format[] before I hit upon this
method.)

_______________________________
Ross Moore                    |
Mathematics Dept              |
Macquarie University          |
North Ryde, Sydney            |
Australia                     |
                              |
ross at macadam.mpce.mq.edu.au   |
______________________________| 






  • Prev by Date: Administrivia
  • Next by Date: Re: FORTRAN
  • Previous by thread: FORTRAN
  • Next by thread: Re: FORTRAN