- #1
warfreak131
- 188
- 0
I have an assignment to calculate the least squares fit line to a set of points, and I have to read in an arbitrary number of points from the user
So my plan was to have the user enter how many elements they have, and then create an array with that many elements. So let's say I read the value N from the user, and then create an array like:
But that's a no-no according to fortran. If any read/write statement goes before declaring the variables, I get a whole host of errors. However, if I remove those read/write statements and create a set number of array elements like:
then all the error go away. Unfortunately, I have to find out how many variables the user wants before creating the array.
So my plan was to have the user enter how many elements they have, and then create an array with that many elements. So let's say I read the value N from the user, and then create an array like:
Code:
real, dimension(N) :: xvals, yvals
But that's a no-no according to fortran. If any read/write statement goes before declaring the variables, I get a whole host of errors. However, if I remove those read/write statements and create a set number of array elements like:
Code:
real, dimension(10) :: xvals, yvals
then all the error go away. Unfortunately, I have to find out how many variables the user wants before creating the array.