我们可以在 Fortran 中创建自定义属性吗?
扩展我之前的问题此处,我想知道是否可能在 fortran 中创建自定义属性?
像这样的事情
real, custom_attribute, allocatable :: variable(:)
如果可以做到,我猜以下也可以做到
custom_type, custom_attribute, allocatable :: variable(:)
Expanding on my previous question here, I want to know if is possible to create custom attributes in fortran ?
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(:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建用户定义的“类型”。也许您可以通过此功能实现您的目标。请参阅http://en.wikipedia.org/wiki/Fortran_95_language_features#Derived_data_types
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
不,标准 Fortran 中不存在自定义属性之类的东西。然而,扩展 MSB 答案,当使用派生数据类型时,您可以使用参数化派生类型,这是 Fortran 2003 中引入的。
它允许您为派生数据类型定义“kind”和“len”属性。
这使您可以执行以下操作: type(my_type(rk=selected_real_kind(15), extent=size(a))) :: b
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