I am trying to port a fortran program from SGI Unix to Linux using ifc6.0. The program runs fine on the SGI. It compiles on linux but gives error while running. From my investigations, it seems that while running a (mesh) data file, it reads some numbers incorrectly. Due to this, some of the calculations result with NaN. How ever as the ifc guide says, the program continues, and at a later stage gives an error in convergence in one of the loops. Is there a way to detect where the NaN is generated?

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Unfortunately, there is no simple solution, such as used to be implemented in SunOS debuggers.
If you call a C subroutine which uses asm() to unmask the invalid exception, you must deal separately with the x87 and SSE/SSE2 exception masks, depending on which type of code is responsible. The SSE intrinsics provide a slightly higher level way to modify the SSE exception mask (mxcsr), and CVF compatibility would do a similar thing, in Fortran, for the x87 mask (fp control word). Call that function where you wish to begin watching for the exception, build your application with -g, and run under debugger.
With luck, this would help you find where a NaN is first generated. In x87 code, there are more possibilities for that to be delayed from the operation which has the problem operands, due to the extended range and precision of the registers.

Can you elaborate on 'fp control word' and how to use it. I am not aware of this. I basically want to watch for the exception almost from the beginning of the program.

As you haven't specified whether you are using CVF or a newer compiler, and whether you may be using SSE, I'll suggest you start by reviewing the CVF documentation on floating point exceptions. Also, browse the supplied files in the CVF installation under INCLUDE*.F90. I'm sorry, I'm a little rusty on CVF, and I don't know how much of this will be supported by the newer Intel Fortran, or whether SSE exceptions will be supported in a way similar to x87.
In particular, look at the PARAMETER masks defined for the INVALID exception in DFLIB.F90 and how they are used.

For the equivalent options for SSE, look at the C include files and documentation associated with the macro _MM_SET_EXCEPTION_STATE() and the _MM_MASK_INVALID mask.

Most likely, you want to get the current state of the relevant exception mask and XOR it with the appropriate INVALID mask, in order to unmask the invalid exception.

Did I say it's not as convenient as the old SunOS debug facility?

Of course, the "real programmers" do this stuff in asm, partly because there appears to be no consistency between the higher level ways of doing it for x87 and SSE.

The claim is that ifc 6 is being used, not CVF (which is a Windows-only product.)


Steve - Intel Developer Support

As I recall, ifc 6.0 didn't include documentation on all of the CVF compatibility functions which were there. Sorry I got distracted from the mention of ifc 6.0; I still have a copy of that here. In the file iflport.f90 there is an entry for FPCW$INVALID, and INTERFACE declarations for FOR_GET_FPE() and FOR_SET_FPE(), so it appears that those functions ought to work in accordance with the CVF documentation. They are mentioned in /docs/for_lib.pdf, which can be displayed by xpdf. I tend to forget about that, since xpdf is broken on our linux-64 installations.

Leave a Comment

Please sign in to add a comment. Not a member? Join today