Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding like arrays

Status
Not open for further replies.

Lloydone

Programmer
Jan 17, 2007
41
NZ
Is there short hand for adding arrays of the same shape to each other rather than having a whole heap of do loops?

Regards,

Lloyd
 
No but you can write an add operator so that you can use some funky notation like

a = b .plus. c

I haven't played with this feature a lot so I can't tell you whether you can have fancy looking operators like .+. or whether you can redefine + for arrays.
 
Sorry xwb,

according to my textbook on Fortran you can perform operations on complete arrays, provided they are of the same size.

Even though I did not test them all, the following is correct:

real a(10),b(10),c(10),d

a = 0.0
b = 3.0
c = a + b
a = d * c

Lloydone,

I would recommend that you get yourself a copy of a good manual on Fortran. I use Stephen J. Chapman, Fortran 90/95 for Scientist and Engineers (McGraw-Hill series in general engineering).

(hopefully this is not thought to be advertising)

Even though it is adressed to engineers and scientists I found it quite comprehensible since most of the examples cover non-engineering problems. I guess that it would pay for you to spend those USD 40 (my guess, take a look in amazon for proper info) instead to have to wait for somebody to answer your forum question and delay your project each and every time you hit on some prob.

Norbert


 
Thanks for your concern Norbert,

I have been using Metcalf FORTRAN 90/95 explained, but it definately leaves alot to be desired

regards,
Lloyd
 
The book is quite expensive - in the UK, the normal price is £95. Probably half that on Amazon but still quite pricy.
 
Yea thats for the hardcover,

Not sure if I am willing to pay that amount. There is alot of online resources about
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top