“%"是什么意思?在 Fortran 中是什么意思? [英] What does "%" mean / do in Fortran?

查看:113
本文介绍了“%"是什么意思?在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆