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

Is a "divide by zero" error possible within a subroutine call instruction? (compiler?)

crazyjake
Beginner
779 Views
Hi all! While running a scientific code (compiled in debug mode (-C -traceback etc.) for testing), i got this error:
forrtl: error (73): floating divide by zero
Image              PC        Routine            Line        Source
libimf.so          4008F337  Unknown               Unknown  Unknown
es_cPIF_debug      08088D34  mover_mp_mmov_shi          97  mover.f90
es_cPIF_debug      080EC442  MAIN__                    220  Main.f90
es_cPIF_debug      0804A869  Unknown               Unknown  Unknown
libc.so.6          4024C37E  Unknown               Unknown  Unknown
es_cPIF_debug      0804A751  Unknown               Unknown  Unknown
Ok, i thought i was the same scatterbrained. But i found the line the error refers to like
do while( [...] )
    ![...]
    call MMov_mMCC( [...] ) !*** line 97
    ![...]
end do
Can anyone help me understanding? To me, it's a good mystery... Thanks.
0 Kudos
5 Replies
Steven_L_Intel1
Employee
779 Views
I think we'd need to see the actual code and not "...". The indications suggest a math library call in there somewhere.
0 Kudos
umar
Beginner
779 Views
Without seeing the actual code I can think of a couple of simple things:

1. Check all the argument types and sizes between the actual
subroutine and the call statement.

2. One thing that caught me few times that the compiler does not
catch but segfaults is if something that is defined in a parameter
statement is passed to the subroutine, which tries to change it
by mistake!! I think this should be caught by the compiler rather
then crash.

Umar
0 Kudos
Steven_L_Intel1
Employee
779 Views
The compiler usually does not know that a called routine will try to change the argument. You can give it that information by always using explicit interfaces with INTENT(OUT) if the argument is always written. However, if it is read as well, then INTENT(INOUT) does not permit the compiler to complain as that is not a guarantee that the argument will be written. In any event, you'll get a segmentation fault for this problem, not a zerodivide.
0 Kudos
Hirchert__Kurt_W
New Contributor II
779 Views
Actually, INTENT(INOUT) does allow the compiler to complain; any argument associated with an INTENT(INOUT) dummy argument is required to be definable. (This requirement can be found in clause 5.1.2.3 of the Fortran 95 standard.) It is unspecified intent (i.e., what you get if you don't specify intent) that doesn't allow the compiler to complain.
0 Kudos
Steven_L_Intel1
Employee
779 Views
You are correct. Thanks for pointing that out.
0 Kudos
Reply