Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Description: Open Text files with fortran

Status
Not open for further replies.

a786b786

Technical User
May 14, 2003
5
US
I want that an existing text file should be opened, and can be changed, for example, change the word value, by the word val, or v only. I actually want that a fortran program can be used to read text files, and it should do any possible changes to the text. My aim is to make a software, for 1.) Sorting out some chemistry files, and, 2.)(if possible)any text files like them,of any subject. AND No. 4) It must not make the text files so big, that they become unable to copy on floppies. Thats what i want. Thanks a ton. Espacially thanks to Mr. Cakiwi for his first reply for me.
 

Post a small example of the Chemistry file you want to change and what you want it to look like after you have changed it.

Also, it is better to add your reply to the bottom of this thread rather than start a new thread

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
For Example, There is a table, of values, up to serial numbers 1 to 550, and all are like this
1. ) Value = 12345 * x
now i want that it should be solved, i.e value should be finalized, while, strictly not making the file big. Now i want that they should be like this:
1.) V= 12345x
Thank you very much.
a786b786
 
Sorry, I still don't understand what you want. Post more examples of input records, what you want them changed to and a description of the the rules for changing them. Is 1.) part of the record? Is the second field always Value and do you always want to output just the first letter? etc.

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Hi Cakiwi, First of all, please tell me how to remove text from my thread .I am new to use fortran , and it is not much (neither so less) time passed when i discovered that fortran means formula translation. You can guess that how much expert i am in fortran. No body could dare challanged my expertiese in fortran. I am sorry i couldn't explain well. I am giving you some notes that what my aim is.

it will be
1. open the text file
2. read it etc.
3. write @ instead of value etc, and this instead of that etc( total roughly about 19 to 23 words to be changed)
4. write x instead of a in a1 to a113,( this will become x1 to x113 several changing of characters is required at different places e.g b1 to b123, c1 to c20, da to dz)
5. read numbers in the text or tables e.g 736254 etc and assign them all by values e.g f1 = 736254, now divide f1 by 'g' e.g g=2 get answer, now give answer the variable name h, e.g h = 368127 (736254/2).
6 divide h again by g e.g 368127 /2 = 18463.5 , give i = 18463.5
7. divide i by j( another previously defined variable, e.g j=5), and give answer the variable name k and then subtract k from i, and get another answer = m.

8. write in some kind of memory that this answer will be added in the product of j the divisor, and the answer m , to get i.


a786b786
 
Sorry a786b786, I still don't understand what you want. You need to post examples of the input and output files. If you won't do that, I can't help you.

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Brother Cakiwi, here are the input and out put examples( i don't have the real data) and if you still can't understand, please guide me so i can get start and open an existing text file and try some manipulation, and then i can tell you better what i want. I thank you for you keeping interest for me and i have said to people that i am an expert, and now its only you who can help me.( I am crying):
Input:
Table 4.1
Value1 = 17465 Value2 =204567
a1 integer/2 answer/2
a2
a3
..
..
a113

Output:
v1 = 17465 v2 = 204567
x1
x2
x3
..
..
x113
 
Here's a simple program which takes the input file you posted and creates the output file you posted. It does not address points 5, 6, and 7 in one of your pervious posts but maybe it will get you started.

program tst
character*80 a,b

open(10,FILE='infile')
open(11,FILE='outfile')

10 continue
read(10,1000,end=8000) a
1000 format(a80)
if (a(1:6).eq.'Value1') then
b = 'v' // a(6:23) // 'v' // a(29:37)
write (11,1000) b
else if (a(1:1).eq.'a') then
b = 'x' // a(2:4)
write (11,1000) b
endif
goto 10
8000 continue
end


CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Brother Cakiwi, thank you very much for your kind help. I will try this and then ask you again for guidence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top