Reading a file in FORTRAN 90 or 95

  • Context: Fortran 
  • Thread starter Thread starter hamidsv
  • Start date Start date
  • Tags Tags
    File Fortran Reading
Click For Summary
SUMMARY

The discussion focuses on reading text files in FORTRAN 90 or 95, specifically how to store each line of a file into string variables. The user initially attempted to use the command "READ(1,*,IOSTAT=EOF) A" but encountered issues with the output. After receiving feedback, the user successfully resolved the problem with assistance from a friend, emphasizing the importance of providing complete information for troubleshooting.

PREREQUISITES
  • Understanding of FORTRAN 90 or 95 syntax
  • Familiarity with file I/O operations in FORTRAN
  • Knowledge of string variable manipulation in FORTRAN
  • Experience with debugging and troubleshooting code
NEXT STEPS
  • Research FORTRAN 90/95 file reading techniques
  • Explore the use of "READ" statements in FORTRAN for different data types
  • Learn about error handling in FORTRAN using IOSTAT
  • Investigate best practices for providing code samples in programming forums
USEFUL FOR

FORTRAN developers, students learning file I/O in FORTRAN, and programmers seeking to troubleshoot file reading issues in their applications.

hamidsv
Messages
3
Reaction score
0
Hi everybody,
I need your help guys. I am using FORTRAN 90(or 95) and try to read a text file. The file contains many lines for instance something like this
CS
DIRECT
1.2 2.5 3.6
1.6 -2.3 2.9
....
....
....
I need to put each line inside a string variable for example
A="CS"
B="DIRECT"
C ="1.2 2.5 3.6 "
....
Please if you know the answer just let me know. I use "READ(1,*,IOSTAT=EOF) A" but the result is totally different.
 
Technology news on Phys.org
Hi, hamidsv:

When it comes to source code, input and results, hand waving does not cut it; please post the actual source code that you are using, an actual sample of the input and the actual results that you are getting...there is no point in trying to help you when you tell us what YOU think what you are doing but the sources say something else.
 
Hi gsal,
Thanks for your quick reply. This time I was able to solve the problem (one of my friends helped me). Next time I try to provide all information if I have any questions.
Thanks again
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
6K