compiler-errors - 如何使用 `real sepaa[allocatable](:)` 语法编译 Fortran?

标签 compiler-errors compilation fortran gfortran

我正在尝试编译这个程序/模块? Fortran 中的 (modulos.f)

      module vars_common
          real sepaa[allocatable](:)
          real sepan[allocatable](:)
          real rt[allocatable](:) 
          real xob[allocatable](:)
          real npx[allocatable](:)
          real*8 bb[allocatable](:)
          real*8 bl[allocatable](:)
          real*8 bu[allocatable](:)
          real*8 cvec[allocatable](:)
          real*8 ww[allocatable](:)
          real*8 a[allocatable](:,:)
          real*8 xi[allocatable](:)
          real*8 q[allocatable](:,:)
          real*8 dd[allocatable](:,:)
          !variables escalares
          integer maxm_var, maxn_var, nrowa_var
          integer liwork_var,lwork_var, maxbnd_var
      end module vars_common
      
*********************************************************************     
       subroutine allocate_data
          !maxm, maxn,maxbnd,mp
          use vars_common
          parameter(mg=1000, mp=2000)
          integer ind
          allocate(sepaa(0:maxm_var),sepan(0:maxm_var),rt(0:maxm_var),
     *    stat=ind)
          if (ind.ne.0) stop 'sin memoria'  
          allocate(xob(maxm_var),npx(0:mp), 
     *    stat=ind)
          if (ind.ne.0) stop 'sin memoria' 
          allocate(bb(0:maxm_var),bl(maxbnd_var),bu(maxbnd_var),
     *    stat=ind)
          if (ind.ne.0) stop 'sin memoria' 
          allocate(cvec(maxn_var), ww(maxn_var), 
     *    stat=ind)
          if (ind.ne.0) stop 'sin memoria' 
          allocate(a(0:maxm_var,0:maxn_var), stat=ind)
          if (ind.ne.0) stop 'sin memoria'
          allocate(xi(maxn_var),q(maxn_var,maxn_var),
     *    stat=ind)
          if (ind.ne.0) stop 'sin memoria'
          allocate(dd(maxn_var,maxn_var),stat=ind)
          if (ind.ne.0) stop 'sin memoria'
      end subroutine allocate_data
          
**********************************************************************
      subroutine deallocate_data
          use vars_common
          integer ind
          deallocate(sepaa,sepan,rt, stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio' 
          deallocate(xob,npx,stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio'
          deallocate(bb,bl,bu,stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio'
          deallocate(cvec,a,stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio'
          deallocate(xi,q,stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio'
          deallocate(dd,stat=ind)
          if (ind.ne.0) stop 'problema liberando espacio'
      end subroutine deallocate_data
***********************************************************************
我不知道 Fortran 是什么版本,但我在 Ubuntu 20.04.1 LTS 的终端中尝试了以下命令。
gfortran modulos.f 我收到此错误消息:
> 模数.f:2:21:
    2 |           real sepaa[allocatable](:)
      |                     1
Fatal Error: Coarrays disabled at (1), use ‘-fcoarray=’ to enable
compilation terminated.
gfortran -fcoarray=lib -c modulos.f gfortran -fcoarray=single -c modulos.f
我收到此错误消息:
modulos.f:2:33:

    2 |           real sepaa[allocatable](:)
      |                                 1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:3:33:

    3 |           real sepan[allocatable](:)
      |                                 1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:4:30:

    4 |           real rt[allocatable](:)
      |                              1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:5:31:

    5 |           real xob[allocatable](:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:6:31:

    6 |           real npx[allocatable](:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:7:32:

    7 |           real*8 bb[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:8:32:

    8 |           real*8 bl[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:9:32:

    9 |           real*8 bu[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:10:34:

   10 |           real*8 cvec[allocatable](:)
      |                                  1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:11:32:

   11 |           real*8 ww[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:12:31:

   12 |           real*8 a[allocatable](:,:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:13:32:

   13 |           real*8 xi[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:14:31:

   14 |           real*8 q[allocatable](:,:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:15:32:

   15 |           real*8 dd[allocatable](:,:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:24:13:

   24 |           use vars_common
      |             1
Fatal Error: Cannot open module file ‘vars_common.mod’ for reading at (1): No such file or directory
compilation terminated.
gfortran -fcoarray=none -c modulos.f 我收到此错误消息:
gfortran -fcoarray=none -c modulos.f 
modulos.f:2:21:

    2 |           real sepaa[allocatable](:)
      |                     1
Fatal Error: Coarrays disabled at (1), use ‘-fcoarray=’ to enable
compilation terminated.
gfortran -fcoarray=single -c modulos.f 我收到此错误消息:
gfortran -fcoarray=single -c modulos.f
modulos.f:2:33:

    2 |           real sepaa[allocatable](:)
      |                                 1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:3:33:

    3 |           real sepan[allocatable](:)
      |                                 1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:4:30:

    4 |           real rt[allocatable](:)
      |                              1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:5:31:

    5 |           real xob[allocatable](:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:6:31:

    6 |           real npx[allocatable](:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:7:32:

    7 |           real*8 bb[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:8:32:

    8 |           real*8 bl[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:9:32:

    9 |           real*8 bu[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:10:34:

   10 |           real*8 cvec[allocatable](:)
      |                                  1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:11:32:

   11 |           real*8 ww[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:12:31:

   12 |           real*8 a[allocatable](:,:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:13:32:

   13 |           real*8 xi[allocatable](:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:14:31:

   14 |           real*8 q[allocatable](:,:)
      |                               1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:15:32:

   15 |           real*8 dd[allocatable](:,:)
      |                                1
Error: Upper bound of last coarray dimension must be ‘*’ at (1)
modulos.f:24:13:

   24 |           use vars_common
      |             1
Fatal Error: Cannot open module file ‘vars_common.mod’ for reading 

at (1): No such file or directory
    compilation terminated.
你能帮我找到解决办法吗?最好使用 gfortran 作为编译器。谢谢

最佳答案

这个[allocatable]不是标准的 Fortran。
代替

      real sepaa[allocatable](:)
      real sepan[allocatable](:)
Fortran 需要
      real, allocatable :: sepaa(:)
      real, allocatable :: sepan(:)
等等。 dimension 的替代品属性或单独的 allocatable声明也存在。
如果不是在太多地方,我建议手动进行此更正。
您可以尝试询问您的主管它是哪种语法以及应该如何编译。他们可能不再知道他们是从哪里学到的,但至少他们可能知道他们曾经使用过哪个编译器。但是如果搜索并购买一些可以接受它作为扩展的编译器,我建议改正代码。

gfortran 告诉您的是标准 Fortran 使用方括号表示 coarrays。 .这些用于并行处理
real, allocatable :: A(:)[:]
我认为这与您的代码无关。

关于compiler-errors - 如何使用 `real sepaa[allocatable](:)` 语法编译 Fortran?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65695435/

相关文章:

c - netdb.h : No such file or directory while trying to run a socket program (in C language) on windows

java - 找不到符号-类文件

c - 错误: expected ')' before numeric constant (fwrite)

kotlin - Kotlin是如何专门编译的?

oop - 在 Fortran 中扩展对象并覆盖过程而不延迟

random - 如何生成一个范围内的随机整数

java - 从嵌套泛型推断泛型类型参数

c++ - Linux g++ 编译

angular - 在 Angular 4/5 中编译动态 HTML——类似于 Angular JS 中的 $compile

python - 将 FORTRAN90 文件生成的数据读入 NUMPY 数组