[UP]


Manual Reference Pages  - rewind (7)

NAME

REWIND(7f) - [FORTRAN:FILE_POSITIONING] rewind specified sequential access I/O unit (LICENSE:PD)

SYNOPSIS

REWIND file-unit-number

    REWIND ( [UNIT=]file-unit-number][,IOMSG=iomsg-variable][,IOSTAT=scalar-int-variable][,ERR=label] )

DESCRIPTION

Execution of a REWIND statement causes the file connected to the specified unit to be positioned at the beginning of the file (its initial point).

If the file is already positioned at its initial point, execution of this statement has no effect on the position of the file.

Execution of a REWIND statement for a file that is connected but does not exist is permitted and has no effect on any file.

OPTIONS

UNIT unit number of file to rewound. A unit open for direct access or unformatted access cannot be referenced by a REWIND.
IOSTAT a compiler-specific number that indicates an error occurred if non-zero.
IOMSG a message describing error IOSTAT if IOSTAT is not zero.
ERR a label number to jump to if an error occurs

EXAMPLE

An example of a REWIND statement is:

   program demo_rewind
   implicit none
   character(len=256) :: line
   character(len=256) :: mssge
   integer            :: i
   integer            :: ios
      open(10,file=’demo_rewind.txt’) ! open a file
      do i=1,100                      ! write lines to it
         write(10,’(a,i0)’) ’line ’,i
      enddo
      rewind(10, iostat=ios,iomsg=mssge)
      if(ios.ne.0)then
         write(*,*)’*error* ’,trim(mssge)
         stop
      endif
      write(*,*)’wrote 100 lines, but now at line ...’
      read(10,’(a)’)line
      write(*,’(a)’)line
      read(10)
      read(10)
      read(10)
      write(*,*)’skipped a few lines, now at ...’
      read(10,’(a)’)line
      write(*,’(a)’)line
      close(10,status=’delete’)
   end program demo_rewind


rewind (7) March 11, 2021
Generated by manServer 1.08 from 2183b0ca-633a-4584-8c8d-c659b9569ab3 using man macros.