Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I have a problem with a code. I would like to read some files and set them to a variable in Fortran programming language. Ihave a file called "number.txt" which has 2 lines and one column. I would like to set the numbers of first line to a variable called x (real number) and the number of second variable to a variable called z (real number too).
after all, I would like to calculate variable y which is calculated from a spesific equation (I set the equation on my code trial).

Could you please help me?

What I have tried:

program test
implicit none

real x,z,y1,y2




end program test
Updated 30-Dec-21 1:56am
0x01AA 30-Dec-21 7:01am    
Try this:
read(7,*) x !first line
read(7,*) z !second line
Member 14991075 30-Dec-21 8:05am    
ok thank you, but the point is that the first line in my file includes three values separated with comma (,) (i.e. 1,2,3 etc.) In this case which commanmd should I use?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900