相关疑难解决方法(0)

假设大小数组:冒号与星号 - DIMENSION(:) arr与arr(*)

这两种声明假定大小数组的方法之间有什么区别吗?

例如

real, dimension(:) :: arr
Run Code Online (Sandbox Code Playgroud)

real               :: arr(*)
Run Code Online (Sandbox Code Playgroud)

arrays fortran fortran90

21
推荐指数
2
解决办法
1万
查看次数

模块调用具有隐式接口的外部过程

以下代码,结合模块程序外部程序

module module_dummy

  implicit none

contains

  subroutine foo(a)

    real, intent(inout) :: a(:)

    call bar(a)

  end subroutine foo

end module module_dummy

program main

  use module_dummy

  implicit none 

  integer, parameter :: nelems = 100000000
  real,  allocatable :: a(:)

  allocate( a(nelems) )
  a = 0.0
  call foo(a)
  print *, a(1:10)
  deallocate(a)

end program main

subroutine bar(a)

  implicit none

  real, intent(inout) :: a(:)

  a = 1.0      

end subroutine bar
Run Code Online (Sandbox Code Playgroud)

似乎失败了:

  1. segmentation fault
  2. 打印块0.000而不是块1.000

在我迄今为止尝试过的任何平台上。该问题与 的隐式接口声明 …

module interface subroutine fortran90

2
推荐指数
1
解决办法
2069
查看次数

标签 统计

fortran90 ×2

arrays ×1

fortran ×1

interface ×1

module ×1

subroutine ×1