- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Initializing a derived type as parameter fails if there is an assignment operator. This happens with latest FORTRAN compiler on openSUSE 11.4. The following code demonstrates the problem:
[fortran]MODULE DType
IMPLICIT NONE
PUBLIC
INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)
!INTEGER, PARAMETER :: QP = SELECTED_REAL_KIND(6,37)
!INTEGER, PARAMETER :: QP = SELECTED_REAL_KIND(15,307)
INTEGER, PARAMETER :: QP = SELECTED_REAL_KIND(32,4931)
TYPE JD
INTEGER(I4B) :: JDN = 2451545
REAL(QP) :: FD = 0.0_QP
CONTAINS
GENERIC :: ASSIGNMENT(=) => setJD
PROCEDURE, PRIVATE, PASS :: setJD
END TYPE JD
CONTAINS
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), PARAMETER :: testa = JD(2451546, 0.5_QP)
TYPE(JD) :: testb = JD(2451546, 0.5_QP)
WRITE(*,*) testa%JDN, testa%FD
WRITE(*,*) testb%JDN, testb%FD
END PROGRAM test_dtype[/fortran]
The first write statement returns1 1.0000000
instead of
2451546 0.50000000
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the nice test case. I can reproduce the problem and verified that it is the presence of the type-bound operator that makes the difference, even though that operator is not used. I have escalated this as issue DPD200170709 and will let you know of any progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is fixed for a release later this year.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page