问题描述
我试图了解一些传给我的Fortran代码。这是子程序中的参数列表:
INTEGER,INTENT(IN):: NKT
REAL,INTENT IN):: NW2(NKT),VAR,SUE
REAL,INTENT(INOUT):: MYSPC(NKT,NKT)
我了解NKT,VAR和SUE的声明。但是NW2(NKT),MYSPC(NKT,NKT)中的(NKT)和(NKT,NKT)的含义是什么? NKT是否指定了阵列NW2和MYSPC的尺寸?还是说该子程序将传入的值存储在NW2的NKTth位置?
我对变量之后的()使用感到困惑。 Nyhoff的FORTRAN 90简介一书没有介绍它。任何帮助,将不胜感激。
(代码是Wavewatch的修改部分,)
I'm trying to understand some Fortran code that was passed to me. This is the argument list in a subroutine:
INTEGER, INTENT(IN) :: NKT
REAL, INTENT(IN) :: NW2(NKT), VAR, SUE
REAL, INTENT(INOUT) :: MYSPC(NKT,NKT)
I understand the declarations of NKT, VAR, and SUE. But what is the meaning of "(NKT)" and "(NKT,NKT)" in NW2(NKT), MYSPC(NKT,NKT)? Does NKT specify the dimensions of the arrays NW2 and MYSPC? Or is it saying the subroutine stores the passed value in the NKTth position of NW2?
I'm really confused by the usage of () after a variable. It's not covered in the "Introduction to FORTRAN 90" book by Nyhoff. Any help would be appreciated.
(Code is a modified segment of Wavewatch, http://polar.ncep.noaa.gov/waves/wavewatch/)
In your example, NW2(NKT), is an array with NKT elements, MYSPC(NKT,NKT) is a NKTxNKT 2D array. If your Fortran book doesn't cover this, really, get a better book. If you have some previous programming experience, I recommend "Modern Fortran Explained" by Metcalf, Reid, and Cohen.
这篇关于参数列表:名称后括号的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!