Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share partial of an array in the module 2

Status
Not open for further replies.

takisword

Technical User
Feb 9, 2010
2
US
Hi everyone. Here I have an array x define in a module. How can I use part of x, say x(1) in a routine? I tried

USE module_name, ONLY: x1 => x(1)

but it didn't work. Can anybody help? Thanks.
 
I doubt whether that's possible.

If it's only for x(1), you might as well copy x(1) into a scalar variable inside your module (say "axeone") and then use ONLY: x1 => axeone

What's against it to use ONLY: x
and take the whole array from the module?

Does that need more memory? I never thought so, I assumed the USE statement works as a sort of pointer for variables without copying the content of the data in another part of the memory.
 
Alternatively in the module
Code:
REAL, POINTER:: x1
REAL, PRIVATE:: x(20)

...
x1 => x(1)
Then from the other module just use x1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top