4

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)

Community
  • 1
  • 1

1 Answers1

4

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
Gilles
  • 9,269
  • 4
  • 34
  • 53
  • 2
    The continuation symbol doesn't necessarily have to be `+`. Any valid Fortran symbol except space and zero can be used. – Hristo Iliev Nov 14 '15 at 13:21
  • 1
    @HristoIliev wow, you're (as always) completely correct. The thing is that I'd always refer to the OpenMP standard for that since as I'm not a fixed format Fortran programmer, I'm never too sure. And the thing is that the only example given in the standard for a continuation line in fixed format is with a `+` as continuation character, so I naïvely assumed until now that it was the expected format. And indeed, pretty much in all fixed format OpenMP code I've see, the continuation line was with a `+`. That's the power of the examples in the standard! I'll fix that anyway – Gilles Nov 15 '15 at 01:30
  • Thanks the solution by Gilles works ! Works : c$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5, c$omp+ i6,x0,y0,z0,vnx0,vny0,vnz0,qs0) Does not work (as proposed in the other forum): c$omp parallel default(shared) private(i,k,i1,i2,i3,i4,i5, & c$omp& i6,x0,y0,z0,vnx0,vny0,vnz0,qs0) – Debasish Das Nov 17 '15 at 01:37