Fortran array help

  • #1
Lukejambo
13
0
Hi,

For fortran 90/95, I've written a 10x10 array of numbers.

2 do loops (n,m) from 1 to 10 indicate the subscript of the elements in this array.

I've applied a generic rule to the array elements where they become 0 if they are above a certain number.

Using an if statement to change the elements they will become 0 or stay the same according to the do loops (ie: so element 1,1 will change first and element 10,10 will change last)

Is it possible to delay or stop the do loop so the if statement does its thing deciding whether an element changes and then change each and every element at the same time?

Any help would be much appreciated.
 

Answers and Replies

  • #2
DrClaude
Mentor
8,114
4,918
You can create an array of type logical, which will be true for elements which need to be changed, and then do the modification independently.

In Fortran 90/95, you can also use the where construct instead of loops
Fortran:
real, dimension(10,10) :: a
where (a > x) a = 0
 
  • #3
phyzguy
Science Advisor
5,092
2,097
By nature a computer program is sequential, so it is only modifying one memory location at a time. The only way to modify all of the memory elements at the same time would be to have 100 cores(or threads) in parallel each modifying one of the memory locations. Even then, the memory modifications will probably not all happen at the same time. Why do you want to change all of the memory locations at once?
 

Suggested for: Fortran array help

  • Last Post
Replies
12
Views
587
  • Last Post
Replies
4
Views
615
  • Last Post
2
Replies
37
Views
2K
  • Last Post
Replies
20
Views
2K
  • Last Post
Replies
8
Views
603
Replies
5
Views
983
  • Last Post
Replies
16
Views
821
  • Last Post
Replies
2
Views
457
  • Last Post
Replies
8
Views
1K
  • Last Post
Replies
4
Views
835
Top