Formatted output problem in Fortran

In summary, the conversation discusses a problem with a WRITE statement in a program, which results in a binary output file instead of formatted output. The issue is eventually resolved, possibly due to a syntax error. The suggestion is made to try putting the format in the write statement.
  • #1
chaimluria
2
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
  • #2
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
 
  • #3
The problem seems to have resolved itself. I must have made some sort of syntax error. Thank you minger for your reply and suggestion.
 

What is the "Formatted output problem" in Fortran?

The formatted output problem in Fortran refers to difficulty in properly displaying or organizing data when outputting it to a file or terminal. This can be caused by incorrect formatting codes or errors in the code itself.

How can I fix the formatted output problem in Fortran?

To fix the formatted output problem in Fortran, you can check your formatting codes and make sure they are correctly matching the data type of the variable being outputted. You can also ensure that your code is error-free and properly structured.

What are some common causes of the formatted output problem in Fortran?

Some common causes of the formatted output problem in Fortran include using incorrect formatting codes, not properly declaring variables, or missing quotation marks around character strings. It can also be caused by errors in the code, such as using the wrong data type or not including necessary input statements.

How can I prevent the formatted output problem in Fortran?

To prevent the formatted output problem in Fortran, it is important to carefully check your code for errors and make sure all formatting codes are correctly matched to the data being outputted. It may also be helpful to test your code with different input values to ensure proper formatting for all possible scenarios.

Are there any resources available for troubleshooting the formatted output problem in Fortran?

Yes, there are several resources available for troubleshooting the formatted output problem in Fortran. You can refer to the Fortran language documentation or seek help from online forums and communities. Additionally, some compilers may provide error messages or warnings that can help identify and fix the issue.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
29
Views
5K
  • Programming and Computer Science
Replies
4
Views
589
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
12
Views
953
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top