Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Can not read .bin file | ifort on Linux

nvh10
New Contributor I
790 Views

Hi,

I want to read a binary file. I create the file by using Matlab and then I read by Fortran. 

For this example, I used the command:

ifort -qopenmp -I$/openmp/intel/oneapi/mkl/2022.1.0/include/intel64/ilb64-m64 -DMKL_ILP64 -i8  -I"$/opt/intel/oneapi/mkl/2022.1.0/include" -fpp -qmkl -nologo -O3 -Os -parallel -heap-arrays[0] Console1.f90 -o Console1

I can run the program well by visual studio. If I use ifort compiler, for small N (N=3) I can read the binary file but for the large N (N=900) I can not read. The error is: 

forrtl: severe (24): end-of-file during read, unit 1, file /home/hieu/Downloads/testbin/A.bin
Image              PC                Routine            Line        Source             
Console1           0000000000440A49  Unknown               Unknown  Unknown
Console1           00000000004150FC  Unknown               Unknown  Unknown
Console1           000000000041258E  Unknown               Unknown  Unknown
Console1           0000000000404F27  Unknown               Unknown  Unknown
Console1           0000000000404D62  Unknown               Unknown  Unknown
libc-2.17.so       00007F9CD0DFE555  __libc_start_main     Unknown  Unknown
Console1           0000000000404C69  Unknown               Unknown  Unknown

 Is there any option of ifort command I am missing or any mistake I made?

I attach the binary file and the Fortran code. Please help me! 

0 Kudos
1 Solution
mecej4
Honored Contributor III
769 Views

The .bin file contains N X N four-byte integers (4 N X N = 3240000 bytes). In contradiction to this assumption, you specify the -i8 compiler option, which tells the compiler that eight-byte integers are to be used. 

 

You are mistaken in your conclusion that for small N the program runs well. You may not see any error messages during such a run, but the values read will definitely be wrong, as you can verify by printing out a few values.

View solution in original post

0 Kudos
3 Replies
mecej4
Honored Contributor III
770 Views

The .bin file contains N X N four-byte integers (4 N X N = 3240000 bytes). In contradiction to this assumption, you specify the -i8 compiler option, which tells the compiler that eight-byte integers are to be used. 

 

You are mistaken in your conclusion that for small N the program runs well. You may not see any error messages during such a run, but the values read will definitely be wrong, as you can verify by printing out a few values.

0 Kudos
nvh10
New Contributor I
754 Views

Thank you very much!

By changing -i8 to -i4 I can run my program. 

0 Kudos
ShanmukhS_Intel
Moderator
744 Views

Hi,


Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS




0 Kudos
Reply