Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
841 views
in Technique[技术] by (71.8m points)

fortran - Syntax for openmp long directive list fortran77

PROBLEM : Long list of directives openmp fortran77

c$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5,
     $ i6,x0,y0,z0,vnx0,vny0,vnz0,qs0)
c$omp do
      Task to be performed
c$omp end do
c$omp end parallel

I'm trying to compile the above program using ifort and it works fine. I have checked with the serial version and I get the same result

ifort -openmp -parallel -o ./solve 

But when I try to compile using gfortran it doesn't work.

gfortran -fopenmp 

I get the following error

quinckedrop.f:2341.57:

*$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5               
                                                         1
Error: Syntax error in OpenMP variable list at (1)
quinckedrop.f:2342.6:

     $        ,i6,x0,y0,z0,vnx0,vny0,vnz0,qs0)                          
      1
Error: Bad continuation line at (1)
quinckedrop.f:2342.15:

     $        ,i6,x0,y0,z0,vnx0,vny0,vnz0,qs0)                          
               1
Error: Invalid character in name at (1)
quinckedrop.f:2381.72:

*$omp end parallel                                                      
                                                                        1
Error: Unexpected !$OMP END PARALLEL statement at (1)
quinckedrop.f:2768.6:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0,vnx0,vny0,vnz0)    
      1
Error: Bad continuation line at (1)
quinckedrop.f:2768.21:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0,vnx0,vny0,vnz0)    
                     1
Error: PRIVATE statement at (1) is only allowed in the specification part of a module
quinckedrop.f:4302.6:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0)                   
      1
Error: Bad continuation line at (1)
quinckedrop.f:4302.21:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0)                   
                     1
Error: PRIVATE statement at (1) is only allowed in the specification part of a module
quinckedrop.f:5738.6:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0                    
      1
Error: Bad continuation line at (1)
quinckedrop.f:5738.21:

     $        private(i,k,i1,i2,i3,i4,i5,i6,x0,y0,z0                    
                     1
Error: PRIVATE statement at (1) is only allowed in the specification part of a module

This proposed solution doesn't work for me (may be because I am using fortran77)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your problem simply boils down to that the OpenMP continuation syntax for fixed format sources Fortran code is like this:

c$omp parallel blah
c$omp+private( blah )
c$omp+reduction( blah )

Well, to be more precise, all the 3 following forms for directives are equivalent:

c$omp
!$omp
*$omp

But in any case, a directive spread across several lines must be split using an extra character in the 6th column, as already shown. This character can be anything but a space or a zero. (thanks to Hristo Iliev for having corrected me in that. Initially mistakenly stated that the continuation character was supposed to be a +)

Adding the various necessary c$omp+ continuation lines should just solve your problem

This should look like this:

c$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5,
c$omp+ i6,x0,y0,z0,vnx0,vny0,vnz0,qs0)
c$omp do
      Task to be performed
c$omp end do
c$omp end parallel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...