双精度数组构造函数 "requires explicit type"

Double precision array constructor "requires explicit type"

我尝试用 gfortran 编译旧的 Fortran 90 程序,但这不起作用:

REAL(DP), DIMENSION(10,6) :: csCO2

csCO2(1,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.18261340d7, &
0.79224365d2, 0.0, 0.0/)
csCO2(2,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.0,&
0.66560660d-4, 0.57152798d-5, 0.3022236d-9/)

这给我错误:

csCO2(1,:) = (/DOUBLE PRECISION :: 0.0, 0.0, 0.18261340d7, &
           ^                                             
cf90-113 f90fe: ERROR FUGCO2, File = CO2EOS.f90, Line = 56, Column = 16 
  IMPLICIT NONE is specified in the local scope, therefore an explicit type 
must be specified for data object "DOUBLE".                      ^                                      
cf90-197 f90fe: ERROR FUGCO2, File = CO2EOS.f90, Line = 56, Column = 23 
  Unexpected syntax: "/)" was expected but found "P".

我该如何解决这个问题?

数组构造函数语法

(/ type :: value, ... /)

不是 Fortran 90 的功能。它是在 Fortran 2003 中引入的。

编译错误表明您的编译器无法识别此语法。您应该使用支持此类数组构造函数的更高版本的编译器。

您可以修改源代码,在本例中为,

 csCO2(1,:) = (/0.0_dp, 0.0_dp, 0.18261340e7_dp, 0.79224365e2_dp, 0.0_dp, 0.0_dp/)

等等,但你最好使用现代编译器。

从 gfortran 更改为 x86_64-w64-mingw32-gfortran.exe 并且有效