- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If S is not dimensioned (6,6), but something larger: S(1:6,1:6) = 1d0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even shorter: s=1d0
complete program:
real(8), dimension(6,6) :: s
s=1d0
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
S is dimensioned as (6,6). Both variants are working excellent. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even "s=1" will give the correct result, as 1d0-1 = 0

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page