Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Arrays and Common Blocks.

kcheathcote
Principiante
492 Vistas
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?
0 kudos
2 Respuestas
Steven_L_Intel1
Empleados
492 Vistas
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.
Steven_L_Intel1
Empleados
492 Vistas
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.
Responder