Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Io 使用名称列表读写的可分配/假定大小数组_Io_Fortran_Intel Fortran_Fortran2003 - Fatal编程技术网

Io 使用名称列表读写的可分配/假定大小数组

Io 使用名称列表读写的可分配/假定大小数组,io,fortran,intel-fortran,fortran2003,Io,Fortran,Intel Fortran,Fortran2003,我正在使用VS2012和英特尔Visual Fortran 2015 根据,现在允许使用可分配和假定大小的数组来读取和写入名称列表;但是,我仍然收到错误“名称列表组对象不能是假定大小的数组” 示例代码: subroutine writeGrid(fname, grid) character*(*) :: fname real*8, dimension(:,:) :: grid namelist /gridNML/ grid open(1, file=fnam

我正在使用VS2012和英特尔Visual Fortran 2015

根据,现在允许使用可分配和假定大小的数组来读取和写入名称列表;但是,我仍然收到错误“名称列表组对象不能是假定大小的数组”

示例代码:

subroutine writeGrid(fname, grid)

    character*(*) :: fname
    real*8, dimension(:,:) :: grid

    namelist /gridNML/ grid

    open(1, file=fname)
    write(1, nml=gridNML)
    close(1)

end subroutine writeGrid
我已经启用了F2003语义


我遗漏了什么?

这看起来像是一个编译器错误。阵列
网格
为假定形状,而非假定大小。自F2003起,在名称列表中允许使用假定形状数组,但假定大小数组仍被禁止(在运行时,假定大小数组的大小不一定已知,因此禁止需要知道大小的操作)

一个简单的解决方法是将伪参数重命名为其他参数,然后将其值复制到名为
grid
的本地可分配文件中

subroutine writeGrid(fname, grid_renamed)
  character*(*) :: fname
  real, dimension(:,:) :: grid_renamed
  real, dimension(:,:), allocatable :: grid

  namelist /gridNML/ grid

  open(1, file=fname)
  allocate(grid, source=grid_renamed)
  write(1, nml=gridNML)
  close(1)
end subroutine writeGrid

这里没有可分配的数组。不可否认,您也没有假定大小的数组。传入的数组是可分配的,不确定这是否有区别。子例程的伪参数是不可分配的。传递的数组(实际参数)是否可分配并不重要。我也没有看到francescalus提到的任何假定大小数组。你确定你发布的是准确的代码吗?Ian是正确的,这是一个编译器错误。但这不是您链接的论坛主题中讨论的情况,它是一个本地的可分配数组。我会把这个发给开发者。太棒了。这就是我昨晚想出的解决办法。谢谢,谢谢你指出了假定形状和假定大小之间的区别。我听说这个错误已经修复了。修复应该出现在16.0编译器的更新1中,可能在10月至11月的时间范围内。