我正在尝试为两个子程序使用相同的名称,但我收到错误:
gfortran gshapes.f08 gshapes_utest.f08 -o gshapes_utest.x
gshapes_utest.f08:53.41:
call ellips%set_ellipse_corner (crnr1, crnr2)
1
Error: Type mismatch in argument 'xlen' at (1); passed TYPE(gcorner) to REAL(4)
这是类型定义和相关子例程:
type, public :: Ellipse
type(GCenter) :: centr ! Center coordinate of ellipse
type(GCorner) :: crnr1 ! Upper left corner
type(GCorner) :: crnr2 ! Botton right corner
real :: xlen
real :: ylen ! Size of ellipse in x- and y-directions
character (len=12) :: parm ! Parameterisation of ellipse
contains
procedure :: set_cpnt_ellipse
procedure :: set_ellipse_corner => set_spnt_ellipse, set_tpnt_ellipse
procedure :: print => print_ellipse
end type Ellipse
contains
! \brief Initialize geographical coordinate system grid object
subroutine set_cpnt_ellipse (ellips, gcentr, xlen, ylen)
class(Ellipse) :: ellips
type(GCenter) :: gcentr
real :: xlen, ylen
ellips%centr = gcentr
ellips%xlen = xlen
ellips%ylen = ylen
ellips%parm = 'center'
end subroutine set_cpnt_ellipse
subroutine set_spnt_ellipse (ellips, gcrnr, xlen, ylen)
class(Ellipse) :: ellips
type(GCorner) :: gcrnr
real :: xlen
real :: ylen
ellips%crnr1 = gcrnr
ellips%xlen = xlen
ellips%ylen = ylen
ellips%parm = 'corner'
end subroutine set_spnt_ellipse
subroutine set_tpnt_ellipse (ellips, gcrnr1, gcrnr2)
class(Ellipse) :: ellips
type(GCorner) :: gcrnr1
type(GCorner) :: gcrnr2
ellips%crnr1 = gcrnr1
ellips%crnr2 = gcrnr2
ellips%parm = 'corners'
end subroutine set_tpnt_ellipse
答案 0 :(得分:0)
我认为你可以将它们放在接口块中:
interface set_tpnt_ellipse
module procedure set_spnt_ellipse, set_cpnt_ellipse
end interface