- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure if this is possible, but I have two fortran modules that a subroutine I have written needs to access. The problem is the global variable in the modules have the same name. In python you can rename an imported module's global variable to overcome this type of conflict.
My current situation is:
[fortran]
USE MOD1, ONLY: VAR
USE MOD2, ONLY: VAR
[/fortran]
Is it possible to do something like:
[fortran]
USE MOD1, ONLY: VAR as VAR1
USE MOD2, ONLY: VAR as VAR2
[/fortran]
I can not change MOD1 and MOD2. Is the only way to work around this is to create two dummy functions to pull the separate values?
[fortran]
SUBROUTINE A()
VAR1=aMOD1VAR()
VAR2=aMOD2VAR()
END SUBROUTINE
FUNCTION aMOD1VAR()
USE MOD1, ONLY: VAR
aMOD1VAR=VAR
END FUNCTION
FUNCTION aMOD2VAR()
USE MOD2, ONLY: VAR
aMOD2VAR=VAR
END FUNCTION
[/fortran]
Thanks for any comments.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes - you can put a rename clause on the USE statement to give a local name to something from a module
[fortran]USE module_name, ONLY: local_name => name_in_module[/fortran]

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page