Fortran Coder

查看: 15605|回复: 10
打印 上一主题 下一主题

[子程序] 关于assumed-shape array和assumed-size array的中文翻译

[复制链接]

69

帖子

7

主题

0

精华

专家

F 币
320 元
贡献
224 点
跳转到指定楼层
楼主
发表于 2016-5-3 22:43:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jason388 于 2016-5-3 22:44 编辑

Fortran中的assumed-shape array和assumed-size array从英文角度很容易理解,但如何确切地译成中文似乎有些难度,请高手指点。

现在看到的assumed-shape array的翻译有:假定形状数组和不定结构数组,个人认为都不太确切。

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

1958

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1341 元
贡献
565 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

沙发
发表于 2016-5-4 06:44:03 | 只看该作者
我一直叫 “假定形状”和“假定大小”

69

帖子

7

主题

0

精华

专家

F 币
320 元
贡献
224 点
板凳
 楼主| 发表于 2016-5-4 08:01:56 | 只看该作者
本帖最后由 jason388 于 2016-5-4 08:06 编辑
fcode 发表于 2016-5-4 06:44
我一直叫 “假定形状”和“假定大小”

标准中assumed-shape array的定义为:an assumed-shape array is a nonpointer dummy argument array that take its shape from the associated actual argument array. 因此,assumed-shape数组的形状是通过虚实结合传递过来的(利用array descriptor),在子程序中其形状可作为已知对待(针对整个数组和部分数组的操作以及数组内置函数均可用)。翻译成“假定形状”,肯定了形状已知的一面,但虚实结合的含义没有体现出来。

assumed-size array与此类似,通过虚实结合,仅传递了数组的大小(size),形状是没有传的,因此依赖于形状的操作都不可用。注意,在传递时没有采用array descriptor.

在标准中,assumed-shape, assumed-size和assumed-type的用法基本类似,都是强调传递和在子程序中可视做已知的部分内容。

69

帖子

7

主题

0

精华

专家

F 币
320 元
贡献
224 点
地板
 楼主| 发表于 2016-5-4 08:10:37 | 只看该作者
explicit-shape(显式形状)和deferred-shape(待定形状)可用于实元和哑元,assumed-shape等只能用于哑元。

1958

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1341 元
贡献
565 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

5#
发表于 2016-5-4 18:06:01 | 只看该作者
这么说起来,确实有些不合理。但是这两个叫法流传了很多年,很多教材里都这么写。如果忽然换个叫法,会影响到交流吧?
话说学术界这种情况还挺多的,比如“磁场强度”和“磁感应强度”

我一直好奇,assumed-shape 如果是用 array descriptor 传递的。为何没有下标?比如实参是 a(-10:20) ,对应的虚参只能是 x(1:31)
难道下标没有再 array descriptor 里包含吗?同样的,传递一个 pointer 就可以传递下标

69

帖子

7

主题

0

精华

专家

F 币
320 元
贡献
224 点
6#
 楼主| 发表于 2016-5-5 11:04:43 | 只看该作者
fcode 发表于 2016-5-4 18:06
这么说起来,确实有些不合理。但是这两个叫法流传了很多年,很多教材里都这么写。如果忽然换个叫法,会影响 ...

个人感觉还是效率问题,毕竟在Fortran中以1为lbound的为绝大多数。

虽然多数翻译成“假定形状”,但也有翻译成“不定结构”的。其实具体叫什么都问题不大,这里讨论下是希望能够对Fortran的数组有个更好的理解。毕竟数组这种数据结构是Fortran中最重要的部分之一。

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

7#
发表于 2017-8-9 16:08:41 | 只看该作者
fcode 发表于 2016-5-4 18:06
这么说起来,确实有些不合理。但是这两个叫法流传了很多年,很多教材里都这么写。如果忽然换个叫法,会影响 ...

"我一直好奇,assumed-shape 如果是用 array descriptor 传递的。为何没有下标?比如实参是 a(-10:20) ,对应的虚参只能是 x(1:31).  难道下标没有再 array descriptor 里包含吗?同样的,传递一个 pointer 就可以传递下标"

請問, 有進一步的看法了嗎?

712

帖子

4

主题

0

精华

大师

农村外出务工人员

F 币
607 元
贡献
311 点

新人勋章爱心勋章水王勋章元老勋章热心勋章

8#
发表于 2017-8-11 08:51:26 | 只看该作者
Intel 的文档中写道:
If the lower bound is not specified, it is assumed to be 1.
The rank of the array is the number of colons (:) specified.
The value of the upper bound is the extent of the corresponding dimension of the associated actual argument array + lower-bound - 1.

根据反汇编分析。假定形状的数组,传递的依然是 array descriptor,里面也有下限的信息。
它包括以下内容:
Bytes 0 to 3 contain the base address.

Bytes 4 to 7 contain the size of a single element of the array.

Bytes 8 to 11 are reserved and should not be explicitly set.

Bytes 12 to 15 contain a set of flags used to store information about the array. This includes:

bit 1 (0x01): array is defined -- set if the array has been defined (storage allocated)

bit 2 (0x02): no deallocation allowed -- set if the array pointed to cannot be deallocated (that is, it is an explicit array target)

bit 3 (0x04): array is contiguous -- set if the array pointed to is a contiguous whole array or slice.

bit 8 (0x80): set if the array pointed to is ALLOCATABLE.

Other bits are reserved.

Bytes 16 to 19 contain the number of dimensions (rank) of the array.

Bytes 20 to 23 are reserved and should not be explicitly set.

The remaining bytes (24 to 107) contain information about each dimension (up to 31). Each dimension is described by a set of 3 4-byte entities:

The number of elements (extent)

The distance between the starting address of two successive elements in this dimension, in bytes.

The lower bound

然而,对于假定形状的参数,虚参并没有使用下限信息,而是视而不见。但对于 pointer 的参数,则取了 array descriptor 的下限信息。

为何对下限视而不见,我想这可能是为了兼顾语法规范的要求。

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

9#
发表于 2017-8-11 12:25:24 | 只看该作者
分兩部分討論
(A) 我不理解 為何 虛參應該要"繼承(or知道)"實參的下限 為宜, 我是持反對意見的
     真有需要, 如下即可:
[Fortran] 纯文本查看 复制代码
  REAL :: A(-100:100)
  CALL B( A, -100)
CONTAINS
  SUBROUTINE B( C, LB )
    INTEGER :: LB
    REAL :: C(LB:)


(B) 传递一个 pointer 就可以传递下标
    POINTER - "deferred" shape, not "assumed" shape

題外話, Compaq->Intel, 對Fortran到底是好還是不好? NVIDIA買下PGI也是
除了runtime在CPU/GPU跑得快有錢賺, 可有心於Fortran語法發展的社會責任心

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

10#
发表于 2017-8-12 15:17:35 | 只看该作者
自言自語:
for (B): 當POINTER A "pointer to"/"associated with"/"aliasing" B, A就是B, A就有B的attributes(lower and upper bounds), may be是我一廂情願的強詞奪理
for (A): assumed shape array的下標能是"浮動"的有何不好? 不然 REAL::A(10) 實參A(3:10), 對應虛參的下標是"3"好還是"1"好, 見仁見智了
傳統上, SHAPE定義是RANK(number of dimensions)與EXTENT(size of each dimsnsion), 並不綁定lower/upper bounds
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-4-24 19:35

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表