Point array(type) error in OpenMP fortran

Point array(type) error in OpenMP fortran

britz0907's picture

I used to pointer as a firstprivate variable in omp parallel do due to compatibility between intel system(IFORT) and IBM system(XLF).

However, intel system generates  below errors.(IBM-xlf can run without error, but value is incorrect.)

*** glibc detected *** ./RGFM.x: double free or corruption (out): 0x00007fffe7ec27a0 ***

======= Backtrace: =========

/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f4bec8a0b96]

./R.x[0x482299]

./R.x[0x43d03b]

/opt/intel/composer_xe_2013.5.192/compiler/lib/intel64/libiomp5.so(__kmp_invoke_microtask+0x93)[0x7f4bed382293]

======= Memory map: ========

My code is

program

TYPE ATOM_DATA
sequence
INTEGER :: name
REAL :: coord(3)
END TYPE

TYPE (ATOM_DATA), POINTER :: atom_block(:,:)

integer,pointer :: block_natom(:)

integer:: nthreads,block_num,nsmp

nthreads = 4

block_num = 100

nsmp = 100

C$OMP PARALLEL do private(..... ,
C$OMP& ismp,  atom_block) firstprivate(block_natom)

     DO ismp = 1, nsmp

     allocate(block_natom(0:block_num+1))   

...

CALL setup_blockham(block_natom,atom_block) < - error from this subroutine

...

end

subroutine setup_blockham(block_natom,atom_block) 

INTEGER :: block_natom(0:block_num+1)
TYPE (ATOM_DATA) :: atom_block(0:block_num+1,block_num)

real ,pointer :: Vp(:)

......

CALL onsite_ham(atom_block(block_num,:)) < - error from this subroutine

... 

end

subroutine onsite_ham(block_num)

TYPE (ATOM_DATA) :: atom_block(max_block_natom)

DO ii=1,n/2
W = Vp(atom_block(ii)%name) < - I've checked error here due to trash value of garbage passing and stop

.....

ENDDO

My ifort is composer_xe_2013.5.192

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
britz0907's picture

Note (about above codes)

Due to security of my job, I wrote pesudo code and my loop-indexs(my mistakes)are omiited(but correct).

jimdempseyatthecove's picture

atom_block is declared as 2D array, but allocated as 1D array (I assume this is a typeo).

Your pseudo code has ATOM_DATA typed in PROGAM and not in a module. The subroutines are not USE-ing the same module defining the ATOM_TYPE type. Add a module to define type ATOM_TYPE.

Also, either place the subroutines manipulating ATOM_DATA types in the CONTAINS section of the module defining ATOM_DATA types .OR. add the INTERFACE blocks to the external subroutines (manipulating ATOM_DATA types) into the data declaration section of the module defining ATOM_DATA types (then USE that module in the subroutines manipulating ATOM_DATA types.

This will assure you do not have issues of passing: a) different ATOM_DATA types, b) differing ranks of ATOM_DATA type arrays.

Jim Dempsey

www.quickthreadprogramming.com
britz0907's picture

Thanks Jim

Could I have another question to you?

As I mentioned, I declare pointers for dynamical array in do-loop.

But I checked same values with openmp (if no error) except for master thread.

For example, do i = 1,16 & number of threads=4

master threads deal with i = 1,2,3,4

other thread 1  deal with i = 5,6,7,8

other thread 2  deal with i = 9,10,11,12

other thread 3  deal with i = 13,14,15,16

values of other thread 1 = other thread 2 = other thread 3

This is situation very unexpceted.  WHY?

And Do I have one more question?

If I have a pointer values as private on omp parallel region, a pointer values is really not effected by other threads?

Such as below 

complex pointer:: kk(:,:)

......

c$omp parallel do private(kk)

....

allocate(kk(i,i)) <- i = variable during do procedure 

above kk is not really affected other threads?

I think this is a point. But I don't know really WHY same values with openmp (if no error) except for master thread.

jimdempseyatthecove's picture

Can you post a short example? Insert comments in code with your questions.

Jim Dempsey

www.quickthreadprogramming.com

Login to leave a comment.