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

Calling module procedure using module name prefix

smedvedoff
Beginner
742 Views

I have two modules, mod1 and mod2, and each has a procedure named Initialize. I would like to call the Initialize procedure from mod1 using the module name as a prefix; something like:

Call mod1::Initialize or Call mod1.Initialize

rather than just "Call Initialize"

But I can't find a syntax that the compiler likes. Is there a way to do this?

Thanks,

Steve

0 Kudos
5 Replies
TimP
Honored Contributor III
742 Views
If you would make Initialize a CONTAINS procedure in the scope where it is called, that should accomplish it.
0 Kudos
Steven_L_Intel1
Employee
742 Views
You can do it this way:

use mod1, mod1_initialize => initialize
use mod2, mod2_initialize => initialize

If initialize was a generic and took arguments of distinct types, you would not need to do this.


0 Kudos
smedvedoff
Beginner
742 Views

Tim,

Thanks for your response. Could you give me a little more info? What syntax would I use to call Initialize in mod1? I know "Call Initialize" will work, but I want to use the module name prefix. I've tried "Call mod1::Initialize" and other variations but all cause compile errors.

Thanks,

Steve

0 Kudos
Steven_L_Intel1
Employee
742 Views
Using a contained procedure wouldn't work - you can't have two different entities of the same name visible in a program unit. There is no qualifying syntax such as :: but renaming on the USE, as I showed, effectively accomplishes this. With this suggestion, you would call mod1_initialize and mod2_initialize.
0 Kudos
smedvedoff
Beginner
742 Views

Thanks Steve!

- Steve

0 Kudos
Reply