This is unrelated to your question, but you might want to think of inheritance as a last resort (i.e., when components might substantially differ).
In the code you showed, both types can be dealt with with simple indices:
INTEGER, PARAMETER :: INTERNA = 1, EXTERNA = 2
TYPE,EXTENDS(propiedad_casa) :: propiedad_intex
INTEGER :: tipo
TYPE(svg_color):: color(2)
REAL(8) :: costo(0:2) = -HUGE(1.d0)
CHARACTER(LEN=10) :: material(2) = ""
END TYPE propiedad_intex
! ĂŤndices para propiedades internas
INTEGER, PARAMETER :: DISENNO = 0, PISO = 1, PARED = 2
! ĂŤndices para propiedades externas
INTEGER, PARAMETER :: PROD = 0, FRONTERA = 2 ! PISO is the same
So, for example, an internal property can be handled as:
TYPE(propiedad_intex) :: a
a%tipo = INTERNA
! ... Set costs here ...
print*,'Costo de piso=',a%costo(PISO)
print*,'Costo de pared=',a%costo(PARED)
a%costo(DISENNO) = SUM(a%costo([PISO, PARED]))
print*,'Costo de diseño=',a%costo(DISENNO)
Notice that I changed the default cost to -HUGE(1.d0), to make it easier to know that something goes wrong if a proper value is not set.
The Fortran array model assumes that all members of an array have the same type. So if you need to maintain a list of properties, the following won’t work:
class(propiedad_casa), allocatable :: props_map(:)
! All elements of the array have the same dynamic type
allocate( propriedad_externa :: props_map(100) )
To have different polymorphic entities in an array, you will need to introduce another type (we really ought to find a better name for such “wrapper” types):
type :: any_prop
class(propiedad_casa), allocatable :: p
end type
type(any_prop), allocatable :: props_map(:)
allocate(props_map(10))
props_map(1)%p = propriedad_interna(piso=...,pared=...)
props_map(2)%p = propriedad_externa(piso=...,frontera=...)
...
Otherwise I agree with @jwmwalrus that a non-polymorphic solution may be a better fit. If it is only two types, I can certainly imagine just keeping two lists:
type :: properties
type(propiedad_interna), allocatable :: pi(:)
type(propiedad_externe), allocatable :: pe(:)
end type