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

omp initializer not properly set

valery_w_
Beginner
323 Views

hi all

the following code is bugus.

v

 

 ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.1.106 Build 20131008
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

cat intel_reduction.f90
program test
  use omp_lib
  implicit none
  integer :: i
  !i=0 !omp initializer wrongly set
  !$omp parallel reduction(+:i)
  i=1
  !$omp end parallel
  if(i.ne.omp_get_max_threads()) then
     write(*,*) i
     stop 'err1'
  endif
end program test
export OMP_NUM_THREADS=4; ifort -fopenmp intel_reduction.f90   ;  ./a.out
       32771
err1

 

 

0 Kudos
1 Reply
valery_w_
Beginner
323 Views

... i should have initialized the var.

my mistake!

v

0 Kudos
Reply