Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development Tools (Compilers, Debuggers, Profilers & Analyzers)
- Intel® Fortran Compiler
- DOUBLE COMPLEX variable returns NaN

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Feby_A_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-10-2019
10:43 PM

6 Views

DOUBLE COMPLEX variable returns NaN

Hi!

I am using Intel Compiler 17.0 Update 2 with Visual Studio 2013 to compile a FORTRAN code. I am supposed to get a complex number after the compute process. However the real part of the variable returns an NaN.

To verify that there is no division by zero I did the same compute in the MATLAB environment, and it promptly returned the exepected complex number.

I have included a MWE for the same. Could someone throw light on what the issue is?

program complx1 implicit none double complex :: dc dc = -(-(((1.00001489783669D0*1.1D0**2.0D0+& (2.0D0*0.0D0*0.0D0+2.0D0*0.0D0*0.0D0)*1.1D0+1.00001374871743D0*0.0D0**2.0D0& +2.0D0*0.0D0*0.0D0*0.0D0+1.00001374871743D0*0.0D0**2.0D0)*474615.661905876D0& +3777440278.20392D0)*1.10002331748149D0**(5.0D0/3.0D0)& -3777440278.20392D0*1.10002331748149D0**(2.0D0/3.0D0))*(-(1.0D0/2.0D0*3777440278.20392D0& -1.0D0/2.0D0*162834746.546865D0/1.10002331748149D0)*8.43301084637337D0& -1.0D0/2.0D0*474615.661905876D0*3.21004552381726D0)**((1.0D0& -0.710000000000000D0)/0.710000000000000D0)*(1.0D0& -0.710000000000000D0)/0.710000000000000D0*(1.0D0/2.0D0*3777440278.20392D0& -1.0D0/2.0D0*162834746.546865D0/1.10002331748149D0)& *0.999985102385248D0/(-(1.0D0/2.0D0*3777440278.20392D0& -1.0D0/2.0D0*162834746.546865D0/1.10002331748149D0)*8.43301084637337D0& -1.0D0/2.0D0*474615.661905876D0*3.21004552381726D0)& +1.10002331748149D0**(5.0D0/3.0D0)*0.999985102385248D0*589000000000.000D0& -1.0D0/3.0D0*1.10002331748149D0*5890000000.00000D0*((-1.0D0/3.0D0*3.21004552381726D0& +1.00001489783669D0*1.1D0**2.0D0+(2.0D0*0.0D0*0.0D0+2.0D0*0.0D0*0.0D0)*1.1D0& +1.00001374871743D0*0.0D0**2.0D0+2.0D0*0.0D0*0.0D0*0.0D0& +1.00001374871743D0*0.0D0**2.0D0)*0.999985102385248D0+1.21000000000000D0& -3.0D0*1.1D0**2.0D0))/1.10002331748149D0**(5.0D0/3.0D0) write (*,*) dc write (*,'(F0.0)') dc write (*,'(F0.0,A,F0.0)') dble(dc), ' + i ' , aimag(dc) end program complx1

Here is a screengrab same computation performed on MATLAB.

6 Replies

Highlighted
##

Arjen_Markus

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-10-2019
11:44 PM

6 Views

I got NaN with Intel Fortran

I got NaN with Intel Fortran 2018 as well, but when I tried to compile the program with gfortran I got the compile time error:

1.10002331748149D0**(2.0D0/3.0D0))*(-(1.0D0/2.0D0*3777440278.20392D0-1.0D0/2.0D0*&

1

Error: Raising a negative REAL at (1) to a REAL power is prohibited

Somewhere in this complex (no pun intended) expression you have a negative real that is raised to a real power. I think you should make that negative real a complex number for this to work.

Highlighted
##

Feby_A_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2019
12:07 AM

6 Views

That was a life saver!

That was a life saver!

A DCMPLX type conversion worked out.

I guess Intel Compiler should throw up a warning for such cases.

Thank you Markus.

Highlighted
##

I think the gfortran compiler uses a different strategy for these cases than the Intel Fortran compiler: the one uses compile-time evaluation, the other does not. I have not found a flag, though, that will cause the program to stop with an understandable error message, alas. May be the limited time I put into that. I did not try any of the IEEE routines to control floating-point behaviour - that mihgt be the way to go, as this is clearly an example of the calculations that are going on in your actual program.

Arjen_Markus

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2019
12:30 AM

6 Views

I think the gfortran compiler

Highlighted
##

Steve_Lionel

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2019
05:55 AM

6 Views

C:\Projects>ifort /fpe0 t.f90

C:\Projects>ifort /fpe0 t.f90 /traceback Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.2.190 Build 20190117 Copyright (C) 1985-2019 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 14.15.26730.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:t.exe -subsystem:console -incremental:no t.obj C:\Projects>t.exe forrtl: error (65): floating invalid Image PC Routine Line Source t.exe 00007FF6076E3239 __libm_pow_e7 0 Unknown t.exe 00007FF6076E1AB7 __libm_pow_dispat 0 Unknown t.exe 00007FF60769105A MAIN__ 10 t.f90

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

Highlighted
##

I knew there was some option to get this result! I just could not find it from the description from "ifort -help"

Arjen_Markus

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2019
05:57 AM

6 Views

I knew there was some option

Highlighted
##

Feby_A_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2019
07:21 AM

6 Views

Thank you Steve. I learned

Thank you Steve. I learned something new. Newbie here. :)