I've written binary data out but can't seem to read it.
Subroutine RanfPut ( fname )
Character(45),intent(in):: fname
Integer:: i, ok
open ( unit=4,file=fname,iostat=ok,form='unformatted', &
status='replace',position='rewind',access=sequential' )
If (ok > 0) Then
print *, 'RanfPut error on file open name = ', fname, ok
return
Else
write(*,'(a,a)') 'Input file := ', fname
End If
write (4) a0
write (4) a1
write (4) a2
write (4) rvals1
write (4) rvals2
write (4) rvals3
write (4) nsum
close (4)
return
End Subroutine RanfPut
Now the part that doesn't work.
Subroutine RanfGet ( fname )
Character(45),intent(in):: fname
Integer(2):: i, ok
logical(2) :: file_exists
inquire(file=fname, exist=file_exists)
if (.NOT.file_exists) Then
write(*,'(a,a)') 'Input file does not exist. fname = ', fname
return
end if
open (unit=4,file=fname,iostat=ok,form='unformatted', &
status='old',position='rewind',access='sequential')
If (ok > 0) Then
print *, 'RanfGet error on file open name = ', fname, ok
return
Else
write(*,'(a,a)') 'Input file = ', fname
End If
read (4) a0
read (4) a1
read (4) a2
read (4) rvals1
read (4) rvals2
read (4) rvals3
read (4) nsum
close (4)
flag = 1 ! set flag to indicate we are using the table
return
End Subroutine RanfGet
Any help will be greatly appreciated.
Brooks Van Horn
Subroutine RanfPut ( fname )
Character(45),intent(in):: fname
Integer:: i, ok
open ( unit=4,file=fname,iostat=ok,form='unformatted', &
status='replace',position='rewind',access=sequential' )
If (ok > 0) Then
print *, 'RanfPut error on file open name = ', fname, ok
return
Else
write(*,'(a,a)') 'Input file := ', fname
End If
write (4) a0
write (4) a1
write (4) a2
write (4) rvals1
write (4) rvals2
write (4) rvals3
write (4) nsum
close (4)
return
End Subroutine RanfPut
Now the part that doesn't work.
Subroutine RanfGet ( fname )
Character(45),intent(in):: fname
Integer(2):: i, ok
logical(2) :: file_exists
inquire(file=fname, exist=file_exists)
if (.NOT.file_exists) Then
write(*,'(a,a)') 'Input file does not exist. fname = ', fname
return
end if
open (unit=4,file=fname,iostat=ok,form='unformatted', &
status='old',position='rewind',access='sequential')
If (ok > 0) Then
print *, 'RanfGet error on file open name = ', fname, ok
return
Else
write(*,'(a,a)') 'Input file = ', fname
End If
read (4) a0
read (4) a1
read (4) a2
read (4) rvals1
read (4) rvals2
read (4) rvals3
read (4) nsum
close (4)
flag = 1 ! set flag to indicate we are using the table
return
End Subroutine RanfGet
Any help will be greatly appreciated.
Brooks Van Horn