Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

How to declare `interface` block for MKL functions?

$
0
0

Hi,

The following code was successfully compiled but returned wrong result:

program main
   use, intrinsic:: iso_fortran_env, only: INPUT_UNIT, OUTPUT_UNIT, ERROR_UNIT

   implicit none

   interface ! returns wrong result
      subroutine sscal(n, alpha, x, incx)
         Integer, intent(in):: n
         Real, intent(in):: alpha
         Real, intent(inout):: x(:)
         Integer, intent(in):: incx
      end subroutine sscal
   end interface
   ! external sscal ! returns expected result

   Real:: xs(2) = [1, 2]

   write(OUTPUT_UNIT, *) xs
   call sscal(2, 3.0, xs, 1)
   write(OUTPUT_UNIT, *) xs

   stop
end program main

 

   1.000000       2.000000
   1.000000       2.000000



If I use `external` statement instead of the `interface` block, it works as expected:

 

   1.000000       2.000000
   3.000000       6.000000



Would you tell me how to make `interface` block version work correctly?

I use `ifort (IFORT) 13.1.0 20130121`.



 


Viewing all articles
Browse latest Browse all 2583


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