Zeus
Zeus

Reputation: 1525

Fortran Equivalence

I want to use Equivalence. How can it be used in gfortran-5?

I am using:

Select Case (dst)
Case ("cm")
  Equivalence :: (cm2Mm_r32, r32), (cm2Mm_r64, r64)
  Call qcdiv (qb, qa, r32, r64, cm2Mm_r128)
Case ("m")
  Equivalence :: (m2Mm_r32, r32), (m2Mm_r64, r64)
  Call qcdiv (qb, qa, r32, r64, m2Mm_r128)
Case ("Km")
  Equivalence :: (Km2Mm_r32, r32), (Km2Mm_r64, r64)
  Call qcdiv (qb, qa, r32, r64, Km2Mm_r128)
End Select

Upvotes: 0

Views: 345

Answers (1)

Equivalence statement must be positioned in the declaration part. You cannot control it with conditionals.

Modern Fortran prefers transfer() to convert bit patterns. If you do not need type conversions, use pointers.

I actually use equivalence in one place of my code, where the Intel compiler is unable to optimize the transfer(), but that is an exception, you should think twice before using it.

Upvotes: 1

Related Questions