Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

eliminating g77 intrinsic function

$
0
0

In the applications that I have ported from g77 to Intel Fortran, many of the remaining run-time bugs are due to use of g77 intrinsic functions.  I am trying to come up with a way to track them down before they cause run-time errors.  I have an idea based on the following small example, but wanted to elicit ideas from this community.

Here is a g77 function that kills a process, given the process id:

       INTEGER FUNCTION KILLER(PID)
       INTEGER*4 PID, RESULT
       CALL KILL(PID,9,RESULT)
       KILLER=RESULT
       END
Notice the signature of the kill subroutine.  This snippet of code would be correctly implemented as follows in Intel Fortran:

       INTEGER FUNCTION KILLER(PID)
       USE IFPORT
       INTEGER*4 PID, RESULT
       RESULT = KILL(PID,9)
       KILLER=RESULT
       END
As in C, kill() is an integer function with 2 arguments.

This was an easy coding change to make, but the run-time bug that it caused was not as easy to track down.  I would rather find these at compile time.  I noticed that if I add "USE IFPORT" to the original implementation with the g77 intrinsic, I get a compile error.  Code is:

       INTEGER FUNCTION KILLER(PID)
       USE IFPORT
       INTEGER*4 PID, RESULT
       CALL KILL(PID,9,RESULT)
       KILLER=RESULT
       END
and compile error is:

killererr.for(4): error #6552: The CALL statement is invoking a function subprogram as a subroutine.   [KILL]
       CALL KILL(PID,9,RESULT)
------------^
killererr.for(4): error #6784: The number of actual arguments cannot be greater than the number of dummy arguments.   [KILL]
       CALL KILL(PID,9,RESULT)
------------^
This is a good thing!  So now I'm wondering: Is there a compiler switch or some other way to indicate that I would like to "USE IFPORT" on all of my code?  Or any other approach that you can suggest, short of searching for every g77 intrinsic (I found an on-line reference) in the source code?

Thanks,
JayB


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>