因为程序很大,简化之后的程序如下所示。原程序是采用ifortran采用参数化结构体编写,因为想对程序实现GPU并行,所以采用gfortran12.x编写。哪位大佬帮忙解答一下哪错了
[Fortran] 纯文本查看 复制代码 module ModParticle
implicit none
integer::x=4
type ParticleType
real(4) , allocatable :: MassGas(:)
contains
Procedure :: CopyParticle => CopyParticle
end type
contains ! Routines of this module
Subroutine CopyParticle( this , ID )
integer(4), intent(in) :: ID
class(ParticleType) :: this
this%MassGas = 0.1
End Subroutine CopyParticle
subroutine CopyType(TempParticlesx,TempParticles)
type(ParticleType)::TempParticles
type(ParticleType)::TempParticlesx
allocate(TempParticles%MassGas(x))
TempParticlesx%MassGas = TempParticles%MassGas
deallocate(TempParticles%MassGas)
end subroutine
end module
[Fortran] 纯文本查看 复制代码 PROGRAM Main
use ModParticle
implicit none
integer::i
type(ParticleType)::TempParticles
type(ParticleType)::TempParticlesx
allocate(TempParticles%MassGas(x))
do i = 1, size(TempParticles%MassGas)
call TempParticles%CopyParticle(i)
end do
write(*,*) TempParticles%MassGas
call CopyType(TempParticlesx,TempParticles)
write(*,*) TempParticlesx%MassGas
deallocate(TempParticles%MassGas)
END PROGRAM Main
|