Formatted output problem in Fortran

  • Context: Fortran 
  • Thread starter Thread starter chaimluria
  • Start date Start date
  • Tags Tags
    Fortran Output
Click For Summary
SUMMARY

The discussion centers on a formatted output issue in Fortran, specifically regarding the placement of WRITE statements within a DO LOOP. User C. Luria initially encountered binary output when moving WRITE statements from the end of the program to the loop. The resolution involved correcting a syntax error and utilizing inline format specifiers in the WRITE statement, such as WRITE(10,(2G15.3,A4)), which successfully produced the desired formatted output.

PREREQUISITES
  • Understanding of Fortran syntax and structure
  • Familiarity with OPEN and CLOSE statements in Fortran
  • Knowledge of WRITE statement formatting in Fortran
  • Experience with DO LOOP constructs in Fortran
NEXT STEPS
  • Explore Fortran WRITE statement formatting options
  • Learn about debugging syntax errors in Fortran code
  • Research best practices for file I/O operations in Fortran
  • Investigate advanced formatting techniques in Fortran, such as using FORMAT statements
USEFUL FOR

This discussion is beneficial for Fortran developers, programmers working on numerical simulations, and anyone troubleshooting formatted output issues in Fortran applications.

chaimluria
Messages
2
Reaction score
0
Hello,

I have correctly defined my OPEN and CLOSE statements. When all of my WRITE statements with their associated FORMAT statements are at the end of the program I get the formatted output that I need.

If I move one of the WRITE statements to the body of the program (within a particular DO LOOP) I get a binary output file.

What am I doing wrong. How can I have a WRITE statement in the body of a program and still get formatted output.

Regards,

C. Luria
 
Technology news on Phys.org
It would help to see some code, I've never seen something like that. However, rather than having format specifiers, you could try putting the format in the write statement, e.g.
Code:
DO i=1,n
  WRITE(10,(2G15.3,A4)) data
END DO
 
The problem seems to have resolved itself. I must have made some sort of syntax error. Thank you minger for your reply and suggestion.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 29 ·
Replies
29
Views
6K
  • · Replies 59 ·
2
Replies
59
Views
12K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K