Help for the problem with OPENMP

General OpenMP discussion

Help for the problem with OPENMP

Postby wkflahd » Mon May 26, 2014 1:13 am

I am a beginner of using OPENMP in intel fortran 90 program.

I have programmed the following but it does not work and gives errors.

The error varies when execute the resultant exe file. (Compile is o.k.)

When execute the exe file, sometimes it gives wrong result, sometimes it gives 'shell returned -1073741819".

I could not find the problem and really need a help.

My main program calls the subroutine "CAL_PHIN" and a parallel procedure is to be conducted in the subroutine.

The subroutine "CAL_PHIN" is:

-------------------------------------------------------------------------------------------

SUBROUTINE CAL_PHIN()

integer(i4b) :: i

integer(i4b) :: n, nev, ncv, maxn, maxnev, maxncv, ldv

!$omp parallel

!$omp do private(i, nev, ncv, maxnev, maxncv, n, maxn, ldv)

do i = 1, tn_subst

nev = PHI(i).nev

ncv = 2*nev + 1

maxnev = nev + 1

maxncv = ncv + 1



n = MKS(i).nn

maxn = n + 1

ldv = maxn

allocate( PHI(i).lambda(nev), PHI(i).aa(n, nev) )

call DSDRV1_ALLT(n, nev, ncv, maxn, maxnev, maxncv, ldv, 'LA', &

MKS(i).am, MKS(i).dmk, MKS(i).ak, MKS(i).dmk, &

PHI(i).lambda, PHI(i).aa)

end do

!$omp end do

!$omp end parallel

END SUBROUTINE CAL_PHIN

-------------------------------------------------------------------------------------------

In the above routine, the subroutine "DSDRV1_ALLT" is called and in the subroutine "DSDRV1_ALLT", the bolded variables are intended output and the others are intended input.

The variables "MKS" and "PHI" are derived data type and global variables. In the derived data type "MKS", MKS(:).am, MKS(:).ak, and MKS(:).dmk are stated allocatable.

I look forward to getting your precious comments.

Thank you.
Last edited by wkflahd on Mon May 26, 2014 6:34 am, edited 1 time in total.
wkflahd
 
Posts: 4
Joined: Tue May 20, 2014 5:24 pm

Re: Help for the problem with OPENMP

Postby ftinetti » Mon May 26, 2014 4:44 am

Hi,

Please include your code between code tags.

the bolded variables are intended output and the others are intended input.


My browser doesn't show any thing in bold face, please list IN/OUT/INOUT variables, do you explicitly declare such intents? Are there global/static variables accessed/changed in DSDRV1_ALLT()?

Fernando.
ftinetti
 
Posts: 567
Joined: Wed Feb 10, 2010 2:44 pm

Re: Help for the problem with OPENMP

Postby wkflahd » Mon May 26, 2014 6:37 am

ftinetti wrote:Hi,

Please include your code between code tags.

the bolded variables are intended output and the others are intended input.


My browser doesn't show any thing in bold face, please list IN/OUT/INOUT variables, do you explicitly declare such intents? Are there global/static variables accessed/changed in DSDRV1_ALLT()?

Fernando.


Hi, I edit the bold face.

there are no global variables in DSDRV1_ALLT().

What you mean of "static variables accessed/changed"? You mean there are variables stated by SAVE statement?

Thank you.
wkflahd
 
Posts: 4
Joined: Tue May 20, 2014 5:24 pm

Re: Help for the problem with OPENMP

Postby wkflahd » Mon May 26, 2014 7:25 am

I found the problem.

In many called subroutines, there are many local variables with SAVE attribute.

Is it possible that local variables are declared as PRIVATE?

Thank you.
wkflahd
 
Posts: 4
Joined: Tue May 20, 2014 5:24 pm

Re: Help for the problem with OPENMP

Postby ftinetti » Mon May 26, 2014 11:38 am

Hi again,

In many called subroutines, there are many local variables with SAVE attribute.

Is it possible that local variables are declared as PRIVATE?


Local variables with SAVE attribute are static (as opposed to "automatic" ones, i.e. unique memory location and retained value between calls), so there will be race conditions when running with threads.

I would suggest using threadprivate.

HTH,

Fernando.
ftinetti
 
Posts: 567
Joined: Wed Feb 10, 2010 2:44 pm

Re: Help for the problem with OPENMP

Postby wkflahd » Tue May 27, 2014 1:00 am

ftinetti wrote:Hi again,

In many called subroutines, there are many local variables with SAVE attribute.

Is it possible that local variables are declared as PRIVATE?


Local variables with SAVE attribute are static (as opposed to "automatic" ones, i.e. unique memory location and retained value between calls), so there will be race conditions when running with threads.

I would suggest using threadprivate.

HTH,


Fernando.


To : Fernando,

Thank you very much.

Because of your precious suggestions, it finally works.
wkflahd
 
Posts: 4
Joined: Tue May 20, 2014 5:24 pm

Re: Help for the problem with OPENMP

Postby ftinetti » Tue May 27, 2014 3:47 am

Hi,

To : Fernando,

Thank you very much.

Because of your precious suggestions, it finally works.


You are welcome, it's good to know it's working.

Fernando.
ftinetti
 
Posts: 567
Joined: Wed Feb 10, 2010 2:44 pm


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 5 guests