Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • 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.

Students Click Here

Fortran 90/95 help

Fortran 90/95 help

Fortran 90/95 help


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

Sorry about that,

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

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

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

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.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close