最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

在 Fortran 中混淆双精度实数

SEO心得admin31浏览0评论
本文介绍了在 Fortran 中混淆双精度实数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我现在有一个紧迫的问题:在现代 Fortran 中声明双精度实数的公认"方式是什么?按照从最旧到最新的顺序,故事似乎是这样的:DOUBLE PRECISION,然后是 REAL(kind=8),然后是 INTEGER, PARAMETER :: dp=kind(1.d0) 和 REAL(kind=dp)--Metcalf 现在说 dp=kind(0.d0)--现在 float32=selected_real_kind(6,37) 或 float64=selected_real_kind(15,307).所以...

Have this burning question on my mind right now: What is the "accepted" way to declare double precision real in modern Fortran? In order from oldest to newest, the story seems to go like this: DOUBLE PRECISION, then REAL(kind=8), then INTEGER, PARAMETER :: dp=kind(1.d0) with REAL(kind=dp)--Metcalf now says dp=kind(0.d0)--and now float32=selected_real_kind(6,37) or float64=selected_real_kind(15,307). So...

  • 我现在应该如何声明双精度真实?
  • 在 REAL(kind=dp) 中 kind 是多余的吗?
  • 在编译时是否需要任何特殊标志来使用 gfortran 或 ifort 调用双精度实数?
  • How should I be declaring double precision real now?
  • Is kind redundant in REAL(kind=dp)?
  • Are there any special flags needed at compile time to invoke double precision real with gfortran or ifort?
  • 推荐答案

    我个人现在写

    use, intrinsic :: iso_fortran_env

    其中包含int32、real64等参数,含义很明显,可以这样使用:

    which includes parameters such as int32,real64 which have the obvious meanings, and can be used like this:

    real(real64) :: a_64_bit_real_scalar

    请注意,标准不保证 kind=8 提供 8 字节的种类.kind 参数采用的值不是标准化的,并且因编译器而异.

    Note that kind=8 is not guaranteed, by the standard, to deliver an 8-byte kind. The values that kind parameters take are not standardised and do vary from compiler to compiler.

    如果需要,您可以编写诸如

    You could, if you want, write statements such as

    use, intrinsic :: iso_fortran_env, dp=>real64 ... real(dp) :: a_64_bit_real_scalar
    发布评论

    评论列表(0)

    1. 暂无评论