- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have a problem and I did not find a solution : I want to use parallelism in the free code , but a problem occurred in the allocation of arrays:
PROGRAM LMTART
USE PARA_CONTROL
use omp_lib
INTEGER I,J
real, allocatable, dimension(:) :: a
PARA_FIRST=.True.
!$OMP PARALLEL DEFAULT(firstprivate)
!$OMP DO
DO I = 1, 10
if(PARA_FIRST) then
allocate(a(100))
DO J = 1, 10
a(j)=j
ENDDO
endif
write(*,*) (a(J),J=1,10)
PARA_FIRST=.False.
ENDDO
!$OMP END DO
!$OMP END PARALLEL
END
It should be noted that : do not reserved the table "a" before entering in the DO directive
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please provide more description than 'a problem occurred'. Compilation problem? Runtime problem? Probably the code compiles (but I can't be sure since it depends on module PARA_CONTROL), so I suppose this is a runtime problem. Please provide details. I don't see suspicious, other than a race condition on the write() statement.
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
..this code fails with a message error saying "allocatable array is already allocated", code not works!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please Help me !!!!!!!!!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have to be able to reproduce (or at least understand) your issue before we can help you.
What version of the compiler are you using?
Is logical variable PARA_FIRST modified outside of the code you showed us? If so, you may need to provide the source for module PARA_CONTROL, along with the code that is modifying PARA_FIRST.
If I define PARA_FIRST as a local variable, all is well with ifort-14.0.3:
$ cat U520439.f90
PROGRAM LMTART
!!!USE PARA_CONTROL
use omp_lib
implicit none
INTEGER I,J
logical PARA_FIRST
real, allocatable, dimension(:) :: a
PARA_FIRST=.True.
!$OMP PARALLEL DEFAULT(firstprivate)
!$OMP DO
DO I = 1, 10
if(PARA_FIRST) then
allocate(a(100))
DO J = 1, 10
a(j)=j
ENDDO
endif
write(*,*) (a(J),J=1,10)
PARA_FIRST=.False.
ENDDO
!$OMP END DO
!$OMP END PARALLEL
END
$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.3.174 Build 20140422
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
$ ifort -openmp U520439.f90 && ./a.out
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
1.000000 2.000000 3.000000 4.000000 5.000000
6.000000 7.000000 8.000000 9.000000 10.00000
$
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Patrick Kennedy , work ,goooooooooooooood hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!
Where is the problem????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note :Where is deallocate procedure !!!! deallocate procedure is the problem ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you allocate something in a PARALLEL region, it is automatically deallocated at the end of the parallel region, so deallocation is not the problem in the code you have shown us.
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page