Expanding on my previous question here, I want to know if is possible to create custom attributes in fortran ?
开发者_Python百科something like this
real, custom_attribute, allocatable :: variable(:)
If that can be done, I am guessing the following can be done too
custom_type, custom_attribute, allocatable :: variable(:)
You can create user-defined "types". Probably you can accomplish your goal with this feature. See http://en.wikipedia.org/wiki/Fortran_95_language_features#Derived_data_types
No, there is no such thing as custom attributes in standard Fortran. However extending M. S. B.s answer, when using derived data types you can use parameterized derived types, which was introduced with Fortran 2003. It allows you to define "kind" and "len" attributes for the derived data types. This enables you to do something like: type(my_type(rk=selected_real_kind(15), extent=size(a))) :: b
精彩评论