Quantcast
Channel: Intel® Fortran Composer XE
Viewing all articles
Browse latest Browse all 1424

Calling a function from a parallelized do concurrent loop

$
0
0

Trying to compile my program in the release mode with parallelization, I've encountered a problem with calling a function, defined in a module. Here is the sample program to reproduce the problem:

program test
use test_mod
implicit none

integer, parameter :: N = 10
integer :: i
real :: a(N)

do concurrent (i = 1:N)
	a(i) = func(real(i))
end do

print *, a

end program

and the module:

module test_mod
implicit none

contains

pure function func(x)
	real, intent(in) :: x
	real :: func

	func = 1/x
end function

end module

When I compile it in the debug mode, the output is:

  1.000000      0.5000000      0.3333333      0.2500000      0.2000000
 0.1666667      0.1428571      0.1250000      0.1111111      0.1000000

but when I switch to the release mode, the output is just random garbage like this:

       Infinity       Infinity  8.3329765E-29  8.3329765E-29  5.9022872E+37
       Infinity  1.0935606E-33  1.1641040E-10  8.3330276E-29  8.3329765E-29

The command lines for release compilation are:

Compiling with Intel(R) Visual Fortran Compiler XE 14.0.1.139 [IA-32]...
ifort /nologo /O2 /Qparallel /module:"Release\\" /object:"Release\\" /libs:dll /threads /c /Qvc12 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\\bin""d:\Projects\ParTest\ParTest\mmod.f90"
ifort /nologo /O2 /Qparallel /module:"Release\\" /object:"Release\\" /libs:dll /threads /c /Qvc12 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\\bin""d:\Projects\ParTest\ParTest\main.f90"

What am I doing wrong? Thank you.


Viewing all articles
Browse latest Browse all 1424

Trending Articles



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