INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Fortran 90/95 help

Fortran 90/95 help

(OP)
Hi,

Is it possible to write an array (say 10x10) with 2 do loops (1,10) calculating each element of the array and then change each element all at the same time rather than changing each element individually as the do loop runs?

RE: Fortran 90/95 help

You lost me.

Why don't you write what you would like to see ideally happen and then we can look at how exactly it should be to become proper Fortran.

RE: Fortran 90/95 help

(OP)

For a 10x10 array, each element is either a 1 or a 0.

Using 2 do loops (n,m) from 1,10 for the subscripts of each element in the array, I've used a select case function to find the sum of each of the element's neighbours (8 in total for each element).

Then depending on the sum of the neighbours of each element, the element will become change (from 0 to 1 and vice versa) using an if statement, however at the moment this change occurs when the do loop reaches that element (so element 100 will change last and element 1 will change first).

Is it possible to delay the if statement from occurring until the sums of all the neighbours have been found and then allowing the if statement to change all elements at once?

Or can I store the original array to a file, to then be called upon where the if statement shall be used?

RE: Fortran 90/95 help

I think I understand a bit better what you mean; but, I still don't quite get it.

Do you really want to evaluate all values before you change them? if so, how about using two copies of the matrix?

Let's say you have matrix A
You go into the double-loop
evaluate entry, but instead of changing the entry in A, you assign it to the same entry in another matrix B
once outside the loops, you can assign B back to A

RE: Fortran 90/95 help

(OP)
Thanks for your help, yes I do want to evaluate all the values before they change.

So declare matrix a before the do loops.
During the do loops, let a=b?
Apply the evaluations to matrix b and then after the do loop change back to a?

RE: Fortran 90/95 help

something like:

declare both matrices: A and B
matrix of interest A

[code]
B = A
do i = 1, 10
do j = 1, 10
if this and that and the surrounding elements of the A(i,j)
add up to whatever, then do something, but do it on B:
B(i,j) = some function/algorithm on A
end do
end do
A = B
[/ccode]

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!