在这个fortran程序中,我被告知要调试,我得到了错误:
“在 (1) 处的参数 'p1' 中的类型不匹配;将 REAL(4) 传递给 TYPE(point)”
而且我似乎无法弄清楚错误发生在哪里。我尝试定义不同的变量来传递给每个函数,而不是 p1 和 p2,但错误相同。有任何想法吗?
MODULE PointType
TYPE POINT
REAL:: x
REAL:: y
END TYPE
CONTAINS
FUNCTION arePointsEqual(p1, p2)
REAL:: arePointsEqual
TYPE(POINT), INTENT(IN):: p1
TYPE(POINT), INTENT(IN):: p2
LOGICAL :: isEqual
IF ( p1%x == p2%x .AND. p1%y == p2%y) THEN
isEqual = .TRUE.
ELSE
isEqual = .FALSE.
END IF
END FUNCTION
FUNCTION arePointsNotEqual(p1,p2)
REAL:: arePointsNotEqual
TYPE(POINT), INTENT(IN):: p1
TYPE(POINT), INTENT(IN):: p2
LOGICAL :: isNotEqual
IF ( p1%x == p2%x .AND. p1%y == p2%y) THEN
isNotEqual = .FALSE.
ELSE
isNotEqual = .TRUE.
END IF
END FUNCTION
FUNCTION distance(p1, p2)
REAL:: distance
TYPE(POINT), INTENT(IN):: p1
TYPE(POINT), INTENT(IN):: p2
distance = SQRT((p2%x - p1%x)**2 + (p2%y - p1%y)**2)
END FUNCTION
END MODULE
!MAIN PROGRAM BELOW THIS LINE
PROGRAM Project3
USE PointType
PRINT *, arePointsEqual(p1, p2)
PRINT *, arePointsNotEqual(p1, p2)
PRINT *, distance(p1, p2)
END PROGRAM Project3