gpt4 book ai didi

fortran - "%"在 Fortran 中意味着什么?

转载 作者:行者123 更新时间:2023-12-02 08:38:12 25 4
gpt4 key购买 nike

我正在尝试读取一些 Fortran 代码,但无法确定 %(百分号)的作用。

它是这样的:

   x = a%rho * g * (-g*a%sigma + m%gb * m%ca * (1.6 * a%rho+g))

它有什么作用?

最佳答案

在 Fortran 90 中,它们允许您创建类似于 C++ 中的结构。它基本上充当点 (.) 运算符。

来自http://www.lahey.com/lookat90.htm :

结构(派生类型)

您可以使用派生类型对数据进行分组。这使用户能够将内部类型(包括数组和指针)组合成新类型,可以使用百分号作为分隔符来访问其各个组件。 (派生类型在 VAX Fortran 中称为记录。)!使用派生类型和模块的示例。

module pipedef
type pipe ! Define new type 'pipe', which
real diameter ! is made up of two reals, an
real flowrate ! integer, and a character.
integer length
character(len=10) :: flowtype
end type pipe
end module pipedef

program main
use pipedef ! Associate module pipedef with main.
type(pipe) water1, gas1 ! Declare two variables of type 'pipe'.
water1 = pipe(4.5,44.8,1200,"turbulent") ! Assign value to water1.
gas1%diameter = 14.9 ! Assign value to parts
gas1%flowrate = 91.284 ! of gas1.
gas1%length = 2550
gas1%flowtype = 'laminar'
.
.
.
end program

关于fortran - "%"在 Fortran 中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8100131/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com