- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am porting modules from a unixFortran 77 complierto a windows intel Fortran complier.
I need to know if it is possible to refer to an element in the common block as an array.
For example: Assume my common blockhas the following labels in sequential orderVAR1, VAR2, VAR3, and VAR4. If Ideclare VAR1(4) in my CP of my module,will the complier understand that I am referring to the common block label VAR3 when I use VAR1(3) in the code?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No. But you can use EQUIVALENCE to do what you're looking for.
real var1, var2, var3, var4, vars(4)
common /mycommon/ var1, var2, var3, var4
equivalence (var1, vars)
Now you can use vars(3) to get at var3.
real var1, var2, var3, var4, vars(4)
common /mycommon/ var1, var2, var3, var4
equivalence (var1, vars)
Now you can use vars(3) to get at var3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No - if you declare VAR1 as being (4), that will make it push out the other variables and give you incorrect results.
What you want is EQUIVALENCE:
real var1, var2, var3, var4, vars(4)
common /mycommon/ var1, var2, var3, var4
equivalence (var1, vars)
Now you can use vars(3) to get at var3.
What you want is EQUIVALENCE:
real var1, var2, var3, var4, vars(4)
common /mycommon/ var1, var2, var3, var4
equivalence (var1, vars)
Now you can use vars(3) to get at var3.

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