Fortran Coder

查看: 2713|回复: 5
打印 上一主题 下一主题

[派生类型] 在使用type时如何将变量顺便设置成整型?

[复制链接]

213

帖子

2

主题

0

精华

宗师

F 币
2126 元
贡献
875 点

规矩勋章

楼主
发表于 2023-3-8 21:26:06 | 显示全部楼层
本帖最后由 风平老涡 于 2023-3-8 23:38 编辑

[Fortran] 纯文本查看 复制代码
type Subblocks  
    integer*4  :: row 
    integer*4  :: coL
end type Subblocks

type blocks  
    integer*4  :: row1,row2,coL1,coL2 
    integer*4  :: rowm,coLm
    integer*4  :: dad
    integer*4  :: son(4)
    integer*4  :: bnum
    type(Subblocks), allocatable :: iSubblocks(:)
end type blocks

type(blocks), allocatable :: iblocks(:)
type(Subblocks), allocatable  :: iSubblocks(:)
integer :: i, n, m



n = 10
m = 20

allocate(iblocks(n))

do i = 1, n
   allocate(iblocks(i) % isubblocks(m))
end do

allocate(isubblocks(m))

print *, iblocks(3) % colm, iblocks % isubblocks(2) % col, isubblocks(3) % col



衍生类型的变量名(iblocks % isubblocks) 与 变量名(isubblocks)不存在冲突。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-3 14:55

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表