Community
cancel
Showing results for 
Search instead for 
Did you mean: 
psing51
Beginner
275 Views

error: unexpected token 'identifier' #pragma omp end critical

I am trying to compile Tycho CFD application , and i am getting following error:

 

mv -f .deps/write_ic_vtk.Tpo .deps/write_ic_vtk.Po
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT write_ifrit.o -MD -MP -MF .deps/write_ifrit.Tpo -c -o write_ifrit.o write_ifrit.c
mv -f .deps/write_ifrit.Tpo .deps/write_ifrit.Po
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT write_restart_tyc.o -MD -MP -MF .deps/write_restart_tyc.Tpo -c -o write_restart_tyc.o write_restart_tyc.c
mv -f .deps/write_restart_tyc.Tpo .deps/write_restart_tyc.Po
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT write_tyc.o -MD -MP -MF .deps/write_tyc.Tpo -c -o write_tyc.o write_tyc.c
mv -f .deps/write_tyc.Tpo .deps/write_tyc.Po
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT write_vtk.o -MD -MP -MF .deps/write_vtk.Tpo -c -o write_vtk.o write_vtk.c
write_vtk.c(262): warning #269: invalid format string conversion
              sprintf(filename, "%TYCHO dB_map_%i.vtk", output_dir, counter);
                                                        ^

mv -f .deps/write_vtk.Tpo .deps/write_vtk.Po
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT noise_generator.o -MD -MP -MF .deps/noise_generator.Tpo -c -o noise_generator.o noise_generator.c
noise_generator.c(62): error: unexpected token 'identifier'
  #pragma omp end critical
                  ^

noise_generator.c(70): error: unexpected token 'identifier'
  #pragma omp end critical
                  ^

compilation aborted for noise_generator.c (code 2)
make[2]: *** [noise_generator.o] Error 2
make[2]: Leaving directory `/opt/user1-INTEL/finaluser1/ToolsInstaller/Mechanical/Tycho/tycho_release_v1.3.0/sources'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/opt/user1-INTEL/finaluser1/ToolsInstaller/Mechanical/Tycho/tycho_release_v1.3.0'
make: *** [all] Error 2
Making install in sources
make[1]: Entering directory `/opt/user1-INTEL/finaluser1/ToolsInstaller/Mechanical/Tycho/tycho_release_v1.3.0/sources'
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT noise_generator.o -MD -MP -MF .deps/noise_generator.Tpo -c -o noise_generator.o noise_generator.c
noise_generator.c(62): error: unexpected token 'identifier'
  #pragma omp end critical
                  ^

noise_generator.c(70): error: unexpected token 'identifier'
  #pragma omp end critical
                  ^

compilation aborted for noise_generator.c 

Any help/hint will be very useful ,
I have attached make file & the noise_generator.c!
(these two files are getting compiled successfully by gnu compilers!!)

Eagerly awaiting your replies.

0 Kudos
5 Replies
275 Views

it looks like fortran syntax, shouldn't be this:

#pragma omp critical [(name)]
{
   code_block
}

or in your case

#ifdef _OPENMP
#pragma omp critical
{
#endif
                        mean_pressure += pre;
#ifdef _OPENMP
}
#endif

--Vladimir

psing51
Beginner
275 Views

Thankyou vladimir for a quick reply The compilation succeeds when i carry out your suggestion. But the command i use for its compilation is:
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT noise_generator.o -MD -MP -MF .deps/noise_generator.Tpo -c -o noise_generator.o noise_generator.c
so i have provided openmp flag !
why this code works when i use gcc (4.4.7) + -fopenmp flag!

is there a workaround to this code without altering source code?

275 Views

puneet s. wrote:

Thankyou vladimir for a quick reply The compilation succeeds when i carry out your suggestion. But the command i use for its compilation is:
icc -DHAVE_CONFIG_H -I. -I..     -O3 -openmp -MT noise_generator.o -MD -MP -MF .deps/noise_generator.Tpo -c -o noise_generator.o noise_generator.c
so i have provided openmp flag !
why this code works when i use gcc (4.4.7) + -fopenmp flag!

If you look at OpenMP 4.0 specification (chapter 2.12.2) there is no "#pragma omp end critical" OpenMP pragma so compiler does not know about this pragma. gcc might handle this spec difference somehow so it might ignore the unexisting pragma.

Added later: if you add more diagnostics you will see following for gcc:

-bash-4.1$ gcc -fopenmp  -DHAVE_CONFIG_H -I. -I.. -c -o noise_generator.o noise_generator.c -Wunknown-pragmas                                                                                                                       
noise_generator.c: In function 'noise_generator':
noise_generator.c:62: warning: ignoring #pragma omp end
noise_generator.c:70: warning: ignoring #pragma omp end

it looks that Intel Compiler is very strict for "#pragma omp" keyword usage.

jimdempseyatthecove
Black Belt
275 Views

I suggest you do this:

#ifdef _OPENMP
#pragma omp critical(mean_pressure)
#endif
{
  mean_pressure += pre;
  counter_mean_pressure++;
}

The above creates one named critical section, not two unnamed critical sections.

Use named critical sections to permit multiple concurrent critical sections, provided they are not manipulating the same variables. Using unnamed critical section, while safe means no concurrency with other unnamed critical sections using different variables.

As Vladimir pointed out, the #pragma omp critica [(name)] extends only to the next statement or brace ({...}) scoped block of code.

Jim Dempsey

Kittur_G_Intel
Employee
275 Views

Hi Puneet,
 Just read your issue and tried and could reproduce the scenario and Jim and Vladimir have indeed correctly pointed out.
_Kittur 

Reply