Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion making even and odd index parameter?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Jørgensen  
View profile  
 More options Nov 22 2007, 5:23 pm
Newsgroups: comp.lang.fortran
From: Martin Jørgensen <megaf...@hotmail.com>
Date: Thu, 22 Nov 2007 23:23:45 +0100
Local: Thurs, Nov 22 2007 5:23 pm
Subject: Re: making even and odd index parameter?

Richard Maine wrote:
> Martin Jørgensen <megaf...@hotmail.com> wrote:

>> integer, parameter, dimension(4) :: odd(1,3,5,7)
>> integer, parameter, dimension(4) :: even(2,4,6,8)

> This is almost valid, but doesn't mean what you think. The (1,3,5,7) is
> not an array of values. It is the dimensions, overriding the
> dimension(4). And you don't specify a value at all, which is what makes
> it invalid. What you want is more like

>   integer, parameter, dimension(4) :: odd = [1,3,5,7]

Aha. Thanks.

> where I'm using the f2003 square bracket array constructor syntax. If
> your compiler doesn't accept that, substitute (/1,3,5,7/), but do note
> that you cannot use just (1,3,5,7).

>> even_index = [2 4 6 8 10]
>> odd_index = [1 3 5 7 9]

> That is fine if you declared even_index and odd_index appropriately. You
> do, however, need declarations.

Ok.

>> somearray(even_index) = somearray(even_index) * 2.0
>> somearray(odd_index) = somearray(odd_index) * 2.0

> This is ok, once you defined even_index and odd_index appropriately. But
> there is a lot simpler way. Just do

>   somearray(2::2) = somearray(2::2) * 2.0  !-- For the even ones
>   somearray(1::2) = somearray(1::2) * 2.0  !-- For the odd ones

That's much better, thanks.

>> Is it possible? I get compiler error when I try it...

> It helps to say what the compiler error is... and what code it goes
> with, as you show multiple alternatives above.

Well, I see you figured it out anyway. If you want to see the specific
error messages, which I personally find irrelevant, you could just make
a test-file and try what I suggested (which ofcourse wasn't very good
suggestions because I didn't knew any better)...

Even though I didn't try your suggestions yet, I would like to thank you
for your help because AFAICS it looks like you know what you're talking
about and I don't see any reason why your suggestions shouldn't work...

Thanks.

Regards,
Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.