From: Richard Maine on
dongyuanxun <dongyuanxun(a)gmail.com> wrote:

> On Apr 20, 12:12 pm, "Gerry Ford" <ge...(a)nowhere.ford> wrote:

> > real(dim =50):: a

> That looks that your Compiler doesn't support the dim sign. Try
> "real :: a(50)",please.

Nor would I expect any compiler to support it.

1. It is spelled dimension rather than dim. (This isn't basic)

2. There are quite a large number of places where one can specify
dimension, but in parens after a type name is not one of them. That
would be a type parameter. The real type does not have a type parameter
named dim (or dimension either). Its only type parameter is named kind.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
From: dongyuanxun on
On Apr 20, 12:29 pm, nos...(a)see.signature (Richard Maine) wrote:
> dongyuanxun <dongyuan...(a)gmail.com> wrote:
> > On Apr 20, 12:12 pm, "Gerry Ford" <ge...(a)nowhere.ford> wrote:
> > > real(dim =50):: a
> >  That looks that your Compiler doesn't support the dim sign. Try
> > "real :: a(50)",please.
>
> Nor would I expect any compiler to support it.
>
> 1. It is spelled dimension rather than dim. (This isn't basic)
>
> 2. There are quite a large number of places where one can specify
> dimension, but in parens after a type name is not one of them. That
> would be a type parameter. The real type does not have a type parameter
> named dim (or dimension either). Its only type parameter is named kind.
>
> --
> Richard Maine                    | Good judgement comes from experience;
> email: last name at domain . net | experience comes from bad judgement.
> domain: summertriangle           |  -- Mark Twain

That's Right. We can write like this "real,DIMENSION(50) :: a".
From: Gerry Ford on

"Richard Maine" <nospam(a)see.signature> wrote in message
news:1ifny75.cq0wgnblsypaN%nospam(a)see.signature...
> dongyuanxun <dongyuanxun(a)gmail.com> wrote:
>
>> On Apr 20, 12:12 pm, "Gerry Ford" <ge...(a)nowhere.ford> wrote:
>
>> > real(dim =50):: a
>
>> That looks that your Compiler doesn't support the dim sign. Try
>> "real :: a(50)",please.
>
> Nor would I expect any compiler to support it.
>
> 1. It is spelled dimension rather than dim. (This isn't basic)
>
> 2. There are quite a large number of places where one can specify
> dimension, but in parens after a type name is not one of them. That
> would be a type parameter. The real type does not have a type parameter
> named dim (or dimension either). Its only type parameter is named kind.

Thanks, Xuan and Richard. I must have been thinking of MM's scatter, where
the dim=1 in the minloc statement is more of a qualifier.

real :: a(50)

do 23 j=1, 50
a(j) = 1.0 * j
23 continue

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


print *, s
end

I know we're not supposed to solve homework, but sometimes I behave more
like I wish others had when I was in school.

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

~~ Joseph Conrad (1857-1924), novelist


From: Luka Djigas on
On Sat, 19 Apr 2008 20:40:11 -0500, "Craig Dedo" <cdedo(a)wi.rr.com>
wrote:

> This most likely is a homework assignment. However, if I am mistaken and
>Luka is new to Fortran . . .

Nope, not homework assignment.
Well, it's work, and I'm doing it at home, but I don't think that
counts ...

>
> 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 know about the sum intristic. Never used it though. I don't like
using intristics where I can do it by plain loop or something (ok, I
don't do the sinus function that way) ... that way I don't have to
think when I'm reading the code next time, what exactly does the
specified intristic do.

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 ?

regards
Luka
From: Luka Djigas on
On Sat, 19 Apr 2008 21:10:10 -0700 (PDT), dongyuanxun
<dongyuanxun(a)gmail.com> wrote:


> You can also prepare a function called sum(),if your IDE doesn't
>support the sum() intrinsic function.

Uhmm, I don't think that IDE has much to do with it. You probably ment
the compiler.

About the function. That is always the possibility. Unfortunately
(unfortunately? :-) my compiler (cvf66c) does support the sum
intristic, but looks like I understood it's capabilities the wrong
way. I didn't understood the mask option.
As far as I have gone with the sum intristic is that it can summ all
elements in specified dimensions of an array.

I didn't understand (no examples in help either) how can one sum just
some elements from an array ...

regards
Luka

p.s. I know this is a little dumb question for some people here. But
I'm a self learned fortran user, learned what i know through reading
old manuals and by figuring out someone else's code.
So far I always found it better just to ask, what seems a dumb
question, and to bear critics for a while, but to get some idea from
other people's answers, than to keep on doing something in a way which
is, for one reason or another, wrong.