Silverfrost Forums

Welcome to our forums

Arithmetic error trapping

10 Apr 2013 2:24 #12024

I'm passing this on for interest, because it doesn't happen in a 'pure' FTN95 application...

We provided DLLs to be called from a 3rd-party application, and got an 'arithmetic under/overflow error' condition when run under their app. Further investigation showed that the error occurs in the MOD function when mixed integer types are involved:

     INTEGER*8  :: I8
     INTEGER*4  :: I4,K4

     K4   =  MAX(1,K4)
     I4   =  I8
     IF( MOD(I4,K4).EQ.0) THEN ! This works but...
     IF( MOD(I8,K4).EQ.0) THEN ! This can cause an arithmetic error under 3rd party app

As I say, only passed on in case others hit the same issue, as it's not reproducible from an FTN95 EXE.

K

10 Apr 2013 4:01 #12027

Interesting observation 😃

The Fortran Standard doesn't allow you use to different integer kinds for each argument of MOD.

I know FTN95 seems to work for some KIND combinations but I always saw this as an extension to the standard.

Please login to reply.