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

question about DCMPLX

LeonardB
New Contributor I
449 Views

Hi

The intrinsic function DCMPLX does not change to 128 bit precision when using compiler option /double_size:128. It seems like DCMPLX(x,y) is equal to CMPLX(x,y,kind=8) instead of CMPLX(x,y,kind=KIND(1.D0)). The problem is illustrated in the enclosed program (the same result in IVF11 and IVF12). Is this a bug or a consequence of the fortran standard?



Program Qtst

double complex z

double precision x

call xxx( dcmplx(1.D0,0.D0))

x=0.213D0

z = DCMPLX( x, 0.D0 )

write(*,*) x,z

end

subroutine xxx(x)

double complex x

write(*,*) x

end

0 Kudos
2 Replies
Steven_L_Intel1
Employee
449 Views
Interesting.

DCMPLX is not a standard intrinsic - it is an extension. I would expect /double_size to affect it - CMPLX/DCMPLX seems to be unusual here, since the option does affect SQRT, for example. Escalated as DPD200173396.
0 Kudos
Steven_L_Intel1
Employee
449 Views
Upon further reading, and discussion with the developers, we determined that this is not a bug.

DCMPLX is explicitly documented as returning COMPLEX(KIND=8) and is not affected by /double-size.

CMPLX is standard but the standard specifies that in the absence of a KIND= specifier, the result is complex of default real kind. So without KIND=, CMPLX is not affected by /double-size either but it is affected by /real-size.

The suggestion I have for you is to replace uses of DCMPLX with CMPLX (x,y,KIND=(KIND(1.0D0)). This will do what you want.
0 Kudos
Reply