- #1
ydonna1990
- 15
- 0
Hello. I am a beginner in the Fortran language and I want to know what isotat=stat means.
also what is exactly the "buf argument"?
also what is exactly the "buf argument"?
ydonna1990 said:I want to know what isotat=stat means
ydonna1990 said:what is exactly the "buf argument"?
jtbell said:A Google search for "fortran iostat" gave me this page as the first result:
http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap04/iostatus.html
I don't know what you're asking about here. It might help if you can show us an example.
ydonna1990 said:if (userdefine==0) then
open(100,file='COORD.DAT',iostat=stat)
if(stat==0)then
read(100,'(a)',iostat=stat)line
read(100,'(a)',iostat=stat)line
if ((line(1:2)/='--').and.(line/=' ').and.(line(1:5)/='COORD'))then
jtbell said:Where is the "buf argument"? That's what I was asking about.
ydonna1990 said:INTEGER,buf ::Iphi_in,Ilnkx_in,Ilnky_in,Ilnkz_in,FirstRun_in
jtbell said:The '::' looks like Fortran 90 (or later). I'm not very familiar with those versions of Fortran, so someone else had best answer this part of your question.
iostat was used in Fortran 77 (possibly earlier) which is what I'm familiar with.
The iostat=stat argument in Fortran is used to capture any error or status codes that may occur during input/output operations. This allows the programmer to check for errors and handle them appropriately.
The iostat=stat argument is typically added to the end of an input/output statement in Fortran, followed by a variable that will store the error or status code. For example, "READ(10, iostat=err) x" will attempt to read from a file with unit number 10 and store any error or status code in the variable "err".
The buf argument in Fortran is used to specify the size of a buffer that is used for input/output operations. This can improve performance by reducing the number of individual input/output operations.
The buf argument is typically added to the end of an input/output statement in Fortran, followed by an integer value that specifies the size of the buffer in bytes. For example, "WRITE(20, buf=1024) y" will write the variable "y" to a file with unit number 20 using a buffer size of 1024 bytes.
If the iostat=stat argument is not included, any errors or status codes will not be captured and the program may continue to run without handling them. If the buf argument is not included, the program will default to using a system-defined buffer size, which may not be optimal for performance.