New Reply

Fortran90 help

 
Share Thread Thread Tools
Nov6-11, 04:44 AM   #1
 

Fortran90 help


Hi guys,

straight to the point, how do you make your READ statement to be able to read both numbers and letters(words) or functions at the same time? okay, for example, i want the user to input a continuous function. what if the function is, let say, sin(x)? do i need to break the READ statement into several READ statements or it can be done with only one statement? i was only taught to use "READ *, " but never told how does this really work.

I'm no programmer and have no programming background, so please help me
greatly appreciated
 
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> 'Whodunnit' of Irish potato famine solved
>> The mammoth's lament: Study shows how cosmic impact sparked devastating climate change
>> Curiosity Mars rover drills second rock target
Nov6-11, 12:25 PM   #2
 
Mentor
This is a harder problem than you might realize, since your program has to parse the input text to recognize function names.

A READ statement can be set up to read numbers (either real or integer) or strings of characters. It can't be set up to read functions such as sqrt or sin. There must be logic in the program to match input strings to a list of functions. If you have no programming experience, this will probably be beyond your abilities.
 
Nov6-11, 06:25 PM   #3
 
Thanks for the reply Mark,
okay, so it is not possible afterall...
guess i will have to break the input structure into several steps then

anyway tyvm
 
Nov7-11, 12:40 PM   #4
 
Mentor

Fortran90 help


I didn't say it wasn't possible. I said that with your lack of experience it would be very difficult.

In your first post you talked about "break(ing) the READ statement into several READ statements..." That's not what you need to do.

Your program needs to read the input as a string, and then it needs to parse the string to determine if the input string contains the name of a function, such as sin, or tan, or ln, or whatever.
 
Nov7-11, 06:23 PM   #5
 
i know that read statement can read strings of texts but the thing is what if it involves operable numbers? e.g. sin2x. i want it so that the inputted "2" by the user can be processed by the program as an operable number not as a part of a string of text. can READ actually do that?
thanks for your help
 
Nov7-11, 08:15 PM   #6
 
Mentor
Everything will necessarily have to come into the program as a string of characters. In your example, if the user enters sin2x, your program will read this as a character string. Your program will then have to have logic so that it can separate out the function name (sin) from the argument (2x).
 
New Reply

Tags
fortran, fortran90, fourier, fourier series, read statement
Thread Tools


Similar Threads for: Fortran90 help
Thread Forum Replies
Need help for error in Fortran90! Programming & Comp Sci 6
help me in fortran90 Programming & Comp Sci 7
Fortran90 help Programming & Comp Sci 4
Another Fortran90 question Programming & Comp Sci 5
Fortran90 vs C vs C++: not a troll!!! Programming & Comp Sci 2