We’re encountering a compilation error using nvfortran when we try to use functions that are contained within a subroutine, and those contained functions both return arrays and are also called within an OpenMP region.
It’s somewhat specific, here is an example code that demonstrates the problem:
module testmod use, intrinsic :: iso_fortran_env IMPLICIT NONE CONTAINS subroutine containingSubroutine() real(REAL64) :: vals(4,3) integer(INT32) :: i !$OMP PARALLEL DO default(shared) do i = 1,4 vals(i,:) = containedFunction() end do contains function containedFunction() result(vecResult) real(REAL64), dimension(3) :: vecResult vecResult = 0.0_REAL64 end function containedFunction end subroutine containingSubroutine end module testmod
If I compile that code with this command:
nvfortran -c -mp testmod.F90
Then it generates this error:
error: /glade/u/apps/opt/nvhpc/22.5/Linux_x86_64/22.5/compilers/share/llvm/bin/llc: /glade/scratch/jeffreyg/nefined value '%vecresult' %7 = bitcast i64* %vecresult to i8*, !dbg !20 ^
There are workarounds such as converting the contained function to a contained subroutine, but it is convenient for us to process some of our large datasets in this way. And it seems as though it may be a bug.