- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greetings all:
In converting libraries over to F90/F2003 I am finding some duplication of routines, and I am wondering about the best way to do it....
Let's say I have two functions Uppr and StrUpCase, both take in a string and return it as upper case. Let's assume I am going to take StrUpCase as being my "golden" source.
I could write a wrapper so
FUNCTION Uppr(string)
Uppr=StrUpCase(string)
RETURN
END FUNCTION UPPR
But this seems "a bit wasteful" is there a STANDARD way to equivalence functions/subroutines like you do variables?
Regards
Carl
In converting libraries over to F90/F2003 I am finding some duplication of routines, and I am wondering about the best way to do it....
Let's say I have two functions Uppr and StrUpCase, both take in a string and return it as upper case. Let's assume I am going to take StrUpCase as being my "golden" source.
I could write a wrapper so
FUNCTION Uppr(string)
Uppr=StrUpCase(string)
RETURN
END FUNCTION UPPR
But this seems "a bit wasteful" is there a STANDARD way to equivalence functions/subroutines like you do variables?
Regards
Carl
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There isn't a standard way to do this. Well, almost. Here's one that works if both routines are in a module.
Let's assume that StrUpCase is a module procedure. In the part of the module before CONTAINS, add this:
If the routines themselves are not in a module but you have explicit interface blocks for them, you could fudge this with some !DEC$ directives but I don't want to lead you down that path.
Let's assume that StrUpCase is a module procedure. In the part of the module before CONTAINS, add this:
[cpp]interface Uppr module procedure StrUpCase end interface[/cpp]Now if code calls Uppr it will actually call StrUpCase and you don't need to duplicate the code or write a jacket. What this does is define a generic interface named Uppr. In most cases, one would have two or more module procedures listed, but there's no requirement for that.
If the routines themselves are not in a module but you have explicit interface blocks for them, you could fudge this with some !DEC$ directives but I don't want to lead you down that path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
Once again your wisdom saves allot of time and recoding.
Regards
Carl

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