same_type_as(a, b) determines whether the dynamic type of a is the same as the dynamic type of b.
Fortran 2003 and later
a - an object of extensible type.b - an object of extensible type.A default logical scalar is returned. The value is .true if the dynamic type of a is the same as the dynamic type of b and .false. otherwise. Differences in type parameters are ignored.