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

Doubt on Read function parameters 1

Status
Not open for further replies.

Fotran

Technical User
Apr 19, 2008
3
BR
Hi all

I am new to fortran and so trying to understand some caracteristics of this language

can anyone explain to me the logic below?

do i=line+1, line+msup
read(*,*) (Akapla(i,j), j=2, nvar+1), Akapla(i,1)
if(Akapla(i,1).lt.0) then
write(*,*) 'Does not matter'
stop
endif

enddo
 
the "read" line includes what is called an "implicit" loop...it is like a do-loop and, in your case, it assigns values 2 to nvar+1 to the variable 'j' and every time it read a value from the input and assigns that to the corresponding item in the 2D matrix Akapla. The other index (row) is simply whatever value 'i' came in with into the do-loop. Lastly, the read statement read one last value into the specified matrix entry, no loop here, just a list-directed read.

 
I see.

Thanks salgerman, It was unduly clarifying.
 
Can anyone put this code into C# or C?

do i=line+1, line+msup
read(*,*) (Akapla(i,j), j=2, nvar+1), Akapla(i,1)
if(Akapla(i,1).lt.0) then
write(*,*) 'Does not matter'
stop
endif

enddo
 
Hhhhmmm...so, you are new to Fortran...are you new to C, too? :)

If you have access to the one file that this code is supposed to read, why don't you just forget about this piece of code and write the code the way you would do it in order to read the file? (Hint: you need an explicit loop, followed by one more read).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top