user-defined type with 1 component

Hi,

Is there a way to make a user-defined type with only 1 component, without a necessity to refer to the unique component? Now I have to do:

TYPE (Vector)
  REAL :: x(3)
END TYPE

TYPE(Vector) :: x

x%x(1) = 17.

The reference to “x%x” seems an overkill in x-es.

Of course I can always call such entities REAL, DIMENSION(3), but just to make a difference between “real vectors” for which vector-operations apply, and “3-REALs-in-a-row”, the definition of type Vector would be useful.

Thanks,

Arjan

Hi Arjan,

Not until the F2003 associate feature is added. However, why not just declare the variable as a REAL array instead of creating a struct with a single member?

  • Mat

Because (copy/paste from my last message):

Of course I can always call such entities REAL, DIMENSION(3), but just to make a difference between “real vectors” for which vector-operations apply, and “3-REALs-in-a-row”, the definition of type Vector would be useful.

But maybe you’re right, and until the F2003 compiler runs, it’s better to use REAL, DIMENSION(3).

Arjan