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

function return integer and ERRSNS

Deleted_U_Intel
Employee
1,255 Views
Hi, I've got two problems here:

1) Can not return integer from a function, it always returns -2147483648 no matter what I assigned to the function. If I return real, it's fine.

2) I have a problem with liker for function ERRSNS, basically, I can call ERRSNS(,,,,int5) but liker complains on my call to ERRSNS(int1, int2, int3, int4, int5)

I've been playing with these two problem for a day and can not find out the solution, anybody has any insight?

Thanks a lot.

Lei
0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,255 Views
You haven't declared your function as INTEGER in the caller.

Did the compiler complain about the call to ERRSNS? What is the exact linker error?

Steve
0 Kudos
Steven_L_Intel1
Employee
1,255 Views
In Fortran, identifiers have implicit types based on the first letter of their name. Names that start with the letters I through N are implicitly INTEGER, everything else is implicitly REAL. The old Fortran programmer's joke about this is "GOD IS REAL (unless declared INTEGER)".

You can avoid worrying about this by adding the line

IMPLICIT NONE

to each and every program unit in your application. This goes right after the PROGRAM, SUBROUTINE or FUNCTION statement, unless you have USE statements, in which case it follows those. This will have the effect of turning off implicit typing and forcing you to explicitly declare the type of everything. This is good - as it will help catch common mistakes.

How are you building the program? Can you come up with a small but complete program that demonstrates the ERRSNS problem? Oh, do you have an EXTERNAL ERRSNS line in there somewhere? If so, take it out.

Steve
0 Kudos
Steven_L_Intel1
Employee
1,255 Views
Glad to hear it. Yes, the INTEGER declaration for ERRSNS apparently "removes" the intrinsic property from it (since in CVF, ERRSNS is an intrinsic subroutine.) It is not entirely clear to me if this is appropriate behavior - I will ask - but it doesn't sound unreasonable.

Steve
0 Kudos
Reply