Fortran90 help


by cibui
Tags: fortran, fortran90, fourier, fourier series, read statement
cibui
cibui is offline
#1
Nov6-11, 04:44 AM
P: 9
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
Phys.Org News Partner Science news on Phys.org
Review: With Galaxy S5, Samsung proves less can be more
Making graphene in your kitchen
Study casts doubt on climate benefit of biofuels from corn residue
Mark44
Mark44 is offline
#2
Nov6-11, 12:25 PM
Mentor
P: 21,032
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.
cibui
cibui is offline
#3
Nov6-11, 06:25 PM
P: 9
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

Mark44
Mark44 is offline
#4
Nov7-11, 12:40 PM
Mentor
P: 21,032

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.
cibui
cibui is offline
#5
Nov7-11, 06:23 PM
P: 9
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
Mark44
Mark44 is offline
#6
Nov7-11, 08:15 PM
Mentor
P: 21,032
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).


Register to reply

Related Discussions
Need help for error in Fortran90! Programming & Computer Science 6
help me in fortran90 Programming & Computer Science 7
Fortran90 help Programming & Computer Science 4
Another Fortran90 question Programming & Computer Science 5
Fortran90 vs C vs C++: not a troll!!! Programming & Computer Science 2