fortran66のブログ

fortran について書きます。

IVF v11.0.074 TYPE

Bugってて、ダミーの仮引数がないと構造体を PASS することができません。

MODULE m_test
IMPLICIT NONE
!
TYPE :: t_person
 CHARACTER (LEN = 10) :: name
 REAL :: age
 INTEGER :: id
END TYPE t_person
!
TYPE, EXTENDS(t_person) :: t_employee
 INTEGER :: national_insurance_number
 REAL :: salary
 PROCEDURE (t_pr), POINTER, PASS :: pr => NULL()
END TYPE t_employee
!
ABSTRACT INTERFACE
 SUBROUTINE t_pr(employee, idummy)
 IMPORT :: t_employee
 TYPE (t_employee), INTENT(IN) :: employee
 INTEGER, INTENT(IN) :: idummy ! bug v11.0
 END SUBROUTINE t_pr
END INTERFACE
!
CONTAINS
!--------------------------------
SUBROUTINE pr0(employee, idummy)
TYPE (t_employee), INTENT(IN) :: employee
INTEGER, INTENT(IN) :: idummy ! bug v11.0
PRINT *, employee%name
PRINT *, employee%age
PRINT *, employee%national_insurance_number
PRINT *, employee%salary
RETURN
END SUBROUTINE pr0
!--------------------------------
END MODULE m_test
!=================================
PROGRAM test
USE m_test
IMPLICIT NONE
TYPE (t_employee) :: a, b
a%name = 'ababaaa'
a%age  = 15
a%national_insurance_number = 12345
a%salary = 1.23456e5
a%pr => pr0

CALL a%pr(0)
STOP
END PROGRAM test