Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29235 Discussions

Problems with pack intrinsic function: catastrophic error and bad results

Corrado_C_
Beginner
774 Views

I noticed that the subroutine sprsin in numerical recipes produces catastrophic error if compiled with ifort 15.
The problem seems due to the line

sa%jcol=pack(spread(arth(1,1,n),1,n),mask)

It is possible to reproduce the error by compiling the code test_err1.f90

ifort test_err1.f90

./a.out

At the same time I found that this line

sa%irow = pack(spread(arth(1,1,NDIM),2,NDIM),mask(:,:))

in test_err2.f90 produce bad results.
gfortran compiler and old version of ifort produce correct results.

I use Ubuntu 14.04.2 LTS 64bit

0 Kudos
4 Replies
Steven_L_Intel1
Employee
774 Views

Thanks, we'll take a look.

0 Kudos
Steven_L_Intel1
Employee
774 Views

Escalated as issue DPD200371368. Thanks for the nice examples.

0 Kudos
Steven_L_Intel1
Employee
774 Views

Here's a workaround.

Declare a local variable such as this:

integer, dimension(NDIM,NDIM) :: arth_temp

and then replace the problem statement with these two lines:

arth_temp = spread(arth(1,1,NDIM),1,NDIM)
sa%irow = pack(arth_temp,mask(:,:))

This is effectively what the compiler needs to do anyway.

0 Kudos
Steven_L_Intel1
Employee
774 Views

I expect this to be fixed in Update 1 to the 16.0 compiler.

0 Kudos
Reply