• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

QUICK FORTRAN QUESTION

Kenji4861

Banned
I just want to know how to output everything onto one line.

do 100 i=1, 10
write (*,*) i
100 continue

If I do this, it outputs as
1
2
3
4
5
6
7
8
9
10

How can I make it so, it'll go
1 2 3 4 5 6 7 8 9 10
 
Its been a REALLY long time, so I may be wrong, but it was either fortran or basic where if U put a ; at the end of the line it'll skip the CR.

if it doesn't work lemme know, I think I still have a fortran book somewhere.
 
Use an implied do loop

Write(*,*) (i, i=1,10)

And you'll probably need to use a format specifier, but you can figure that out pretty easily.

Ryan
 
One way is:

Do 100 i=1,10
Write (6,150) i
150 Format (I3,$)
100 continue
Write (6,*)

There are other ways too.
 
Back
Top