s3_rewind Subroutine

public subroutine s3_rewind(unit, iostat)

Rewind an S3 file to the beginning.

Resets the read position to the start of the file buffer. Only valid for read mode.

@param[in] unit The unit number to rewind @param[out] iostat Status code: 0 on success, -1 on error

Example

! Read file twice
call s3_open(unit, 'data/file.txt', 'read', iostat)
! ... read operations ...
call s3_rewind(unit, iostat)
! ... read again from start ...
call s3_close(unit, iostat)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit
integer, intent(out) :: iostat

Source Code

    subroutine s3_rewind(unit, iostat)
        integer, intent(in) :: unit
        integer, intent(out) :: iostat

        iostat = 0

        if (unit < 1 .or. unit > MAX_FILES) then
            iostat = -1
            return
        end if

        if (.not. files(unit)%is_open) then
            iostat = -1
            return
        end if

        files(unit)%position = 1
    end subroutine s3_rewind