Fortran 2003中参数化派生类型的问题 [英] Problems with parametrized derived types in Fortran 2003

查看:155
本文介绍了Fortran 2003中参数化派生类型的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自学Fortran 2003以用于我目前正在研究的一个研究项目。我习惯了Fortran 90,但是这个项目需要使用参数化类型,所以我将继续到2003年。

I'm teaching myself Fortran 2003 to use for a research project I'm currently working on. I'm used to Fortran 90, but this project requires the use of parametrized types, and so I'm moving on to 2003.

我跟随这个网站的关于如何定义参数化类型的描述,并且写了一个非常简单的示例程序在该网站的示例中进行测试:

I was following this site's description of how to define a parametrized type, and wrote a very simple example program based on the site's example to test it out:

module example
implicit none

  type :: param_matrix(k,a,b)
     integer, kind :: k
     integer, len :: a
     integer, len :: b
     real(kind=k), dimension(a,b) :: m
  end type param_matrix

end module example

当我使用命令编译这个命令时:

When I compile this with the command

gfortran -c test.F03

我收到错误

test.F03:4.2:

  type :: param_matrix(k, a, b)

  1

Error: Unclassifiable statement at (1)

test.F03:5.13:

     integer, kind :: k

             1

Error: Invalid character in name at (1)

test.F03:6.13:

     integer, len :: a

             1

Error: Invalid character in name at (1)

test.F03:7.13:

     integer, len :: b

             1

Error: Invalid character in name at (1)

test.F03:8.16:

     real(kind=k), dimension(a,b) :: m

                1

Error: Symbol 'k' at (1) has no IMPLICIT type

test.F03:9.5:

  end type param_matrix

     1

Error: Expecting END MODULE statement at (1)

当我删除公式的参数化部分时,它编译得很好(即识别类型)。对于Fortran 2003特定的任何东西似乎都有特别的麻烦,但是当我使用命令运行时,

When I remove the parametrized parts of the formula, it compiles fine (that is, it recognizes the type). It seems to be having particular trouble with anything specific to Fortran 2003, but when I run with the command

-std=f2003

它仍然有同样的问题。可能会发生什么?

it still has the same problems. What might be going on?

推荐答案

参数化派生类型尚未在 gfortran

Parameterized derived types are not yet implemented in gfortran:

https:// gcc。 gnu.org/wiki/OOP (请参阅未实现的功能

目前,只有Cray,PGI和IBM Fortran编译器支持此功能:

Currently, only Cray, PGI, and IBM Fortran compilers support this feature:

http:/ /fortranwiki.org/fortran/show/Fortran+2003+status

这篇关于Fortran 2003中参数化派生类型的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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