<MOLD= Example Program>
Module mold_types
Type t1
Integer :: a = 3
End Type
Type,Extends(t1) :: t2
Integer :: b = 4
End Type
End Module
Program mold_example
Use mold_types
Class(t1),Allocatable :: x
Type(t2) :: y = t2(123,456)
Allocate(x,Mold=y)
Print 1,'Y',y
1 Format(1X,'Value of ',A,' is',99(1X,I0,:,','))
Select Type (x)
Type Is (t2)
Print 1,'X',x
Class Default
Stop 'Impossible'
End Select
End Program
■ Execution Results
Value of Y is 123, 456 Value of X is 3, 4