# I can not read character "0A" in a bmp file with "Compaq Visual Fortran 6.6C"

by roy437
Tags: character, file
 P: 6 Hi, How to read character "0A" in a bmp file with "Compaq Visual Fortran 6.6C" Here's an excerpt from bmp file: 42 4D 16 02 00 00 00 00 00 00 36 00 00 00 28 00 00 00 10 00 00 00 0A 00 00 00 01 00 18 00 00 00 Because the meeting this character appears error: "forrtl: severe (268): end of record during read, unit 1, file 16x10.bmp" Thanks
 P: 2,477 it seems you are trying to read a binary file with an ascii read function or you've not opened the file as binary. The 0A you mention is a linefeed character, commonly used to terminate lines of text in ascii files and stripped off when you read a line of text. BMP files are images files (screen shots...) created on windows machines or by image editors that support that file type.
 P: 166 What fortran interpreter?
P: 6

## I can not read character "0A" in a bmp file with "Compaq Visual Fortran 6.6C"

Here are some of the source code:

! file_size - in bits
! hpix - numbers horizontal pixels
! vpix - numbers vertical pixels
! reading remains the first pixel

implicit none

character *8 fs, hm, vm
character *4 h

integer (2) i, j, nfile
integer (4) file_size, hpix, vpix

do i = 1, 4
j = 7 - i
j = 2 * i
write(fs(j-1:j), '(z2.2)') ichar(h(i:i))
j = 23 - i
j = 2 * i
write(hm(j-1:j), '(z2.2)') ichar(h(i:i))
j = 27 - i
j = 2 * i
write(vm(j-1:j), '(z2.2)') ichar(h(i:i))
end do

return
end

 P: 2,477 you're reading a binary file with as if it were a text file. You need to modify your read to open the file as binary. http://software.intel.com/en-us/forums/topic/273296 Notice the open statement with the form=binary open (55,file=xxx,access='DIRECT',form='BINARY',recl=1)
 P: 166 Where is your open() statement for nfile? That is what needs changed. You need FORM='BINARY' in the compaq fortran interpreter.
 P: 6 Here is the calling unit: implicit none integer (4) file_size, hpix, vpix integer (2) k, l, m character *100 fisi character *54 header character *1, allocatable :: r(:), g(:), b(:) open(1, file = fisi) call read_bmp_header(int2(1), file_size, hpix, vpix)
 P: 166 You need to pass in UNFORMATTED or BINARY for the open mode as discussed. This should help you: http://jp.xlsoft.com/documents/intel/cvf/cvf_pg.pdf