Fortran Fortran Program Test: How to Change Line in File

  • Thread starter Thread starter kth
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
The discussion revolves around a Fortran program that writes integers to both the screen and a data file. The output on the screen displays the numbers 111 and 222 on separate lines, while the data file, test.dat, contains the numbers 111222 without line breaks. Users are seeking solutions to modify the file output to include line breaks between the numbers. One user notes that when compiling with F77, the data file correctly shows 111 and 222 on separate lines, but an extra line appears after 222. The conversation also touches on the differences in behavior when using F77 versus F90 compilers and the operating systems being used, specifically Linux and Windows XP.
kth
Messages
3
Reaction score
0
program test
open(50,file='test.dat')
write(6 ,FMT='(I3,/)') 111
WRITE(6 ,FMT='(I3,/)') 222
write(50,FMT='(I3,/)') 111
WRITE(50,FMT='(I3,/)') 222
close(50)
end

In the above, at the screen i see:
111
222
but in the dat file i see:
111222

How can i change line in the file??
 
Technology news on Phys.org
Kth
When I run the above code compiled with F77 fortran, test.dat contains
111

222

with an extra line between the numbers and after the line 222.
On the other hand, the first character on the screen has been used for printer carriage control, namely the first 1 had been taken as a new page.

Are you running with f77 or f90, and on Linux or Windows XP?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 4 ·
Replies
4
Views
11K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 20 ·
Replies
20
Views
37K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K