object - 嵌套可分配组件
问题描述
当我尝试使用可分配组件嵌套派生类型时,我在 gfortran 7 和 8 中发现了一个奇怪的行为。
这是 Gfortran 中的错误还是标准禁止的?我的理解是否正确,唯一的解决方法是改用指针?
module test_mod
implicit none
private
public :: A_t, C_t
type :: A_t
integer, allocatable :: x(:)
end type
type :: B_t
integer :: x
end type
type :: C_t
! this works
! integer, allocatable :: S(:)
! this works
! type(B_t), allocatable :: S(:)
! this does not work
type(A_t), allocatable :: S(:)
end type
contains
end module
program test_allocatable_compoenten
use test_mod, only: A_t, C_t
implicit none
block
type(C_t) :: orbs
orbs = C_t()
end block
end program
解决方案
推荐阅读
- reactjs - React-router-dom 导航链接未呈现
- css - 无法在 HTML/CSS 中添加本地图像作为背景图像
- node.js - 当行分隔符为换行符且 csv 数据中包含换行符时,如何使用 fs readfile 读取 csv?
- java - INSERT IGNORE 在 mysql 模式下使用 h2 引发主键冲突
- c# - Fluent Migration:如何在删除/更新语句中添加和/或子句
- javascript - 如何修复输入字段不通过多次更改更新 Firebase
- text - 如何仅删除 TextField 中没有文本的行?
- python - Pandas - 如何通过各种条件对多列进行“分组”?
- c# - 将年份值分配给 sbyte
- oracle - Oracle DB 12C 的 SQL Developer 连接错误