Fortran Coder

查看: 10601|回复: 5
打印 上一主题 下一主题

[数值问题] 有关fortran位数取舍问题

[复制链接]

13

帖子

4

主题

0

精华

入门

F 币
51 元
贡献
30 点
跳转到指定楼层
楼主
发表于 2017-12-11 15:27:02 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
不知道怎么设置才能正确读写啦问题如图所示
设置了kind=8或kind=16都一样,
感觉是设置的问题
希望大神解答
谢谢




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

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

沙发
发表于 2017-12-12 10:33:51 | 只看该作者
本站的教学视频都看过了?
看过三遍还是一知半解,那是教学视频做得不好;一遍都没看过,那是lz人生的重大遗憾!
言归真正:
首先,小数点后的第二位就有差别,岂能熟视无睹?
其次,硬件与编译器是否支持呢?
https://gcc.gnu.org/onlinedocs/g ... 005fFORTRAN_005fENV
REAL32, REAL64, REAL128:
Kind type parameters to specify a REAL type with a storage size of 32, 64, and 128 bits. It is negative if a target platform does not support the particular kind. (Fortran 2008 or later.)

REAL_KINDS:
Default-kind integer constant array of rank one containing the supported kind parameters of the REAL type. (Fortran 2008 or later.)

954

帖子

0

主题

0

精华

大师

F 币
184 元
贡献
75 点

规矩勋章元老勋章新人勋章水王勋章热心勋章

QQ
板凳
发表于 2017-12-12 13:17:58 | 只看该作者
a=-14099.409813d0

a=-14099.409813_8

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

地板
发表于 2017-12-13 09:32:32 | 只看该作者
补充一个gfortran的四精度扩展支持
https://gcc.gnu.org/onlinedocs/g ... l#Q-exponent-letter
6.1.8 Q exponent-letter
GNU Fortran accepts real literal constants with an exponent-letter of Q, for example, 1.23Q45. The constant is interpreted as a REAL(16) entity on targets that support this type. If the target does not support REAL(16) but has a REAL(10) type, then the real-literal-constant will be interpreted as a REAL(10) entity. In the absence of REAL(16) and REAL(10), an error will occur.


13

帖子

4

主题

0

精华

入门

F 币
51 元
贡献
30 点
5#
 楼主| 发表于 2017-12-13 17:08:44 | 只看该作者
pasuka 发表于 2017-12-12 10:33
本站的教学视频都看过了?
看过三遍还是一知半解,那是教学视频做得不好;一遍都没看过,那是lz人生的重大 ...

谢谢啦,看过该网站视频啦,可能看的不够仔细,我会再看的

13

帖子

4

主题

0

精华

入门

F 币
51 元
贡献
30 点
6#
 楼主| 发表于 2017-12-13 17:09:25 | 只看该作者
vvt 发表于 2017-12-12 13:17
a=-14099.409813d0

a=-14099.409813_8

谢谢啦,我按第二种解决的
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2024-4-25 17:56

Powered by Tencent X3.4

© 2013-2024 Tencent

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