openmp 长指令列表 fortran77 的语法

Syntax for openmp long directive list fortran77

问题:一长串指令 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

我正在尝试使用 ifort 编译上述程序,它工作正常。我检查了串行版本,得到了相同的结果

ifort -openmp -parallel -o ./solve 

但是当我尝试使用 gfortran 编译时它不起作用。

gfortran -fopenmp 

我收到以下错误

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 对我不起作用(可能是因为我使用的是 fortran77)

您的问题简单地归结为固定格式源 Fortran 代码的 OpenMP 延续语法如下所示:

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

嗯,更准确地说,指令的以下 3 种形式都是等价的:

c$omp
!$omp
*$omp

但是无论如何,一个分布在多行中的指令必须在第 6 列中使用一个额外的字符来拆分,如前所示。此字符可以是 space 或零以外的任何字符。 (感谢 Hristo Iliev 纠正了我的错误。最初错误地指出延续字符应该是 +

添加各种必要的 c$omp+ 续行应该可以解决您的问题

这应该是这样的:

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