Quantcast
Channel: Fortran
Viewing all articles
Browse latest Browse all 3108

OpenMP and !DEC$ attributes

$
0
0

I am using OpenMP and Intel Fortran within Visual Studio 2010 Ultimate. I am calling some functions that are exported from a homemade DLL using the attribute DLLEXPORT and aliases. I use DLLIMPORT for the importation. No problem there.

The problem comes when I try using an OpenMP sentinel (!$, without omp, as in !$ call omp_set_num_threads(4) for instance) right after those DLLIMPORT statements. The conditional compilation that is supposed to be performed by the compiler when using /Qopenmp does not work, and the statements seem to be ignored. However, if I have any standard Fortran statement between the !DEC$ and !$, no problem anymore. Same if the openMP statement is an actual openMP directive, usig !$omp instead of just !$. To resume:

      PROGRAM main

        !$ use omp_lib

        integer :: i

        !$ print*, 'OMP 1'
        !DEC$ ATTRIBUTES DLLIMPORT, ALIAS : 'func1'  :: func1
        !$ print*, 'OMP 2'

        i = 5
        !$ print*, 'OMP 3'

      end program

outputs: 'OMP 1'
              'OMP 3'

I have not found any references to this problem anywhere else, or any doc explicitly stating that an openMP sentinel should not directly follow a !DEC$ attributes statement, so I thought that maybe it was a bug that had not been discovered yet.


Viewing all articles
Browse latest Browse all 3108

Trending Articles