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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A problem i cannot solve (beginner question)

Status
Not open for further replies.

Tieske909090

Technical User
Feb 17, 2011
2
NL
For school I have to do a project with Fortran95. Without saying too much about the project, this is my problem:

------------------------------------
implicit none

! Declaration of variables:
integer :: nnodes
integer, dimension(1:nnodes,1:2) :: coor %%error in this line
integer :: i = 0

! Input of the nodes:
write (*,*) 'Number of nodes: '
read (*,*) nnodes
write (*,*) 'Number of nodes is ', nnodes
-------------------------------------------

I need the coor matrix to fill in the coordinates of the nodes later on. But the program gives me this error:
"error 304 - Non-writable expression in READ statement"

I think it has something to do that I didnt give a value to 'nnodes' in that line yet. But if I paste the line to beneath the 'read and write'-lines, it gives this error:
"error 299 - Statement ordering error - INTEGER cannot appear after executable statements"


Anyone can help? Thanks in advance! :)

Tieske909090
 
Well Tieske, as you've been so honest to say that it's for school...

You can't allocate space of an unknown dimension, which is why you get the error message at:"integer, dimension(1:nnodes,1:2) :: coor "

Placing it after having read the value nnodes doesn't solve it becuase if you do so, your program doesn't fulfill the order of statements the compiler expects.

If you really don't know nnodes beforehand you can use
INTEGER, DIMENSION:),:), ALLOCATABLE :: coor
instead, but then you need to allocate it as soon as you read the value nnodes...

Well, I gave you more than a hint, look in your Fortran book for ALLOCATE examples.

Gerrit
 
Thank you very much,, Will try to do this as soon as possible :)

(And for the school part, my teacher suggested us to search and ask on the internet, if we didnt know something.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top