Problems with parametrized derived types in Fortran 2003

吃可爱长大的小学妹 提交于 2019-12-02 12:27:48

问题


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

I get the errors

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)

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?


回答1:


Parameterized derived types are not yet implemented in gfortran:

https://gcc.gnu.org/wiki/OOP (see Unimplemented features)

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

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



来源:https://stackoverflow.com/questions/24372093/problems-with-parametrized-derived-types-in-fortran-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!