Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OpenMP error with allocatable component

3 views
Skip to first unread message

Gib Bogle

unread,
Jan 2, 2009, 4:39:55 PM1/2/09
to
The code that follows demonstrates a problem that can occur with ifort
on the assignment of a PRIVATE variable which is a derived type with an
allocatable component. This program fails with the message:
"A pointer passed to DEALLOCATE points to an array that cannot be
deallocated."
In the code below, when the parallel section is entered
cell_array(k)%dclist(:) has not been allocated, but allocating dclist
before the parallel section does not stop the error. On the other hand,
on my system the program does execute without error if I change nlist to
100. In addition, commenting out any of the components of cell_type
makes the program run OK. Removing the line 'cell = cell_array(1)' also
stops the error.

The advice from respondees on the Intel Fortran forum is that in the
private copy of the variable cell, without initialisation, the
allocation status of the dclist component is garbage. Assignment to an
allocatable can cause reallocation if the size or allocation status of
the lhs array is not suitable, and attempting to reallocate with garbage
in the allocation status gives rise to the error.

I'm curious to know if other compilers also give this error, or
something like it, and whether I should file a bug report or consider
this a programming error. By the way, the Intel forum yielded a couple
of easy ways to avoid the problem (make cell a pointer, or put the
parallel section in a subroutine, or use the !$omp clause
FIRSTPRIVATE(cell)).

! test_omp.f90
! compiled with: ifort /Qopenmp test_omp.f90

program test_omp

type cell_type
integer :: site(3)
integer :: step
integer(2) :: lastdir
integer(2) :: DCbound(2)
real :: unbindtime(2)
integer :: visits,revisits,ndclist
integer, allocatable :: dclist(:)
end type

integer, parameter :: nlist = 1000
type(cell_type) :: cell_array(nlist)
type(cell_type) :: cell
integer :: k
call omp_set_num_threads(4)
cell = cell_array(1)
!$omp parallel private(k,cell)
do k = 1,nlist
cell = cell_array(k)
enddo
!$omp end parallel
end

paul.rich...@gmail.com

unread,
Jan 3, 2009, 5:56:50 PM1/3/09
to
Gib,

Your code compiles and runs fine on ifort 10.1 and gfortran 4.4.

Cheers

Paul

George

unread,
Jan 3, 2009, 6:34:06 PM1/3/09
to


C:\MinGW\source> g95 gib1.f90 -o b.exe
C:\DOCUME~1\dan\LOCALS~1\Temp/cc3kxco9.o:gib1.f90:(.text+0x9b): undefined
refere
nce to `omp_set_num_threads__'

C:\MinGW\source> gfortran gib1.f90 -o b.exe
ld: crtbegin.o: No such file: No such file or directory

C:\MinGW\source>

I get different errors for different reasons. Does anyone have a mingw
installation where all the open source distros just get along?


C:\MinGW\source>gfortran -fopenmp gib1.f90 -o b.exe
gfortran: libgomp.spec: No such file or directory

C:\MinGW\source>

That's three strikes: I'm out.
--
George

You teach a child to read, and he or her will be able to pass a literacy
test.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/

Gib Bogle

unread,
Jan 3, 2009, 8:18:52 PM1/3/09
to

Interesting - I'm using ifort beta 11.0.039.

Gib

Gib Bogle

unread,
Jan 4, 2009, 3:38:37 AM1/4/09
to

I've just installed ifort 11.0.066, and my code runs without error.

user1

unread,
Jan 4, 2009, 10:44:02 AM1/4/09
to
George wrote:

> C:\MinGW\source>
>
> I get different errors for different reasons. Does anyone have a mingw
> installation where all the open source distros just get along?
>
>

It is easy to break an installation by trying to install or copy too
many things into a single MingW folder. Been there, done that.

When installing a prepackaged g95 of gfortran, you would perhaps be
better off to put each in it's own folder. Then use a startup batch file
to fire up cmd.exe after setting the environment variables as needed.


0 new messages