If I understand the standard correctly then the following program should work
MODULE DType IMPLICIT NONE PUBLIC INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9) !INTEGER, PARAMETER :: WP = SELECTED_REAL_KIND(6,37) !INTEGER, PARAMETER :: WP = SELECTED_REAL_KIND(15,307) INTEGER, PARAMETER :: WP = SELECTED_REAL_KIND(32,4931) TYPE JD INTEGER(I4B) :: JDN = 2451545 REAL(WP) :: FD = 0.0_WP, tmp CONTAINS GENERIC :: ASSIGNMENT(=) => setJD PROCEDURE, PRIVATE, PASS :: setJD END TYPE JD INTERFACE JD MODULE PROCEDURE constructor END INTERFACE JD CONTAINS FUNCTION constructor(n, f) INTEGER(I4B), INTENT(IN) :: n REAL(WP), INTENT(IN) :: f TYPE(JD) :: constructor constructor%JDN = n constructor%FD = f RETURN END FUNCTION constructor SUBROUTINE setJD(a, b) CLASS(JD), INTENT(INOUT) :: a TYPE(JD), INTENT(IN) :: b a%JDN = b%JDN a%FD = b%FD END SUBROUTINE setJD END MODULE DType PROGRAM test_dtype USE DType IMPLICIT NONE TYPE(JD) :: a, c a = constructor(2451546, 0.5_WP) WRITE(*,*) a%JDN, a%FD c = JD(2451546, 0.5_WP) WRITE(*,*) c%JDN, c%FD END PROGRAM test_dtype
Compiling the program with latest compiler on openSUSE 11.4 fails with
Omittedfield is not initialized. Field initialization missing: [TMP]".Hence, it looks like the compiler ignores the interface definition, while the release notes does say that it supports generic interface with the same name as a derived type. Regards Oystein
c = JD(2451546, 0.5_WP)