getrf Fortran 77 Call Corrupts Integers

getrf Fortran 77 Call Corrupts Integers

I have a helper subroutine that basically calls the MKL getrf/getrs functions like this:

 

  INTERFACE GETRF
          SUBROUTINE SGETRF(M,N,A,NMAX,IR,ISING)
              INTEGER NMAX,M,N,ISING
              INTEGER, DIMENSION(NMAX) :: IR
              REAL(4), DIMENSION(NMAX,NMAX) :: A
          END SUBROUTINE
          SUBROUTINE DGETRF(M,N,A,NMAX,IR,ISING)
              INTEGER NMAX,M,N,ISING
              INTEGER, DIMENSION(NMAX) :: IR
              REAL(8), DIMENSION(NMAX,NMAX) :: A
          END SUBROUTINE
      END INTERFACE GETRF
C
      INTERFACE GETRS
          SUBROUTINE SGETRS(TRANS,M,N,A,NMAX,IR,B,NMAX2,ISING)
              INTEGER NMAX,NMAX2,M,N,ISING
              INTEGER, DIMENSION(NMAX) :: IR
              CHARACTER TRANS
              REAL(4), DIMENSION(NMAX) :: B
              REAL(4), DIMENSION(NMAX,NMAX) :: A
          END SUBROUTINE
          SUBROUTINE DGETRS(TRANS,M,N,A,NMAX,IR,B,NMAX2,ISING)
              INTEGER NMAX,NMAX2,M,N,ISING
              INTEGER, DIMENSION(NMAX) :: IR
              CHARACTER TRANS
              REAL(8), DIMENSION(NMAX) :: B
              REAL(8), DIMENSION(NMAX,NMAX) :: A
          END SUBROUTINE
      END INTERFACE GETRS

I just upgraded from Update 2 to Update 4 of the 2013 compiler (version 13.1.2.190).

My incoming real arguments can be either real(4) or real(8).  My integer arguments are always (project setting /integer_size:64) integer(8).

If I run this code with real(8) and Win32 project configuration, the IR() array gets corrupted.  If I run it with real(8) and x64 project configuration, IR() does not get corrupted.  What am I doing wrong now?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

There's no support for 64-bit integers in MKL for IA32.  It comes with the ilp64 libraries for Intel64.

If, through your project settings or using a compiler switch, you have chosen default integers that are 8 bytes long, then the interfaces that you gave above are incorrect for 32-bit MKL (as TimP pointed out). The compiler, having been given false information, will produce code that will fail at run time, as you have discovered.

You have to be very careful about giving correct interfaces to library routines, especially so because the compiler has no access to the source code to the routines in the library. Intel has already provided you the correct interfaces in the various .FI include files that come with MKL. Why not use them?

Leave a Comment

Please sign in to add a comment. Not a member? Join today