English 中文(简体)
不要将微笑论点撤回到Fortran的阵列。
原标题:No lifting of scalar arguments to arrays in Fortran

为什么预先准备在expression上向一个阵列作标记,但不作为程序的理由? 特别是,标准机构为何作出这一设计决定? 程序是否仅仅因为含糊不清而超负荷? 这一情况中的错误信息是否是一种替代方法?

例如, 在以下代码中,最后一份说明(x = foo(7))产生了GFortran错误:Error: Rank mismatch in debate a at (1) (1 and 0).

module m

  public :: foo

  contains

  function foo(a) result(b)
    integer, dimension(:)       :: a
    integer, dimension(size(a)) :: b
    b = a+1
  end function foo

end module m

program p

  use m

  integer, dimension(4) :: x
  integer, parameter, dimension(4) :: y = (/1,2,3,4/)

  x = 7
  x = foo(x)
  x = foo(y)
  x = foo(x + 7)
  x = foo(7)

end program p

This question should have asked about why an array assignment will promote a scalar value source to an array target; unlike an array function. I expect that s simply a convenient special case though. Any comments gratefully received in the begging caps below.

最佳回答

如果你想要处理规模和阵论,宣布其为“灵魂”和大米论。 然后,它将能够处理规模和阵列的实际论点,包括规模表示。 满足你们的需要吗?

变化:

  elemental function foo(a) result(b)
    integer, intent (in)      :: a
    integer :: b
    b = a+1
  end function foo

也许它们为你想要做些什么提供了途径,一种方式是足够的?

问题回答

要求有明确接口(在使用模块程序时自动获得)的档次程序要求TKR(类型、类型、级别)匹配。 由于一个阵列的类型不同,更不用说等级错误,因此不允许这样做。

www.un.org/Depts/DGACM/index_spanish.htm 程序是否因含糊不清而超负荷?

这将是一个问题,是。

在这种情况下的错误信息是否是一种替代方法?>

单角是否存在吗? 也许,但是,根据我所知,通用标准目前要求TKR匹配,因此,符合标准的汇编者必须执行这一要求。 如果你想改变这一点,我建议向标准委员会提出建议。

I would think the answer to this is pretty clear. Let s slightly modify your example:

module m

  public :: foo

  contains

  function foo(a) result(b)
    integer, dimension(:)       :: a
    integer, dimension(size(a)) :: b
    b = a+1
    a(2) = -777     ! new line; modify one element
  end function foo

end module m

program p

  use m

  integer :: x
  integer, dimension(4) :: y 

  x = 7
  y = foo(x)  ! pass a scalar

end program p

在呼吁禁忌之后应该做些什么?

现在,可以肯定的是,根据是否载有<条码>intent(in)变量,但可以有经过改动的论点的语句,即而不是,而现在要向方案制定者说明<>> /em>。

如果该职能呼吁本应在阵列要素上分配一些how,那么,正如国际会计准则理事会指出的,要素就是前进的道路。 否则,人们只能确保一个论点与一个参数相符。





相关问题
How do I fix this Fortran text parser for Lapack within Gem5

After about an hour, I need to ask for some help. I ve downloaded the math benchmark Lapack to run within a few CPU configurations for the simulation tool Gem5, which lets you build X86 computers and ...

gfortran, DLL, underscore

I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention. Running dumpbin /export foo.dll gives me something like: ... 7 6 ...

Getting started with a new code in an unfamiliar language

I m starting a new project in a language I m less familiar with (FORTRAN) and am in the discovery phase. Normally reading through and figuring out code is a fairly simple task, however, this code ...

assigning values to an integer array within a Fortran module

I have a module in Fortran called QFoo. It defines a type QFooType. I want to initialize all the elements of integer array is_n to 0 and want to do it within the module. Could someone help? Thank ...

WinDbg and Intel Visual Fortran

Has anyone used WinDbg to debug an Intel Visual Fortran routine? If I have the Fortran source file that crashes with an AccViol, how can I use WinDbg to determine the line that is crashing?

converting MATLAB code to Fortran [closed]

I a medical researcher with code written in MATLAB 2009b that runs very slowly because of a self-referential loop (not sure of the programming lingo here), i.e., the results of the first iteration is ...

热门标签