Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How to reduce the code?

Ivan_S_
Beginner
729 Views

How to reduce the following code?

[fortran]P0=1.D0

DO I=1,6
  DO J=1,6
    S(J,I)=P0
  END DO
END DO[/fortran]

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

[fortran]| 1.D0 1.D0 1.D0 |
| 1.D0 1.D0 1.D0 |
| 1.D0 1.D0 1.D0 |[/fortran]

0 Kudos
4 Replies
mecej4
Honored Contributor III
729 Views

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

0 Kudos
rase
New Contributor I
729 Views

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

0 Kudos
Ivan_S_
Beginner
729 Views

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

0 Kudos
John_Campbell
New Contributor II
729 Views

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

0 Kudos
Reply