Hello, unfortunately I am having a segfault issue with the nvfortran compiler. When using OpenMP to parallelize a loop with an allocatable array of derived types the compiler is generating code that results in a segfault. Bellow is a simplified version of my code that reproduces the error on nvfortran but works fine with gfortran.
module myTypeMod
integer, parameter :: realType = kind(0.0d0)
type myType
contains
procedure :: create=>create_type
end type myType
contains
subroutine create_type(d)
class(myType) :: d
write(*,*) 'hi from create'
end subroutine create_type
end module myTypeMod
program main
use myTypeMod, only : myType
implicit none
type(myType), dimension(:), allocatable :: myTypeArr1
call testOMP(myTypeArr1)
contains
subroutine testOMP(myTypeArr)
use myTypeMod, only : myType
type(myType), dimension(:), allocatable :: myTypeArr
integer :: idx, n
n = 3
allocate(myTypeArr(n))
!$omp parallel default(none) &
!$omp shared(myTypeArr,n) &
!$omp private(idx)
!$omp do schedule(dynamic)
clusterLoop: do idx=1, n
call myTypeArr(idx)%create()
end do clusterLoop
!$omp end do
!$omp end parallel
end subroutine testOMP
end program main
I am compiling and running the program with
> nvfortran -O0 -mp -o reproducer_omp reproducer_omp.f90 && ./reproducer_omp
zsh: segmentation fault (core dumped) ./reproducer_omp
Using the latest version of nvfortran
> nvfortran --version
nvfortran 25.1-0 64-bit target on x86-64 Linux -tp skylake-avx512
NVIDIA Compilers and Tools
Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
What I have tried
What has no effect
- using static omp scheduling
- setting the scirpt to use one thread with
export OMP_NUM_THREADS=1
- different optimization levels
- using the older 24.7 compiler
what prevents the issue
- removing the OMP derictives or compiling without -mp
- making myTypeArr statically allocated