Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28952 Discussions

How to get stack traces in a OMP loop

WiserOrb
Novice
295 Views

I would like to print stack traces when a check fails, like the ones I get with the option "-trace"

 

main.f90

program main
  implicit none
  
  integer :: i, a(10)
  
  !$OMP PARALLEL DO PRIVATE(i) SHARED(a)
  do i = 1, 10
    a(5 - i) = i
  end do
  
  write(*,*) a
endprogram

 

Complied without -qopenmp I get the correct stack trace:

ifx -check -trace main.f90; ./a.out
forrtl: severe (408): fort: (3): Subscript #1 of the array A has value 0 which is less than the lower bound of 1

Image              PC                Routine            Line        Source             
a.out              0000000000405228  main                        8  main.f90
a.out              000000000040517D  Unknown               Unknown  Unknown
libc.so.6          00007F5543A2A2AE  Unknown               Unknown  Unknown
libc.so.6          00007F5543A2A379  __libc_start_main     Unknown  Unknown
a.out              0000000000405085  Unknown               Unknown  Unknown

 

With -qopenmp

ifx -check -trace -qopenmp main.f90; ./a.out
forrtl: severe (408): fort: (3): Subscript #1 of the array A has value -1 which is less than the lower bound of 1

forrtl: severe (408): fort: (3): Subscript #1 of the array A has value -2 which is less than the lower bound of 1

 

Ifx version: ifx (IFX) 2025.0.0 20241008

 

1 Reply
TobiasK
Moderator
110 Views

@WiserOrb

thanks for reporting this. At the moment, I can only provide the workaround of setting OMP_NUM_THREADS=1. I am checking with the developers why this is happening for OMP_NUM_THREADS>1


0 Kudos
Reply