Fortran中的PGI编译问题:延迟过程产生分段错误
我正在测试PGI Fortran 19.10编译器。 当我运行名为Fortran中的PGI编译问题:延迟过程产生分段错误,fortran,pgi,Fortran,Pgi,我正在测试PGI Fortran 19.10编译器。 当我运行名为test.f90的文件时,在使用PGI编译之后,我得到了一个分段错误;而当我使用gfortran或ifort编译和运行时,我没有遇到任何问题 文件test.f90: MODULE modu IMPLICIT NONE ! Format type, abstract :: FormatFile contains procedure(File_open_file),nopass, deferred :: open_fil
test.f90的文件时,在使用PGI编译之后,我得到了一个分段错误
;而当我使用gfortran或ifort编译和运行时,我没有遇到任何问题
文件test.f90
:
MODULE modu
IMPLICIT NONE
! Format
type, abstract :: FormatFile
contains
procedure(File_open_file),nopass, deferred :: open_files
end type FormatFile
type, extends(FormatFile) :: FormatA
contains
procedure, nopass :: open_files => open_fileA
end type FormatA
! Type
type, abstract :: TypeFile
class(FormatFile), allocatable :: format
end type TypeFile
type, extends(TypeFile) :: TypeB
end type TypeB
! FileHandler
type, public :: FileHandler
private
class(TypeFile), allocatable :: type
contains
procedure, pass(fd), public :: open_file
end type FileHandler
abstract interface
subroutine File_open_file( fd )
import FileHandler
class(FileHandler), intent(inout) :: fd
end subroutine
end interface
CONTAINS
subroutine write_output()
IMPLICIT NONE
type(FileHandler) :: FileH
!-------------------------------------------------------------------------
print*, 'write_output: start.'
allocate(TypeB :: FileH%type)
allocate( FormatA :: FileH%type%format)
call FileH%open_file()
print*, 'write_output: end.'
end subroutine write_output
subroutine open_file( fd )
implicit none
class(FileHandler), intent(inout) :: fd
!-------------------------------------------------------------------------
print *, 'open_file: start'
call fd%type%format%open_files(fd)
print *, 'open_file: end'
end subroutine open_file
subroutine open_fileA( fd )
implicit none
class(FileHandler), intent(inout) :: fd
!-------------------------------------------------------------------------
print *, 'open_fileA: start'
!print*, 'job done'
print *, 'open_fileA: end'
end subroutine open_fileA
end module modu
PROGRAM main_prog
USE modu
print*, "Start main"
call write_output()
print*, "End main"
END PROGRAM main_prog
因此,命令pgfortran-c test.f90&&pgfortran-o main_test.o&&./main_test
返回我:
Start main
write_output: start.
open_file: start
Segmentation fault (core dumped)
而它使用gfortran或ifort按预期运行。否则,我还使用PGI编译器的选项-Mnollvm
测试了这段代码,它会产生相同的分段错误
当然,在这个简单的例子中,我可以删除中间对象TypeFile
,这就消除了分割错误问题;但我真的需要它在一些更大的项目
我是不是错过了什么?还是PGI编译器的一个bug