Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Summing arr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 26 of 27 Topic 8156 of 8656
Post > Topic >>

Re: Summing array elements

by "Gerry Ford" <gerry@[EMAIL PROTECTED] > Apr 21, 2008 at 01:40 AM

"dpb" <none@[EMAIL PROTECTED]
> wrote in message news:fufn4b$gcg$1@[EMAIL PROTECTED]
> David Frank wrote:
>> "Luka Djigas" <ldigas@[EMAIL PROTECTED]
> wrote in message 
>> news:pu4l04dnt3apg1hf1a1jvesp0gf3jttiol@[EMAIL PROTECTED]
>>> What would be the shortest way to sum some elements of an array? For
>>> example from 5 to 50.
>>>
>>
>> Gee whiz, all these replies and no-one shows him what he asked for.
>>
>>    asum = SUM(a(5:50))
>>
> I missed that... :)
>
> I saw a response that used 5,50 in a loop but didn't realize it was the 
> actual question.
>
> The reply to look at array sections was spot on, though, wasn't it?? :)

Yup.

real :: a(50)
real asum

do  j=1, 50
  a(j) = real(j)
end do

s=0.
do 1 i=5,50
s=s+a(i)
1 continue

asum = SUM(a(5:50))

print *, asum


print *, SUM(a, MASK= a > 42.3)


print *, s
end


-- 
"A belief in a supernatural source of evil is not necessary; men alone
are quite capable of every wickedness."

~~  Joseph Conrad (1857-1924), novelist
 




 27 Posts in Topic:
Summing array elements
Luka Djigas <ldigas@[E  2008-04-20 02:58:34 
Re: Summing array elements
"Craig Dedo" &l  2008-04-19 20:40:11 
Re: Summing array elements
"Gerry Ford" &l  2008-04-19 23:12:13 
Re: Summing array elements
dongyuanxun <dongyuanx  2008-04-19 21:19:08 
Re: Summing array elements
nospam@[EMAIL PROTECTED]   2008-04-19 21:29:07 
Re: Summing array elements
"Gerry Ford" &l  2008-04-20 01:29:19 
Re: Summing array elements
dongyuanxun <dongyuanx  2008-04-19 21:37:45 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-20 16:07:55 
Re: Summing array elements
Ron Shepard <ron-shepa  2008-04-20 09:44:15 
Re: Summing array elements
"Gerry Ford" &l  2008-04-21 01:25:07 
Re: Summing array elements
nospam@[EMAIL PROTECTED]   2008-04-21 07:58:38 
Re: Summing array elements
Ron Shepard <ron-shepa  2008-04-21 11:25:29 
Re: Summing array elements
"Gerry Ford" &l  2008-04-22 23:39:35 
Re: Summing array elements
"Gerry Ford" &l  2008-04-22 23:31:10 
Re: Summing array elements
"jamesgiles@[EMAIL P  2008-04-20 14:10:59 
Re: Summing array elements
dongyuanxun <dongyuanx  2008-04-19 21:10:10 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-20 16:30:12 
Re: Summing array elements
dpb <none@[EMAIL PROTE  2008-04-20 09:48:56 
Re: Summing array elements
"David Frank" &  2008-04-20 11:05:57 
Re: Summing array elements
dpb <none@[EMAIL PROTE  2008-04-20 10:21:27 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-21 01:35:50 
Re: Summing array elements
dpb <none@[EMAIL PROTE  2008-04-20 18:59:37 
Re: Summing array elements
glen herrmannsfeldt <g  2008-04-20 16:21:20 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-21 04:03:01 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-21 04:01:17 
Re: Summing array elements
"Gerry Ford" &l  2008-04-21 01:40:21 
Re: Summing array elements
Luka Djigas <ldigas@[E  2008-04-21 01:12:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Aug 30 8:25:39 CDT 2008.