Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Best way to do an alias for a function/subroutine

carlls
Beginner
1,511 Views
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
0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,511 Views
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:

[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.
0 Kudos
carlls
Beginner
1,511 Views


Thanks Steve.

Once again your wisdom saves allot of time and recoding.

Regards
Carl

0 Kudos
Reply