Fortran How to handle empty txt files when reading data in Fortran 90?

  • Thread starter Thread starter toni_2374
  • Start date Start date
  • Tags Tags
    Data Fortran
AI Thread Summary
To handle reading data in Fortran 90 from a text file that may be empty, the ERROR= option for the READ statement can be utilized to manage errors that arise during the reading process. However, the END= option is recommended as it specifically addresses the situation where the end of the file is reached without sufficient data. This allows the program to continue executing even if the file is empty, preventing it from stopping unexpectedly.
toni_2374
Messages
5
Reaction score
0
Hi
I have a problem with reading data in fortran 90. my programs try to read a txt file that only contains one number in it but if the txt file is empty it stops. i want to make it continue what should i do?
 
Technology news on Phys.org
Look up the ERROR= option for the READ statement.
 
Even better, look up the END= option.

ERROR= might pick up any type of error, not just that the file doesn't contain enough data.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
8
Views
1K
Replies
25
Views
3K
Replies
12
Views
3K
Replies
5
Views
2K
Replies
1
Views
3K
Replies
5
Views
5K
Replies
17
Views
6K
Replies
2
Views
2K
Back
Top