Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fortran中的PGI编译问题:延迟过程产生分段错误_Fortran_Pgi - Fatal编程技术网

Fortran中的PGI编译问题:延迟过程产生分段错误

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

我正在测试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_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