This example won't compile.I'm using ftn95 6.20. gfortran and the Lahey f95 checker say its OK (but insist on sequence for TYPE_A & TYPE_B, required by example_A_T and example_B_T ). The compilation error is in B_TO_STR. The message states that ASSIGN_S_A expects the second dummy argument to be type TYPE_A (true, but shouldn't = resolve to ASSIGN_S_B?), whereas what is supplied is TYPE_B.
Remove sequence from TYPE_A and TYPE_B and ftn95 says all is OK.
module TESTAB
!
implicit none
!
type type_A
sequence
character(8) ch
end type
type type_B
sequence
character(8) ch
end type
!
interface assignment(=)
module procedure assign_A_S,assign_B_S,assign_S_A,assign_S_B
end interface
contains
!================================================================================
subroutine assign_A_S(a,s)
character(8),intent(in) :: s
type(type_A),intent(inout) :: a
a%ch = s
end subroutine
!================================================================================
subroutine assign_B_S(b,s)
character(8),intent(in) :: s
type(type_B),intent(inout) :: b
b%ch = s
end subroutine
!================================================================================
subroutine assign_S_A(s,a)
character(8),intent(inout) :: s
type(type_A),intent(in) :: a
s = a%ch
end subroutine
!================================================================================
subroutine assign_S_B(s,b)
character(8),intent(inout) :: s
type(type_B),intent(in) :: b
s = b%ch
end subroutine
end module TESTAB
module TEST_DATA
use TESTAB
implicit none
!
type example_A_T
sequence
type(type_A) A
real x,y,z
end type example_A_T
type example_B_T
sequence
type(type_B) B
integer flag
end type example_B_T
contains
!================================================================================
function A_to_str(from) result (s)
implicit none
type(type_A) from
character(8) s
s = from
end function
!================================================================================
function B_to_str(from) result (s)
implicit none
type(type_B) from
character(8) s
s = from
end function
end module TEST_DATA