For Programmers: Free Programming Magazines  


Home > Archive > Fortran > September 2006 > While we are on the subject of modules...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author While we are on the subject of modules...
David Flower

2006-09-28, 7:00 pm

.... is there a solution to the following problem ?

I want a module that contains

1) INTERFACE OPERATOR and INTERFACE ASSIGNMENT statements

and

2) The corresponding FUNCTIONs and SUBROUTINEs

However, there is a catch, if I just use:

MODULE LESS
C
INTERFACE OPERATOR ( + )
MODULE PROCEDURE PLUS
END INTERFACE
C
CONTAINS
C
FUNCTION PLUS ( X,Y )
etc.
END FUNCTION
C
END MODULE

Then the FUNCTION PLUS will itself be subject to the INTERFACE OPERATOR
statement.


Now I know that this example is simplistic, and possibly illegal, but
in the more general case with many INTERFACE OPERATOR and INTERFACE
ASSIGNMENT statements, a genuine problem arises (For example code for
arrays accessing code for scalars).

My guess is somehow to use multiple modules accessed in a hierarchical
manner, but exactly how ?

I would add that all the module procedures are moved elsewhere, my
program works.

Thanks in advance

Dave Flower

Jugoslav Dujic

2006-09-28, 7:00 pm

David Flower wrote:
| ... is there a solution to the following problem ?
|
| I want a module that contains
|
| 1) INTERFACE OPERATOR and INTERFACE ASSIGNMENT statements
|
| and
|
| 2) The corresponding FUNCTIONs and SUBROUTINEs

I must say I don't get the definition of the problem (and thus the question),
in particular:

| Then the FUNCTION PLUS will itself be subject to the INTERFACE OPERATOR
| statement.

"be subject to the" -- in which sense?

What you wrote is a legal code (modulo shortening) whereby an addition can
be expressed in the USEing program unit as

Z = X + Y

or

Z = PLUS(X,Y)

being semantically equivalent. Are you saying you don't want that or...?

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com