找回密码
 注册
Simdroid-非首页
查看: 267|回复: 6

[H. 有限元编程] feapv 程序 就是R.LTaylor写的那个,数组内存管理问题

[复制链接]
发表于 2012-9-16 13:17:28 | 显示全部楼层 |阅读模式 来自 湖南长沙

feapv数组内存管理没懂,明白的指教下,下面文字来自feapv开发手册上的。

integer num_nps , num_ups
parameter (num_nps = 400 , num_ups = 200)
integer np , up
common /pointer/ np(num_nps) , up(num_ups)

Each pointer is an offset relative to the address of a REAL*8 array hr(1) or an INTEGER

array mr(1) defined in a blank common
real*8 hr
integer mr
common hr(1),mr(1)

说是hr,mr,记录地址的偏移,感觉他是把所有的数组写在一个内存空白区域hr(real*8),mr(integer),然后记录每个生成数组在空白区域的位置,并且用字典把数组名来记录下来。
他还举了个得到节点坐标的数组的例子
For example, if a development requires the nodal coordinate
data the call
integer xpoint, xlen, xpre
logical flag
....
call pgetd ('X ',xpoint,xlen,xpre,flag)
x1 = hr(xpoint)
For example y1 is located at hr(xpoint+1)
这么看来hr存的是具体的内容,而非地址。
但他在头文件中把hr,mr大小定义好了,都是1,hr(xpoint+1)岂不是会数组越界..


发表于 2012-9-16 13:59:34 | 显示全部楼层 来自 北京
Simdroid开发平台
必须是哑元/公用区传递
hr(1)中的1只起了个hr定义为数组的作用
这事fortran中传递数组指针的经典方法
回复 不支持

使用道具 举报

发表于 2012-9-16 14:01:19 | 显示全部楼层 来自 北京
好处是:一次申请一块大的内存,然后分区使用
这种方法利用内存的效率最高,
高效利用内存是fortran提高计算速度的关键
回复 不支持

使用道具 举报

 楼主| 发表于 2012-9-16 14:47:56 | 显示全部楼层 来自 湖南长沙
本帖最后由 yingfashi 于 2012-9-16 15:08 编辑
penultimate 发表于 2012-9-16 13:59
必须是哑元/公用区传递
hr(1)中的1只起了个hr定义为数组的作用
这事fortran中传递数组指针的经典方法 ...

他的开发手册上说,The arrays 'hr' and 'mr' are used to establish addresses only and not to physically store
data. 可我怎么觉得hr就是一大块空白内存还有个问题是他在头文件中声明了 hr(1),在实际中如何修改hr大小,这些都是fortran77的,现在书都没讲这些,讲的是allocateble,module可以代换吧
回复 不支持

使用道具 举报

发表于 2012-9-17 10:14:45 | 显示全部楼层 来自 北京
hr是一段指定内存区域的起始位置,也就是指针
大小通过使用时给他预留的空间决定,不需要分配
注意,这段区域是一次性分配一块大内存中的一部分/或全部,用ALLOCATE
仔细看一下使用数组时,内存片段大小布局的代码片段,应该不难搞清楚
回复 不支持

使用道具 举报

发表于 2012-9-17 16:31:12 | 显示全部楼层 来自 上海普陀区
yingfashi 发表于 2012-9-16 14:47
他的开发手册上说,The arrays 'hr' and 'mr' are used to establish addresses only and not to physical ...

这类F77的common块古老语法能够看懂就行,没特殊情况就别深入研究
真要搞数值计算要么一步到位C/C++,要么过渡到F90/95、F03
回复 不支持

使用道具 举报

发表于 2013-12-10 11:48:16 | 显示全部楼层 来自 天津
楼主  我也觉得有你说的这个问题  现在看了feap两个多月 能交流一下吗
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-25 09:42 , Processed in 0.034840 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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