- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I knew there was some option to get this result! I just could not find it from the description from "ifort -help"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve. I learned something new. Newbie here. :)
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page