undefined reference to `..Dm_omp_lib'

Hello,

I can’t compile the following program. The compiling error quoted in the subject occurs
only when I use the command: pgf95 -mp -g omp_support.f90
Forgive me lengthy code.

Regards,
James

MODULE lib_aux
  IMPLICIT NONE

  INTEGER, PRIVATE :: i

! number of threads
 INTEGER, PARAMETER  :: n = 3
! sleep time
 INTEGER, PARAMETER  :: nsleep = 5

 TYPE :: history
    INTEGER   :: idh = -1
    DOUBLE PRECISION :: htime
    CHARACTER :: descr*20
 END TYPE history

 TYPE (history), DIMENSION(0:(n-1)), SAVE :: histA,histB                                            
 INTEGER, SAVE  :: iA = 0
 INTEGER, SAVE  :: iB = 0

 CONTAINS

   SUBROUTINE print_history()

     DO i=0, n-1
        IF (histA(i)%idh /= -1) THEN
           PRINT *, histA(i)%idh, histA(i)%htime,'   ', histA(i)%descr
        END IF
     END DO
     
     DO i=0, n-1
        IF (histB(i)%idh /= -1) THEN
           PRINT *, histB(i)%idh, histB(i)%htime,'   ', histB(i)%descr
        END IF
     END DO
     
   END SUBROUTINE print_history

END MODULE lib_aux

MODULE lib
  USE lib_aux
  USE omp_lib
  IMPLICIT NONE
  
  INTEGER (omp_lock_kind), SAVE :: rlck
  
  TYPE :: struct	
     REAL, DIMENSION(:), POINTER :: r_ptr => null()
  END TYPE struct
 
  TYPE (struct), SAVE :: structA

CONTAINS

 SUBROUTINE write_struct (DATA)
   REAL, INTENT(in) :: DATA(:)
   
   IF (.NOT. ASSOCIATED(structA%r_ptr)) THEN
      ALLOCATE (structA%r_ptr(SIZE(DATA)) )
   END IF
   
!$OMP CRITICAL (WR)

   histA(iA)%idh   = omp_get_thread_num()
   histA(iA)%htime = omp_get_wtime()
   histA(iA)%descr = 'write_struct_r'
   iA = iA + 1
   CALL sleep(2)

   DO WHILE (.NOT. omp_test_lock(rlck))
      PRINT *, 'waiting', omp_get_thread_num(), omp_test_lock(rlck)
   END DO

   CALL omp_unset_lock(rlck)
   structA%r_ptr = DATA  
      
!$OMP END CRITICAL (WR)

 END SUBROUTINE write_struct

 SUBROUTINE read_struct(DATA)
    REAL, INTENT(out) :: DATA(:)

!$OMP CRITICAL (RS)
    histB(iB)%idh   = omp_get_thread_num()
    histB(iB)%htime = omp_get_wtime()
    histB(iB)%descr = 'read_struct'
    iB = iB + 1

    CALL omp_set_lock(rlck)    
!$OMP FLUSH
    DATA = structA%r_ptr
    CALL sleep(nsleep)
    CALL omp_unset_lock(rlck)
!$OMP END CRITICAL (RS)

 END SUBROUTINE read_struct

END MODULE lib

PROGRAM test
 USE lib
 IMPLICIT NONE
 INTEGER :: i
 REAL    :: wr_data1(10), wr_data2(10), rr_data(10)

 
 wr_data1 = (/(REAL(i),i=1,10)/)
 wr_data2 = -wr_data1

 CALL omp_set_dynamic(.false.) 
 CALL omp_set_num_threads(n)
 CALL omp_init_lock(rlck)

!$OMP PARALLEL DEFAULT(SHARED)
!$OMP SECTIONS

!$OMP SECTION
 CALL write_struct(wr_data1)

!$OMP SECTION
 CALL write_struct(wr_data2)
 
!$OMP SECTION 
 CALL read_struct(rr_data)

!$OMP END SECTIONS
!$OMP END PARALLEL  

 CALL omp_destroy_lock(rlck)

 CALL print_history()

END PROGRAM test

Hi Jamie,

It compiles correctly for me using the latest release (6.1) on a 64-bit SuSE 9.3 system. Which version of the compiler and OS are you using? Also, could you post the output of compilation with the addition of the “-v” flag?

Thanks,
Mat

Hello Mat,

I use SuSE 8.2 IA-32. Notice that everythink is OK without -g option.
It concerns 6.1-4 and 6.1-5 (evaluation) as well.

Below the output you requested:

Regards,
Jamie

pgf95 -v -g -mp omp_support.f90

/usr/pgi/linux86/6.1/bin/p3/pgf901 omp_support.f90 -debug -x 120 0x200 -opt 0 -nohpf -nostatic -x 119 0x100000 -x 19 0x400000 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0xfb0000 -x 58 0x78031040 -x 48 3328 -stdinc /usr/pgi/linux86/6.1/include:/usr/local/include:/usr/lib/gcc-lib/i486-suse-linux/3.3/include:/usr/lib/gcc-lib/i486-suse-linux/3.3//include:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def inline= -def i386 -def __i386 -def i386 -def __NO_MATH_INLINES -def linux86 -def __THROW= -freeform -vect 48 -x 49 0x1000 -mp -x 69 0x200 -output /tmp/pgf95wJHctZd-D57.ilm
0 inform, 0 warnings, 0 severes, 0 fatal for lib_aux
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
2 inform, 0 warnings, 0 severes, 0 fatal for print_history
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
1 inform, 0 warnings, 0 severes, 0 fatal for lib
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
3 inform, 0 warnings, 0 severes, 0 fatal for write_struct
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
1 inform, 0 warnings, 0 severes, 0 fatal for read_struct
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
PGF90-I-0063-Gap in common block lib_aux$0 before histb (omp_support.f90)
2 inform, 0 warnings, 0 severes, 0 fatal for test
PGF90/any Linux/x86 6.1-5: compilation completed with informational messages

/usr/pgi/linux86/6.1/bin/p3/pgf902 /tmp/pgf95wJHctZd-D57.ilm -fn omp_support.f90 -debug -x 120 0x200 -opt 0 -x 51 0x20 -x 119 0xa10000 -x 119 0x100000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 16 -x 119 0x40000000 -x 19 0x400000 -x 28 0x40000 -x 59 4 -x 80 0x300 -y 80 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -astype 0 -x 124 1 -mp -x 69 0x200 -cmdline ‘+pgf95 omp_support.f90 -v -g -mp’ -asm /tmp/pgf95gJHsRnfSMje.s
0 inform, 0 warnings, 0 severes, 0 fatal for lib_aux
0 inform, 0 warnings, 0 severes, 0 fatal for print_history
0 inform, 0 warnings, 0 severes, 0 fatal for lib
0 inform, 0 warnings, 0 severes, 0 fatal for write_struct
0 inform, 0 warnings, 0 severes, 0 fatal for read_struct
0 inform, 0 warnings, 0 severes, 0 fatal for test
PGF90/x86 Linux/x86 6.1-5: compilation successful

/usr/bin/as /tmp/pgf95gJHsRnfSMje.s -o /tmp/pgf952JHIf7PWWrw.o

/usr/bin/ld /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i486-suse-linux/3.3//crtbegin.o /usr/pgi/linux86/6.1/lib/initmp.o /usr/pgi/linux86/6.1/lib/f90main.o -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/pgi/linux86/6.1/lib/pgi.ld /tmp/pgf952JHIf7PWWrw.o -L/usr/pgi/linux86/6.1/lib -L/usr/lib -L/usr/lib/gcc-lib/i486-suse-linux/3.3/ -rpath /usr/pgi/linux86/6.1/lib -lpgmp -lpgthread -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i486-suse-linux/3.3//crtend.o /usr/lib/crtn.o
/tmp/pgf952JHIf7PWWrw.o(.debug_info+0x1e5): In function print_history': /home/wojcik/test/pgi/openmp/omp_support.f90:33: undefined reference to …Dm_omp_lib’
pgf95-Fatal-linker completed with exit code 1

Unlinking /tmp/pgf95wJHctZd-D57.ilm
Unlinking /tmp/pgf95gJHsRnfSMje.s
Unlinking /tmp/pgf952JHIf7PWWrw.o

Hi James,

I was able to recreate the error (even in 64-bits) and have filed a techincal problem report (TPR#3827). The issue is that the omp_lib.mod file just contains an interface and no actual executable code so the object file was not included with the release. However, we obviously missed the one case where the object is needed, i.e. the debug symbol.

We’ll get this fixed in a future release. In the mean time, please send a note to trs@pgroup.com which references this post and I’ll have customer service send you a “omp_lib.o” file which you can use to link with.

Thanks,
Mat