I ran into an internal compiler error while building a larger Fortran code base (GitHub - NOAA-GFDL/FMS: GFDL's Flexible Modeling System). I created a much smaller reproducer for the error. It’s related to a variable in a derived type that is class(*).
module test_mod
implicit none
type fmsDiagOutputBuffer_type
class(*), allocatable :: buffer(:) !< Causing the issue
end type
type fmsDiagObject_type
type(fmsDiagOutputBuffer_type),dimension(:), allocatable :: FMS_diag_output_buffers !< Type within a type. The function func returns one of these
contains
procedure func
end type
type(fmsDiagObject_type) :: obj
contains
function func (this, bufferid) &
result(rslt)
class(fmsDiagObject_type), intent(in) :: this
integer, intent(in) :: bufferid
type(fmsDiagOutputBuffer_type),allocatable:: rslt
if( (bufferid .gt. UBOUND(this%FMS_diag_output_buffers, 1)) .or. &
(bufferid .lt. LBOUND(this%FMS_diag_output_buffers, 1))) &
write(*,*) 'get_diag_bufer: invalid bufferid given'
rslt = this%FMS_diag_output_buffers(bufferid)
end function
end module
I tried compiling in a container on a grace hopper system using nvfortran 25.5. I also tried on an x86 system using 25.1 and in a container using 25.7 and got the same error:
NVFORTRAN-F-0000-Internal compiler error. chk_assign_sptr: not enough dimensions 0 (test.F90: 29)
NVFORTRAN/x86-64 Linux 25.7-0: compilation aborted
If I switch the type of buffer to real, the code compiles. In my actual code, the buffer array is 5 dimensions, and going down to one didn’t change the error reported.
I successfully compiled this with gfortran, ifx, and aocc flang.