Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

reading big endian file?

$
0
0

 

I'm trying to read a big endian file from http://yann.lecun.com/exdb/mnist/

So far I open the file as in a test program

Program Arraytest3

   	Type magic
       	        byte :: byte1  ! INTEGER(1)
  		byte :: byte2
  		byte :: dataType
  		byte :: dimentions
     END Type magic


    Type Images
 		Type(magic) :: magic_number
  		INTEGER(kind=4) 	:: numberOfImages
  		INTEGER(kind=4) 	:: numberOfRows
  		INTEGER(kind=4) 	:: numberOfColumns
  		byte        :: imageCount(1)
  	END Type Images



    Type (Images) :: idx


open(10, CONVERT='LITTLE_ENDIAN',file='t10k-images-idx3-ubyte', access='stream', status='old', FORM='BINARY')
    read(10), idx
    close(10)

    !! Need to byteFlip each byte
    print*,"numberOfImages", idx%numberOfImages
    print*,"numberOfRows", idx%numberOfRows
    print*,"numberOfColumns", idx%numberOfColumns
    print*,"magic_number", idx%imageCount(1)

   print*,"Should be 10000 28x28 images"
end Program Arraytest3

 

referencing the intel page here https://software.intel.com/en-us/node/524834 none of the key words seem to have any effect the result always being the same 

 numberOfImages   270991360

 numberOfRows   469762048

 numberOfColumns   469762048

 

Now if I put these numbers into my calculator and byte flip them then I get the expected result. Does this mean Convert doesn't work on derived types?


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>