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 3 of 27 Topic 8156 of 8775
Post > Topic >>

Re: Summing array elements

by "Gerry Ford" <gerry@[EMAIL PROTECTED] > Apr 19, 2008 at 11:12 PM

"Craig Dedo" <cdedo@[EMAIL PROTECTED]
> wrote in message 
news:480a9ef9$0$7077$4c368faf@[EMAIL PROTECTED]
> "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.
>>
>> I know the "obvious" way to do it:
>> s=0.
>> do 1 i=5,50
>> s=s+a(i)
>> 1 continue
>>
>> but since I'm currently doing something which requires quite a number
>> of summing, I was wondering is there something shorter ?
>>
>> Any idead appreciated
>>
>> regards
>> Luka
>
>    This most likely is a homework assignment.  However, if I am mistaken

> and Luka is new to Fortran . . .
>
>    There is always the SUM() intrinsic function.  It can sum an array 
> along any dimension or the whole array and can even sum those array 
> elements for which the value of a corresponding MASK array is true. 
RTFM.

I thought I was gonna clean up the snippet and write an amusing mask. 
This 
*is* wrong, but it doesn't look wrong to me.
real(dim =50):: a

s=0.
do 1 i=5,50
s=s+a(i)
1 continue
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 Mon Oct 13 3:08:04 CDT 2008.