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 10 of 27 Topic 8156 of 8767
Post > Topic >>

Re: Summing array elements

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

"Ron Shepard" <ron-shepard@[EMAIL PROTECTED]
> wrote in message 
news:ron-shepard-76B796.09441520042008@[EMAIL PROTECTED]
> In article <u0jm049f123f0c3ntnvi9dqbgo162dtvac@[EMAIL PROTECTED]
>,
> Luka Djigas <ldigas@[EMAIL PROTECTED]
> wrote:
>
>> Anyway, I read the help. But didn't manage to figure it out.
>> As far as I can see, sum can be used to summ an entire array in one or
>> more dimensions. How can one sum just some elements from, for example
>> one dimensional array ?
>
> Here is a description with examples:
>
>   http://gcc.gnu.org/onlinedocs/gfortran/SUM.html
>
> If you want a subset of an array, or you want a nonunit stride, then
> use the colon notation.
>
> $.02 -Ron Shepard

My compiler spits out an error here, Ron, and leaves me with warning 179 -

Comparing floating point quantities for equality may give misleading 
results.  mod has to have both types the same.  Mine were reals.  Yours
were 
ints, so it matters whether you compare to 2 or 2.0.  I think I get
reliable 
output for these data as real.

real :: a(50)

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

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

print *, SUM(a, MASK=MOD(a, 2.0)==1.0)


print *, s
end
output:
625.000
1265.00
, about half an dodd.
-- 
"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 Oct 11 12:56:31 CDT 2008.