Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

openmp and fortran77 issues

Status
Not open for further replies.

blasco

Programmer
Jul 22, 2011
4
IE
Hi all. I have a provlem trying to use openmp to parallelize a code. The code is written in fortran77 (with a lot of commons, goto and old stuff) but I think it should work.

Code:
[...]
      DO 210 I=1,NK1
      I1=I-1
      IF(I.GE.NKM)MG=MG-1
      ME=2

C$OMP PARALLEL DEFAULT(SHARED)

C         write(*,*) "NUM THREADS USED: ", omp_get_num_threads() ! take the number of threads                                                                                   

C$OMP DO PRIVATE (K,AIK,ME,C,IK,J,L)
      DO 220 K=2,MG
      AIK=CDABS(APOM(I,K))
      IF(AIK.EQ.0.)GOTO 220
      C=APOM(I,K)/APOM(I,1)
      IK=I1+K
      J=0
      DO 230 L=ME,MG
      J=J+1
  230 APOM(IK,J)=APOM(IK,J)-C*APOM(I,L)
      BPOM(IK)=BPOM(IK)-C*BPOM(I)
  220 ME=ME+1
C$OMP END PARALLEL

[...]
  210 CONTINUE
It seems that at a certain point at the label 230 the value of j = 0 and i obtain a runtime error. If I compile the code w/o the -openmp flag it work perfectly. If I compile the code with the openmp flag and I set only one thread it crashes.

Can any of you catch an error I don't see?
Any idea/workaround tip ?
 
I do not know any OMP and I don't know what
C$OMP DO PRIVATE (K,AIK,ME,C,IK,J,L)
means...I presume that those are the variables that are supposed to have their own values in each thread?

Regardless...

I would make a couple of changes to the program just to be more proper.

First, I wouldn't do "(AIK.EQ.0.)"...that's just not cool. You can only do that with integers; with reals, I would use some kind of tolerance 1.e-06 or whatever is good enough for you.

I have never liked ending DO-loops with an executable statement. I prefer "DO...END DO"; if your f77 compiler cannot handle "END DO", then at least add a "continue" and let all other executable statements truly be inside the loop.

...you would be surprised...stupid little things like these reshuffle things and sometime things start working :)

are you sure there is not a single "GO TO 230" anywhere else in the program? is there the possibility you are jumping in?

You COULD stop using 'J' altogether and replace that with
(1+L-ME)
as the index.

How is the inner loop going to be parallelized? It seems that the value of ME is not independent; instead, it depends on how many times the outer loop has been executed...so...like I said, I don't know OMP, but if these "parallel" execution of loops are supposed to happen, I would think that they need to be independent.

my 2 cents.

could use some brief explanation, if you don't mind.

gsal

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top