Fortran Beginner: What is iostat=stat & buf Argument?

  • Fortran
  • Thread starter ydonna1990
  • Start date
  • Tags
    Fortran
In summary, the conversation discusses the meaning of isotat=stat in Fortran and the purpose of the "buf argument". The first result from a Google search provides information on iostat in Fortran, but it is not clear what the "buf argument" refers to. The use of '::' suggests the code may be in Fortran 90 or later, while iostat was used in Fortran 77 or earlier.
  • #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"?
 
Technology news on Phys.org
  • #2
ydonna1990 said:
I want to know what isotat=stat means

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

ydonna1990 said:
what is exactly the "buf argument"?

I don't know what you're asking about here. It might help if you can show us an example.
 
  • #3
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.

Thanks for the reply.

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
 
  • #4
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

Where is the "buf argument"? That's what I was asking about.
 
  • #5
jtbell said:
Where is the "buf argument"? That's what I was asking about.

SUBROUTINE ConProdOpt(Iphi_in,Ilnkx_in,Ilnky_in,Ilnkz_in,FirstRun_in,Neindx_in)
IMPLICIT NONE
INTEGER,buf ::Iphi_in,Ilnkx_in,Ilnky_in,Ilnkz_in,FirstRun_in

I saw it everywhere earlier but for some reason I can't find it and now I can only find this one.
 
  • #6
ydonna1990 said:
INTEGER,buf ::Iphi_in,Ilnkx_in,Ilnky_in,Ilnkz_in,FirstRun_in

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.
 
  • #7
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.

Ah ok. Thanks anyway
 

Related to Fortran Beginner: What is iostat=stat & buf Argument?

1. What is the purpose of the iostat=stat argument in Fortran?

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.

2. How is the iostat=stat argument used in Fortran?

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".

3. What is the purpose of the buf argument in Fortran?

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.

4. How is the buf argument used in Fortran?

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.

5. What happens if the iostat=stat or buf argument is not included in a Fortran input/output statement?

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.

Similar threads

  • Programming and Computer Science
Replies
2
Views
937
  • Programming and Computer Science
Replies
17
Views
5K
  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
2
Replies
37
Views
3K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
4
Views
7K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top