- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Did the compiler complain about the call to ERRSNS? What is the exact linker error?
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page