7 Replies Latest reply on Sep 15, 2013 12:52 AM by juaneco2710

    Incorrect symbol generated for omp_set_num_threads

    allen@radiative.com

      I'm using the 4.2.5.1 FORTRAN compiler on a code with extensive OpenMP directives. In some cases the compiler generates the incorrect symbol for the OpenMP intrinsic set_omp_num_threads; instead of generating "omp_set_num_threads_", the compiler adds an extra _ to the external symbol: omp_set_num_threads__. This results in an undefined external at link time.  I'm attaching a highly reduced set of source code, but it is a strange problem: Sometimes the compiler generates the (correct?) external omp_set_num_threads_ and sometimes it generates (incorrectly?) omp_set_num_threads__. Even something as simple as changing the name of a variable or deleting a line of code can cause it to generate omp_set_num_threads__, which is not resolved by the linker.

      So, for example, using the four source files:

      openf95 -mp mess.f90 strin.f90 writp.f90 fmp.f90

      yields

      /tmp/cco.8qaBUa: In function `b00_':
      fmp.f90:94: undefined reference to `omp_set_num_threads__'
      collect2: ld returned 1 exit status

      Hopefully, I can attach the code to this message with the correct file names.

        • Incorrect symbol generated for omp_set_num_threads
          allen@radiative.com

          This is the example file mess.f90

          module mess implicit none character(len=*), parameter :: AA = "AA" character(len=*), parameter :: BB = "BB" end module mess

            • Incorrect symbol generated for omp_set_num_threads
              allen@radiative.com

              This is the example file strin.f90

              module strin implicit none private public :: ii contains subroutine ii end subroutine ii end module strin

                • Incorrect symbol generated for omp_set_num_threads
                  allen@radiative.com

                  This is the file writp.f90

                  module writp public :: wp public :: dp contains subroutine wp end subroutine wp subroutine dp end subroutine dp end module writp

                    • Incorrect symbol generated for omp_set_num_threads
                      allen@radiative.com

                      This is the file fmp.f90

                      program fmp end program fmp subroutine B00( c, b, D, & e, F, g, H, & i, j, k, L, P, Q, & R, S, t, fl, xxt, XXC, & XXV, XXS, nxx, XXM, XXD, & nf, FLC, FLV, FLS, & nfd, FD, ns, SC, SVC, & SVS, SCS, nsd, SD, & nb, ZT, ZCC, ncd, & BXX, ZCF, ZCP, & ZCN, nv, mm, u, & v, OU, OT, & DW, DM ) !$ use omp_lib, only : omp_get_max_threads, omp_set_num_threads use, intrinsic :: iso_c_binding, only : c_int, c_float, c_ptr, c_char use strin, only : ii use writp, only : wp, dp use mess, only : AA, BB implicit none ! Dummy arguments integer, intent(in) :: b character(len=1), intent(in) :: D(b) integer, intent(in) :: e character(len=1), intent(in) :: F(e) integer, intent(in) :: g character(len=1), intent(in) :: H(g) integer, intent(in) :: i type(c_ptr), intent(in) :: c integer, intent(in) :: j real, intent(in) :: k real, intent(in) :: L(3) real, intent(in) :: P(3) real, intent(in) :: Q(3) integer, intent(in) :: R(3) real, intent(in) :: S(3) real, intent(in) :: t integer, intent(in) :: fl integer, intent(in) :: xxt real, intent(in) :: XXC(3) integer, intent(in) :: XXV(3) real, intent(in) :: XXS(3) integer, intent(in) :: nxx integer, intent(in) :: XXM(nxx) real, intent(in) :: XXD(nxx) integer, intent(in) :: nf real, intent(in) :: FLC(3,nf) integer, intent(in) :: FLV(3,nf) real, intent(in) :: FLS(3,nf) integer, intent(in) :: nfd real, intent(in) :: FD(nfd) integer, intent(in) :: ns real, intent(in) :: SC(4,ns) integer, intent(in) :: SVC(4,ns) real, intent(in) :: SVS(4,ns) integer, intent(in) :: SCS(ns) integer, intent(in) :: nsd real, intent(in) :: SD(nsd) integer, intent(in) :: nb real, intent(in) :: ZT(4,3,nb) integer, intent(in) :: ZCC(nb) integer, intent(in) :: ncd integer, intent(in) :: BXX(ncd) integer, intent(in) :: ZCF(ncd) integer, intent(in) :: ZCP(ncd) real, intent(in) :: ZCN(ncd) integer, intent(in) :: nv integer, intent(in) :: mm integer, intent(in) :: u integer, intent(out) :: v character(len=1), intent(out) :: OU(u, mm) integer, intent(out) :: OT(nv) real, intent(out) :: DW(nv) real, intent(out) :: DM(nv) integer, parameter :: n_pvoi = 1 real :: ZT_TP(3,4,nb) !$ integer :: n_threads_cache !$ logical :: dynamic_threads_cache ! Mangage the number of threads !$ if ( i .gt. 0 ) then !$ n_threads_cache = omp_get_max_threads() !$ call omp_set_num_threads( i ) !$ end if end subroutine B00