How to reduce the code?

How to reduce the code?

How to reduce the following code?

P0=1.D0
…
DO I=1,6
  DO J=1,6
    S(J,I)=P0
  END DO
END DO

I am looking for the simple solution for the following array:

| 1.D0 1.D0 1.D0 |
| 1.D0 1.D0 1.D0 |
| 1.D0 1.D0 1.D0 |

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If S is not dimensioned (6,6), but something larger: S(1:6,1:6) = 1d0

Even shorter:  s=1d0
complete program:
real(8), dimension(6,6) :: s
s=1d0
end

S is dimensioned as (6,6). Both variants are working excellent. Thanks!

Even "s=1" will give the correct result, as 1d0-1 = 0

Leave a Comment

Please sign in to add a comment. Not a member? Join today