Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29396 Discussions

read file into integer*1 array without stream

MWind2
New Contributor III
621 Views

Would the following be a way to read all the bytes from a file into an array of integer*1 where isz is determined by FSTAT?(older version without 'stream')

isz = -1
open(iFN,file=sfilef,action='read',IOSTAT=iiostat,FORM='BINARY',ACCESS='SEQUENTIAL')
ISTAT = FSTAT (iFN, statarray)
if (.NOT. istat) then
print *, statarray
isz = statarray(8)
end if
if (isz > 0) then
ALLOCATE(ab(1:isz))
open(iFN,file=sfilef,action='read',IOSTAT=iiostat,FORM='BINARY',ACCESS='SEQUENTIAL')
read(iFN) ab
close (iFN)
ireturn = isz
else
close (iFN)
ireturn = -1
endif
f2a = ireturn

0 Kudos
0 Replies
Reply