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

Adding write statements to a subroutine breaks the MKL lib

Henk_K_
Beginner
301 Views

Hi all,

Classic strange behaviour with write statements in a subroutine. Adding them breaks the MKL library.

Without the writes, the dolfyn CFD code (written in f2003) runs:

 Flag   Step    Res U     Res V     Res W     Mass      Res k     Res eps   Res T          U         V         W         P         k        eps        T
     :     1:  1.36E-04  7.41E-05  0.00E+00  5.71E-02  0.00E+00  0.00E+00  0.00E+00     4.58E+00 -1.65E+00  0.00E+00 -1.39E+01  0.00E+00  0.00E+00  0.00E+00
     :     2:  9.50E-04  1.02E-03  0.00E+00  3.35E-02  0.00E+00  0.00E+00  0.00E+00     4.73E+00 -1.57E+00  0.00E+00 -1.47E+01  0.00E+00  0.00E+00  0.00E+00

Adding them:

 *** Error: Failed preconditioner of mkl solver         -103
 *** Error: Failed in mkl solver dfgmres, i =         302 RCI          -1
 *** Error: Failed in mkl solver dfgmres, i =         302 RCI          -1
 *** Error: Failed in mkl solver dfgmres, i =         302 RCI          -1
 *** Error: Failed in mkl solver dfgmres, i =         302 RCI          -1
 Flag   Step    Res U     Res V     Res W     Mass      Res k     Res eps   Res T          U         V         W         P         k        eps        T
     :     1:  1.36E-04  7.41E-05  0.00E+00  3.61E-01  0.00E+00  0.00E+00  0.00E+00     4.68E+00 -2.52E+00  0.00E+00 -2.22E+01  0.00E+00  0.00E+00  0.00E+00
 *** Error: Failed preconditioner of mkl solver         -103
     :     2:  1.24E-03  1.54E-03  0.00E+00  6.94E-02  0.00E+00  0.00E+00  0.00E+00     4.92E+00 -1.41E+00  0.00E+00  1.13E+01  0.00E+00  0.00E+00  0.00E+00
 *** Error: Failed preconditioner of mkl solver         -103

The difference in the two subroutines is:

$ diff solver_mkl_OK.f90 solver_mkl_FOUT.f90
199c199
<        write(IOdef,*)'*** Error: Failed preconditioner of mkl solver'
---
>        write(IOdef,*)'*** Error: Failed preconditioner of mkl solver ',IERR
238a239
>      write(IOdbg,*)'*** start solver dfgmres'
242a244
>        !    dfgmres( n,    x,  b,  RCI_request,    ipar,    dpar,    tmp)
243a246
>        write(IOdbg,*)'*** solver dfgmres returns with ',RCI_request
250a254,256
>          ! multiply the matrix by tmp(ipar(22)), put the result in tmp(ipar(23)), 
>          ! and return the control to the dfgmres routine
>          
259c265,266
<          write(iodef,*)'*** Error: Failed in mkl solver'
---
>          write(IOdbg,*)'*** Error: Failed in mkl solver dfgmres, i =',i,'RCI',RCI_request
>          write(iodef,*)'*** Error: Failed in mkl solver dfgmres, i =',i,'RCI',RCI_request
270c277
<      write(IOdbg,*)'Leave MKL solve P'
---
>      write(IOdbg,*)'Leave MKL solve P',RCI_request

As you can see no significant differences.

The full code, with two versions of subroutines, is in the tarball along with a small demo data set. Unpack it on a linux box with ifort. Change into test and hit:

$ ./go.sh

To reproduce the bug (or not). 

$ ifort --version
ifort (IFORT) 17.0.4 20170411
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

$ uname -a
Linux tennekes 4.4.0-83-generic #106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

 

Ubuntu 16.04.2 LTS
Intel i7-6700HQ CPU @ 2.60GHz
Lenovo Y700 16GB 

Any hints or suggestions welcome, but this might interest the developers more.

Thank you!

Henk

 

 

 

0 Kudos
2 Replies
Jing_Xu
Employee
301 Views

I've tested your code using ifort 2018 and had no error. You can try to join our PS XE 2018 program as a workaround.

I'm testing ifort 2017 for this issue.

0 Kudos
Henk_K_
Beginner
301 Views

Thank you for responding!

The workaround options are simple; as it is a calling (driver) subroutine only one can alter the compiler statements (-g and/or -O0 etc), or change the order of the write statements (and yes alter them as well).

It is not a big issue, but somewhere the compiler (on Ubuntu 16.04.2) fails. I do agree that these are very annoying bugs :- )

 

 

 

 

 

0 Kudos
Reply