neural-fortran icon indicating copy to clipboard operation
neural-fortran copied to clipboard

File input error when testing with ifort 2021.5.0 Build 20211109_000000

Open rouson opened this issue 2 years ago • 2 comments

After unzipping data/mnist/mnist.tar.gz, checking out the main branch, and building with the above compiler, running the tests yields the error below even though doing the same with gfortran 10.2.0 avoids this error.

$ fpm test --compiler ifort --flag "-cpp"
Project is up to date
 Reading MNIST data..
forrtl: severe (36): attempt to access non-existent record, unit -129, file /storage/users/rouson/neural-fortran/data/mnist/mnist_training_images.dat
Image              PC                Routine            Line        Source             
test_mnist         0000000000407428  Unknown               Unknown  Unknown
test_mnist         000000000042174E  Unknown               Unknown  Unknown
test_mnist         000000000041F65B  Unknown               Unknown  Unknown
test_mnist         00000000004049C9  Unknown               Unknown  Unknown
test_mnist         0000000000404059  Unknown               Unknown  Unknown
test_mnist         0000000000402E5B  Unknown               Unknown  Unknown
test_mnist         0000000000402DA2  Unknown               Unknown  Unknown
libc-2.28.so       00007F77396B2493  __libc_start_main     Unknown  Unknown
test_mnist         0000000000402CAE  Unknown               Unknown  Unknown
 Initializing 2 networks with random weights and biases
 Save network 1 into file
 Load network 2 from file
 Layer            1 , weights equal:  F , biases equal: T
 Layer            2 , weights equal:  F , biases equal: F
 Layer            3 , weights equal:  T , biases equal: F
 
 Setting different activation functions for each layer of network 1
 Save network 1 into file
 Load network 2 from file
 Layer            1 , activation functions equal: T (network 1: sigmoid
 , network 2: sigmoid)
 Layer            2 , activation functions equal: T (network 1: tanh
 , network 2: tanh)
 Layer            3 , activation functions equal: T (network 1: gaussian
 , network 2: gaussian)
           1 -0.1052737     -0.1680061      0.2748350      0.1508894    
  4.4866543E-02  0.1150012      0.2544496     -7.8449592E-02  0.1209764    
  0.1076126      0.2480879      8.8033140E-02 -0.2845391      5.8349479E-02
  0.1221117    
 T T T T T T T T T T T T T T T T T T T T
 All tests passed.
<ERROR> Execution failed for object " test_mnist "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

rouson avatar Apr 15 '22 22:04 rouson

I just updated the initial comment on this issue to indicate that the issue happens after checking out the main branch. (It also happens on the "submodules" branch, but it appears the problem predates the submodules branch.

rouson avatar Apr 15 '22 23:04 rouson

This is because Intel Fortran by default uses a different definition unit of record length than GFortran. Pass -assume byterecl to ifort, see:

https://github.com/modern-fortran/neural-fortran/blob/f49d95f4c48ba2b985d6e848bea8df23e846b62c/CMakeLists.txt#L63

I'm not sure if -assume realloc_lhs is still needed, but it used to be with earlier versions of ifort.

I think it's possible to make a portable recl in direct access using the inquire statement before open, though I think a better fix would be to switch to stream access for reading the data.

milancurcic avatar Apr 16 '22 00:04 milancurcic