什么是“%"?在Fortran中是什么意思? [英] What does "%" mean / do in Fortran?
问题描述
我正在尝试阅读一些Fortran代码,但无法确定%
(百分号)的作用.
I am trying to read some Fortran code, but can not determine what the %
(percentage sign) does.
它像这样的一行:
x = a%rho * g * (-g*a%sigma + m%gb * m%ca * (1.6 * a%rho+g))
它是做什么的?
推荐答案
在Fortran 90中,它们允许您创建类似于C ++的结构.它基本上充当点(.)运算符.
In Fortran 90 they allow you to create structures like in C++. It basically acts as the dot (.) operator.
来自 http://www.lahey.com/lookat90.htm :
结构(派生类型)
您可以使用派生类型对数据进行分组.这使用户可以将固有类型(包括数组和指针)组合成新的类型,可以使用百分号作为分隔符来访问各个组件. (派生类型在VAX Fortran中称为记录.) !使用派生类型和模块的示例.
You can group your data using derived types. This enables users to combine intrinsic types (including arrays and pointers) into new types whose individual components can be accessed using the percent sign as a delimiter. (Derived types are known as records in VAX Fortran.) ! Example using derived types and modules.
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中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!