Fortran Fortran 90 question about reading files with text

AI Thread Summary
The discussion focuses on how to extract numerical values from a text file containing two distinct formats of data. The first format consists of text followed by numbers, while the second format features strings that start with 'is' and include multiple numerical values. The user seeks to read only the numbers without altering the text. It is suggested that DO loops can be utilized to process each format separately by counting the number of lines. The identification of the starting string 'is' in the second format can serve as a trigger to initiate the second DO loop. A tutorial with relevant source code is provided as a resource for further guidance.
dealove
Messages
3
Reaction score
0
I have a file with text and adjacent to it, the number i want to read. Below is the format. I was wondering how to read just the numbers without touching the text.

trhy 30.0
difje 30.0
sdjk 66.5
xmb 15.0
dcos 15.0
fjvm 2.573e-4
srht 9.05e-3
art3 0.0
19.954
39.499
43.852
48.713
51.660
53.801
54.715
55.602

another format is:

is...o2. mw2 31.998 htf2 0.0
is...n2. mw3 28.014 htf3 0.0
is..co2. mw4 44.009 htf4 -93.965
is..h2o. mw5 18.015 htf5 -57.103

if above two formats are in the same file, can I use DO loops for first format and second format individually by counting the number of lines?
 
Technology news on Phys.org
if the second set always starts with 'is' then once you are able to identify strings you can use this as a starting point to start your second do loop.
I have found a tutorial with source code online. This should help you out:
http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/class-avg.html"
 
Last edited by a moderator:
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
12
Views
3K
Replies
5
Views
2K
Replies
2
Views
2K
Replies
2
Views
1K
Replies
33
Views
5K
Replies
12
Views
15K
Replies
1
Views
3K
Replies
1
Views
2K
Replies
19
Views
6K
Back
Top